Skip to content

Commit

Permalink
Merge pull request #3611 from SomberNight/mnemonic_enforce_num_words
Browse files Browse the repository at this point in the history
avoid shorter seeds 'by luck'
  • Loading branch information
ecdsa committed Jan 6, 2018
2 parents c4e4d8a + 295dc12 commit 1fe18ab
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/mnemonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ def make_seed(self, seed_type='standard', num_bits=132, custom_entropy=1):
n_custom = int(math.ceil(math.log(custom_entropy, 2)))
n = max(16, num_bits - n_custom)
print_error("make_seed", prefix, "adding %d bits"%n)
my_entropy = ecdsa.util.randrange(pow(2, n))
my_entropy = 1
while my_entropy < pow(2, n - bpw):
# try again if seed would not contain enough words
my_entropy = ecdsa.util.randrange(pow(2, n))
nonce = 0
while True:
nonce += 1
Expand Down

0 comments on commit 1fe18ab

Please sign in to comment.