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 +4 -4
- data/.github/workflows/ruby.yml +3 -4
- data/lib/schnorr/version.rb +1 -1
- data/lib/schnorr.rb +5 -3
- 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: 62086f5dc865721a602e4ac25f1c58920eba47d0e7bb5ab59d389af297095750
|
4
|
+
data.tar.gz: 3e6ddfbc75956f04e84f01412b034974cb592ef1adea72775acdc949946d2ebf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f599b83ba35a76df8425eb7eb436740f690ec011dcfc6eac65af1591bb748d1421dd71d2cf15c480e44302bd821ffda6f385799549a37f2a8159a592c510482
|
7
|
+
data.tar.gz: f7cb59f75a709bb05509697a55bd3864944a82d4a9768bc34db84da0b6a215b9060fa875722ebb597731f3df6a4155e738b419c413b5ef06278378f2b3055627
|
data/.github/workflows/ruby.yml
CHANGED
data/lib/schnorr/version.rb
CHANGED
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
|
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.
|
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-
|
11
|
+
date: 2023-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecdsa_ext
|