1
0

mnemonic: make sure newly generated seeds are not valid as bip39

This commit is contained in:
SomberNight
2020-02-29 00:34:06 +01:00
parent b7a8b1aae6
commit 9f08293c0e
2 changed files with 13 additions and 2 deletions

View File

@@ -188,6 +188,7 @@ class Mnemonic(Logger):
return i
def make_seed(self, *, seed_type=None, num_bits=None) -> str:
from .keystore import bip39_is_checksum_valid
if seed_type is None:
seed_type = 'segwit'
if num_bits is None:
@@ -210,6 +211,11 @@ class Mnemonic(Logger):
raise Exception('Cannot extract same entropy from mnemonic!')
if is_old_seed(seed):
continue
# Make sure the mnemonic we generate is not also a valid bip39 seed
# by accident. Note that this test has not always been done historically,
# so it cannot be relied upon.
if bip39_is_checksum_valid(seed, wordlist=self.wordlist) == (True, True):
continue
if is_new_seed(seed, prefix):
break
self.logger.info(f'{len(seed.split())} words')