tapyrus 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/lib/tapyrus/key.rb +1 -1
- data/lib/tapyrus/merkle_tree.rb +8 -5
- data/lib/tapyrus/network/peer_discovery.rb +10 -7
- data/lib/tapyrus/script/script.rb +27 -23
- data/lib/tapyrus/slip39/sss.rb +9 -3
- data/lib/tapyrus/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cf211d0ab36f04dbc16d8ee2c60c1f86bc33b5b2d8c68378c7c550e7c0697db
|
4
|
+
data.tar.gz: 831801fc796432c6c61ee167dd6acc4778ef49853699babb95614a7765e37fd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84092b5fd80adc5a7121d3923c9fa4350dde4b271b19df1ed1b39579b0589862087e9c73916650948231c4bd3f1ad9b0d58c38711bad7be2e571466f2f46b2e4
|
7
|
+
data.tar.gz: 14389a4e0df4fc5eb78c5ae9c63de6aab4a2a10fe52dcc8e655fe17fa6d6056422c6f0a9233dfc452a14f95480af7081570307124203ec1cbbbb11e77a5731ef
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.2
|
data/lib/tapyrus/key.rb
CHANGED
@@ -31,7 +31,7 @@ module Tapyrus
|
|
31
31
|
# @return [Tapyrus::Key] a key object.
|
32
32
|
def initialize(priv_key: nil, pubkey: nil, key_type: nil, compressed: true, allow_hybrid: false)
|
33
33
|
if key_type.nil? && !compressed.nil? && pubkey.nil?
|
34
|
-
|
34
|
+
warn('Use key_type parameter instead of compressed. compressed parameter removed in the future.')
|
35
35
|
end
|
36
36
|
if key_type
|
37
37
|
@key_type = key_type
|
data/lib/tapyrus/merkle_tree.rb
CHANGED
@@ -16,11 +16,14 @@ module Tapyrus
|
|
16
16
|
nodes = [Node.new(txids.first)]
|
17
17
|
else
|
18
18
|
nodes =
|
19
|
-
txids
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
txids
|
20
|
+
.each_slice(2)
|
21
|
+
.map do |m|
|
22
|
+
left = Node.new(m[0])
|
23
|
+
right = Node.new(m[1] ? m[1] : m[0])
|
24
|
+
[left, right]
|
25
|
+
end
|
26
|
+
.flatten
|
24
27
|
end
|
25
28
|
new(build_initial_tree(nodes))
|
26
29
|
end
|
@@ -26,14 +26,17 @@ module Tapyrus
|
|
26
26
|
|
27
27
|
def find_from_dns_seeds
|
28
28
|
logger.debug 'discover peer address from DNS seeds.'
|
29
|
-
dns_seeds
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
dns_seeds
|
30
|
+
.map do |seed|
|
31
|
+
begin
|
32
|
+
Socket.getaddrinfo(seed, Tapyrus.chain_params.default_port).map { |a| a[2] }.uniq
|
33
|
+
rescue SocketError => e
|
34
|
+
logger.error "SocketError occurred when load DNS seed: #{seed}, error: #{e.message}"
|
35
|
+
nil
|
36
|
+
end
|
35
37
|
end
|
36
|
-
|
38
|
+
.flatten
|
39
|
+
.compact
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -281,10 +281,12 @@ module Tapyrus
|
|
281
281
|
# get public keys in the stack.
|
282
282
|
# @return[Array[String]] an array of the pubkeys with hex format.
|
283
283
|
def get_pubkeys
|
284
|
-
chunks
|
285
|
-
|
286
|
-
|
287
|
-
|
284
|
+
chunks
|
285
|
+
.select do |c|
|
286
|
+
c.pushdata? && [33, 65].include?(c.pushed_data.bytesize) &&
|
287
|
+
[2, 3, 4, 6, 7].include?(c.pushed_data[0].bth.to_i(16))
|
288
|
+
end
|
289
|
+
.map { |c| c.pushed_data.bth }
|
288
290
|
end
|
289
291
|
|
290
292
|
# returns the self payload. ScriptInterpreter does not use this.
|
@@ -349,30 +351,32 @@ module Tapyrus
|
|
349
351
|
end
|
350
352
|
|
351
353
|
def to_s
|
352
|
-
chunks
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
v
|
362
|
-
|
363
|
-
data = c.pushed_data
|
364
|
-
if data.bytesize <= 4
|
365
|
-
Script.decode_number(data.bth) # for scriptnum
|
354
|
+
chunks
|
355
|
+
.map do |c|
|
356
|
+
case c
|
357
|
+
when Integer
|
358
|
+
opcode_to_name(c)
|
359
|
+
when String
|
360
|
+
return c if c.empty?
|
361
|
+
if c.pushdata?
|
362
|
+
v = Opcodes.opcode_to_small_int(c.ord)
|
363
|
+
if v
|
364
|
+
v
|
366
365
|
else
|
367
|
-
data.
|
366
|
+
data = c.pushed_data
|
367
|
+
if data.bytesize <= 4
|
368
|
+
Script.decode_number(data.bth) # for scriptnum
|
369
|
+
else
|
370
|
+
data.bth
|
371
|
+
end
|
368
372
|
end
|
373
|
+
else
|
374
|
+
opcode = Opcodes.opcode_to_name(c.ord)
|
375
|
+
opcode ? opcode : 'OP_UNKNOWN [error]'
|
369
376
|
end
|
370
|
-
else
|
371
|
-
opcode = Opcodes.opcode_to_name(c.ord)
|
372
|
-
opcode ? opcode : 'OP_UNKNOWN [error]'
|
373
377
|
end
|
374
378
|
end
|
375
|
-
|
379
|
+
.join(' ')
|
376
380
|
end
|
377
381
|
|
378
382
|
# generate sha-256 hash for payload
|
data/lib/tapyrus/slip39/sss.rb
CHANGED
@@ -190,9 +190,15 @@ module Tapyrus
|
|
190
190
|
shares.each do |share|
|
191
191
|
log_basis_eval = (log_prod - LOG_TABLE[share[0] ^ x] - shares.sum { |s| LOG_TABLE[share[0] ^ s[0]] }) % 255
|
192
192
|
result =
|
193
|
-
share[1]
|
194
|
-
|
195
|
-
|
193
|
+
share[1]
|
194
|
+
.htb
|
195
|
+
.bytes
|
196
|
+
.each
|
197
|
+
.map
|
198
|
+
.with_index do |v, i|
|
199
|
+
(result[i].bti ^ (v == 0 ? 0 : (EXP_TABLE[(LOG_TABLE[v] + log_basis_eval) % 255]))).itb
|
200
|
+
end
|
201
|
+
.join
|
196
202
|
end
|
197
203
|
result.bth
|
198
204
|
end
|
data/lib/tapyrus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapyrus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecdsa
|
@@ -425,7 +425,7 @@ homepage: https://github.com/chaintope/tapyrusrb
|
|
425
425
|
licenses:
|
426
426
|
- MIT
|
427
427
|
metadata: {}
|
428
|
-
post_install_message:
|
428
|
+
post_install_message:
|
429
429
|
rdoc_options: []
|
430
430
|
require_paths:
|
431
431
|
- lib
|
@@ -440,8 +440,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
440
440
|
- !ruby/object:Gem::Version
|
441
441
|
version: '0'
|
442
442
|
requirements: []
|
443
|
-
rubygems_version: 3.
|
444
|
-
signing_key:
|
443
|
+
rubygems_version: 3.2.22
|
444
|
+
signing_key:
|
445
445
|
specification_version: 4
|
446
446
|
summary: The implementation of Tapyrus Protocol for Ruby.
|
447
447
|
test_files: []
|