bip-schnorr 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59a58963a82f699909cca6b06ac8dcd548f9bd0422f4bf6e70b97c98dcab5f5a
4
- data.tar.gz: 8dbdae61ff3bbcef518572873a2075fe70dffc7db0fe780f535c601f5d23422b
3
+ metadata.gz: 726ee90533a30264534d3ba2fff1e967334c56e870a25e778d86688001e6a5e2
4
+ data.tar.gz: 50b8e0df0e3c5bacb276b5dc77b088e2b59dddf6485c8f62ba95f68f4a4a4e3d
5
5
  SHA512:
6
- metadata.gz: 61c23efb396954378c60219d61743d83e6bb50ecfa7ee0e26218c5974e8d52dca4293a5d8c86e4bd0aee87b77d93366bdd4f0c3576064c183d8e93c29d5775b7
7
- data.tar.gz: 29a13266559a6d3ec5eb5d856ae1059bf68d5ee429c8c5c803b010a2d1823a252b50f83a2bd7c34cbf85fb03bc2e913ee8ae8bf5233d8a246e8b5395fe276c52
6
+ metadata.gz: 0ac0a2ec193d10e41cba96f1a5071998abf6602a0cf05fc44dc8bdd82853fb392f554857d6632cb1d3c655d7d0155c22efaea20ec0b0d089ee690de4a7443af0
7
+ data.tar.gz: 8b9023e307606166981b1ac136fb6e84382a0de003175fc67bc6e07624ae997c0554674ad96f5f56782539427d2d1cf441b993b78b9a62f0812881538604dd5a
@@ -0,0 +1,35 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.6', '2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ # uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run tests
35
+ run: bundle exec rake spec
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.0
1
+ ruby-3.0.0
data/lib/schnorr.rb CHANGED
@@ -11,20 +11,20 @@ module Schnorr
11
11
  # Generate schnorr signature.
12
12
  # @param message (String) A message to be signed with binary format.
13
13
  # @param private_key (String) The private key with binary format.
14
- # @param aux_rand (String) The auxiliary random data with binary format. If not specified, SecureRandom is used to generate a random value.
15
- # (The number of times to add the generator point to itself to get the public key.)
14
+ # @param aux_rand (String) The auxiliary random data with binary format.
15
+ # If not specified, random data is not used and the private key is used to calculate the nonce.
16
16
  # @return (Schnorr::Signature)
17
- def sign(message, private_key, aux_rand = SecureRandom.bytes(32))
17
+ def sign(message, private_key, aux_rand = nil)
18
18
  raise 'The message must be a 32-byte array.' unless message.bytesize == 32
19
19
 
20
20
  d0 = private_key.unpack1('H*').to_i(16)
21
21
  raise 'private_key must be an integer in the range 1..n-1.' unless 0 < d0 && d0 <= (GROUP.order - 1)
22
- raise 'aux_rand must be 32 bytes.' unless aux_rand.bytesize == 32
22
+ raise 'aux_rand must be 32 bytes.' if !aux_rand.nil? && aux_rand.bytesize != 32
23
23
 
24
24
  p = GROUP.new_point(d0)
25
25
  d = p.has_even_y? ? d0 : GROUP.order - d0
26
26
 
27
- t = d ^ tagged_hash('BIP0340/aux', aux_rand).unpack1('H*').to_i(16)
27
+ t = aux_rand.nil? ? d : d ^ tagged_hash('BIP0340/aux', aux_rand).unpack1('H*').to_i(16)
28
28
  t = ECDSA::Format::IntegerOctetString.encode(t, GROUP.byte_length)
29
29
 
30
30
  k0 = ECDSA::Format::IntegerOctetString.decode(tagged_hash('BIP0340/nonce', t + p.encode(true) + message)) % GROUP.order
@@ -1,3 +1,3 @@
1
1
  module Schnorr
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bip-schnorr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-04 00:00:00.000000000 Z
11
+ date: 2021-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa
@@ -73,11 +73,11 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/workflows/ruby.yml"
76
77
  - ".gitignore"
77
78
  - ".rspec"
78
79
  - ".ruby-gemset"
79
80
  - ".ruby-version"
80
- - ".travis.yml"
81
81
  - CODE_OF_CONDUCT.md
82
82
  - Gemfile
83
83
  - LICENSE.txt
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.1.4
112
+ rubygems_version: 3.2.3
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: The ruby implementation of bip-schnorr.
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 3.0.0
4
- - 2.7.2
5
- - 2.6.6
6
- - 2.5.8
7
- - 2.4.10
8
-
9
- bundler_args: --jobs=2
10
-
11
- script:
12
- - bundle exec rake spec