Merge commits '3bab71cf 4258c54f 566faa17 9ce9984f 04bf3f67 5be353d6 2e035af2 5b0444a3 a6f4bcf6 5ec1333d f6bef03c 1f33bb2b 1c895367 6b7e5b71 596b336f 4b84f4bf 024a4094 222ecaf6 4b0f711d 3c818388 f30c7486 1cf15ebd 24c768ae 341cc197 c63ec88e 54d34b6c 073d98a0 9eb6934f ab5a9171 fb3a8063 006ddc1f 3353d3c7 b54a0672 7d4f86d2 e8295d07 3e3d125b acf5c55a ' into temp-merge-1312
This commit is contained in:
@@ -50,7 +50,7 @@ int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *output, const se
|
||||
overflow |= secp256k1_scalar_is_zero(&s);
|
||||
secp256k1_scalar_cmov(&s, &secp256k1_scalar_one, overflow);
|
||||
|
||||
secp256k1_ecmult_const(&res, &pt, &s, 256);
|
||||
secp256k1_ecmult_const(&res, &pt, &s);
|
||||
secp256k1_ge_set_gej(&pt, &res);
|
||||
|
||||
/* Compute a hash of the point */
|
||||
|
||||
@@ -81,7 +81,7 @@ static void secp256k1_dleq_pair(const secp256k1_ecmult_gen_context *ecmult_gen_c
|
||||
|
||||
secp256k1_ecmult_gen(ecmult_gen_ctx, &p1j, sk);
|
||||
secp256k1_ge_set_gej(p1, &p1j);
|
||||
secp256k1_ecmult_const(&p2j, gen2, sk, 256);
|
||||
secp256k1_ecmult_const(&p2j, gen2, sk);
|
||||
secp256k1_ge_set_gej(p2, &p2j);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ int secp256k1_ecdsa_adaptor_encrypt(const secp256k1_context* ctx, unsigned char
|
||||
secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &rpj, &k);
|
||||
secp256k1_ge_set_gej(&rp, &rpj);
|
||||
/* R = k*Y; */
|
||||
secp256k1_ecmult_const(&rj, &enckey_ge, &k, 256);
|
||||
secp256k1_ecmult_const(&rj, &enckey_ge, &k);
|
||||
secp256k1_ge_set_gej(&r, &rj);
|
||||
/* We declassify the non-secret values rp and r to allow using them
|
||||
* as branch points. */
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "../../../include/secp256k1.h"
|
||||
#include "../../../include/secp256k1_extrakeys.h"
|
||||
#include "hsort_impl.h"
|
||||
#include "../../util.h"
|
||||
|
||||
static SECP256K1_INLINE int secp256k1_xonly_pubkey_load(const secp256k1_context* ctx, secp256k1_ge *ge, const secp256k1_xonly_pubkey *pubkey) {
|
||||
return secp256k1_pubkey_load(ctx, ge, (const secp256k1_pubkey *) pubkey);
|
||||
@@ -28,7 +29,7 @@ int secp256k1_xonly_pubkey_parse(const secp256k1_context* ctx, secp256k1_xonly_p
|
||||
memset(pubkey, 0, sizeof(*pubkey));
|
||||
ARG_CHECK(input32 != NULL);
|
||||
|
||||
if (!secp256k1_fe_set_b32(&x, input32)) {
|
||||
if (!secp256k1_fe_set_b32_limit(&x, input32)) {
|
||||
return 0;
|
||||
}
|
||||
if (!secp256k1_ge_set_xo_var(&pk, &x, 0)) {
|
||||
|
||||
@@ -47,7 +47,7 @@ static void test_exhaustive_extrakeys(const secp256k1_context *ctx, const secp25
|
||||
CHECK(secp256k1_memcmp_var(xonly_pubkey_bytes[i - 1], buf, 32) == 0);
|
||||
|
||||
/* Compare the xonly_pubkey bytes against the precomputed group. */
|
||||
secp256k1_fe_set_b32(&fe, xonly_pubkey_bytes[i - 1]);
|
||||
secp256k1_fe_set_b32_mod(&fe, xonly_pubkey_bytes[i - 1]);
|
||||
CHECK(secp256k1_fe_equal_var(&fe, &group[i].x));
|
||||
|
||||
/* Check the parity against the precomputed group. */
|
||||
|
||||
@@ -39,9 +39,9 @@ const secp256k1_generator *secp256k1_generator_h = &secp256k1_generator_h_intern
|
||||
|
||||
static void secp256k1_generator_load(secp256k1_ge* ge, const secp256k1_generator* gen) {
|
||||
int succeed;
|
||||
succeed = secp256k1_fe_set_b32(&ge->x, &gen->data[0]);
|
||||
succeed = secp256k1_fe_set_b32_limit(&ge->x, &gen->data[0]);
|
||||
VERIFY_CHECK(succeed != 0);
|
||||
succeed = secp256k1_fe_set_b32(&ge->y, &gen->data[32]);
|
||||
succeed = secp256k1_fe_set_b32_limit(&ge->y, &gen->data[32]);
|
||||
VERIFY_CHECK(succeed != 0);
|
||||
ge->infinity = 0;
|
||||
(void) succeed;
|
||||
@@ -64,7 +64,7 @@ int secp256k1_generator_parse(const secp256k1_context* ctx, secp256k1_generator*
|
||||
ARG_CHECK(input != NULL);
|
||||
|
||||
if ((input[0] & 0xFE) != 10 ||
|
||||
!secp256k1_fe_set_b32(&x, &input[1]) ||
|
||||
!secp256k1_fe_set_b32_limit(&x, &input[1]) ||
|
||||
!secp256k1_ge_set_xquad(&ge, &x)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ int secp256k1_generator_serialize(const secp256k1_context* ctx, unsigned char *o
|
||||
|
||||
secp256k1_generator_load(&ge, gen);
|
||||
|
||||
output[0] = 11 ^ secp256k1_fe_is_quad_var(&ge.y);
|
||||
output[0] = 11 ^ secp256k1_fe_is_square_var(&ge.y);
|
||||
secp256k1_fe_normalize_var(&ge.x);
|
||||
secp256k1_fe_get_b32(&output[1], &ge.x);
|
||||
return 1;
|
||||
@@ -205,7 +205,7 @@ static int secp256k1_generator_generate_internal(const secp256k1_context* ctx, s
|
||||
secp256k1_sha256_write(&sha256, prefix1, 16);
|
||||
secp256k1_sha256_write(&sha256, key32, 32);
|
||||
secp256k1_sha256_finalize(&sha256, b32);
|
||||
ret &= secp256k1_fe_set_b32(&t, b32);
|
||||
ret &= secp256k1_fe_set_b32_limit(&t, b32);
|
||||
shallue_van_de_woestijne(&add, &t);
|
||||
if (blind32) {
|
||||
secp256k1_gej_add_ge(&accum, &accum, &add);
|
||||
@@ -217,7 +217,7 @@ static int secp256k1_generator_generate_internal(const secp256k1_context* ctx, s
|
||||
secp256k1_sha256_write(&sha256, prefix2, 16);
|
||||
secp256k1_sha256_write(&sha256, key32, 32);
|
||||
secp256k1_sha256_finalize(&sha256, b32);
|
||||
ret &= secp256k1_fe_set_b32(&t, b32);
|
||||
ret &= secp256k1_fe_set_b32_limit(&t, b32);
|
||||
shallue_van_de_woestijne(&add, &t);
|
||||
secp256k1_gej_add_ge(&accum, &accum, &add);
|
||||
|
||||
@@ -244,7 +244,7 @@ int secp256k1_generator_generate_blinded(const secp256k1_context* ctx, secp256k1
|
||||
|
||||
static void secp256k1_pedersen_commitment_load(secp256k1_ge* ge, const secp256k1_pedersen_commitment* commit) {
|
||||
secp256k1_fe fe;
|
||||
secp256k1_fe_set_b32(&fe, &commit->data[1]);
|
||||
secp256k1_fe_set_b32_mod(&fe, &commit->data[1]);
|
||||
secp256k1_ge_set_xquad(ge, &fe);
|
||||
if (commit->data[0] & 1) {
|
||||
secp256k1_ge_neg(ge, ge);
|
||||
@@ -254,7 +254,7 @@ static void secp256k1_pedersen_commitment_load(secp256k1_ge* ge, const secp256k1
|
||||
static void secp256k1_pedersen_commitment_save(secp256k1_pedersen_commitment* commit, secp256k1_ge* ge) {
|
||||
secp256k1_fe_normalize(&ge->x);
|
||||
secp256k1_fe_get_b32(&commit->data[1], &ge->x);
|
||||
commit->data[0] = 9 ^ secp256k1_fe_is_quad_var(&ge->y);
|
||||
commit->data[0] = 9 ^ secp256k1_fe_is_square_var(&ge->y);
|
||||
}
|
||||
|
||||
int secp256k1_pedersen_commitment_parse(const secp256k1_context* ctx, secp256k1_pedersen_commitment* commit, const unsigned char *input) {
|
||||
@@ -267,7 +267,7 @@ int secp256k1_pedersen_commitment_parse(const secp256k1_context* ctx, secp256k1_
|
||||
(void) ctx;
|
||||
|
||||
if ((input[0] & 0xFE) != 8 ||
|
||||
!secp256k1_fe_set_b32(&x, &input[1]) ||
|
||||
!secp256k1_fe_set_b32_limit(&x, &input[1]) ||
|
||||
!secp256k1_ge_set_xquad(&ge, &x)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -287,7 +287,7 @@ int secp256k1_pedersen_commitment_serialize(const secp256k1_context* ctx, unsign
|
||||
|
||||
secp256k1_pedersen_commitment_load(&ge, commit);
|
||||
|
||||
output[0] = 9 ^ secp256k1_fe_is_quad_var(&ge.y);
|
||||
output[0] = 9 ^ secp256k1_fe_is_square_var(&ge.y);
|
||||
secp256k1_fe_normalize_var(&ge.x);
|
||||
secp256k1_fe_get_b32(&output[1], &ge.x);
|
||||
return 1;
|
||||
|
||||
@@ -34,7 +34,7 @@ static void secp256k1_pedersen_scalar_set_u64(secp256k1_scalar *sec, uint64_t va
|
||||
static void secp256k1_pedersen_ecmult_small(secp256k1_gej *r, uint64_t gn, const secp256k1_ge* genp) {
|
||||
secp256k1_scalar s;
|
||||
secp256k1_pedersen_scalar_set_u64(&s, gn);
|
||||
secp256k1_ecmult_const(r, genp, &s, 64);
|
||||
secp256k1_ecmult_const(r, genp, &s);
|
||||
secp256k1_scalar_clear(&s);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ static void secp256k1_point_load(secp256k1_ge *ge, const unsigned char *data) {
|
||||
} else {
|
||||
/* Otherwise, fall back to 32-byte big endian for X and Y. */
|
||||
secp256k1_fe x, y;
|
||||
secp256k1_fe_set_b32(&x, data);
|
||||
secp256k1_fe_set_b32(&y, data + 32);
|
||||
secp256k1_fe_set_b32_mod(&x, data);
|
||||
secp256k1_fe_set_b32_mod(&y, data + 32);
|
||||
secp256k1_ge_set_xy(ge, &x, &y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ SECP256K1_INLINE static void secp256k1_rangeproof_serialize_point(unsigned char*
|
||||
secp256k1_fe pointx;
|
||||
pointx = point->x;
|
||||
secp256k1_fe_normalize(&pointx);
|
||||
data[0] = !secp256k1_fe_is_quad_var(&point->y);
|
||||
data[0] = !secp256k1_fe_is_square_var(&point->y);
|
||||
secp256k1_fe_get_b32(data + 1, &pointx);
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ SECP256K1_INLINE static int secp256k1_rangeproof_verify_impl(const secp256k1_ecm
|
||||
}
|
||||
for(i = 0; i < rings - 1; i++) {
|
||||
secp256k1_fe fe;
|
||||
if (!secp256k1_fe_set_b32(&fe, &proof[offset]) ||
|
||||
if (!secp256k1_fe_set_b32_limit(&fe, &proof[offset]) ||
|
||||
!secp256k1_ge_set_xquad(&c, &fe)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ static int secp256k1_ecdsa_sig_recover(const secp256k1_scalar *sigr, const secp2
|
||||
}
|
||||
|
||||
secp256k1_scalar_get_b32(brx, sigr);
|
||||
r = secp256k1_fe_set_b32(&fx, brx);
|
||||
r = secp256k1_fe_set_b32_limit(&fx, brx);
|
||||
(void)r;
|
||||
VERIFY_CHECK(r); /* brx comes from a scalar, so is less than the order; certainly less than p */
|
||||
if (recid & 2) {
|
||||
|
||||
@@ -232,7 +232,7 @@ int secp256k1_schnorrsig_verify(const secp256k1_context* ctx, const unsigned cha
|
||||
ARG_CHECK(msg != NULL || msglen == 0);
|
||||
ARG_CHECK(pubkey != NULL);
|
||||
|
||||
if (!secp256k1_fe_set_b32(&rx, &sig64[0])) {
|
||||
if (!secp256k1_fe_set_b32_limit(&rx, &sig64[0])) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,28 +215,36 @@ static void test_schnorrsig_sha256_tagged(void) {
|
||||
|
||||
/* Helper function for schnorrsig_bip_vectors
|
||||
* Signs the message and checks that it's the same as expected_sig. */
|
||||
static void test_schnorrsig_bip_vectors_check_signing(const unsigned char *sk, const unsigned char *pk_serialized, const unsigned char *aux_rand, const unsigned char *msg32, const unsigned char *expected_sig) {
|
||||
static void test_schnorrsig_bip_vectors_check_signing(const unsigned char *sk, const unsigned char *pk_serialized, const unsigned char *aux_rand, const unsigned char *msg, size_t msglen, const unsigned char *expected_sig) {
|
||||
unsigned char sig[64];
|
||||
secp256k1_keypair keypair;
|
||||
secp256k1_xonly_pubkey pk, pk_expected;
|
||||
|
||||
secp256k1_schnorrsig_extraparams extraparams = SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT;
|
||||
extraparams.ndata = (unsigned char*)aux_rand;
|
||||
|
||||
CHECK(secp256k1_keypair_create(CTX, &keypair, sk));
|
||||
CHECK(secp256k1_schnorrsig_sign32(CTX, sig, msg32, &keypair, aux_rand));
|
||||
CHECK(secp256k1_schnorrsig_sign_custom(CTX, sig, msg, msglen, &keypair, &extraparams));
|
||||
CHECK(secp256k1_memcmp_var(sig, expected_sig, 64) == 0);
|
||||
if (msglen == 32) {
|
||||
memset(sig, 0, 64);
|
||||
CHECK(secp256k1_schnorrsig_sign32(CTX, sig, msg, &keypair, aux_rand));
|
||||
CHECK(secp256k1_memcmp_var(sig, expected_sig, 64) == 0);
|
||||
}
|
||||
|
||||
CHECK(secp256k1_xonly_pubkey_parse(CTX, &pk_expected, pk_serialized));
|
||||
CHECK(secp256k1_keypair_xonly_pub(CTX, &pk, NULL, &keypair));
|
||||
CHECK(secp256k1_memcmp_var(&pk, &pk_expected, sizeof(pk)) == 0);
|
||||
CHECK(secp256k1_schnorrsig_verify(CTX, sig, msg32, 32, &pk));
|
||||
CHECK(secp256k1_schnorrsig_verify(CTX, sig, msg, msglen, &pk));
|
||||
}
|
||||
|
||||
/* Helper function for schnorrsig_bip_vectors
|
||||
* Checks that both verify and verify_batch (TODO) return the same value as expected. */
|
||||
static void test_schnorrsig_bip_vectors_check_verify(const unsigned char *pk_serialized, const unsigned char *msg32, const unsigned char *sig, int expected) {
|
||||
static void test_schnorrsig_bip_vectors_check_verify(const unsigned char *pk_serialized, const unsigned char *msg, size_t msglen, const unsigned char *sig, int expected) {
|
||||
secp256k1_xonly_pubkey pk;
|
||||
|
||||
CHECK(secp256k1_xonly_pubkey_parse(CTX, &pk, pk_serialized));
|
||||
CHECK(expected == secp256k1_schnorrsig_verify(CTX, sig, msg32, 32, &pk));
|
||||
CHECK(expected == secp256k1_schnorrsig_verify(CTX, sig, msg, msglen, &pk));
|
||||
}
|
||||
|
||||
/* Test vectors according to BIP-340 ("Schnorr Signatures for secp256k1"). See
|
||||
@@ -256,7 +264,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0xB5, 0x31, 0xC8, 0x45, 0x83, 0x6F, 0x99, 0xB0,
|
||||
0x86, 0x01, 0xF1, 0x13, 0xBC, 0xE0, 0x36, 0xF9
|
||||
};
|
||||
unsigned char aux_rand[32] = {
|
||||
const unsigned char aux_rand[32] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -278,8 +286,8 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0xEB, 0xEE, 0xE8, 0xFD, 0xB2, 0x17, 0x2F, 0x47,
|
||||
0x7D, 0xF4, 0x90, 0x0D, 0x31, 0x05, 0x36, 0xC0
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 1);
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sizeof(msg), sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 1);
|
||||
}
|
||||
{
|
||||
/* Test vector 1 */
|
||||
@@ -295,7 +303,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
|
||||
0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
|
||||
};
|
||||
unsigned char aux_rand[32] = {
|
||||
const unsigned char aux_rand[32] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -317,8 +325,8 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0x89, 0x7E, 0xFC, 0xB6, 0x39, 0xEA, 0x87, 0x1C,
|
||||
0xFA, 0x95, 0xF6, 0xDE, 0x33, 0x9E, 0x4B, 0x0A
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 1);
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sizeof(msg), sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 1);
|
||||
}
|
||||
{
|
||||
/* Test vector 2 */
|
||||
@@ -334,7 +342,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0x01, 0x39, 0x71, 0x53, 0x09, 0xB0, 0x86, 0xC9,
|
||||
0x60, 0xE1, 0x8F, 0xD9, 0x69, 0x77, 0x4E, 0xB8
|
||||
};
|
||||
unsigned char aux_rand[32] = {
|
||||
const unsigned char aux_rand[32] = {
|
||||
0xC8, 0x7A, 0xA5, 0x38, 0x24, 0xB4, 0xD7, 0xAE,
|
||||
0x2E, 0xB0, 0x35, 0xA2, 0xB5, 0xBB, 0xBC, 0xCC,
|
||||
0x08, 0x0E, 0x76, 0xCD, 0xC6, 0xD1, 0x69, 0x2C,
|
||||
@@ -356,8 +364,8 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0x7A, 0xDE, 0xA9, 0x8D, 0x82, 0xF8, 0x48, 0x1E,
|
||||
0x0E, 0x1E, 0x03, 0x67, 0x4A, 0x6F, 0x3F, 0xB7
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 1);
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sizeof(msg), sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 1);
|
||||
}
|
||||
{
|
||||
/* Test vector 3 */
|
||||
@@ -373,7 +381,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0x3A, 0x0D, 0x95, 0xFB, 0xF2, 0x1D, 0x46, 0x8A,
|
||||
0x1B, 0x33, 0xF8, 0xC1, 0x60, 0xD8, 0xF5, 0x17
|
||||
};
|
||||
unsigned char aux_rand[32] = {
|
||||
const unsigned char aux_rand[32] = {
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
@@ -395,8 +403,8 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0xF2, 0x5F, 0xD7, 0x88, 0x81, 0xEB, 0xB3, 0x27,
|
||||
0x71, 0xFC, 0x59, 0x22, 0xEF, 0xC6, 0x6E, 0xA3
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 1);
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sizeof(msg), sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 1);
|
||||
}
|
||||
{
|
||||
/* Test vector 4 */
|
||||
@@ -422,7 +430,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0x60, 0xCB, 0x71, 0xC0, 0x4E, 0x80, 0xF5, 0x93,
|
||||
0x06, 0x0B, 0x07, 0xD2, 0x83, 0x08, 0xD7, 0xF4
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 1);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 1);
|
||||
}
|
||||
{
|
||||
/* Test vector 5 */
|
||||
@@ -460,7 +468,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0x7A, 0x73, 0xC6, 0x43, 0xE1, 0x66, 0xBE, 0x5E,
|
||||
0xBE, 0xAF, 0xA3, 0x4B, 0x1A, 0xC5, 0x53, 0xE2
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 0);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 0);
|
||||
}
|
||||
{
|
||||
/* Test vector 7 */
|
||||
@@ -486,7 +494,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0x62, 0x2A, 0x95, 0x4C, 0xFE, 0x54, 0x57, 0x35,
|
||||
0xAA, 0xEA, 0x51, 0x34, 0xFC, 0xCD, 0xB2, 0xBD
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 0);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 0);
|
||||
}
|
||||
{
|
||||
/* Test vector 8 */
|
||||
@@ -512,7 +520,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0xE8, 0xD7, 0xC9, 0x3E, 0x00, 0xC5, 0xED, 0x0C,
|
||||
0x18, 0x34, 0xFF, 0x0D, 0x0C, 0x2E, 0x6D, 0xA6
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 0);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 0);
|
||||
}
|
||||
{
|
||||
/* Test vector 9 */
|
||||
@@ -538,7 +546,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0x4F, 0xB7, 0x34, 0x76, 0xF0, 0xD5, 0x94, 0xDC,
|
||||
0xB6, 0x5C, 0x64, 0x25, 0xBD, 0x18, 0x60, 0x51
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 0);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 0);
|
||||
}
|
||||
{
|
||||
/* Test vector 10 */
|
||||
@@ -564,7 +572,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0xDB, 0xA8, 0x7F, 0x11, 0xAC, 0x67, 0x54, 0xF9,
|
||||
0x37, 0x80, 0xD5, 0xA1, 0x83, 0x7C, 0xF1, 0x97
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 0);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 0);
|
||||
}
|
||||
{
|
||||
/* Test vector 11 */
|
||||
@@ -590,7 +598,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0xD1, 0xD7, 0x13, 0xA8, 0xAE, 0x82, 0xB3, 0x2F,
|
||||
0xA7, 0x9D, 0x5F, 0x7F, 0xC4, 0x07, 0xD3, 0x9B
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 0);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 0);
|
||||
}
|
||||
{
|
||||
/* Test vector 12 */
|
||||
@@ -616,7 +624,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0xD1, 0xD7, 0x13, 0xA8, 0xAE, 0x82, 0xB3, 0x2F,
|
||||
0xA7, 0x9D, 0x5F, 0x7F, 0xC4, 0x07, 0xD3, 0x9B
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 0);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 0);
|
||||
}
|
||||
{
|
||||
/* Test vector 13 */
|
||||
@@ -642,7 +650,7 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B,
|
||||
0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sig, 0);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 0);
|
||||
}
|
||||
{
|
||||
/* Test vector 14 */
|
||||
@@ -656,6 +664,147 @@ static void test_schnorrsig_bip_vectors(void) {
|
||||
/* No need to check the signature of the test vector as parsing the pubkey already fails */
|
||||
CHECK(!secp256k1_xonly_pubkey_parse(CTX, &pk_parsed, pk));
|
||||
}
|
||||
{
|
||||
/* Test vector 15 */
|
||||
const unsigned char sk[32] = {
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
};
|
||||
const unsigned char pk[32] = {
|
||||
0x77, 0x8C, 0xAA, 0x53, 0xB4, 0x39, 0x3A, 0xC4,
|
||||
0x67, 0x77, 0x4D, 0x09, 0x49, 0x7A, 0x87, 0x22,
|
||||
0x4B, 0xF9, 0xFA, 0xB6, 0xF6, 0xE6, 0x8B, 0x23,
|
||||
0x08, 0x64, 0x97, 0x32, 0x4D, 0x6F, 0xD1, 0x17,
|
||||
};
|
||||
const unsigned char aux_rand[32] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
/* const unsigned char msg[0] = {}; */
|
||||
const unsigned char sig[64] = {
|
||||
0x71, 0x53, 0x5D, 0xB1, 0x65, 0xEC, 0xD9, 0xFB,
|
||||
0xBC, 0x04, 0x6E, 0x5F, 0xFA, 0xEA, 0x61, 0x18,
|
||||
0x6B, 0xB6, 0xAD, 0x43, 0x67, 0x32, 0xFC, 0xCC,
|
||||
0x25, 0x29, 0x1A, 0x55, 0x89, 0x54, 0x64, 0xCF,
|
||||
0x60, 0x69, 0xCE, 0x26, 0xBF, 0x03, 0x46, 0x62,
|
||||
0x28, 0xF1, 0x9A, 0x3A, 0x62, 0xDB, 0x8A, 0x64,
|
||||
0x9F, 0x2D, 0x56, 0x0F, 0xAC, 0x65, 0x28, 0x27,
|
||||
0xD1, 0xAF, 0x05, 0x74, 0xE4, 0x27, 0xAB, 0x63,
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, NULL, 0, sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, NULL, 0, sig, 1);
|
||||
}
|
||||
{
|
||||
/* Test vector 16 */
|
||||
const unsigned char sk[32] = {
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
};
|
||||
const unsigned char pk[32] = {
|
||||
0x77, 0x8C, 0xAA, 0x53, 0xB4, 0x39, 0x3A, 0xC4,
|
||||
0x67, 0x77, 0x4D, 0x09, 0x49, 0x7A, 0x87, 0x22,
|
||||
0x4B, 0xF9, 0xFA, 0xB6, 0xF6, 0xE6, 0x8B, 0x23,
|
||||
0x08, 0x64, 0x97, 0x32, 0x4D, 0x6F, 0xD1, 0x17,
|
||||
};
|
||||
const unsigned char aux_rand[32] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
const unsigned char msg[] = { 0x11 };
|
||||
const unsigned char sig[64] = {
|
||||
0x08, 0xA2, 0x0A, 0x0A, 0xFE, 0xF6, 0x41, 0x24,
|
||||
0x64, 0x92, 0x32, 0xE0, 0x69, 0x3C, 0x58, 0x3A,
|
||||
0xB1, 0xB9, 0x93, 0x4A, 0xE6, 0x3B, 0x4C, 0x35,
|
||||
0x11, 0xF3, 0xAE, 0x11, 0x34, 0xC6, 0xA3, 0x03,
|
||||
0xEA, 0x31, 0x73, 0xBF, 0xEA, 0x66, 0x83, 0xBD,
|
||||
0x10, 0x1F, 0xA5, 0xAA, 0x5D, 0xBC, 0x19, 0x96,
|
||||
0xFE, 0x7C, 0xAC, 0xFC, 0x5A, 0x57, 0x7D, 0x33,
|
||||
0xEC, 0x14, 0x56, 0x4C, 0xEC, 0x2B, 0xAC, 0xBF,
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sizeof(msg), sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 1);
|
||||
}
|
||||
{
|
||||
/* Test vector 17 */
|
||||
const unsigned char sk[32] = {
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
};
|
||||
const unsigned char pk[32] = {
|
||||
0x77, 0x8C, 0xAA, 0x53, 0xB4, 0x39, 0x3A, 0xC4,
|
||||
0x67, 0x77, 0x4D, 0x09, 0x49, 0x7A, 0x87, 0x22,
|
||||
0x4B, 0xF9, 0xFA, 0xB6, 0xF6, 0xE6, 0x8B, 0x23,
|
||||
0x08, 0x64, 0x97, 0x32, 0x4D, 0x6F, 0xD1, 0x17,
|
||||
};
|
||||
const unsigned char aux_rand[32] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
const unsigned char msg[] = {
|
||||
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
||||
0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
|
||||
0x11,
|
||||
};
|
||||
const unsigned char sig[64] = {
|
||||
0x51, 0x30, 0xF3, 0x9A, 0x40, 0x59, 0xB4, 0x3B,
|
||||
0xC7, 0xCA, 0xC0, 0x9A, 0x19, 0xEC, 0xE5, 0x2B,
|
||||
0x5D, 0x86, 0x99, 0xD1, 0xA7, 0x1E, 0x3C, 0x52,
|
||||
0xDA, 0x9A, 0xFD, 0xB6, 0xB5, 0x0A, 0xC3, 0x70,
|
||||
0xC4, 0xA4, 0x82, 0xB7, 0x7B, 0xF9, 0x60, 0xF8,
|
||||
0x68, 0x15, 0x40, 0xE2, 0x5B, 0x67, 0x71, 0xEC,
|
||||
0xE1, 0xE5, 0xA3, 0x7F, 0xD8, 0x0E, 0x5A, 0x51,
|
||||
0x89, 0x7C, 0x55, 0x66, 0xA9, 0x7E, 0xA5, 0xA5,
|
||||
};
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sizeof(msg), sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 1);
|
||||
}
|
||||
{
|
||||
/* Test vector 18 */
|
||||
const unsigned char sk[32] = {
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
0x03, 0x40, 0x03, 0x40, 0x03, 0x40, 0x03, 0x40,
|
||||
};
|
||||
const unsigned char pk[32] = {
|
||||
0x77, 0x8C, 0xAA, 0x53, 0xB4, 0x39, 0x3A, 0xC4,
|
||||
0x67, 0x77, 0x4D, 0x09, 0x49, 0x7A, 0x87, 0x22,
|
||||
0x4B, 0xF9, 0xFA, 0xB6, 0xF6, 0xE6, 0x8B, 0x23,
|
||||
0x08, 0x64, 0x97, 0x32, 0x4D, 0x6F, 0xD1, 0x17,
|
||||
};
|
||||
const unsigned char aux_rand[32] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
const unsigned char sig[64] = {
|
||||
0x40, 0x3B, 0x12, 0xB0, 0xD8, 0x55, 0x5A, 0x34,
|
||||
0x41, 0x75, 0xEA, 0x7E, 0xC7, 0x46, 0x56, 0x63,
|
||||
0x03, 0x32, 0x1E, 0x5D, 0xBF, 0xA8, 0xBE, 0x6F,
|
||||
0x09, 0x16, 0x35, 0x16, 0x3E, 0xCA, 0x79, 0xA8,
|
||||
0x58, 0x5E, 0xD3, 0xE3, 0x17, 0x08, 0x07, 0xE7,
|
||||
0xC0, 0x3B, 0x72, 0x0F, 0xC5, 0x4C, 0x7B, 0x23,
|
||||
0x89, 0x7F, 0xCB, 0xA0, 0xE9, 0xD0, 0xB4, 0xA0,
|
||||
0x68, 0x94, 0xCF, 0xD2, 0x49, 0xF2, 0x23, 0x67,
|
||||
};
|
||||
unsigned char msg[100];
|
||||
memset(msg, 0x99, sizeof(msg));
|
||||
test_schnorrsig_bip_vectors_check_signing(sk, pk, aux_rand, msg, sizeof(msg), sig);
|
||||
test_schnorrsig_bip_vectors_check_verify(pk, msg, sizeof(msg), sig, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Nonce function that returns constant 0 */
|
||||
|
||||
Reference in New Issue
Block a user