MCPcopy Create free account
hub / github.com/ElementsProject/elements / default_signature

Function default_signature

test/functional/feature_taproot.py:293–307  ·  view source on GitHub ↗

Default expression for "signature": BIP340 signature or ECDSA signature depending on mode.

(ctx)

Source from the content-addressed store, hash-verified

291 return tweak_add_privkey(key, tweak)
292
293def default_signature(ctx):
294 """Default expression for "signature": BIP340 signature or ECDSA signature depending on mode."""
295 sighash = get(ctx, "sighash")
296 deterministic = get(ctx, "deterministic")
297 if get(ctx, "mode") == "taproot":
298 key = get(ctx, "key_tweaked")
299 flip_r = get(ctx, "flag_flip_r")
300 flip_p = get(ctx, "flag_flip_p")
301 aux = bytes([0] * 32)
302 if not deterministic:
303 aux = random.getrandbits(256).to_bytes(32, 'big')
304 return sign_schnorr(key, sighash, flip_r=flip_r, flip_p=flip_p, aux=aux)
305 else:
306 key = get(ctx, "key")
307 return key.sign_ecdsa(sighash, rfc6979=deterministic)
308
309def default_hashtype_actual(ctx):
310 """Default expression for "hashtype_actual": hashtype, unless mismatching SIGHASH_SINGLE in taproot."""

Callers

nothing calls this directly

Calls 3

sign_schnorrFunction · 0.90
getFunction · 0.85
sign_ecdsaMethod · 0.80

Tested by

no test coverage detected