mirror of
https://github.com/bitcoin/bips.git
synced 2025-05-12 12:03:29 +00:00
Merge pull request #1369 from DariusParvin/bip341
BIP 341: add missing conversions between bytes and int
This commit is contained in:
commit
194ee7320b
@ -186,12 +186,13 @@ def taproot_tweak_pubkey(pubkey, h):
|
|||||||
return 0 if has_even_y(Q) else 1, bytes_from_int(x(Q))
|
return 0 if has_even_y(Q) else 1, bytes_from_int(x(Q))
|
||||||
|
|
||||||
def taproot_tweak_seckey(seckey0, h):
|
def taproot_tweak_seckey(seckey0, h):
|
||||||
P = point_mul(G, int_from_bytes(seckey0))
|
seckey0 = int_from_bytes(seckey0)
|
||||||
|
P = point_mul(G, seckey0)
|
||||||
seckey = seckey0 if has_even_y(P) else SECP256K1_ORDER - seckey0
|
seckey = seckey0 if has_even_y(P) else SECP256K1_ORDER - seckey0
|
||||||
t = int_from_bytes(tagged_hash("TapTweak", bytes_from_int(x(P)) + h))
|
t = int_from_bytes(tagged_hash("TapTweak", bytes_from_int(x(P)) + h))
|
||||||
if t >= SECP256K1_ORDER:
|
if t >= SECP256K1_ORDER:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
return (seckey + t) % SECP256K1_ORDER
|
return bytes_from_int((seckey + t) % SECP256K1_ORDER)
|
||||||
</source>
|
</source>
|
||||||
|
|
||||||
The following function, <code>taproot_output_script</code>, returns a byte array with the scriptPubKey (see [[bip-0141.mediawiki|BIP141]]).
|
The following function, <code>taproot_output_script</code>, returns a byte array with the scriptPubKey (see [[bip-0141.mediawiki|BIP141]]).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user