ecdsa 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: 659d2790437db01e2e7392e4237a3058f9c7a211
4
- data.tar.gz: 6583a0653af11baae081378b934b49a84deb827c
3
+ metadata.gz: 43b972ebb083f20d5ea5875f00a6c235d77f1aec
4
+ data.tar.gz: 946c40b1039fc9c8fddfd194f58edc1c213f1239
5
5
  SHA512:
6
- metadata.gz: 02e6bc216e5f61bf290d2a9386046412de388d135036771da1a9c52a9167268883025b8f50cb0d849a7eeb50782e9cdff181294b2839b82bdfa8e43675545c51
7
- data.tar.gz: 431eeb2ee94b0515a48ad30d8fd9132c307536707cdf5907646658f3305e894a38e9764b74610af1d7c22e0400b55c718598640be42e1099c77d207b0b19aafc
6
+ metadata.gz: 9466417bfd9244c36997edc141881472658343ba52d03e62d14b603f15ad13ac612009ceb91666c4359d32c9950b3ebd20d33232eb677b33f207c88a8b6ea5ea
7
+ data.tar.gz: e5293e8f992ca92257d81076755f7c96243f5e9bab1f04a92acc91d25aef5e9faada7ba83ddfe27ba0ca76ce27abe87fb5a5f0eae719cc838478a5d8fe48f8ba
@@ -30,7 +30,7 @@ module ECDSA
30
30
  case string[0].ord
31
31
  when 0
32
32
  check_length string, 1
33
- return group.infinity_point
33
+ return group.infinity
34
34
  when 2
35
35
  decode_compressed string, group, 0
36
36
  when 3
@@ -44,7 +44,7 @@ module ECDSA
44
44
  def new_point(p)
45
45
  case p
46
46
  when :infinity
47
- infinity_point
47
+ infinity
48
48
  when Array
49
49
  x, y = p
50
50
  Point.new(self, x, y)
@@ -55,8 +55,8 @@ module ECDSA
55
55
  end
56
56
  end
57
57
 
58
- def infinity_point
59
- @infinity_point ||= Point.new(self, :infinity)
58
+ def infinity
59
+ @infinity ||= Point.new(self, :infinity)
60
60
  end
61
61
 
62
62
  # The number of bits that it takes to represent a member of the field.
@@ -122,5 +122,9 @@ module ECDSA
122
122
  NAMES.each do |name|
123
123
  autoload name, 'ecdsa/group/' + name.downcase
124
124
  end
125
+
126
+ # Group#infinity_point was deprecated in favor of #infinity.
127
+ # This alias is for backwards compatibility with versions 0.1.4 and before.
128
+ alias_method :infinity_point, :infinity
125
129
  end
126
130
  end
@@ -40,7 +40,7 @@ module ECDSA
40
40
  return self if point.infinity?
41
41
 
42
42
  # SEC1, section 2.2.1, rule 3
43
- return group.infinity_point if x == point.x && y == field.mod(-point.y)
43
+ return group.infinity if x == point.x && y == field.mod(-point.y)
44
44
 
45
45
  # SEC1, section 2.2.1, rule 4
46
46
  if x != point.x
@@ -62,6 +62,7 @@ module ECDSA
62
62
  end
63
63
 
64
64
  def double
65
+ return self if infinity?
65
66
  gamma = field.mod((3 * x * x + @group.param_a) * field.inverse(2 * y))
66
67
  new_x = field.mod(gamma * gamma - 2 * x)
67
68
  new_y = field.mod(gamma * (x - new_x) - y)
@@ -69,7 +70,9 @@ module ECDSA
69
70
  end
70
71
 
71
72
  def multiply_by_scalar(i)
72
- result = group.infinity_point
73
+ raise ArgumentError, 'Scalar is not an integer.' if !i.is_a?(Integer)
74
+ raise ArgumentError, 'Scalar is negative.' if i < 0
75
+ result = group.infinity
73
76
  v = self
74
77
  while i > 0
75
78
  result = result.add_to_point(v) if i.odd?
@@ -1,3 +1,3 @@
1
1
  module ECDSA
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecdsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Grayson