mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-05 05:15:12 +00:00
remove pbkdf2 dependency, use stdlib instead
This commit is contained in:
parent
b4b862b0cc
commit
1e715113ab
6 changed files with 9 additions and 13 deletions
|
@ -1,6 +1,5 @@
|
||||||
pyaes>=0.1a1
|
pyaes>=0.1a1
|
||||||
ecdsa>=0.9
|
ecdsa>=0.9
|
||||||
pbkdf2
|
|
||||||
requests
|
requests
|
||||||
qrcode
|
qrcode
|
||||||
protobuf
|
protobuf
|
||||||
|
|
|
@ -552,13 +552,12 @@ def bip39_normalize_passphrase(passphrase):
|
||||||
return normalize('NFKD', passphrase or '')
|
return normalize('NFKD', passphrase or '')
|
||||||
|
|
||||||
def bip39_to_seed(mnemonic, passphrase):
|
def bip39_to_seed(mnemonic, passphrase):
|
||||||
import pbkdf2, hashlib, hmac
|
import hashlib, hmac
|
||||||
PBKDF2_ROUNDS = 2048
|
PBKDF2_ROUNDS = 2048
|
||||||
mnemonic = normalize('NFKD', ' '.join(mnemonic.split()))
|
mnemonic = normalize('NFKD', ' '.join(mnemonic.split()))
|
||||||
passphrase = bip39_normalize_passphrase(passphrase)
|
passphrase = bip39_normalize_passphrase(passphrase)
|
||||||
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase,
|
return hashlib.pbkdf2_hmac('sha512', mnemonic.encode('utf-8'),
|
||||||
iterations = PBKDF2_ROUNDS, macmodule = hmac,
|
b'mnemonic' + passphrase.encode('utf-8'), iterations = PBKDF2_ROUNDS)
|
||||||
digestmodule = hashlib.sha512).read(64)
|
|
||||||
|
|
||||||
# returns tuple (is_checksum_valid, is_wordlist_valid)
|
# returns tuple (is_checksum_valid, is_wordlist_valid)
|
||||||
def bip39_is_checksum_valid(mnemonic):
|
def bip39_is_checksum_valid(mnemonic):
|
||||||
|
|
|
@ -30,7 +30,6 @@ import unicodedata
|
||||||
import string
|
import string
|
||||||
|
|
||||||
import ecdsa
|
import ecdsa
|
||||||
import pbkdf2
|
|
||||||
|
|
||||||
from .util import print_error
|
from .util import print_error
|
||||||
from .bitcoin import is_old_seed, is_new_seed
|
from .bitcoin import is_old_seed, is_new_seed
|
||||||
|
@ -131,7 +130,7 @@ class Mnemonic(object):
|
||||||
PBKDF2_ROUNDS = 2048
|
PBKDF2_ROUNDS = 2048
|
||||||
mnemonic = normalize_text(mnemonic)
|
mnemonic = normalize_text(mnemonic)
|
||||||
passphrase = normalize_text(passphrase)
|
passphrase = normalize_text(passphrase)
|
||||||
return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
|
return hashlib.pbkdf2_hmac('sha512', mnemonic.encode('utf-8'), b'electrum' + passphrase.encode('utf-8'), iterations = PBKDF2_ROUNDS)
|
||||||
|
|
||||||
def mnemonic_encode(self, i):
|
def mnemonic_encode(self, i):
|
||||||
n = len(self.wordlist)
|
n = len(self.wordlist)
|
||||||
|
|
|
@ -120,8 +120,8 @@ class DigitalBitbox_Client():
|
||||||
|
|
||||||
|
|
||||||
def stretch_key(self, key):
|
def stretch_key(self, key):
|
||||||
import pbkdf2, hmac
|
import hmac
|
||||||
return to_hexstr(pbkdf2.PBKDF2(key, b'Digital Bitbox', iterations = 20480, macmodule = hmac, digestmodule = hashlib.sha512).read(64))
|
return to_hexstr(hashlib.pbkdf2_hmac('sha512', key.encode('utf-8'), b'Digital Bitbox', iterations = 20480))
|
||||||
|
|
||||||
|
|
||||||
def backup_password_dialog(self):
|
def backup_password_dialog(self):
|
||||||
|
|
|
@ -29,7 +29,7 @@ import json
|
||||||
import copy
|
import copy
|
||||||
import re
|
import re
|
||||||
import stat
|
import stat
|
||||||
import pbkdf2, hmac, hashlib
|
import hmac, hashlib
|
||||||
import base64
|
import base64
|
||||||
import zlib
|
import zlib
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
@ -165,7 +165,7 @@ class WalletStorage(PrintError):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_eckey_from_password(password):
|
def get_eckey_from_password(password):
|
||||||
secret = pbkdf2.PBKDF2(password, '', iterations=1024, macmodule=hmac, digestmodule=hashlib.sha512).read(64)
|
secret = hashlib.pbkdf2_hmac('sha512', password.encode('utf-8'), b'', iterations=1024)
|
||||||
ec_key = ecc.ECPrivkey.from_arbitrary_size_secret(secret)
|
ec_key = ecc.ECPrivkey.from_arbitrary_size_secret(secret)
|
||||||
return ec_key
|
return ec_key
|
||||||
|
|
||||||
|
@ -637,7 +637,7 @@ class WalletStorage(PrintError):
|
||||||
# version 1.9.8 created v6 wallets when an incorrect seed was entered in the restore dialog
|
# version 1.9.8 created v6 wallets when an incorrect seed was entered in the restore dialog
|
||||||
msg += '\n\nThis file was created because of a bug in version 1.9.8.'
|
msg += '\n\nThis file was created because of a bug in version 1.9.8.'
|
||||||
if self.get('master_public_keys') is None and self.get('master_private_keys') is None and self.get('imported_keys') is None:
|
if self.get('master_public_keys') is None and self.get('master_private_keys') is None and self.get('imported_keys') is None:
|
||||||
# pbkdf2 was not included with the binaries, and wallet creation aborted.
|
# pbkdf2 (at that time an additional dependency) was not included with the binaries, and wallet creation aborted.
|
||||||
msg += "\nIt does not contain any keys, and can safely be removed."
|
msg += "\nIt does not contain any keys, and can safely be removed."
|
||||||
else:
|
else:
|
||||||
# creation was complete if electrum was run from source
|
# creation was complete if electrum was run from source
|
||||||
|
|
|
@ -46,7 +46,6 @@ def check_imports():
|
||||||
import ecdsa
|
import ecdsa
|
||||||
import requests
|
import requests
|
||||||
import qrcode
|
import qrcode
|
||||||
import pbkdf2
|
|
||||||
import google.protobuf
|
import google.protobuf
|
||||||
import jsonrpclib
|
import jsonrpclib
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
|
|
Loading…
Add table
Reference in a new issue