mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 01:35:20 +00:00
add 8 bits to entropy target, to offset the constraint imposed by is_new_seed
This commit is contained in:
parent
4d71707be8
commit
8816d7072f
1 changed files with 2 additions and 1 deletions
|
@ -83,7 +83,7 @@ class Mnemonic(object):
|
||||||
def make_seed(self, num_bits=128, custom_entropy=1):
|
def make_seed(self, num_bits=128, custom_entropy=1):
|
||||||
n = int(math.ceil(math.log(custom_entropy,2)))
|
n = int(math.ceil(math.log(custom_entropy,2)))
|
||||||
# we add at least 16 bits
|
# we add at least 16 bits
|
||||||
n_added = max(16, num_bits-n)
|
n_added = max(16, 8 + num_bits - n)
|
||||||
print_error("make_seed: adding %d bits"%n_added)
|
print_error("make_seed: adding %d bits"%n_added)
|
||||||
my_entropy = ecdsa.util.randrange( pow(2, n_added) )
|
my_entropy = ecdsa.util.randrange( pow(2, n_added) )
|
||||||
nonce = 0
|
nonce = 0
|
||||||
|
@ -97,5 +97,6 @@ class Mnemonic(object):
|
||||||
# this removes 8 bits of entropy
|
# this removes 8 bits of entropy
|
||||||
if is_new_seed(seed):
|
if is_new_seed(seed):
|
||||||
break
|
break
|
||||||
|
print_error('%d words'%len(seed.split()))
|
||||||
return seed
|
return seed
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue