def test_PBKDF2_invalid_prf(prf, valid): if valid: PBKDF2(password="******", salt="mysalt", dklen=64, c=2048, prf=prf) else: with pytest.raises(ValueError): PBKDF2( password="******", salt="mysalt", dklen=64, c=2048, prf=prf, )
def get_seed(*, mnemonic: str, password: str = '') -> bytes: """ Derives the seed for the pre-image root of the tree. """ mnemonic = normalize('NFKD', mnemonic) salt = normalize('NFKD', 'mnemonic' + password).encode('utf-8') return PBKDF2(password=mnemonic, salt=salt, dklen=64, c=2048, prf='sha512')
def get_seed(*, mnemonic: str, password: str) -> bytes: """ Derive the seed for the pre-image root of the tree. Ref: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#from-mnemonic-to-seed """ encoded_mnemonic = normalize('NFKD', mnemonic).encode('utf-8') salt = normalize('NFKD', 'mnemonic' + password).encode('utf-8') return PBKDF2(password=encoded_mnemonic, salt=salt, dklen=64, c=2048, prf='sha512')
def kdf(self, **kwargs: Any) -> bytes: return scrypt( **kwargs) if 'scrypt' in self.crypto.kdf.function else PBKDF2( **kwargs)