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

Function tweak_add_pubkey

test/functional/test_framework/key.py:438–456  ·  view source on GitHub ↗

Tweak a public key and return whether the result had to be negated.

(key, tweak)

Source from the content-addressed store, hash-verified

436 return x.to_bytes(32, 'big')
437
438def tweak_add_pubkey(key, tweak):
439 """Tweak a public key and return whether the result had to be negated."""
440
441 assert len(key) == 32
442 assert len(tweak) == 32
443
444 x_coord = int.from_bytes(key, 'big')
445 if x_coord >= SECP256K1_FIELD_SIZE:
446 return None
447 P = SECP256K1.lift_x(x_coord)
448 if P is None:
449 return None
450 t = int.from_bytes(tweak, 'big')
451 if t >= SECP256K1_ORDER:
452 return None
453 Q = SECP256K1.affine(SECP256K1.mul([(SECP256K1_G, t), (P, 1)]))
454 if Q is None:
455 return None
456 return (Q[0].to_bytes(32, 'big'), not SECP256K1.has_even_y(Q))
457
458def verify_schnorr(key, sig, msg):
459 """Verify a Schnorr signature (see BIP 340).

Callers 3

pegin_testMethod · 0.90
issuance_testMethod · 0.90
taproot_constructFunction · 0.85

Calls 4

lift_xMethod · 0.80
affineMethod · 0.80
has_even_yMethod · 0.80
mulMethod · 0.45

Tested by

no test coverage detected