Browse Source
Merge pull request #3611 from SomberNight/mnemonic_enforce_num_words
avoid shorter seeds 'by luck'
3.1
ThomasV
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
4 additions and
1 deletions
-
lib/mnemonic.py
|
@ -171,7 +171,10 @@ class Mnemonic(object): |
|
|
n_custom = int(math.ceil(math.log(custom_entropy, 2))) |
|
|
n_custom = int(math.ceil(math.log(custom_entropy, 2))) |
|
|
n = max(16, num_bits - n_custom) |
|
|
n = max(16, num_bits - n_custom) |
|
|
print_error("make_seed", prefix, "adding %d bits"%n) |
|
|
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 |
|
|
nonce = 0 |
|
|
while True: |
|
|
while True: |
|
|
nonce += 1 |
|
|
nonce += 1 |
|
|