ecdsa_ext 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/lib/ecdsa/ext/abstract_point.rb +21 -4
- data/lib/ecdsa/ext/point.rb +9 -0
- data/lib/ecdsa/ext/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 344f77af4186a6c073efd7ceb86c1023f9395921e360a6239e6443aeaf31c957
|
4
|
+
data.tar.gz: e9a32a697a607c61dd7f7993975eea458bfb09ccd1445ebe9715809b6c3620d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b45f1ef8661a6b1a6a3b222f29b8ed5b95dbf90576040bc6cef13f295b496017508867d1ae0a6ef14c51310d349e6b01d881ba9e8f151b5fa01bc02bb6f04093
|
7
|
+
data.tar.gz: e5717cb07126434a13051d760a9b2c797f6834d7e95a31a2ec433128480f55a40b2cf8e4d336913781319858e0fc7de30a00832bd3810a624a67498a9cab08ef
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.
|
1
|
+
ruby-3.3.0
|
data/Gemfile
CHANGED
@@ -78,11 +78,14 @@ module ECDSA
|
|
78
78
|
|
79
79
|
q = self.class.infinity_point(group)
|
80
80
|
v = self
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
p, n = to_naf(x)
|
82
|
+
len = [p.bit_length, n.bit_length].max
|
83
|
+
len.times do
|
84
|
+
q += v if p.odd?
|
85
|
+
q += v.negate if n.odd?
|
84
86
|
v = v.double
|
85
|
-
|
87
|
+
p >>= 1
|
88
|
+
n >>= 1
|
86
89
|
end
|
87
90
|
q
|
88
91
|
end
|
@@ -103,6 +106,20 @@ module ECDSA
|
|
103
106
|
def ==(other)
|
104
107
|
raise NotImplementedError
|
105
108
|
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
# Convert Integer to NAF
|
113
|
+
# @param [Integer] x Integer.
|
114
|
+
# @return [Array] (positive, negative)
|
115
|
+
def to_naf(x)
|
116
|
+
xh = x >> 1
|
117
|
+
x3 = x + xh
|
118
|
+
c = xh ^ x3
|
119
|
+
positive = x3 & c
|
120
|
+
negative = xh & c
|
121
|
+
[positive, negative]
|
122
|
+
end
|
106
123
|
end
|
107
124
|
end
|
108
125
|
end
|
data/lib/ecdsa/ext/point.rb
CHANGED
@@ -14,5 +14,14 @@ module ECDSA
|
|
14
14
|
def to_jacobian
|
15
15
|
ECDSA::Ext::JacobianPoint.from_affine(self)
|
16
16
|
end
|
17
|
+
|
18
|
+
# Convert coordinates to hex string.
|
19
|
+
# @return [String]
|
20
|
+
def to_hex(compression = true) # rubocop:disable all
|
21
|
+
ECDSA::Format::PointOctetString.encode(
|
22
|
+
self,
|
23
|
+
compression: compression
|
24
|
+
).unpack1("H*")
|
25
|
+
end
|
17
26
|
end
|
18
27
|
end
|
data/lib/ecdsa/ext/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecdsa
|