-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtss_burn_brute.rb
30 lines (28 loc) · 1.11 KB
/
tss_burn_brute.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'test_helper'
describe TSS do
describe 'end-to-end burn-in test' do
it 'must split and combine the secret properly using many combinations of options' do
[0, 32, 128, 255].each do |pb|
['HUMAN', 'BINARY'].each do |f|
['NONE', 'SHA1', 'SHA256'].each do |h|
(1..10).each do |m|
(m..10).each do |n|
id = SecureRandom.hex(rand(1..8))
s = SecureRandom.hex(rand(1..8))
shares = TSS.split(secret: s, identifier: id, threshold: m, num_shares: n, hash_alg: h, format: f, pad_blocksize: pb)
shares.first.encoding.name.must_equal f == 'HUMAN' ? 'UTF-8' : 'ASCII-8BIT'
['FIRST', 'SAMPLE', 'COMBINATIONS'].each do |sb|
# can't use combinations with NONE
sb = (h == 'NONE') ? 'FIRST' : sb
sec = TSS.combine(shares: shares, select_by: sb)
sec[:secret].must_equal s
sec[:secret].encoding.name.must_equal 'UTF-8'
end
end
end
end
end
end
end
end
end