ecc 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/ecc/point.rb +14 -12
- data/lib/ecc/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: 36b895b4f9fa437cfe648d0c07b647e743c66959
|
4
|
+
data.tar.gz: e850dc2713412f5c8c67616d377bce9a93b6674e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1d8229f6e2b4e8b8525f9e04b34087bb5625b59e34aca41a1a594f3bb73ad5cf0fbb3002e8093c30caaa43cbc95cbcc62c901e82b59d74213c809a128ac4d3e
|
7
|
+
data.tar.gz: 8d897df94b8762ff77da808e5f5ef1f3cb4dad85362c0550624fb3998464a2b3fc8f0262809ba31c6c9b14307e17b0dcd03765b0388fdb2634e5f64e8404e9b5
|
data/README.md
CHANGED
data/lib/ecc/point.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Ecc
|
2
|
+
|
2
3
|
class Point
|
3
4
|
|
4
5
|
attr_accessor :x, :y
|
@@ -6,7 +7,7 @@ module Ecc
|
|
6
7
|
def initialize(curve, x, y)
|
7
8
|
|
8
9
|
if curve.class != Curve
|
9
|
-
raise "1st argument type error"
|
10
|
+
raise "1st argument type error: "
|
10
11
|
end
|
11
12
|
|
12
13
|
@curve = curve
|
@@ -35,29 +36,30 @@ module Ecc
|
|
35
36
|
|
36
37
|
def +(other)
|
37
38
|
|
38
|
-
u =
|
39
|
-
v =
|
40
|
-
|
39
|
+
u = self
|
40
|
+
v = other
|
41
|
+
|
41
42
|
return u if v.zero?
|
42
43
|
return v if u.zero?
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
t = 0
|
46
|
+
|
46
47
|
if u != v
|
47
|
-
|
48
|
+
t = ((v.y - u.y) * (((v.x - u.x) ** (@curve.fp - 2)) % @curve.fp)) % @curve.fp
|
48
49
|
else
|
49
|
-
|
50
|
+
t = ((3 * u.x ** 2 + @curve.a) * (((2 * u.y) ** (@curve.fp - 2)) % @curve.fp)) % @curve.fp
|
50
51
|
end
|
51
52
|
|
52
|
-
x3 =
|
53
|
-
y3 =
|
54
|
-
|
53
|
+
x3 = t ** 2 - u.x - v.x
|
54
|
+
y3 = t * (u.x - x3) - u.y
|
55
|
+
|
56
|
+
Point.new(@curve, x3 % @curve.fp, y3 % @curve.fp)
|
55
57
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def *(d)
|
59
61
|
|
60
|
-
sum =
|
62
|
+
sum = self
|
61
63
|
|
62
64
|
(d - 1).times do
|
63
65
|
sum = sum + self
|
data/lib/ecc/version.rb
CHANGED