summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Nick <jonasd.nick@gmail.com>2019-09-30 11:15:23 +0000
committerPieter Wuille <pieter.wuille@gmail.com>2020-01-19 14:47:33 -0800
commitd112f5b0352f404e2cfebd6f3d9bf030c6894917 (patch)
treeff18b4115bb6fe8dc3c1a62e0b9a41bde65d6fef
parentafa5519ade7d1b90d91fb725bf37eecd38cc4eb3 (diff)
Replace taproot_tweak_pubkey assertion with exception and add it to taproot_tweak_seckey too
-rw-r--r--bip-taproot.mediawiki5
1 files changed, 4 insertions, 1 deletions
diff --git a/bip-taproot.mediawiki b/bip-taproot.mediawiki
index 8abf6e1..ba54689 100644
--- a/bip-taproot.mediawiki
+++ b/bip-taproot.mediawiki
@@ -187,7 +187,8 @@ For any byte string <code>h</code> it holds that <code>taproot_tweak_pubkey(pubk
<source lang="python">
def taproot_tweak_pubkey(pubkey, h):
t = int_from_bytes(tagged_hash("TapTweak", pubkey + h))
- assert t < SECP256K1_ORDER
+ if t >= SECP256K1_ORDER:
+ raise ValueError
Q = point_mul(point(pubkey), t)
return bytes_from_int(x(Q)), is_quad(y(Q))
@@ -195,6 +196,8 @@ def taproot_tweak_seckey(seckey0, h):
P = point_mul(G, int_from_bytes(seckey0))
seckey = SECP256K1_ORDER - seckey0 if not is_quad(y(R)) else seckey
t = int_from_bytes(tagged_hash("TapTweak", bytes_from_int(x(P)) + h))
+ if t >= SECP256K1_ORDER:
+ raise ValueError
return (seckey + t) % SECP256K1_ORDER
</source>