@@ -69,12 +69,14 @@ def vector4():
69
69
default_seckey = bytes_from_int (0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF )
70
70
default_msg = bytes_from_int (0x243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89 )
71
71
72
+ # Public key is not on the curve
72
73
def vector5 ():
74
+ # This creates a dummy signature that doesn't have anything to do with the
75
+ # public key.
73
76
seckey = default_seckey
74
77
msg = default_msg
75
78
sig = schnorr_sign (msg , seckey )
76
79
77
- # Public key is not on the curve
78
80
pubkey = bytes_from_int (0xEEFDEA4CDB677750A420FEE807EACF21EB9898AE79B9768766E4FAA04A2D4A34 )
79
81
assert (point_from_bytes (pubkey ) is None )
80
82
@@ -185,6 +187,27 @@ def vector13():
185
187
186
188
return (None , pubkey_gen (seckey ), msg , sig , "FALSE" , "sig[32:64] is equal to curve order" )
187
189
190
+ # Test out of range pubkey
191
+ # It's cryptographically impossible to create a test vector that fails if run
192
+ # in an implementation which accepts out of range pubkeys because we can't find
193
+ # a secret key for such a public key and therefore can not create a signature.
194
+ # This test vector just increases test coverage.
195
+ def vector14 ():
196
+ # This creates a dummy signature that doesn't have anything to do with the
197
+ # public key.
198
+ seckey = default_seckey
199
+ msg = default_msg
200
+ sig = schnorr_sign (msg , seckey )
201
+
202
+ pubkey_int = p + 1
203
+ pubkey = bytes_from_int (pubkey_int )
204
+ assert (point_from_bytes (pubkey ) is None )
205
+ # If an implementation would reduce a given public key modulo p then the
206
+ # pubkey would be valid
207
+ assert (point_from_bytes (bytes_from_int (pubkey_int % p )) is not None )
208
+
209
+ return (None , pubkey , msg , sig , "FALSE" , "public key is not a valid X coordinate because it exceeds the field size" )
210
+
188
211
vectors = [
189
212
vector0 (),
190
213
vector1 (),
@@ -200,6 +223,7 @@ def vector13():
200
223
vector11 (),
201
224
vector12 (),
202
225
vector13 (),
226
+ vector14 ()
203
227
]
204
228
205
229
# Converts the byte strings of a test vector into hex strings
0 commit comments