bitcoinrb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52fe21b51d659b4d5a45abbe8207727101813f1f30d7e0cf3438dad43ad3be8d
4
- data.tar.gz: b8d94902ad2733c963f23507bdde7f018560cf8cd2ceef17bc349f78373b67ec
3
+ metadata.gz: 4890635391be36111da08563b43a42f02aeb51088c87a71431ed6b6f22cbe45b
4
+ data.tar.gz: 75bbbc13e4244fdd40b1f8aef63a3759ff685d184abeb0867549fe6dbeab3248
5
5
  SHA512:
6
- metadata.gz: 62f1c0c37657b0f3a1df74d902c42d53a0134cbf254968db70d3814bd1190937c049fc9362bc2f7a6b7570958909bf8ce7fb080ee40d1ff3a6ce410f77305ff7
7
- data.tar.gz: 7306ece331df7d9fffd781d0d8bcabcd1f6fc0d6ca64271acbc6138de6ebcb1e7bd843021ef432067136c5ec28bdad4613cb42356daeb6246bf17c3f51ea4526
6
+ metadata.gz: d33ec224e5dd0fa03dd9adcd7e2caa78dd1c7021fc121e9431cb49e331e8176dfdae02420af3a6b6921018b9e17582eec225c26afde6ed733649b47c95340a68
7
+ data.tar.gz: 76ac351103ff577d6e4acb07c35a0f00af1e3bb00a4eeac3035fb7471ce51d3df64d2ae2411d2cf34d775bea7b50181f7bc4086dfa61979b4926eb4bd4ab8b78
@@ -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
@@ -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))
@@ -1,3 +1,3 @@
1
1
  module Bitcoin
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.0
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-30 00:00:00.000000000 Z
11
+ date: 2019-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa