btcruby 1.5 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/RELEASE_NOTES.md +7 -0
- data/lib/btcruby/outpoint.rb +7 -0
- data/lib/btcruby/script/test_signature_checker.rb +1 -1
- data/lib/btcruby/script/transaction_signature_checker.rb +13 -2
- data/lib/btcruby/ssss.rb +2 -1
- data/lib/btcruby/transaction.rb +1 -1
- data/lib/btcruby/version.rb +1 -1
- data/spec/ssss_spec.rb +6 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bbec90a3ce39cd29196eafbbbfc18e884e8c514
|
4
|
+
data.tar.gz: 05eb71dfff15d7b3f4949945623be1dfdebd8855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d658653097c2a101c5e42f03b287f2769070a379c6a6e2f1ec244f1782421f9cfcc10bad946e3d9e4a6721bb13f8ef4148a21dd6cc2baac6635115cc96b001d
|
7
|
+
data.tar.gz: fc9c6d2bb51365065b558590f0f5a45b8bac0d1ac6df795fd3ce195ee5e4f8af241772d4e34a8634f66826747e08389cb34d497f4a8ccc7ed80194205f2e593f
|
data/RELEASE_NOTES.md
CHANGED
@@ -2,11 +2,18 @@
|
|
2
2
|
BTCRuby Release Notes
|
3
3
|
=====================
|
4
4
|
|
5
|
+
1.5.1 (December 30, 2015)
|
6
|
+
-----------------------
|
7
|
+
|
8
|
+
* `BTC::TransactionSignatureChecker` accepts `version` and `amount` to support different hashing schemes (e.g. segwit) and passes them to `BTC::Transaction#signature_hash` function.
|
9
|
+
|
10
|
+
|
5
11
|
1.5 (November 29, 2015)
|
6
12
|
-----------------------
|
7
13
|
|
8
14
|
* `BTC::SecretSharing` changes API to support 96-, 104- and 128-bit secrets.
|
9
15
|
|
16
|
+
|
10
17
|
1.4 (November 26, 2015)
|
11
18
|
-----------------------
|
12
19
|
|
data/lib/btcruby/outpoint.rb
CHANGED
@@ -33,6 +33,13 @@ module BTC
|
|
33
33
|
@index == INVALID_INDEX && @transaction_hash == ZERO_HASH256
|
34
34
|
end
|
35
35
|
|
36
|
+
def data
|
37
|
+
data = "".b
|
38
|
+
data << BTC::Data.ensure_binary_encoding(transaction_hash)
|
39
|
+
data << BTC::WireFormat.encode_uint32le(index)
|
40
|
+
data
|
41
|
+
end
|
42
|
+
|
36
43
|
def ==(other)
|
37
44
|
index == other.index &&
|
38
45
|
transaction_hash == other.transaction_hash
|
@@ -2,11 +2,16 @@ module BTC
|
|
2
2
|
class TransactionSignatureChecker
|
3
3
|
include SignatureChecker
|
4
4
|
|
5
|
+
attr_accessor :version
|
5
6
|
attr_accessor :transaction
|
6
7
|
attr_accessor :input_index
|
7
|
-
|
8
|
+
attr_accessor :amount
|
9
|
+
|
10
|
+
def initialize(version: 0, transaction: nil, input_index: nil, amount: 0)
|
11
|
+
@version = version
|
8
12
|
@transaction = transaction
|
9
13
|
@input_index = input_index
|
14
|
+
@amount = amount
|
10
15
|
end
|
11
16
|
|
12
17
|
def check_signature(script_signature:nil, public_key:nil, script:nil)
|
@@ -19,7 +24,13 @@ module BTC
|
|
19
24
|
ecdsa_sig = script_signature[0..-2]
|
20
25
|
|
21
26
|
key = BTC::Key.new(public_key: public_key)
|
22
|
-
hash = @transaction.signature_hash(
|
27
|
+
hash = @transaction.signature_hash(
|
28
|
+
input_index: @input_index,
|
29
|
+
output_script: script,
|
30
|
+
hash_type: hashtype,
|
31
|
+
version: version,
|
32
|
+
amount: amount
|
33
|
+
)
|
23
34
|
result = key.verify_ecdsa_signature(ecdsa_sig, hash)
|
24
35
|
return result
|
25
36
|
rescue BTC::FormatError => e # public key is invalid
|
data/lib/btcruby/ssss.rb
CHANGED
data/lib/btcruby/transaction.rb
CHANGED
@@ -332,7 +332,7 @@ module BTC
|
|
332
332
|
# Hash for signing a transaction.
|
333
333
|
# You should specify an input index, output script of the previous transaction for that input,
|
334
334
|
# and an optional hash type (default is SIGHASH_ALL).
|
335
|
-
def signature_hash(input_index: nil, output_script: nil, hash_type: BTC::SIGHASH_ALL)
|
335
|
+
def signature_hash(input_index: nil, output_script: nil, hash_type: BTC::SIGHASH_ALL, version: 0, amount: 0)
|
336
336
|
|
337
337
|
raise ArgumentError, "Should specify input_index in Transaction#signature_hash." if !input_index
|
338
338
|
raise ArgumentError, "Should specify output_script in Transaction#signature_hash." if !output_script
|
data/lib/btcruby/version.rb
CHANGED
data/spec/ssss_spec.rb
CHANGED
@@ -127,9 +127,12 @@ describe BTC::SecretSharing do
|
|
127
127
|
shares = ssss.split(secret, m, n)
|
128
128
|
hexshares = shares.map{|s| BTC.to_hex(s)}
|
129
129
|
hexshares.must_equal defined_shares
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
[shares, shares.reverse].each do |list|
|
131
|
+
[list[0...m], list[0...m].reverse].each do |subshares|
|
132
|
+
restored_secret = ssss.restore(subshares)
|
133
|
+
BTC.to_hex(restored_secret).must_equal hexsecret
|
134
|
+
end
|
135
|
+
end
|
133
136
|
end
|
134
137
|
end
|
135
138
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: btcruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Andreev
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|