schnorr_sig 1.0.1.1 → 1.2.0.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 +4 -9
- data/Rakefile +7 -7
- data/VERSION +1 -1
- data/lib/schnorr_sig/pure.rb +0 -6
- data/lib/schnorr_sig/utils.rb +6 -0
- data/lib/schnorr_sig.rb +4 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2168b7333b06337bd90e65f6838a59acc10f87c2101ef3a300f832546c51c2ef
|
4
|
+
data.tar.gz: 4499c662534c9c88dd5129d6922817704935be94d1266e7553abb38907e05cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a7e5e7c1247580889901b1711a4d49dfb1d48003b8818dc0697eb7b22f2cf99488e16a1b0c1ef07b9f3b964856b2733a8bda9ddcfa38d806310090fd015945c
|
7
|
+
data.tar.gz: 34bbccee610a93c138f8a060cba1f216cc95c5129245bfa42dec820ca4eacd317461ec48026bca107b257eba5300070f7af45d75308452f22c2908a57e7f1a2c
|
data/README.md
CHANGED
@@ -110,7 +110,7 @@ Here are the fundamental functions common to both implementations:
|
|
110
110
|
* `tagged_hash(str tag, str msg)` *returns* `32B hash`
|
111
111
|
* `keypair()` *returns* `[32B sk, 32B pk]`
|
112
112
|
|
113
|
-
Use `soft_verify?(pk, msg, sig)` to
|
113
|
+
Use `soft_verify?(pk, msg, sig)` to return false if errors are raised.
|
114
114
|
|
115
115
|
### Differences
|
116
116
|
|
@@ -129,14 +129,9 @@ though `Random` may also be used via `NO_SECURERANDOM` environment variable.
|
|
129
129
|
|
130
130
|
## Enable Fast Implementation
|
131
131
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
Ensure `ENV['SCHNORR_SIG']&.downcase == 'fast'`, and then
|
136
|
-
`require 'schnorr_sig'` will try the fast implementation first, before
|
137
|
-
falling back to the pure implementation.
|
138
|
-
|
139
|
-
After `require 'schnorr_sig'`, you can check which implementation is loaded
|
132
|
+
If the `rbsecp256k1` gem is installed and loadable, it will be loaded and used.
|
133
|
+
Otherwise, we fall back to the pure implementation. After
|
134
|
+
`require 'schnorr_sig'`, you can check which implementation is loaded
|
140
135
|
by the presence of `SchnorrSig::Pure` or `SchnorrSig::Fast`.
|
141
136
|
|
142
137
|
### Load Directly
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
|
3
|
-
Rake::TestTask.new :test do |t|
|
3
|
+
Rake::TestTask.new :test => :vectors do |t|
|
4
4
|
t.test_files = [
|
5
5
|
'test/utils.rb',
|
6
6
|
'test/pure.rb',
|
@@ -8,18 +8,18 @@ Rake::TestTask.new :test do |t|
|
|
8
8
|
t.warning = true
|
9
9
|
end
|
10
10
|
|
11
|
-
Rake::TestTask.new :vectors do |t|
|
11
|
+
Rake::TestTask.new :fast => :vectors do |t|
|
12
12
|
t.test_files = [
|
13
|
-
'test/
|
14
|
-
'test/
|
13
|
+
'test/utils.rb',
|
14
|
+
'test/fast.rb',
|
15
15
|
]
|
16
16
|
t.warning = true
|
17
17
|
end
|
18
18
|
|
19
|
-
Rake::TestTask.new :
|
19
|
+
Rake::TestTask.new :vectors do |t|
|
20
20
|
t.test_files = [
|
21
|
-
'test/
|
22
|
-
'test/
|
21
|
+
'test/vectors.rb',
|
22
|
+
'test/vectors_extra.rb',
|
23
23
|
]
|
24
24
|
t.warning = true
|
25
25
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.1
|
1
|
+
1.2.0.1
|
data/lib/schnorr_sig/pure.rb
CHANGED
@@ -17,12 +17,6 @@ module SchnorrSig
|
|
17
17
|
# Utils
|
18
18
|
#
|
19
19
|
|
20
|
-
# use SecureRandom unless ENV['NO_SECURERANDOM'] is nonempty
|
21
|
-
def random_bytes(count)
|
22
|
-
nsr = ENV['NO_SECURERANDOM']
|
23
|
-
(nsr and !nsr.empty?) ? Random.bytes(count) : SecureRandom.bytes(count)
|
24
|
-
end
|
25
|
-
|
26
20
|
# int (dot) G, returns ECDSA::Point
|
27
21
|
def point(int)
|
28
22
|
(GROUP.generator.to_jacobian * int).to_affine # 10x faster via ecdsa_ext
|
data/lib/schnorr_sig/utils.rb
CHANGED
@@ -38,5 +38,11 @@ module SchnorrSig
|
|
38
38
|
|
39
39
|
# convert a hex string to a binary string
|
40
40
|
def hex2bin(hex) = [hex].pack('H*')
|
41
|
+
|
42
|
+
# use SecureRandom unless ENV['NO_SECURERANDOM'] is nonempty
|
43
|
+
def random_bytes(count)
|
44
|
+
nsr = ENV['NO_SECURERANDOM']
|
45
|
+
(nsr and !nsr.empty?) ? Random.bytes(count) : SecureRandom.bytes(count)
|
46
|
+
end
|
41
47
|
end
|
42
48
|
end
|
data/lib/schnorr_sig.rb
CHANGED
@@ -1,16 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
require 'schnorr_sig/fast'
|
6
|
-
SchnorrSig.extend SchnorrSig::Fast
|
7
|
-
loaded = true
|
8
|
-
rescue LoadError => e
|
9
|
-
warn [e.class, e.message].join(': ')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
unless loaded
|
1
|
+
begin
|
2
|
+
require 'schnorr_sig/fast'
|
3
|
+
SchnorrSig.extend SchnorrSig::Fast
|
4
|
+
rescue LoadError
|
14
5
|
require 'schnorr_sig/pure'
|
15
6
|
SchnorrSig.extend SchnorrSig::Pure
|
16
7
|
end
|