Skip to content

Commit d41e778

Browse files
committed
BIP 340: Update reference code and test vectors as follows:
- use evenness as tiebreaker - using different tags for nonce- and challenge hashing - add pubkey to nonce function.
1 parent 88d30c7 commit d41e778

File tree

3 files changed

+66
-41
lines changed

3 files changed

+66
-41
lines changed

bip-0340/reference.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def bytes_from_int(x):
5151
def bytes_from_point(P):
5252
return bytes_from_int(x(P))
5353

54-
def point_from_bytes(b):
54+
def lift_x_square_y(b):
5555
x = int_from_bytes(b)
5656
if x >= p:
5757
return None
@@ -61,6 +61,13 @@ def point_from_bytes(b):
6161
return None
6262
return [x, y]
6363

64+
def lift_x_even_y(b):
65+
P = lift_x_square_y(b)
66+
if P is None:
67+
return None
68+
else:
69+
return [x(P), y(P) if y(P) % 2 == 0 else p - y(P)]
70+
6471
def int_from_bytes(b):
6572
return int.from_bytes(b, byteorder="big")
6673

@@ -73,6 +80,9 @@ def is_square(x):
7380
def has_square_y(P):
7481
return not is_infinity(P) and is_square(y(P))
7582

83+
def has_even_y(P):
84+
return y(P) % 2 == 0
85+
7686
def pubkey_gen(seckey):
7787
x = int_from_bytes(seckey)
7888
if not (1 <= x <= n - 1):
@@ -87,13 +97,13 @@ def schnorr_sign(msg, seckey0):
8797
if not (1 <= seckey0 <= n - 1):
8898
raise ValueError('The secret key must be an integer in the range 1..n-1.')
8999
P = point_mul(G, seckey0)
90-
seckey = seckey0 if has_square_y(P) else n - seckey0
91-
k0 = int_from_bytes(tagged_hash("BIPSchnorrDerive", bytes_from_int(seckey) + msg)) % n
100+
seckey = seckey0 if has_even_y(P) else n - seckey0
101+
k0 = int_from_bytes(tagged_hash("BIP340/nonce", bytes_from_int(seckey) + bytes_from_point(P) + msg)) % n
92102
if k0 == 0:
93103
raise RuntimeError('Failure. This happens only with negligible probability.')
94104
R = point_mul(G, k0)
95105
k = n - k0 if not has_square_y(R) else k0
96-
e = int_from_bytes(tagged_hash("BIPSchnorr", bytes_from_point(R) + bytes_from_point(P) + msg)) % n
106+
e = int_from_bytes(tagged_hash("BIP340/challenge", bytes_from_point(R) + bytes_from_point(P) + msg)) % n
97107
return bytes_from_point(R) + bytes_from_int((k + e * seckey) % n)
98108

99109
def schnorr_verify(msg, pubkey, sig):
@@ -103,14 +113,14 @@ def schnorr_verify(msg, pubkey, sig):
103113
raise ValueError('The public key must be a 32-byte array.')
104114
if len(sig) != 64:
105115
raise ValueError('The signature must be a 64-byte array.')
106-
P = point_from_bytes(pubkey)
116+
P = lift_x_even_y(pubkey)
107117
if (P is None):
108118
return False
109119
r = int_from_bytes(sig[0:32])
110120
s = int_from_bytes(sig[32:64])
111121
if (r >= p or s >= n):
112122
return False
113-
e = int_from_bytes(tagged_hash("BIPSchnorr", sig[0:32] + pubkey + msg)) % n
123+
e = int_from_bytes(tagged_hash("BIP340/challenge", sig[0:32] + pubkey + msg)) % n
114124
R = point_add(point_mul(G, s), point_mul(P, n - e))
115125
if R is None or not has_square_y(R) or x(R) != r:
116126
return False

