summaryrefslogtreecommitdiff
path: root/bip-schnorr
diff options
context:
space:
mode:
authorJonas Nick <jonasd.nick@gmail.com>2019-11-01 14:44:02 +0000
committerJonas Nick <jonasd.nick@gmail.com>2019-11-04 23:35:11 +0000
commit854a33ab48771316932930978f47c9c2311ed5f1 (patch)
treecacfc27099ee111d94fcf1a788d6be2ff84656f5 /bip-schnorr
parent2f1c4d80ae5302347ec63f9f216b36a7c5849d79 (diff)
Fix test vector generation code after changing schnorrsig_sign api
Diffstat (limited to 'bip-schnorr')
-rw-r--r--bip-schnorr/test-vectors.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/bip-schnorr/test-vectors.py b/bip-schnorr/test-vectors.py
index 768d9f1..16b82f7 100644
--- a/bip-schnorr/test-vectors.py
+++ b/bip-schnorr/test-vectors.py
@@ -2,7 +2,7 @@ import sys
from reference import *
def vector0():
- seckey = 1
+ seckey = bytes_from_int(1)
msg = bytes_from_int(0)
sig = schnorr_sign(msg, seckey)
pubkey = pubkey_gen(seckey)
@@ -11,10 +11,10 @@ def vector0():
pubkey_point = point_from_bytes(pubkey)
assert(pubkey_point[1] & 1 == 0)
- return (bytes_from_int(seckey), pubkey, msg, sig, "TRUE", None)
+ return (seckey, pubkey, msg, sig, "TRUE", None)
def vector1():
- seckey = 0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF
+ seckey = bytes_from_int(0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF)
msg = bytes_from_int(0x243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89)
sig = schnorr_sign(msg, seckey)
pubkey = pubkey_gen(seckey)
@@ -23,10 +23,10 @@ def vector1():
pubkey_point = point_from_bytes(pubkey)
assert(pubkey_point[1] & 1 == 1)
- return (bytes_from_int(seckey), pubkey, msg, sig, "TRUE", None)
+ return (seckey, pubkey, msg, sig, "TRUE", None)
def vector2():
- seckey = 0xC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B14E5C9
+ seckey = bytes_from_int(0xC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B14E5C9)
msg = bytes_from_int(0x5E2D58D8B3BCDF1ABADEC7829054F90DDA9805AAB56C77333024B9D0A508B75C)
sig = schnorr_sign(msg, seckey)
@@ -35,18 +35,19 @@ def vector2():
R = point_from_bytes(sig[0:32])
assert(not is_square(R[0]))
- return (bytes_from_int(seckey), pubkey_gen(seckey), msg, sig, "TRUE", None)
+ return (seckey, pubkey_gen(seckey), msg, sig, "TRUE", None)
def vector3():
- seckey = 0x0B432B2677937381AEF05BB02A66ECD012773062CF3FA2549E44F58ED2401710
+ seckey = bytes_from_int(0x0B432B2677937381AEF05BB02A66ECD012773062CF3FA2549E44F58ED2401710)
msg = bytes_from_int(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
sig = schnorr_sign(msg, seckey)
- return (bytes_from_int(seckey), pubkey_gen(seckey), msg, sig, "TRUE", "test fails if msg is reduced modulo p or n")
+ 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):
if len(msg) != 32:
raise ValueError('The message must be a 32-byte array.')
+ seckey0 = int_from_bytes(seckey0)
if not (1 <= seckey0 <= n - 1):
raise ValueError('The secret key must be an integer in the range 1..n-1.')
P = point_mul(G, seckey0)
@@ -58,12 +59,12 @@ def schnorr_sign_fixed_nonce(msg, seckey0, k):
# Creates a singature with a small x(R) by using k = 1/2
def vector4():
one_half = 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0
- seckey = 0x763758E5CBEEDEE4F7D3FC86F531C36578933228998226672F13C4F0EBE855EB
+ seckey = bytes_from_int(0x763758E5CBEEDEE4F7D3FC86F531C36578933228998226672F13C4F0EBE855EB)
msg = bytes_from_int(0x4DF3C3F68FCC83B27E9D42C90431A72499F17875C81A599B566C9889B9696703)
sig = schnorr_sign_fixed_nonce(msg, seckey, one_half)
return (None, pubkey_gen(seckey), msg, sig, "TRUE", None)
-default_seckey = 0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF
+default_seckey = bytes_from_int(0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF)
default_msg = bytes_from_int(0x243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89)
def vector5():