Change secp256k1_ec_pubkey_combine's count argument to size_t.
This commit is contained in:
parent
c69dea025a
commit
8e48787d97
|
@ -571,7 +571,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine(
|
|||
const secp256k1_context* ctx,
|
||||
secp256k1_pubkey *out,
|
||||
const secp256k1_pubkey * const * ins,
|
||||
int n
|
||||
size_t n
|
||||
) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
|
||||
|
||||
# ifdef __cplusplus
|
||||
|
|
|
@ -163,7 +163,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorr_partial_combine
|
|||
const secp256k1_context* ctx,
|
||||
unsigned char *sig64,
|
||||
const unsigned char * const * sig64sin,
|
||||
int n
|
||||
size_t n
|
||||
) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
|
||||
|
||||
# ifdef __cplusplus
|
||||
|
|
|
@ -154,7 +154,7 @@ int secp256k1_schnorr_partial_sign(const secp256k1_context* ctx, unsigned char *
|
|||
return secp256k1_schnorr_sig_sign(&ctx->ecmult_gen_ctx, sig64, &sec, &non, &pubnon, secp256k1_schnorr_msghash_sha256, msg32);
|
||||
}
|
||||
|
||||
int secp256k1_schnorr_partial_combine(const secp256k1_context* ctx, unsigned char *sig64, const unsigned char * const *sig64sin, int n) {
|
||||
int secp256k1_schnorr_partial_combine(const secp256k1_context* ctx, unsigned char *sig64, const unsigned char * const *sig64sin, size_t n) {
|
||||
ARG_CHECK(sig64 != NULL);
|
||||
ARG_CHECK(n >= 1);
|
||||
ARG_CHECK(sig64sin != NULL);
|
||||
|
|
|
@ -15,6 +15,6 @@ typedef void (*secp256k1_schnorr_msghash)(unsigned char *h32, const unsigned cha
|
|||
static int secp256k1_schnorr_sig_sign(const secp256k1_ecmult_gen_context* ctx, unsigned char *sig64, const secp256k1_scalar *key, const secp256k1_scalar *nonce, const secp256k1_ge *pubnonce, secp256k1_schnorr_msghash hash, const unsigned char *msg32);
|
||||
static int secp256k1_schnorr_sig_verify(const secp256k1_ecmult_context* ctx, const unsigned char *sig64, const secp256k1_ge *pubkey, secp256k1_schnorr_msghash hash, const unsigned char *msg32);
|
||||
static int secp256k1_schnorr_sig_recover(const secp256k1_ecmult_context* ctx, const unsigned char *sig64, secp256k1_ge *pubkey, secp256k1_schnorr_msghash hash, const unsigned char *msg32);
|
||||
static int secp256k1_schnorr_sig_combine(unsigned char *sig64, int n, const unsigned char * const *sig64ins);
|
||||
static int secp256k1_schnorr_sig_combine(unsigned char *sig64, size_t n, const unsigned char * const *sig64ins);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -178,9 +178,9 @@ static int secp256k1_schnorr_sig_recover(const secp256k1_ecmult_context* ctx, co
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int secp256k1_schnorr_sig_combine(unsigned char *sig64, int n, const unsigned char * const *sig64ins) {
|
||||
static int secp256k1_schnorr_sig_combine(unsigned char *sig64, size_t n, const unsigned char * const *sig64ins) {
|
||||
secp256k1_scalar s = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
int i;
|
||||
size_t i;
|
||||
for (i = 0; i < n; i++) {
|
||||
secp256k1_scalar si;
|
||||
int overflow;
|
||||
|
|
|
@ -530,8 +530,8 @@ int secp256k1_context_randomize(secp256k1_context* ctx, const unsigned char *see
|
|||
return 1;
|
||||
}
|
||||
|
||||
int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *pubnonce, const secp256k1_pubkey * const *pubnonces, int n) {
|
||||
int i;
|
||||
int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *pubnonce, const secp256k1_pubkey * const *pubnonces, size_t n) {
|
||||
size_t i;
|
||||
secp256k1_gej Qj;
|
||||
secp256k1_ge Q;
|
||||
|
||||
|
|
18
src/tests.c
18
src/tests.c
|
@ -3078,28 +3078,22 @@ void run_eckey_edge_case_test(void) {
|
|||
VG_CHECK(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0);
|
||||
CHECK(ecount == 1);
|
||||
memset(&pubkey, 255, sizeof(secp256k1_pubkey));
|
||||
VG_UNDEF(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, -1) == 0);
|
||||
VG_CHECK(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0);
|
||||
CHECK(ecount == 2);
|
||||
CHECK(secp256k1_ec_pubkey_combine(ctx, NULL, pubkeys, 1) == 0);
|
||||
CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0);
|
||||
CHECK(ecount == 3);
|
||||
CHECK(ecount == 2);
|
||||
memset(&pubkey, 255, sizeof(secp256k1_pubkey));
|
||||
VG_UNDEF(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, NULL, 1) == 0);
|
||||
VG_CHECK(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0);
|
||||
CHECK(ecount == 4);
|
||||
CHECK(ecount == 3);
|
||||
pubkeys[0] = &pubkey_negone;
|
||||
memset(&pubkey, 255, sizeof(secp256k1_pubkey));
|
||||
VG_UNDEF(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, 1) == 1);
|
||||
VG_CHECK(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) > 0);
|
||||
CHECK(ecount == 4);
|
||||
CHECK(ecount == 3);
|
||||
len = 33;
|
||||
CHECK(secp256k1_ec_pubkey_serialize(ctx, ctmp, &len, &pubkey, SECP256K1_EC_COMPRESSED) == 1);
|
||||
CHECK(secp256k1_ec_pubkey_serialize(ctx, ctmp2, &len, &pubkey_negone, SECP256K1_EC_COMPRESSED) == 1);
|
||||
|
@ -3112,7 +3106,7 @@ void run_eckey_edge_case_test(void) {
|
|||
CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, 2) == 0);
|
||||
VG_CHECK(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) == 0);
|
||||
CHECK(ecount == 4);
|
||||
CHECK(ecount == 3);
|
||||
/* Passes through infinity but comes out one. */
|
||||
pubkeys[2] = &pubkey_one;
|
||||
memset(&pubkey, 255, sizeof(secp256k1_pubkey));
|
||||
|
@ -3120,7 +3114,7 @@ void run_eckey_edge_case_test(void) {
|
|||
CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, 3) == 1);
|
||||
VG_CHECK(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) > 0);
|
||||
CHECK(ecount == 4);
|
||||
CHECK(ecount == 3);
|
||||
len = 33;
|
||||
CHECK(secp256k1_ec_pubkey_serialize(ctx, ctmp, &len, &pubkey, SECP256K1_EC_COMPRESSED) == 1);
|
||||
CHECK(secp256k1_ec_pubkey_serialize(ctx, ctmp2, &len, &pubkey_one, SECP256K1_EC_COMPRESSED) == 1);
|
||||
|
@ -3132,7 +3126,7 @@ void run_eckey_edge_case_test(void) {
|
|||
CHECK(secp256k1_ec_pubkey_combine(ctx, &pubkey, pubkeys, 2) == 1);
|
||||
VG_CHECK(&pubkey, sizeof(secp256k1_pubkey));
|
||||
CHECK(memcmp(&pubkey, zeros, sizeof(secp256k1_pubkey)) > 0);
|
||||
CHECK(ecount == 4);
|
||||
CHECK(ecount == 3);
|
||||
secp256k1_context_set_illegal_callback(ctx, NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue