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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f71a8a1ec3a2e0fef42f9820fd59ba1f7d440ec86e0c85922da554f4d1f9d8f2
4
- data.tar.gz: 7c1db1f1c79d783f307f2fac3185ed837882bd68b516770da063a5d08dd04755
3
+ metadata.gz: 344f77af4186a6c073efd7ceb86c1023f9395921e360a6239e6443aeaf31c957
4
+ data.tar.gz: e9a32a697a607c61dd7f7993975eea458bfb09ccd1445ebe9715809b6c3620d5
5
5
  SHA512:
6
- metadata.gz: f2472cd8dbf5f124619222e00b55c661dcd74962a92a4decb5a4acaa31d281ed052177949875ae68d9b0ec581df2c602c1bc8e9dd72fa2409efebbdc5f51ae17
7
- data.tar.gz: 8c4678914dae19af4f13408547ef95ee86041131541b37b68275a13c3da6f8d02641c134d4984e649d665f7c7eeb8d317e1a06a6a950128661c306bb29f98bb7
6
+ metadata.gz: b45f1ef8661a6b1a6a3b222f29b8ed5b95dbf90576040bc6cef13f295b496017508867d1ae0a6ef14c51310d349e6b01d881ba9e8f151b5fa01bc02bb6f04093
7
+ data.tar.gz: e5717cb07126434a13051d760a9b2c797f6834d7e95a31a2ec433128480f55a40b2cf8e4d336913781319858e0fc7de30a00832bd3810a624a67498a9cab08ef
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-3.2.0
1
+ ruby-3.3.0
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
- gem 'prettier'
12
+ gem 'prettier', '4.0.3'
13
13
 
14
14
  gem 'rubocop-rake'
15
15
  gem 'rubocop-rspec'
@@ -78,11 +78,14 @@ module ECDSA
78
78
 
79
79
  q = self.class.infinity_point(group)
80
80
  v = self
81
- i = x
82
- while i.positive?
83
- q = q.add_to_point(v) if i.odd?
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
- i >>= 1
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
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ECDSA
4
4
  module Ext
5
- VERSION = "0.5.0"
5
+ VERSION = "0.5.1"
6
6
  end
7
7
  end
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.0
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: 2023-03-30 00:00:00.000000000 Z
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa