def ecdsa_sign(node: bip32.HDNode, digest: bytes) -> bytes: sig = secp256k1.sign(node.private_key(), digest) sigder = der.encode_seq((sig[1:33], sig[33:65])) return sigder
def _get_public_key(node: bip32.HDNode) -> Tuple[str, bytes]: seckey = node.private_key() public_key = secp256k1.publickey(seckey, True) wif = public_key_to_wif(public_key) return wif, public_key
def bip340_sign(node: bip32.HDNode, digest: bytes) -> bytes: internal_private_key = node.private_key() output_private_key = bip340.tweak_secret_key(internal_private_key) return bip340.sign(output_private_key, digest)