bip-0340/test-vectors.csv

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
index,secret key,public key,message,signature,verification result,comment
2-
0,0000000000000000000000000000000000000000000000000000000000000001,79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798,0000000000000000000000000000000000000000000000000000000000000000,528F745793E8472C0329742A463F59E58F3A3F1A4AC09C28F6F8514D4D0322A258BD08398F82CF67B812AB2C7717CE566F877C2F8795C846146978E8F04782AE,TRUE,
3-
1,B7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,667C2F778E0616E611BD0C14B8A600C5884551701A949EF0EBFD72D452D64E844160BCFC3F466ECB8FACD19ADE57D8699D74E7207D78C6AEDC3799B52A8E0598,TRUE,
4-
2,C90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B14E5C9,DD308AFEC5777E13121FA72B9CC1B7CC0139715309B086C960E18FD969774EB8,5E2D58D8B3BCDF1ABADEC7829054F90DDA9805AAB56C77333024B9D0A508B75C,2D941B38E32624BF0AC7669C0971B990994AF6F9B18426BF4F4E7EC10E6CDF386CF646C6DDAFCFA7F1993EEB2E4D66416AEAD1DDAE2F22D63CAD901412D116C6,TRUE,
5-
3,0B432B2677937381AEF05BB02A66ECD012773062CF3FA2549E44F58ED2401710,25D1DFF95105F5253C4022F628A996AD3A0D95FBF21D468A1B33F8C160D8F517,FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,8BD2C11604B0A87A443FCC2E5D90E5328F934161B18864FB48CE10CB59B45FB9B5B2A0F129BD88F5BDC05D5C21E5C57176B913002335784F9777A24BD317CD36,TRUE,test fails if msg is reduced modulo p or n
6-
4,,D69C3509BB99E412E68B0FE8544E72837DFA30746D8BE2AA65975F29D22DC7B9,4DF3C3F68FCC83B27E9D42C90431A72499F17875C81A599B566C9889B9696703,00000000000000000000003B78CE563F89A0ED9414F5AA28AD0D96D6795F9C63EE374AC7FAE927D334CCB190F6FB8FD27A2DDC639CCEE46D43F113A4035A2C7F,TRUE,
7-
5,,EEFDEA4CDB677750A420FEE807EACF21EB9898AE79B9768766E4FAA04A2D4A34,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,667C2F778E0616E611BD0C14B8A600C5884551701A949EF0EBFD72D452D64E844160BCFC3F466ECB8FACD19ADE57D8699D74E7207D78C6AEDC3799B52A8E0598,FALSE,public key not on the curve
8-
6,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9935554D1AA5F0374E5CDAACB3925035C7C169B27C4426DF0A6B19AF3BAEAB138,FALSE,has_square_y(R) is false
9-
7,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,10AC49A6A2EBF604189C5F40FC75AF2D42D77DE9A2782709B1EB4EAF1CFE9108D7003B703A3499D5E29529D39BA040A44955127140F81A8A89A96F992AC0FE79,FALSE,negated message
10-
8,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,667C2F778E0616E611BD0C14B8A600C5884551701A949EF0EBFD72D452D64E84BE9F4303C0B9913470532E6521A827951D39F5C631CFD98CE39AC4D7A5A83BA9,FALSE,negated s value
11-
9,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,000000000000000000000000000000000000000000000000000000000000000099D2F0EBC2996808208633CD9926BF7EC3DAB73DAAD36E85B3040A698E6D1CE0,FALSE,sG - eP is infinite. Test fails in single verification if has_square_y(inf) is defined as true and x(inf) as 0
12-
10,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,000000000000000000000000000000000000000000000000000000000000000124E81D89F01304695CE943F7D5EBD00EF726A0864B4FF33895B4E86BEADC5456,FALSE,sG - eP is infinite. Test fails in single verification if has_square_y(inf) is defined as true and x(inf) as 1
13-
11,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,4A298DACAE57395A15D0795DDBFD1DCB564DA82B0F269BC70A74F8220429BA1D4160BCFC3F466ECB8FACD19ADE57D8699D74E7207D78C6AEDC3799B52A8E0598,FALSE,sig[0:32] is not an X coordinate on the curve
14-
12,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F4160BCFC3F466ECB8FACD19ADE57D8699D74E7207D78C6AEDC3799B52A8E0598,FALSE,sig[0:32] is equal to field size
15-
13,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,667C2F778E0616E611BD0C14B8A600C5884551701A949EF0EBFD72D452D64E84FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141,FALSE,sig[32:64] is equal to curve order
16-
14,,FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC30,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,667C2F778E0616E611BD0C14B8A600C5884551701A949EF0EBFD72D452D64E844160BCFC3F466ECB8FACD19ADE57D8699D74E7207D78C6AEDC3799B52A8E0598,FALSE,public key is not a valid X coordinate because it exceeds the field size
2+
0,0000000000000000000000000000000000000000000000000000000000000003,F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9,0000000000000000000000000000000000000000000000000000000000000000,514F0E96BB9AD56A245A7F4ED1030D4DE3FB0F5DE285116514292B2F910C979201D5C686A9D968E169C3ED1C2249C81F2BD27D53C42D15FA275EA6445389410A,TRUE,
3+
1,B7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,74556372D3369E8C53E6B84B5D7EE9AE0220EB37A6EA5501EF828FBFBA90A864092EF727796DACA51118BE8FBD70B3EC50536E65DB6F3B3B3FE1049862018B02,TRUE,
4+
2,C90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B14E5C9,DD308AFEC5777E13121FA72B9CC1B7CC0139715309B086C960E18FD969774EB8,7E2D58D8B3BCDF1ABADEC7829054F90DDA9805AAB56C77333024B9D0A508B75C,FAD73AE779EDD67BA40772867FEF9F20F151EB4BFDDECC53B90DD3017FC5D6035670DB8C83BA96EAF51C069B2AA7CEEF556787AE897F84F8D822C4ED7115B851,TRUE,
5+
3,0B432B2677937381AEF05BB02A66ECD012773062CF3FA2549E44F58ED2401710,25D1DFF95105F5253C4022F628A996AD3A0D95FBF21D468A1B33F8C160D8F517,FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,60DC1A7E50D2269424060FF66361601075EB4B516DE89BF1D91B1D6AD78900DACDA5AC4B697491430CAA7604C8D819B2150DEC26E8D01E2981DDA071D7556CD3,TRUE,test fails if msg is reduced modulo p or n
6+
4,,D69C3509BB99E412E68B0FE8544E72837DFA30746D8BE2AA65975F29D22DC7B9,4DF3C3F68FCC83B27E9D42C90431A72499F17875C81A599B566C9889B9696703,00000000000000000000003B78CE563F89A0ED9414F5AA28AD0D96D6795F9C630EC50E5363E227ACAC6F542CE1C0B186657E0E0D1A6FFE283A33438DE4738419,TRUE,
7+
5,,EEFDEA4CDB677750A420FEE807EACF21EB9898AE79B9768766E4FAA04A2D4A34,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,74556372D3369E8C53E6B84B5D7EE9AE0220EB37A6EA5501EF828FBFBA90A864092EF727796DACA51118BE8FBD70B3EC50536E65DB6F3B3B3FE1049862018B02,FALSE,public key not on the curve
8+
6,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F995A579DA959FA739FCE39E8BD16FECB5CDCF97060B2C73CDE60E87ABCA1AA5D9,FALSE,has_square_y(R) is false
9+
7,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,0B3E00AF0641F28B4B52F7E7AD3DDEB9BD313F9E382563BA9C9A8274F45D3D72D8F733F2901432C8DD99C739B0C1EE4030E79A94318278EC4E7160A65CDE8015,FALSE,negated message
10+
8,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,74556372D3369E8C53E6B84B5D7EE9AE0220EB37A6EA5501EF828FBFBA90A864F6D108D88692535AEEE74170428F4C126A5B6E80D3D965007FF159F46E34B63F,FALSE,negated s value
11+
9,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,00000000000000000000000000000000000000000000000000000000000000009915EE59F07F9DBBAEDC31BFCC9B34AD49DE669CD24773BCED77DDA36D073EC8,FALSE,sG - eP is infinite. Test fails in single verification if has_square_y(inf) is defined as true and x(inf) as 0
12+
10,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,0000000000000000000000000000000000000000000000000000000000000001C7EC918B2B9CF34071BB54BED7EB4BB6BAB148E9A7E36E6B228F95DFA08B43EC,FALSE,sG - eP is infinite. Test fails in single verification if has_square_y(inf) is defined as true and x(inf) as 1
13+
11,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,4A298DACAE57395A15D0795DDBFD1DCB564DA82B0F269BC70A74F8220429BA1D092EF727796DACA51118BE8FBD70B3EC50536E65DB6F3B3B3FE1049862018B02,FALSE,sig[0:32] is not an X coordinate on the curve
14+
12,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F092EF727796DACA51118BE8FBD70B3EC50536E65DB6F3B3B3FE1049862018B02,FALSE,sig[0:32] is equal to field size
15+
13,,DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,74556372D3369E8C53E6B84B5D7EE9AE0220EB37A6EA5501EF828FBFBA90A864FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141,FALSE,sig[32:64] is equal to curve order
16+
14,,FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC30,243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89,74556372D3369E8C53E6B84B5D7EE9AE0220EB37A6EA5501EF828FBFBA90A864092EF727796DACA51118BE8FBD70B3EC50536E65DB6F3B3B3FE1049862018B02,FALSE,public key is not a valid X coordinate because it exceeds the field size

