summaryrefslogtreecommitdiff
path: root/bip-schnorr/test-vectors.py
diff options
context:
space:
mode:
Diffstat (limited to 'bip-schnorr/test-vectors.py')
-rw-r--r--bip-schnorr/test-vectors.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/bip-schnorr/test-vectors.py b/bip-schnorr/test-vectors.py
index dca700c..da7aec6 100644
--- a/bip-schnorr/test-vectors.py
+++ b/bip-schnorr/test-vectors.py
@@ -43,8 +43,10 @@ def vector3():
sig = schnorr_sign(msg, seckey)
return (seckey, pubkey_gen(seckey), msg, sig, "TRUE", "test fails if msg is reduced modulo p or n")
-# Signs with a given nonce. Results in an invalid signature if y(kG) is not a square
-def schnorr_sign_fixed_nonce(msg, seckey0, k):
+# Signs with a given nonce. This can be INSECURE and is only INTENDED FOR
+# GENERATING TEST VECTORS. Results in an invalid signature if y(kG) is not
+# square.
+def insecure_schnorr_sign_fixed_nonce(msg, seckey0, k):
if len(msg) != 32:
raise ValueError('The message must be a 32-byte array.')
seckey0 = int_from_bytes(seckey0)
@@ -61,7 +63,7 @@ def vector4():
one_half = 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0
seckey = bytes_from_int(0x763758E5CBEEDEE4F7D3FC86F531C36578933228998226672F13C4F0EBE855EB)
msg = bytes_from_int(0x4DF3C3F68FCC83B27E9D42C90431A72499F17875C81A599B566C9889B9696703)
- sig = schnorr_sign_fixed_nonce(msg, seckey, one_half)
+ sig = insecure_schnorr_sign_fixed_nonce(msg, seckey, one_half)
return (None, pubkey_gen(seckey), msg, sig, "TRUE", None)
default_seckey = bytes_from_int(0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF)
@@ -82,7 +84,7 @@ def vector6():
seckey = default_seckey
msg = default_msg
k = 3
- sig = schnorr_sign_fixed_nonce(msg, seckey, k)
+ sig = insecure_schnorr_sign_fixed_nonce(msg, seckey, k)
# Y coordinate of R is not a square
R = point_mul(G, k)
@@ -118,7 +120,7 @@ def vector9():
k = 0
bytes_from_point_tmp = bytes_from_point.__code__
bytes_from_point.__code__ = bytes_from_point_inf0.__code__
- sig = schnorr_sign_fixed_nonce(msg, seckey, k)
+ sig = insecure_schnorr_sign_fixed_nonce(msg, seckey, k)
bytes_from_point.__code__ = bytes_from_point_tmp
return (None, pubkey_gen(seckey), msg, sig, "FALSE", "sG - eP is infinite. Test fails in single verification if has_square_y(inf) is defined as true and x(inf) as 0")
@@ -137,7 +139,7 @@ def vector10():
k = 0
bytes_from_point_tmp = bytes_from_point.__code__
bytes_from_point.__code__ = bytes_from_point_inf1.__code__
- sig = schnorr_sign_fixed_nonce(msg, seckey, k)
+ sig = insecure_schnorr_sign_fixed_nonce(msg, seckey, k)
bytes_from_point.__code__ = bytes_from_point_tmp
return (None, pubkey_gen(seckey), msg, sig, "FALSE", "sG - eP is infinite. Test fails in single verification if has_square_y(inf) is defined as true and x(inf) as 1")