7 #ifndef SECP256K1_MODULE_WHITELIST_MAIN
8 #define SECP256K1_MODULE_WHITELIST_MAIN
13 #define MAX_KEYS SECP256K1_WHITELIST_MAX_N_KEYS
15 int secp256k1_whitelist_sign(
const secp256k1_context2* ctx,
secp256k1_whitelist_signature *sig,
const secp256k1_pubkey2 *online_pubkeys,
const secp256k1_pubkey2 *offline_pubkeys,
const size_t n_keys,
const secp256k1_pubkey2 *sub_pubkey,
const unsigned char *online_seckey,
const unsigned char *summed_seckey,
const size_t index,
secp256k1_nonce_function2 noncefp,
const void *noncedata) {
19 unsigned char msg32[32];
22 if (noncefp == NULL) {
40 ret = secp256k1_whitelist_compute_keys_and_message(ctx, msg32, pubs, online_pubkeys, offline_pubkeys, n_keys, sub_pubkey);
44 ret = secp256k1_whitelist_compute_tweaked_privkey(ctx, &sec, online_seckey, summed_seckey);
48 unsigned char seckey32[32];
49 unsigned int count = 0;
52 secp256k1_scalar_get_b32(seckey32, &sec);
55 unsigned char nonce32[32];
57 ret = noncefp(nonce32, msg32, seckey32, NULL, (
void*)noncedata, count);
61 secp256k1_scalar_set_b32(&non, nonce32, &overflow);
62 memset(nonce32, 0, 32);
63 if (overflow || secp256k1_scalar_is_zero(&non)) {
68 for (i = 0; i < n_keys; i++) {
70 msg32[1] ^= (i + 1) / 0x100;
71 ret = noncefp(&sig->
data[32 * (i + 1)], msg32, seckey32, NULL, (
void*)noncedata, count);
75 secp256k1_scalar_set_b32(&s[i], &sig->
data[32 * (i + 1)], &overflow);
77 msg32[1] ^= (i + 1) / 0x100;
78 if (overflow || secp256k1_scalar_is_zero(&s[i])) {
88 memset(seckey32, 0, 32);
93 ret =
secp256k1_borromean_sign(&ctx->
ecmult_ctx, &ctx->
ecmult_gen_ctx, &sig->
data[0], s, pubs, &non, &sec, &n_keys, &index, 1, msg32, 32);
95 secp256k1_scalar_get_b32(&sig->
data[32 * (index + 1)], &s[index]);
98 secp256k1_scalar_clear(&non);
99 secp256k1_scalar_clear(&sec);
106 unsigned char msg32[32];
119 for (i = 0; i < sig->
n_keys; i++) {
121 secp256k1_scalar_set_b32(&s[i], &sig->
data[32 * (i + 1)], &overflow);
122 if (overflow || secp256k1_scalar_is_zero(&s[i])) {
128 if (!secp256k1_whitelist_compute_keys_and_message(ctx, msg32, pubs, online_pubkeys, offline_pubkeys, sig->
n_keys, sub_pubkey)) {
144 if (input_len == 0) {
163 if (*output_len < 1 + 32 * (sig->
n_keys + 1)) {
169 *output_len = 1 + 32 * (sig->
n_keys + 1);