Skip to content

Commit 637f384

Browse files
committed
Further integration of Entropy Analysis into GUI
o Display of Harmonics and Shannon Entropy for Seed Data
1 parent 07d56ac commit 637f384

File tree

8 files changed

+444
-140
lines changed

8 files changed

+444
-140
lines changed

slip39/api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from hdwallet import cryptocurrencies
3737

3838
from .defaults import BITS_DEFAULT, BITS, MNEM_ROWS_COLS, GROUP_REQUIRED_RATIO, CRYPTO_PATHS
39-
from .util import ordinal
39+
from .util import ordinal, commas
4040
from .recovery import produce_bip39, recover_bip39
4141

4242
log = logging.getLogger( __package__ )
@@ -364,7 +364,7 @@ def path_default( cls, crypto, format=None ):
364364
crypto = cls.supported( crypto )
365365
format = format.lower() if format else cls.address_format( crypto )
366366
if format not in cls.CRYPTO_FORMAT_PATH[crypto]:
367-
raise ValueError( f"{format} not supported for {crypto}; specify one of {', '.join( cls.CRYPTO_FORMAT_PATH[crypto].keys() )}" )
367+
raise ValueError( f"{format} not supported for {crypto}; specify one of {commas( cls.CRYPTO_FORMAT_PATH[crypto].keys() )}" )
368368
return cls.CRYPTO_FORMAT_PATH[crypto][format]
369369

370370
@classmethod
@@ -380,7 +380,7 @@ def address_format( cls, crypto, format=None ):
380380

381381
format = format.lower() if format else None
382382
if format not in cls.FORMATS:
383-
raise ValueError( f"{crypto} address format {format!r} not recognized; specify one of {', '.join( cls.FORMATS )}" )
383+
raise ValueError( f"{crypto} address format {format!r} not recognized; specify one of {commas( cls.FORMATS )}" )
384384
cls.CRYPTO_FORMAT[crypto] = format
385385

386386
@classmethod
@@ -395,7 +395,7 @@ def supported( cls, crypto ):
395395
)
396396
if validated:
397397
return validated
398-
raise ValueError( f"{crypto} not presently supported; specify {', '.join( cls.CRYPTOCURRENCIES )}" )
398+
raise ValueError( f"{crypto} not presently supported; specify {commas( cls.CRYPTOCURRENCIES )}" )
399399

