Skip to content

Commit d4be179

Browse files
committed
fix schnorr sign
1 parent 14c29f1 commit d4be179

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

c_src/libsecp256k1_nif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ schnorr_sign(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
577577
secp256k1_keypair keypair;
578578
secp256k1_pubkey pubkey;
579579
secp256k1_xonly_pubkey xonly_pubkey;
580-
unsigned char* sig64;
580+
unsigned char sig64[64];
581581
unsigned char* finishedsig;
582582
size_t siglen = 64;
583583

test/libsecp256k1_test.exs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ defmodule Libsecp256k1Test do
4646
end
4747

4848
test "schnorr sign" do
49-
{prv, xonly_pub} = generate_valid_schnorr_keypair()
50-
msg = :crypto.strong_rand_bytes(32)
51-
{:ok, signature} = :libsecp256k1.schnorr_sign(msg, prv)
49+
for _ <- 0..10 do
50+
{prv, xonly_pub} = generate_valid_schnorr_keypair()
51+
msg = :crypto.strong_rand_bytes(32)
52+
{:ok, signature} = :libsecp256k1.schnorr_sign(msg, prv)
5253

53-
assert :ok == :libsecp256k1.schnorr_verify(msg, signature, xonly_pub)
54+
assert :ok == :libsecp256k1.schnorr_verify(msg, signature, xonly_pub)
55+
end
5456
end
5557

5658
defp generate_valid_schnorr_keypair() do
@@ -104,9 +106,9 @@ defmodule Libsecp256k1Test do
104106
end
105107

106108
test "ec_privkey_tweak_add" do
107-
prv = <<0x6b973d88838f27366ed61c9ad6367663045cb456e28335c109e30717ae0c6baa::256>>
108-
tweak = <<0xb86e7be8f39bab32a6f2c0443abbc210f0edac0e2c53d501b36b64437d9c6c70::256>>
109-
tweaked_prv = <<0x2405b971772ad26915c8dcdf10f238753a9b837e5f8e6a86fd7c0cce5b7296d9::256>>
109+
prv = <<0x6B973D88838F27366ED61C9AD6367663045CB456E28335C109E30717AE0C6BAA::256>>
110+
tweak = <<0xB86E7BE8F39BAB32A6F2C0443ABBC210F0EDAC0E2C53D501B36B64437D9C6C70::256>>
111+
tweaked_prv = <<0x2405B971772AD26915C8DCDF10F238753A9B837E5F8E6A86FD7C0CCE5B7296D9::256>>
110112

111113
assert {:ok, tweaked_prv} == :libsecp256k1.ec_privkey_tweak_add(prv, tweak)
112114
end

0 commit comments

Comments
 (0)