|
16 | 16 | from collections import deque |
17 | 17 |
|
18 | 18 | import shamir_mnemonic |
| 19 | +from shamir_mnemonic.constants import MAX_SHARE_COUNT |
19 | 20 |
|
20 | 21 | from .api import create, account, path_hardened |
21 | 22 | from .recovery import recover, recover_bip39, shannon_entropy, signal_entropy, analyze_entropy |
@@ -478,14 +479,23 @@ def test_create_recover_smoke_extendable(): |
478 | 479 | slip_simple_mnems[0][:1] + slip_extend_b_mnems[2][:2] |
479 | 480 | ) |
480 | 481 |
|
481 | | - # OK, extended allows you to create a SLIP-39 system with a certain number of groups of certain |
482 | | - # sizes, and later, produce *additional* cards in any of those same groups. The number of |
483 | | - # groups, group required and cards required in each group stays the same. |
| 482 | + # OK, extended allows you to create a SLIP-39 mnemonic system with a certain number of groups of |
| 483 | + # certain sizes, and later, produce *additional* cards in any of those same groups (w/ mnemonics |
| 484 | + # required > 1). The number of groups, group required and mnemonics required in each group |
| 485 | + # stays the same. |
| 486 | + |
| 487 | + for _ in range( 10 ): |
| 488 | + group_count = random.choice( range( 1, MAX_SHARE_COUNT + 1 )) |
| 489 | + group_threshold = random.choice( range( 1, group_count + 1 )) |
| 490 | + groups = {} |
| 491 | + for gn in range( group_count ): |
| 492 | + gn_req = random.choice( range( 1, MAX_SHARE_COUNT + 1 )) |
| 493 | + gn_req_of = random.choice( range( gn_req, gn_req + ( 1 if gn_req == 1 else MAX_SHARE_COUNT - gn_req + 1 ))) |
| 494 | + groups[ordinal( gn+1 )] = (gn_req, gn_req_of) |
| 495 | + log.warning( f"SLIP-39 {group_threshold} of {group_count}: {commas( ': '.join(map(str, i)) for i in groups.items() )}" ) |
| 496 | + g = create( "non-extendable", group_threshold, groups, SEED_ONES, extendable=False ) |
| 497 | + g_ext = create( "non-extendable", group_threshold, groups, SEED_ONES, extendable=True ) |
484 | 498 |
|
485 | | - for _ in range( 100 ): |
486 | | - groups = random.choice( range( 1, 5 )) |
487 | | - groups_required = random.choice( range( 1, groups + 1 )) |
488 | | - #xxx |
489 | 499 |
|
490 | 500 | @substitute( shamir_mnemonic.shamir, 'RANDOM_BYTES', nonrandom_bytes ) |
491 | 501 | def test_create_recover_bip39_extendable(): |
|
0 commit comments