400400
def __str__( self ):
401401
"""Until from_seed/from_path are invoked, may not have an address or derivation path."""
@@ -905,7 +905,7 @@ def create(
905905
group_reqs = list(
906906
f"{g_nam}({g_of}/{len(g_mns)})" if g_of != len(g_mns) else f"{g_nam}({g_of})"
907907
for g_nam,(g_of,g_mns) in groups.items() )
908-
requires = f"Recover w/ {group_threshold} of {len(groups)} groups {', '.join(group_reqs)}"
908+
requires = f"Recover w/ {group_threshold} of {len(groups)} groups {commas( group_reqs )}"
909909
for g_n,(g_name,(g_of,g_mnems)) in enumerate( groups.items() ):
910910
log.info( f"{g_name}({g_of}/{len(g_mnems)}): {requires}" )
911911
for mn_n,mnem in enumerate( g_mnems ):
@@ -932,7 +932,7 @@ def mnemonics(
932932
master_secret = random_secret( strength // 8 )
933933
if len( master_secret ) * 8 not in BITS:
934934
raise ValueError(
935-
f"Only {', '.join( f'{b}-' for b in BITS )}bit seeds supported; {len(master_secret)*8}-bit master_secret supplied" )
935+
f"Only {commas( BITS, final_and=True )}-bit seeds supported; {len(master_secret)*8}-bit seed supplied" )
936936
return generate_mnemonics(
937937
group_threshold = group_threshold,
938938
groups = groups,

slip39/defaults.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@
102102
LAYOUT_REC = 2
103103
LAYOUT_PRO = 3
104104

105-
BITS = (128, 256, 512)
106105
BITS_DEFAULT = 128
106+
BITS = (128, 256, 512)
107+
BITS_BIP39 = BITS + (160, 192, 224)
107108

108109
MNEM_ROWS_COLS = {
109110
20: ( 7, 3), # 128-bit seed

slip39/gui/SLIP-39-SD.org

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
Create (or recover) Seed Data for your SLIP-39 Mnemonic. Or, backup your insecure/unreliable
66
BIP-39 Mnemonic using SLIP-39.
77

8-
| Controls | Source | Description |
9-
|----------+---------+-----------------------------------------------------------|
10-
| Backup | BIP-39 | Create SLIP-39 Mnemonics from existing BIP-39 Seed Phrase |
11-
| Create | Random | Create SLIP-39 Mnemonics from secure randomnes |
12-
| Recover | SLIP-39 | Recover Seed from SLIP-39 Mnemonics |
13-
| Pro | BIP-39 | Recover BIP-39 Seed resulting from Mnemonics + passphrase |
14-
| Pro | Fixed | Hex data may be supplied for the Seed |
8+
| Controls | Source | Description |
9+
|----------+-------------+--------------------------------------------------------|
10+
| Backup | BIP-39 | Create SLIP-39 Mnemonics to recover BIP-39 Seed Phrase |
11+
| Create | Random | Create SLIP-39 Mnemonics from secure randomnes |
12+
| Recover | SLIP-39 | Recover Seed from SLIP-39 Mnemonics |
13+
| Pro | BIP-39 Seed | Backup 512-bit BIP-39 Seed from Mnemonics + passphrase |
14+
| Pro | Fixed | Hex data may be supplied for the Seed |
1515
#+END_ABSTRACT
1616

1717
* BIP-39
1818

1919
Backup an existing 12- or 24-word BIP-39 Seed Phrase Mnemonic. Or, select Create to produce a new
2020
BIP-39 Mnemonic. Save your BIP-39 Seed Phrase as a set of SLIP-39 Mnemonic Card Groups.
2121

22-
Later, select Recover to input your SLIP-39 Mnemonics, and recover your BIP-39 Seed Phrase.
22+
Later, select Recover to input your SLIP-39 Mnemonics, and recover your BIP-39 Seed Phrase. Use
23+
this BIP-39 Seed Phrase (plus your passphrase, if any) to initialize a BIP-39 Hardware Wallet.
2324

2425
You can then securely destroy your BIP-39 Mnemonic card(s) (or, keep a copy in some *extremely*
2526
secure location), and use the SLIP-39 Mnemonic cards as your distributed backup in case of its
@@ -71,6 +72,18 @@ BIP-39 Mnemonic using SLIP-39.
7172

7273
So, 128-bit seeds are probably fine for most practical levels of account security...
7374

75+
* BIP-39 Seed
76+
77+
If you wish, you can backup a /complete/ BIP-39 Seed Phrase *including its passphrase*, as a raw
78+
512-bit BIP-39 Seed! This ensures that whoever uses the SLIP-39 Mnemonics to recover the wallets
79+
does not need to know the original BIP-39 Mnemonic + passphrase.
80+
81+
There are a couple of drawbacks with this approach, though:
82+
83+
- Large 59-word SLIP-39 Mnemonics are produced, to store the 512-bit seed
84+
- Seed cannot be used with a BIP-39 Hardware Wallet
85+
- Produce "Paper Wallets" for whichever derived HD wallets you need to access
86+
7487
** The Birthday Paradox
7588

7689
However, due to the [[https://en.wikipedia.org/wiki/Birthday_attack][Birthday Attack]], the probability of two parties out of /a large number

slip39/gui/SLIP-39-SD.txt

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Create (or recover) Seed Data for your SLIP-39 Mnemonic. Or, backup
22
your insecure/unreliable BIP-39 Mnemonic using SLIP-39.
33

4-
Controls Source Description
5-
------------------------------------------------------------------------------
6-
Backup BIP-39 Create SLIP-39 Mnemonics from existing BIP-39 Seed Phrase
7-
Create Random Create SLIP-39 Mnemonics from secure randomnes
8-
Recover SLIP-39 Recover Seed from SLIP-39 Mnemonics
9-
Pro BIP-39 Recover BIP-39 Seed resulting from Mnemonics + passphrase
10-
Pro Fixed Hex data may be supplied for the Seed
4+
Controls Source Description
5+
-------------------------------------------------------------------------------
6+
Backup BIP-39 Create SLIP-39 Mnemonics to recover BIP-39 Seed Phrase
7+
Create Random Create SLIP-39 Mnemonics from secure randomnes
8+
Recover SLIP-39 Recover Seed from SLIP-39 Mnemonics
9+
Pro BIP-39 Seed Backup 512-bit BIP-39 Seed from Mnemonics + passphrase
10+
Pro Fixed Hex data may be supplied for the Seed
1111

1212

1313
1 BIP-39
@@ -18,7 +18,8 @@ your insecure/unreliable BIP-39 Mnemonic using SLIP-39.
1818
Phrase as a set of SLIP-39 Mnemonic Card Groups.
1919

2020
Later, select Recover to input your SLIP-39 Mnemonics, and recover
21-
your BIP-39 Seed Phrase.
21+
your BIP-39 Seed Phrase. Use this BIP-39 Seed Phrase (plus your
22+
passphrase, if any) to initialize a BIP-39 Hardware Wallet.
2223

2324
You can then securely destroy your BIP-39 Mnemonic card(s) (or, keep a
2425
copy in some *extremely* secure location), and use the SLIP-39
@@ -88,7 +89,24 @@ your insecure/unreliable BIP-39 Mnemonic using SLIP-39.
8889
account security...
8990

9091

91-
3.1 The Birthday Paradox
92+
4 BIP-39 Seed
93+
=============
94+
95+
If you wish, you can backup a /complete/ BIP-39 Seed Phrase *including
96+
its passphrase*, as a raw 512-bit BIP-39 Seed! This ensures that
97+
whoever uses the SLIP-39 Mnemonics to recover the wallets does not
98+
need to know the original BIP-39 Mnemonic + passphrase.
99+
100+
There are a couple of drawbacks with this approach, though:
101+
102+
- Large 59-word SLIP-39 Mnemonics are produced, to store the 512-bit
103+
seed
104+
- Seed cannot be used with a BIP-39 Hardware Wallet
105+
- Produce "Paper Wallets" for whichever derived HD wallets you need
106+
to access
107+
108+
109+
4.1 The Birthday Paradox
92110
~~~~~~~~~~~~~~~~~~~~~~~~
93111

94112
However, due to the [Birthday Attack], the probability of two parties

0 commit comments

Comments
 (0)