bip-schnorr 0.5.0 → 0.7.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: 69bdb0abd7ac947cf22620a9255558c156f33dd9176a4624303aa331e5c47604
4
- data.tar.gz: 251e9488c10c854c94ce4335382616c3efbb4b976797c5cecf6bb80925bdfa1a
3
+ metadata.gz: 62086f5dc865721a602e4ac25f1c58920eba47d0e7bb5ab59d389af297095750
4
+ data.tar.gz: 3e6ddfbc75956f04e84f01412b034974cb592ef1adea72775acdc949946d2ebf
5
5
  SHA512:
6
- metadata.gz: 11b9401858d45aecac6f26564c31cbb3829233ce9ada0dee75d7456b95d2ec7299522e47691636da7cc54e110b936343b8862afef2184a610ba51f5095df8b4d
7
- data.tar.gz: c823d9c89c26494389f53e3502b4a450d6a1dc0a5ad6a4ca5cb39bfdf154e97c893f16b9cbb6ef84bcc3f05ecb87f4edb960b15e8ab69ddaee562aca55aeb263
6
+ metadata.gz: 4f599b83ba35a76df8425eb7eb436740f690ec011dcfc6eac65af1591bb748d1421dd71d2cf15c480e44302bd821ffda6f385799549a37f2a8159a592c510482
7
+ data.tar.gz: f7cb59f75a709bb05509697a55bd3864944a82d4a9768bc34db84da0b6a215b9060fa875722ebb597731f3df6a4155e738b419c413b5ef06278378f2b3055627
@@ -20,10 +20,9 @@ jobs:
20
20
  strategy:
21
21
  matrix:
22
22
  ruby:
23
- - '2.7.7'
24
- - '3.0.5'
25
- - '3.1.3'
26
- - '3.2.1'
23
+ - '3.0.6'
24
+ - '3.1.4'
25
+ - '3.2.2'
27
26
  steps:
28
27
  - uses: actions/checkout@v2
29
28
  - name: Set up Ruby
@@ -1,3 +1,3 @@
1
1
  module Schnorr
2
- VERSION = "0.5.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/schnorr.rb CHANGED
@@ -10,15 +10,16 @@ module Schnorr
10
10
  module_function
11
11
 
12
12
  GROUP = ECDSA::Group::Secp256k1
13
+ DEFAULT_AUX = ([0x00] * 32).pack('C*')
13
14
 
14
15
  # Generate schnorr signature.
15
16
  # @param [String] message A message to be signed with binary format.
16
17
  # @param [String] private_key The private key(binary format or hex format).
17
18
  # @param [String] aux_rand The auxiliary random data(binary format or hex format).
18
- # If not specified, random data is not used and the private key is used to calculate the nonce.
19
+ # If aux_rand is nil, it is treated the same as an all-zero one.
20
+ # See BIP-340 "Default Signing" for a full explanation of this argument and for guidance if randomness is expensive.
19
21
  # @return [Schnorr::Signature]
20
22
  def sign(message, private_key, aux_rand = nil)
21
- raise 'The message must be a 32-byte array.' unless message.bytesize == 32
22
23
  private_key = private_key.unpack1('H*') unless hex_string?(private_key)
23
24
 
24
25
  d0 = private_key.to_i(16)
@@ -26,6 +27,8 @@ module Schnorr
26
27
  if aux_rand
27
28
  aux_rand = [aux_rand].pack("H*") if hex_string?(aux_rand)
28
29
  raise 'aux_rand must be 32 bytes.' unless aux_rand.bytesize == 32
30
+ else
31
+ aux_rand = DEFAULT_AUX
29
32
  end
30
33
 
31
34
  p = (GROUP.generator.to_jacobian * d0).to_affine
@@ -66,7 +69,6 @@ module Schnorr
66
69
  def check_sig!(message, public_key, signature)
67
70
  message = hex2bin(message)
68
71
  public_key = hex2bin(public_key)
69
- raise InvalidSignatureError, 'The message must be a 32-byte array.' unless message.bytesize == 32
70
72
  public_key = [public_key].pack('H*') if hex_string?(public_key)
71
73
  raise InvalidSignatureError, 'The public key must be a 32-byte array.' unless public_key.bytesize == 32
72
74
 
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.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-05 00:00:00.000000000 Z
11
+ date: 2023-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa_ext