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 +4 -4
- data/lib/ecdsa/format/point_octet_string.rb +1 -1
- data/lib/ecdsa/group.rb +7 -3
- data/lib/ecdsa/point.rb +5 -2
- data/lib/ecdsa/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43b972ebb083f20d5ea5875f00a6c235d77f1aec
|
4
|
+
data.tar.gz: 946c40b1039fc9c8fddfd194f58edc1c213f1239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9466417bfd9244c36997edc141881472658343ba52d03e62d14b603f15ad13ac612009ceb91666c4359d32c9950b3ebd20d33232eb677b33f207c88a8b6ea5ea
|
7
|
+
data.tar.gz: e5293e8f992ca92257d81076755f7c96243f5e9bab1f04a92acc91d25aef5e9faada7ba83ddfe27ba0ca76ce27abe87fb5a5f0eae719cc838478a5d8fe48f8ba
|
data/lib/ecdsa/group.rb
CHANGED
@@ -44,7 +44,7 @@ module ECDSA
|
|
44
44
|
def new_point(p)
|
45
45
|
case p
|
46
46
|
when :infinity
|
47
|
-
|
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
|
59
|
-
@
|
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
|
data/lib/ecdsa/point.rb
CHANGED
@@ -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.
|
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
|
-
|
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?
|
data/lib/ecdsa/version.rb
CHANGED