mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
remove custom entropy option; nobody uses it
This commit is contained in:
parent
19cee0e6c0
commit
e0c38b31b4
2 changed files with 5 additions and 21 deletions
|
@ -150,18 +150,12 @@ class Commands:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@command('')
|
@command('')
|
||||||
def make_seed(self, nbits=128, entropy=1, language=None):
|
def make_seed(self, nbits=128, language=None):
|
||||||
"""Create a seed"""
|
"""Create a seed"""
|
||||||
from mnemonic import Mnemonic
|
from mnemonic import Mnemonic
|
||||||
s = Mnemonic(language).make_seed(nbits, custom_entropy=entropy)
|
s = Mnemonic(language).make_seed(nbits)
|
||||||
return s.encode('utf8')
|
return s.encode('utf8')
|
||||||
|
|
||||||
@command('')
|
|
||||||
def check_seed(self, seed, entropy=1, language=None):
|
|
||||||
"""Check that a seed was generated with given entropy"""
|
|
||||||
from mnemonic import Mnemonic
|
|
||||||
return Mnemonic(language).check_seed(seed, entropy)
|
|
||||||
|
|
||||||
@command('n')
|
@command('n')
|
||||||
def getaddresshistory(self, address):
|
def getaddresshistory(self, address):
|
||||||
"""Return the transaction history of any address. Note: This is a
|
"""Return the transaction history of any address. Note: This is a
|
||||||
|
@ -671,7 +665,6 @@ command_options = {
|
||||||
'from_addr': ("-F", "--from", "Source address. If it isn't in the wallet, it will ask for the private key unless supplied in the format public_key:private_key. It's not saved in the wallet."),
|
'from_addr': ("-F", "--from", "Source address. If it isn't in the wallet, it will ask for the private key unless supplied in the format public_key:private_key. It's not saved in the wallet."),
|
||||||
'change_addr': ("-c", "--change", "Change address. Default is a spare address, or the source address if it's not in the wallet"),
|
'change_addr': ("-c", "--change", "Change address. Default is a spare address, or the source address if it's not in the wallet"),
|
||||||
'nbits': (None, "--nbits", "Number of bits of entropy"),
|
'nbits': (None, "--nbits", "Number of bits of entropy"),
|
||||||
'entropy': (None, "--entropy", "Custom entropy"),
|
|
||||||
'language': ("-L", "--lang", "Default language for wordlist"),
|
'language': ("-L", "--lang", "Default language for wordlist"),
|
||||||
'gap_limit': ("-G", "--gap", "Gap limit"),
|
'gap_limit': ("-G", "--gap", "Gap limit"),
|
||||||
'privkey': (None, "--privkey", "Private key. Set to '?' to get a prompt."),
|
'privkey': (None, "--privkey", "Private key. Set to '?' to get a prompt."),
|
||||||
|
@ -694,7 +687,6 @@ json_loads = lambda x: json.loads(x, parse_float=lambda x: str(Decimal(x)))
|
||||||
arg_types = {
|
arg_types = {
|
||||||
'num': int,
|
'num': int,
|
||||||
'nbits': int,
|
'nbits': int,
|
||||||
'entropy': long,
|
|
||||||
'tx': tx_from_str,
|
'tx': tx_from_str,
|
||||||
'pubkeys': json_loads,
|
'pubkeys': json_loads,
|
||||||
'jsontx': json_loads,
|
'jsontx': json_loads,
|
||||||
|
|
|
@ -154,24 +154,16 @@ class Mnemonic(object):
|
||||||
i = i*n + k
|
i = i*n + k
|
||||||
return i
|
return i
|
||||||
|
|
||||||
def check_seed(self, seed, custom_entropy):
|
def make_seed(self, num_bits=128, prefix=version.SEED_PREFIX):
|
||||||
assert is_new_seed(seed)
|
|
||||||
i = self.mnemonic_decode(seed)
|
|
||||||
return i % custom_entropy == 0
|
|
||||||
|
|
||||||
def make_seed(self, num_bits=128, prefix=version.SEED_PREFIX, custom_entropy=1):
|
|
||||||
# increase num_bits in order to obtain a uniform distibution for the last word
|
# increase num_bits in order to obtain a uniform distibution for the last word
|
||||||
bpw = math.log(len(self.wordlist), 2)
|
bpw = math.log(len(self.wordlist), 2)
|
||||||
num_bits = int(math.ceil(num_bits/bpw)) * bpw
|
n = int(math.ceil(num_bits/bpw)) * bpw
|
||||||
# handle custom entropy; make sure we add at least 16 bits
|
|
||||||
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)
|
print_error("make_seed", prefix, "adding %d bits"%n)
|
||||||
my_entropy = ecdsa.util.randrange(pow(2, n))
|
my_entropy = ecdsa.util.randrange(pow(2, n))
|
||||||
nonce = 0
|
nonce = 0
|
||||||
while True:
|
while True:
|
||||||
nonce += 1
|
nonce += 1
|
||||||
i = custom_entropy * (my_entropy + nonce)
|
i = my_entropy + nonce
|
||||||
seed = self.mnemonic_encode(i)
|
seed = self.mnemonic_encode(i)
|
||||||
assert i == self.mnemonic_decode(seed)
|
assert i == self.mnemonic_decode(seed)
|
||||||
if is_old_seed(seed):
|
if is_old_seed(seed):
|
||||||
|
|
Loading…
Add table
Reference in a new issue