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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0f115741184aa3013de736e9693506b7c6d90191b648658ab6f3215da2172a3
4
- data.tar.gz: d85bd0930d0c62d4abeb62445a950566d80b625339433d40eb3f9ed165c68d8a
3
+ metadata.gz: d034afcff3fe0f7bcdd0a201387242296617c4115c8a5e5c17be9c55727aa7b5
4
+ data.tar.gz: 94ca9bd31bd199527df5e77d82bfad340d81a869675ecaec0dec2f41c63a4ae7
5
5
  SHA512:
6
- metadata.gz: 44fbb5bef58b93924b9f5128663d83840dbe3c465fdd5c3abc36c798a34d797bf9dd98233ebc5a3260b21c323fe1466c4251282a840bd2d1e23e70d85d6f2de5
7
- data.tar.gz: 5f31293b891b21fd42074b1d550f16ad844a5903e47be45e95c5c35ce14e38250941ac830470f707d2d990a80bf9f3db821f4f6b271d9d0cdaa38d25746ba17d
6
+ metadata.gz: 57ce381df7da79e9e4853c1e0f9e7a67157a49c7e6701db9076eec31f41b6e87e6e03350280c833d9b5d91c125ca3619364c96b9e621688b5f5b0ea09456f7d5
7
+ data.tar.gz: 75ecb95e6e18a751dea27a435555b6ae4dc583c93c5dda206a7a9bfd24fbda045d6a09a715f4d962060165aad0c961366977d4092743f3755e0cc04080731e20
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
- # EcdsaExt
1
+ # Extension of the ecdsa gem
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ecdsa_ext`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
27
+ ### Convert coordinate from affine to projective
26
28
 
27
- ## Development
29
+ ```ruby
30
+ require 'ecdsa_ext'
31
+ require 'securerandom'
28
32
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
- ## Contributing
43
+ ### Create directory
34
44
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ecdsa_ext. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ecdsa_ext/blob/master/CODE_OF_CONDUCT.md).
45
+ ```ruby
46
+ require 'ecdsa_ext'
47
+ require 'securerandom'
36
48
 
37
- ## License
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
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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
- ## Code of Conduct
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
- Everyone interacting in the EcdsaExt project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ecdsa_ext/blob/master/CODE_OF_CONDUCT.md).
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
- ECDSA::Point.new(
107
- group,
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ECDSA
4
4
  module Ext
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.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.2.0
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-25 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa