bitcoinrb 0.3.0 → 0.3.1
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/lib/bitcoin/slip39/sss.rb +5 -2
- data/lib/bitcoin/util.rb +9 -0
- data/lib/bitcoin/version.rb +1 -1
- 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: 4890635391be36111da08563b43a42f02aeb51088c87a71431ed6b6f22cbe45b
|
4
|
+
data.tar.gz: 75bbbc13e4244fdd40b1f8aef63a3759ff685d184abeb0867549fe6dbeab3248
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d33ec224e5dd0fa03dd9adcd7e2caa78dd1c7021fc121e9431cb49e331e8176dfdae02420af3a6b6921018b9e17582eec225c26afde6ed733649b47c95340a68
|
7
|
+
data.tar.gz: 76ac351103ff577d6e4acb07c35a0f00af1e3bb00a4eeac3035fb7471ce51d3df64d2ae2411d2cf34d775bea7b50181f7bc4086dfa61979b4926eb4bd4ab8b78
|
data/lib/bitcoin/slip39/sss.rb
CHANGED
@@ -6,6 +6,9 @@ module Bitcoin
|
|
6
6
|
# Shamir's Secret Sharing
|
7
7
|
class SSS
|
8
8
|
|
9
|
+
include Bitcoin::Util
|
10
|
+
extend Bitcoin::Util
|
11
|
+
|
9
12
|
# Create SSS shares.
|
10
13
|
#
|
11
14
|
# [Usage]
|
@@ -171,7 +174,7 @@ module Bitcoin
|
|
171
174
|
e = (Bitcoin::SLIP39::BASE_ITERATION_COUNT << exp) / Bitcoin::SLIP39::ROUND_COUNT
|
172
175
|
Bitcoin::SLIP39::ROUND_COUNT.times.to_a.reverse.each do |i|
|
173
176
|
f = OpenSSL::PKCS5.pbkdf2_hmac((i.itb + passphrase), salt + r, e, r.bytesize, 'sha256')
|
174
|
-
l, r = r, (l.bti ^ f.bti).itb
|
177
|
+
l, r = padding_zero(r, r.bytesize), padding_zero((l.bti ^ f.bti).itb, r.bytesize)
|
175
178
|
end
|
176
179
|
(r + l).bth
|
177
180
|
end
|
@@ -189,7 +192,7 @@ module Bitcoin
|
|
189
192
|
e = (Bitcoin::SLIP39::BASE_ITERATION_COUNT << exp) / Bitcoin::SLIP39::ROUND_COUNT
|
190
193
|
Bitcoin::SLIP39::ROUND_COUNT.times.to_a.each do |i|
|
191
194
|
f = OpenSSL::PKCS5.pbkdf2_hmac((i.itb + passphrase), salt + r, e, r.bytesize, 'sha256')
|
192
|
-
l, r = r, (l.bti ^ f.bti).itb
|
195
|
+
l, r = padding_zero(r, r.bytesize), padding_zero((l.bti ^ f.bti).itb, r.bytesize)
|
193
196
|
end
|
194
197
|
(r + l).bth
|
195
198
|
end
|
data/lib/bitcoin/util.rb
CHANGED
@@ -82,6 +82,15 @@ module Bitcoin
|
|
82
82
|
byte.unpack('b*').first
|
83
83
|
end
|
84
84
|
|
85
|
+
# padding zero to the left of binary string until bytesize.
|
86
|
+
# @param [String] binary string
|
87
|
+
# @param [Integer] bytesize total bytesize.
|
88
|
+
# @return [String] padded binary string.
|
89
|
+
def padding_zero(binary, bytesize)
|
90
|
+
return binary unless binary.bytesize < bytesize
|
91
|
+
('00' * (bytesize - binary.bytesize)).htb + binary
|
92
|
+
end
|
93
|
+
|
85
94
|
# generate sha256-ripemd160 hash for value
|
86
95
|
def hash160(hex)
|
87
96
|
Digest::RMD160.hexdigest(Digest::SHA256.digest(hex.htb))
|
data/lib/bitcoin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitcoinrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecdsa
|