ecdsa_ext 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -13
- data/lib/ecdsa/ext/projective_point.rb +2 -5
- 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: d034afcff3fe0f7bcdd0a201387242296617c4115c8a5e5c17be9c55727aa7b5
|
4
|
+
data.tar.gz: 94ca9bd31bd199527df5e77d82bfad340d81a869675ecaec0dec2f41c63a4ae7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57ce381df7da79e9e4853c1e0f9e7a67157a49c7e6701db9076eec31f41b6e87e6e03350280c833d9b5d91c125ca3619364c96b9e621688b5f5b0ea09456f7d5
|
7
|
+
data.tar.gz: 75ecb95e6e18a751dea27a435555b6ae4dc583c93c5dda206a7a9bfd24fbda045d6a09a715f4d962060165aad0c961366977d4092743f3755e0cc04080731e20
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# Extension of the ecdsa gem
|
2
2
|
|
3
|
-
|
3
|
+
This library is an extension of the [ecdsa gem](https://github.com/DavidEGrayson/ruby_ecdsa/),
|
4
|
+
which mainly speeds up the computation of points on elliptic curves by using projective rather than affine coordinates.
|
4
5
|
|
5
|
-
|
6
|
+
This gem was not written by a cryptography expert and has not been carefully checked as with the original gem.
|
7
|
+
It is provided "as is" and it is the user's responsibility to make sure it will be suitable for the desired purpose.
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -22,22 +24,55 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
### Convert coordinate from affine to projective
|
26
28
|
|
27
|
-
|
29
|
+
```ruby
|
30
|
+
require 'ecdsa_ext'
|
31
|
+
require 'securerandom'
|
28
32
|
|
29
|
-
|
33
|
+
group = ECDSA::Group::Secp256k1
|
34
|
+
private_key = 1 + SecureRandom.random_number(group.order - 1)
|
35
|
+
affine_point = group.generator * private_key
|
36
|
+
#<ECDSA::Point: secp256k1, 0x22a7d03cd6fec52e13d2713da6921cf8f374631ecea7d575d31c3f338a410ad, 0x530b82285b951582bc330fc0b1d26df56bf93277d1229676ab9c2d4749098a7c>
|
30
37
|
|
31
|
-
|
38
|
+
# convert to projective point
|
39
|
+
projective_point = affine_point.to_projective
|
40
|
+
#<ECDSA::Ext::ProjectivePoint:0x00007f45baa7f5b0 @group=#<ECDSA::Group:secp256k1>, @x=979696094695476041658010915065787178569931130816884020506645009594358960301, @y=37562300065191370074864991137132392549749230653372621152572375247509483260540, @z=1>
|
41
|
+
```
|
32
42
|
|
33
|
-
|
43
|
+
### Create directory
|
34
44
|
|
35
|
-
|
45
|
+
```ruby
|
46
|
+
require 'ecdsa_ext'
|
47
|
+
require 'securerandom'
|
36
48
|
|
37
|
-
|
49
|
+
group = ECDSA::Group::Secp256k1
|
50
|
+
private_key = 1 + SecureRandom.random_number(group.order - 1)
|
51
|
+
projective_point = group.generator.to_projective * private_key
|
52
|
+
#<ECDSA::Ext::ProjectivePoint:0x00007f45baa7f5b0 @group=#<ECDSA::Group:secp256k1>, @x=979696094695476041658010915065787178569931130816884020506645009594358960301, @y=37562300065191370074864991137132392549749230653372621152572375247509483260540, @z=1>
|
53
|
+
```
|
38
54
|
|
39
|
-
|
55
|
+
### Operation
|
56
|
+
|
57
|
+
`ECDSA::Ext::ProjectivePoint` instance supports point addition, scalar multiplication and negation.
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
require 'ecdsa_ext'
|
40
61
|
|
41
|
-
|
62
|
+
# addition
|
63
|
+
projective_point3 = projective_point1 + projective_point2
|
64
|
+
|
65
|
+
# multiplication
|
66
|
+
projective_point4 = projective_point3 * 123
|
67
|
+
|
68
|
+
# negation
|
69
|
+
projective_point4_neg = projective_point4.negate
|
70
|
+
```
|
71
|
+
|
72
|
+
### Convert coordinate from projective to affine
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
require 'ecdsa_ext'
|
42
76
|
|
43
|
-
|
77
|
+
affine_point = projective_point4.to_affine
|
78
|
+
```
|
@@ -103,11 +103,8 @@ module ECDSA
|
|
103
103
|
if infinity?
|
104
104
|
group.infinity
|
105
105
|
else
|
106
|
-
|
107
|
-
|
108
|
-
field.mod(x * field.inverse(z)),
|
109
|
-
field.mod(y * field.inverse(z))
|
110
|
-
)
|
106
|
+
z_inv = field.inverse(z)
|
107
|
+
ECDSA::Point.new(group, field.mod(x * z_inv), field.mod(y * z_inv))
|
111
108
|
end
|
112
109
|
end
|
113
110
|
|
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.2.
|
4
|
+
version: 0.2.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-02-
|
11
|
+
date: 2023-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecdsa
|