def from_seed(cls, ledger, seed): # This hard-coded message string seems to be coin-independent... hmac = hmac_sha512(b'Bitcoin seed', seed) privkey, chain_code = hmac[:32], hmac[32:] return cls(ledger, privkey, chain_code, 0, 0)
def _hmac_sha512(self, msg): """ Use SHA-512 to provide an HMAC, returned as a pair of 32-byte objects. """ hmac = hmac_sha512(self.chain_code, msg) return hmac[:32], hmac[32:]
def is_new_seed(seed, prefix): seed = normalize_text(seed) seed_hash = hexlify(hmac_sha512(b"Seed version", seed.encode('utf8'))) return seed_hash.startswith(prefix)