ecdsa_ext 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile +7 -1
- data/lib/ecdsa/ext/jacobian_point.rb +1 -0
- data/lib/ecdsa/ext/projective_point.rb +1 -0
- data/lib/ecdsa/ext/sign_verify.rb +10 -6
- data/lib/ecdsa/ext/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 49c7d6aa8f97890fc13a7648051ca3c232cd2bdf35dd5e669c071e6fb8dd3e58
|
|
4
|
+
data.tar.gz: 576286bd095cde15807d3512cbe57e08c10c8936549b4280c854abf29ee1a12b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1209c40701adcb12a716d70914ce4c03ec4bb92cf6e1df4b628ff1d62944aa0cbf5f7172c7ad45679e04fa376baca65e87d1e7e97ce9202315e0312e5b165b90
|
|
7
|
+
data.tar.gz: 010464b3223ba96790714b0c705661bd8445acc780e95d28de73137c42b3dbf592e9a5d0a9c1fcdec91f0e4276d9cb862cc258280d0ac2d5d8139f8dbf3f98e4
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby-
|
|
1
|
+
ruby-4.0.0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.5.2] - 2026-08-07
|
|
4
|
+
|
|
5
|
+
- Fix a timing leak of the ephemeral key's bit length in `ECDSA.sign` by padding the scalar with the group order
|
|
6
|
+
- Check r and s against the range [1, n-1] (group order) instead of the curve's prime field in `ECDSA.check_signature!`
|
|
7
|
+
- Fix `NoMethodError` when comparing an infinity point with a non-infinity point via `==`
|
|
8
|
+
|
|
3
9
|
## [0.1.0] - 2023-02-23
|
|
4
10
|
|
|
5
11
|
- Initial release
|
data/Gemfile
CHANGED
|
@@ -5,7 +5,12 @@ module ECDSA
|
|
|
5
5
|
def self.sign(group, private_key, digest, temporary_key)
|
|
6
6
|
# Second part of step 1: Select ephemeral elliptic curve key pair
|
|
7
7
|
# temporary_key was already selected for us by the caller
|
|
8
|
-
|
|
8
|
+
# Pad the scalar with the group order so that its bit length is fixed,
|
|
9
|
+
# mitigating a timing leak of the bit length of temporary_key.
|
|
10
|
+
# Since (k + i * n)G = kG, this does not change the result.
|
|
11
|
+
k = temporary_key + group.order
|
|
12
|
+
k += group.order if k.bit_length == group.order.bit_length
|
|
13
|
+
r_point = (group.generator.to_jacobian * k).to_affine
|
|
9
14
|
|
|
10
15
|
# Steps 2 and 3
|
|
11
16
|
point_field = PrimeField.new(group.order)
|
|
@@ -29,13 +34,13 @@ module ECDSA
|
|
|
29
34
|
|
|
30
35
|
def self.check_signature!(public_key, digest, signature)
|
|
31
36
|
group = public_key.group
|
|
32
|
-
|
|
37
|
+
point_field = PrimeField.new(group.order)
|
|
33
38
|
|
|
34
|
-
# Step 1: r and s must be in the
|
|
35
|
-
unless
|
|
39
|
+
# Step 1: r and s must be in the range [1, n-1].
|
|
40
|
+
unless point_field.include?(signature.r)
|
|
36
41
|
raise InvalidSignatureError, "Invalid signature: r is not in the field."
|
|
37
42
|
end
|
|
38
|
-
unless
|
|
43
|
+
unless point_field.include?(signature.s)
|
|
39
44
|
raise InvalidSignatureError, "Invalid signature: s is not in the field."
|
|
40
45
|
end
|
|
41
46
|
if signature.r.zero?
|
|
@@ -51,7 +56,6 @@ module ECDSA
|
|
|
51
56
|
e = normalize_digest(digest, group.bit_length)
|
|
52
57
|
|
|
53
58
|
# Step 4
|
|
54
|
-
point_field = PrimeField.new(group.order)
|
|
55
59
|
s_inverted = point_field.inverse(signature.s)
|
|
56
60
|
u1 = point_field.mod(e * s_inverted)
|
|
57
61
|
u2 = point_field.mod(signature.r * s_inverted)
|
data/lib/ecdsa/ext/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ecdsa_ext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- azuchi
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: ecdsa
|
|
@@ -61,7 +60,6 @@ metadata:
|
|
|
61
60
|
homepage_uri: https://github.com/azuchi/ruby_ecdsa_ext
|
|
62
61
|
source_code_uri: https://github.com/azuchi/ruby_ecdsa_ext
|
|
63
62
|
changelog_uri: https://github.com/azuchi/ruby_ecdsa_ext
|
|
64
|
-
post_install_message:
|
|
65
63
|
rdoc_options: []
|
|
66
64
|
require_paths:
|
|
67
65
|
- lib
|
|
@@ -76,8 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
76
74
|
- !ruby/object:Gem::Version
|
|
77
75
|
version: '0'
|
|
78
76
|
requirements: []
|
|
79
|
-
rubygems_version:
|
|
80
|
-
signing_key:
|
|
77
|
+
rubygems_version: 4.0.3
|
|
81
78
|
specification_version: 4
|
|
82
79
|
summary: Extension of the ecdsa gem.
|
|
83
80
|
test_files: []
|