def from_public_key(cls, public_key, chain_path='\x00'*32, depth=0, fingerprint='\x00'*4, child_index=0): public_key_bytes = encode_public_key(public_key, 'bin_compressed') chain_path = extract_bin_chain_path(chain_path) keychain_parts = (version_bytes, depth, fingerprint, child_index, chain_path, public_key_bytes) public_keychain_string = bip32_serialize(keychain_parts) return PublicKeychain(public_keychain_string)
def derive_childkey(key, chaincode, prefix=bitcoin.MAINNET_PUBLIC): """ Given a 33 byte public key and 32 byte chaincode (both in hex) derive the first child key. """ master_key = bitcoin.bip32_serialize((prefix, 0, b"\x00" * 4, 0, unhexlify(chaincode), unhexlify(key))) child_key = bitcoin.bip32_ckd(master_key, 0) return bitcoin.bip32_extract_key(child_key)
def derive_childkey(key, chaincode, prefix=bitcoin.MAINNET_PUBLIC): """ Given a 33 byte public key and 32 byte chaincode (both in hex) derive the first child key. """ master_key = bitcoin.bip32_serialize((prefix, 0, b'\x00'*4, 0, unhexlify(chaincode), unhexlify(key))) child_key = bitcoin.bip32_ckd(master_key, 0) return bitcoin.bip32_extract_key(child_key)