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F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
59#define NUM_INVALID_KEYS (sizeof(invalid_pubkey_bytes) / sizeof(invalid_pubkey_bytes[0]))
61static int secp256k1_hardened_nonce_function_smallint(
unsigned char *nonce32,
const unsigned char *msg,
63 const unsigned char *key32,
const unsigned char *xonly_pk32,
64 const unsigned char *algo,
size_t algolen,
74 secp256k1_scalar_set_int(&
s, *idata);
75 secp256k1_scalar_get_b32(nonce32, &
s);
86 unsigned char pk32[32];
87 memcpy(pk32, xonly_pubkey_bytes[d - 1], 32);
92 unsigned char sig64[64];
96 if (skip_section(&iter))
continue;
98 memcpy(sig64, xonly_pubkey_bytes[k - 1], 32);
106 unsigned char msg32[32];
107 secp256k1_testrand256(msg32);
108 secp256k1_schnorrsig_challenge(&e, sig64, msg32,
sizeof(msg32), pk32);
113 int count_valid = 0,
s;
115 int expect_valid, valid;
118 secp256k1_scalar_set_int(&s_s,
s);
119 secp256k1_scalar_get_b32(sig64 + 32, &s_s);
123 secp256k1_testrand256(sig64 + 32);
127 CHECK(valid == expect_valid);
128 count_valid += valid;
131 CHECK(count_valid == (actual_k != -1));
141static void test_exhaustive_schnorrsig_sign(
const secp256k1_context *ctx,
unsigned char (*xonly_pubkey_bytes)[32],
const secp256k1_keypair* keypairs,
const int* parities) {
153 int e_count_done = 0;
154 unsigned char msg32[32];
155 unsigned char sig64[64];
157 if (skip_section(&iter))
continue;
158 extraparams.
noncefp = secp256k1_hardened_nonce_function_smallint;
159 extraparams.
ndata = &k;
164 secp256k1_testrand256(msg32);
165 secp256k1_schnorrsig_challenge(&e, xonly_pubkey_bytes[k - 1], msg32,
sizeof(msg32), xonly_pubkey_bytes[d - 1]);
169 unsigned char expected_s_bytes[32];
170 secp256k1_scalar_get_b32(expected_s_bytes, &expected_s);
174 CHECK(secp256k1_memcmp_var(sig64, xonly_pubkey_bytes[k - 1], 32) == 0);
176 CHECK(secp256k1_memcmp_var(sig64 + 32, expected_s_bytes, 32) == 0);
202 unsigned char buf[32];
203 secp256k1_scalar_set_int(&scalar_i, i);
204 secp256k1_scalar_get_b32(
buf, &scalar_i);
210 test_exhaustive_schnorrsig_sign(ctx, xonly_pubkey_bytes, keypair, parity);
211 test_exhaustive_schnorrsig_verify(ctx, xonly_pubkey, xonly_pubkey_bytes, parity);
#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT
SECP256K1_API int secp256k1_schnorrsig_sign_custom(const secp256k1_context *ctx, unsigned char *sig64, const unsigned char *msg, size_t msglen, const secp256k1_keypair *keypair, secp256k1_schnorrsig_extraparams *extraparams) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(5)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorrsig_verify(const secp256k1_context *ctx, const unsigned char *sig64, const unsigned char *msg, size_t msglen, const secp256k1_xonly_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(5)
unsigned __int64 uint64_t
#define EXHAUSTIVE_TEST_ORDER
memcpy((char *) pInfo->slotDescription, s, l)