bip-0340/test-vectors.py

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,58 @@
22
from reference import *
33

44
def vector0():
5-
seckey = bytes_from_int(1)
5+
seckey = bytes_from_int(3)
66
msg = bytes_from_int(0)
77
sig = schnorr_sign(msg, seckey)
88
pubkey = pubkey_gen(seckey)
99

10-
# The point reconstructed from the public key has an even Y coordinate.
11-
pubkey_point = point_from_bytes(pubkey)
12-
assert(pubkey_point[1] & 1 == 0)
10+
# We should have at least one test vector where the seckey needs to be
11+
# negated and one where it doesn't. In this one the seckey doesn't need to
12+
# be negated.
13+
x = int_from_bytes(seckey)
14+
P = point_mul(G, x)
15+
assert(y(P) % 2 == 0)
16+
17+
# For historic reasons (pubkey tiebreaker was squareness and not evenness)
18+
# we should have at least one test vector where the the point reconstructed
19+
# from the public key has a square and one where it has a non-square Y
20+
# coordinate. In this one Y is non-square.
21+
pubkey_point = lift_x_even_y(pubkey)
22+
assert(not has_square_y(pubkey_point))
1323

1424
return (seckey, pubkey, msg, sig, "TRUE", None)
1525

1626
def vector1():
1727
seckey = bytes_from_int(0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF)
1828
msg = bytes_from_int(0x243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89)
1929
sig = schnorr_sign(msg, seckey)
20-
pubkey = pubkey_gen(seckey)
21-
22-
# The point reconstructed from the public key has an odd Y coordinate.
23-
pubkey_point = point_from_bytes(pubkey)
24-
assert(pubkey_point[1] & 1 == 1)
25-
26-
return (seckey, pubkey, msg, sig, "TRUE", None)
30+
return (seckey, pubkey_gen(seckey), msg, sig, "TRUE", None)
2731

