diff options
author | kallewoof <karljohan-alm@garage.co.jp> | 2022-08-25 16:05:58 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 16:05:58 +0900 |
commit | 52f68fecd8ec9604672e26392468e7e7edf25a5e (patch) | |
tree | 83bc306aa263d3771b4f68e1742ed0c899040c70 /bip-0340 | |
parent | 64aba767e2d422b5d471509acc340750432613ae (diff) | |
parent | 3998dbbc8a3ab3bfabb1b2e90a4840ad93a84adb (diff) | |
download | bips-52f68fecd8ec9604672e26392468e7e7edf25a5e.tar.xz |
Merge pull request #1355 from jonasnick/fix-missing-int
BIP 340 & 341: use consistent definition of lift_x
Diffstat (limited to 'bip-0340')
-rw-r--r-- | bip-0340/reference.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/bip-0340/reference.py b/bip-0340/reference.py index 5b38c0a..162bb88 100644 --- a/bip-0340/reference.py +++ b/bip-0340/reference.py @@ -68,8 +68,7 @@ def bytes_from_point(P: Point) -> bytes: def xor_bytes(b0: bytes, b1: bytes) -> bytes: return bytes(x ^ y for (x, y) in zip(b0, b1)) -def lift_x(b: bytes) -> Optional[Point]: - x = int_from_bytes(b) +def lift_x(x: int) -> Optional[Point]: if x >= p: return None y_sq = (pow(x, 3, p) + 7) % p @@ -128,7 +127,7 @@ def schnorr_verify(msg: bytes, pubkey: bytes, sig: bytes) -> bool: raise ValueError('The public key must be a 32-byte array.') if len(sig) != 64: raise ValueError('The signature must be a 64-byte array.') - P = lift_x(pubkey) + P = lift_x(int_from_bytes(pubkey)) r = int_from_bytes(sig[0:32]) s = int_from_bytes(sig[32:64]) if (P is None) or (r >= p) or (s >= n): |