Skip to content

Commit 854a33a

Browse files
committed
Fix test vector generation code after changing schnorrsig_sign api
1 parent 2f1c4d8 commit 854a33a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

bip-schnorr/test-vectors.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from reference import *
33

44
def vector0():
5-
seckey = 1
5+
seckey = bytes_from_int(1)
66
msg = bytes_from_int(0)
77
sig = schnorr_sign(msg, seckey)
88
pubkey = pubkey_gen(seckey)
@@ -11,10 +11,10 @@ def vector0():
1111
pubkey_point = point_from_bytes(pubkey)
1212
assert(pubkey_point[1] & 1 == 0)
1313

14-
return (bytes_from_int(seckey), pubkey, msg, sig, "TRUE", None)
14+
return (seckey, pubkey, msg, sig, "TRUE", None)
1515

1616
def vector1():
17-
seckey = 0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF
17+
seckey = bytes_from_int(0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF)
1818
msg = bytes_from_int(0x243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89)
1919
sig = schnorr_sign(msg, seckey)
2020
pubkey = pubkey_gen(seckey)
@@ -23,10 +23,10 @@ def vector1():
2323
pubkey_point = point_from_bytes(pubkey)
2424
assert(pubkey_point[1] & 1 == 1)
2525

26-
return (bytes_from_int(seckey), pubkey, msg, sig, "TRUE", None)
26+
return (seckey, pubkey, msg, sig, "TRUE", None)
2727

2828
def vector2():
29-
seckey = 0xC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B14E5C9
29+
seckey = bytes_from_int(0xC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B14E5C9)
3030
msg = bytes_from_int(0x5E2D58D8B3BCDF1ABADEC7829054F90DDA9805AAB56C77333024B9D0A508B75C)
3131
sig = schnorr_sign(msg, seckey)
3232

@@ -35,18 +35,19 @@ def vector2():
3535
R = point_from_bytes(sig[0:32])
3636
assert(not is_square(R[0]))
3737

38-
return (bytes_from_int(seckey), pubkey_gen(seckey), msg, sig, "TRUE", None)
38+
return (seckey, pubkey_gen(seckey), msg, sig, "TRUE", None)
3939

4040
def vector3():
41-
seckey = 0x0B432B2677937381AEF05BB02A66ECD012773062CF3FA2549E44F58ED2401710
41+
seckey = bytes_from_int(0x0B432B2677937381AEF05BB02A66ECD012773062CF3FA2549E44F58ED2401710)
4242
msg = bytes_from_int(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
4343
sig = schnorr_sign(msg, seckey)
44-
return (bytes_from_int(seckey), pubkey_gen(seckey), msg, sig, "TRUE", "test fails if msg is reduced modulo p or n")
44+
return (seckey, pubkey_gen(seckey), msg, sig, "TRUE", "test fails if msg is reduced modulo p or n")
4545

4646
# Signs with a given nonce. Results in an invalid signature if y(kG) is not a square
4747
def schnorr_sign_fixed_nonce(msg, seckey0, k):
4848
if len(msg) != 32:
4949
raise ValueError('The message must be a 32-byte array.')
50+
seckey0 = int_from_bytes(seckey0)
5051
if not (1 <= seckey0 <= n - 1):
5152
raise ValueError('The secret key must be an integer in the range 1..n-1.')
5253
P = point_mul(G, seckey0)
@@ -58,12 +59,12 @@ def schnorr_sign_fixed_nonce(msg, seckey0, k):
5859
# Creates a singature with a small x(R) by using k = 1/2
5960
def vector4():
6061
one_half = 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0
61-
seckey = 0x763758E5CBEEDEE4F7D3FC86F531C36578933228998226672F13C4F0EBE855EB
62+
seckey = bytes_from_int(0x763758E5CBEEDEE4F7D3FC86F531C36578933228998226672F13C4F0EBE855EB)
6263
msg = bytes_from_int(0x4DF3C3F68FCC83B27E9D42C90431A72499F17875C81A599B566C9889B9696703)
6364
sig = schnorr_sign_fixed_nonce(msg, seckey, one_half)
6465
return (None, pubkey_gen(seckey), msg, sig, "TRUE", None)
6566

66-
default_seckey = 0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF
67+
default_seckey = bytes_from_int(0xB7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF)
6768
default_msg = bytes_from_int(0x243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89)
6869

6970
def vector5():

0 commit comments

Comments
 (0)