2832
def vector2():
2933
seckey = bytes_from_int(0xC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B14E5C9)
30-
msg = bytes_from_int(0x5E2D58D8B3BCDF1ABADEC7829054F90DDA9805AAB56C77333024B9D0A508B75C)
34+
msg = bytes_from_int(0x7E2D58D8B3BCDF1ABADEC7829054F90DDA9805AAB56C77333024B9D0A508B75C)
3135
sig = schnorr_sign(msg, seckey)
3236

37+
# The point reconstructed from the public key has a square Y coordinate.
38+
pubkey = pubkey_gen(seckey)
39+
pubkey_point = lift_x_even_y(pubkey)
40+
assert(has_square_y(pubkey_point))
41+
3342
# This signature vector would not verify if the implementer checked the
3443
# squareness of the X coordinate of R instead of the Y coordinate.
35-
R = point_from_bytes(sig[0:32])
44+
R = lift_x_square_y(sig[0:32])
3645
assert(not is_square(R[0]))
3746

38-
return (seckey, pubkey_gen(seckey), msg, sig, "TRUE", None)
47+
return (seckey, pubkey, msg, sig, "TRUE", None)
3948

4049
def vector3():
4150
seckey = bytes_from_int(0x0B432B2677937381AEF05BB02A66ECD012773062CF3FA2549E44F58ED2401710)
51+
52+
# Need to negate this seckey before signing
53+
x = int_from_bytes(seckey)
54+
P = point_mul(G, x)
55+
assert(y(P) % 2 != 0)
56+
4257
msg = bytes_from_int(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
4358
sig = schnorr_sign(msg, seckey)
4459
return (seckey, pubkey_gen(seckey), msg, sig, "TRUE", "test fails if msg is reduced modulo p or n")
@@ -53,9 +68,9 @@ def insecure_schnorr_sign_fixed_nonce(msg, seckey0, k):
5368
if not (1 <= seckey0 <= n - 1):
5469
raise ValueError('The secret key must be an integer in the range 1..n-1.')
5570
P = point_mul(G, seckey0)
56-
seckey = seckey0 if has_square_y(P) else n - seckey0
71+
seckey = seckey0 if has_even_y(P) else n - seckey0
5772
R = point_mul(G, k)
58-
e = int_from_bytes(tagged_hash("BIPSchnorr", bytes_from_point(R) + bytes_from_point(P) + msg)) % n
73+
e = int_from_bytes(tagged_hash("BIP340/challenge", bytes_from_point(R) + bytes_from_point(P) + msg)) % n
5974
return bytes_from_point(R) + bytes_from_int((k + e * seckey) % n)
6075

6176
# Creates a singature with a small x(R) by using k = 1/2
@@ -78,7 +93,7 @@ def vector5():
7893
sig = schnorr_sign(msg, seckey)
7994

8095
pubkey = bytes_from_int(0xEEFDEA4CDB677750A420FEE807EACF21EB9898AE79B9768766E4FAA04A2D4A34)
81-
assert(point_from_bytes(pubkey) is None)
96+
assert(lift_x_even_y(pubkey) is None)
8297

8398
return (None, pubkey, msg, sig, "FALSE", "public key not on the curve")
8499

@@ -156,7 +171,7 @@ def vector11():
156171

157172
# Replace R's X coordinate with an X coordinate that's not on the curve
158173
x_not_on_curve = bytes_from_int(0x4A298DACAE57395A15D0795DDBFD1DCB564DA82B0F269BC70A74F8220429BA1D)
159-
assert(point_from_bytes(x_not_on_curve) is None)
174+
assert(lift_x_square_y(x_not_on_curve) is None)
160175
sig = x_not_on_curve + sig[32:64]
161176

162177
return (None, pubkey_gen(seckey), msg, sig, "FALSE", "sig[0:32] is not an X coordinate on the curve")
@@ -201,10 +216,10 @@ def vector14():
201216

202217
pubkey_int = p + 1
203218
pubkey = bytes_from_int(pubkey_int)
204-
assert(point_from_bytes(pubkey) is None)
219+
assert(lift_x_even_y(pubkey) is None)
205220
# If an implementation would reduce a given public key modulo p then the
206221
# pubkey would be valid
207-
assert(point_from_bytes(bytes_from_int(pubkey_int % p)) is not None)
222+
assert(lift_x_even_y(bytes_from_int(pubkey_int % p)) is not None)
208223

209224
return (None, pubkey, msg, sig, "FALSE", "public key is not a valid X coordinate because it exceeds the field size")
210225

0 commit comments

Comments
 (0)