1
0
mirror of https://github.com/bitcoin/bips.git synced 2026-03-16 15:55:37 +00:00

Fix point_from_bytes accepting out-of-range pubkeys and add test vector

This commit is contained in:
Jonas Nick
2019-11-04 12:53:37 +00:00
committed by Pieter Wuille
parent 9b5ba158c1
commit c8281deec6
2 changed files with 27 additions and 1 deletions

View File

@@ -53,6 +53,8 @@ def bytes_from_point(P):
def point_from_bytes(b):
x = int_from_bytes(b)
if x >= p:
return None
y_sq = (pow(x, 3, p) + 7) % p
y = pow(y_sq, (p + 1) // 4, p)
if pow(y, 2, p) != y_sq: