Merge commits '4392f0f7 ' into temp-merge-1533
This commit is contained in:
commit
513e550e8a
21 files changed
+578
-581
No files matched your search
@@ -5,7 +5,7 @@
|
||||
|
||||
static void rand_scalar(secp256k1_scalar *scalar) {
|
||||
unsigned char buf32[32];
|
||||
secp256k1_testrand256(buf32);
|
||||
testrand256(buf32);
|
||||
secp256k1_scalar_set_b32(scalar, buf32, NULL);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ static void dleq_nonce_bitflip(unsigned char **args, size_t n_flip, size_t n_byt
|
||||
secp256k1_scalar k1, k2;
|
||||
|
||||
CHECK(secp256k1_dleq_nonce(&k1, args[0], args[1], args[2], args[3], NULL, args[4]) == 1);
|
||||
secp256k1_testrand_flip(args[n_flip], n_bytes);
|
||||
testrand_flip(args[n_flip], n_bytes);
|
||||
CHECK(secp256k1_dleq_nonce(&k2, args[0], args[1], args[2], args[3], NULL, args[4]) == 1);
|
||||
CHECK(secp256k1_scalar_eq(&k1, &k2) == 0);
|
||||
}
|
||||
@@ -73,11 +73,11 @@ static void dleq_tests(void) {
|
||||
CHECK(secp256k1_eckey_pubkey_serialize(&p2, p2_33, &pubkey_size, 1));
|
||||
CHECK(secp256k1_dleq_nonce(&k, sk32, gen2_33, p1_33, p2_33, NULL, NULL) == 1);
|
||||
|
||||
secp256k1_testrand_bytes_test(sk32, sizeof(sk32));
|
||||
secp256k1_testrand_bytes_test(gen2_33, sizeof(gen2_33));
|
||||
secp256k1_testrand_bytes_test(p1_33, sizeof(p1_33));
|
||||
secp256k1_testrand_bytes_test(p2_33, sizeof(p2_33));
|
||||
secp256k1_testrand_bytes_test(aux_rand, sizeof(aux_rand));
|
||||
testrand_bytes_test(sk32, sizeof(sk32));
|
||||
testrand_bytes_test(gen2_33, sizeof(gen2_33));
|
||||
testrand_bytes_test(p1_33, sizeof(p1_33));
|
||||
testrand_bytes_test(p2_33, sizeof(p2_33));
|
||||
testrand_bytes_test(aux_rand, sizeof(aux_rand));
|
||||
|
||||
/* Check that a bitflip in an argument results in different nonces. */
|
||||
args[0] = sk32;
|
||||
@@ -101,7 +101,7 @@ static void dleq_tests(void) {
|
||||
}
|
||||
|
||||
static void rand_flip_bit(unsigned char *array, size_t n) {
|
||||
array[secp256k1_testrand_int(n)] ^= 1 << secp256k1_testrand_int(8);
|
||||
array[testrand_int(n)] ^= 1 << testrand_int(8);
|
||||
}
|
||||
|
||||
/* Helper function for test_ecdsa_adaptor_spec_vectors
|
||||
@@ -713,7 +713,7 @@ static int ecdsa_adaptor_nonce_function_overflowing(unsigned char *nonce32, cons
|
||||
static void nonce_function_ecdsa_adaptor_bitflip(unsigned char **args, size_t n_flip, size_t n_bytes, size_t algolen) {
|
||||
unsigned char nonces[2][32];
|
||||
CHECK(nonce_function_ecdsa_adaptor(nonces[0], args[0], args[1], args[2], args[3], algolen, args[4]) == 1);
|
||||
secp256k1_testrand_flip(args[n_flip], n_bytes);
|
||||
testrand_flip(args[n_flip], n_bytes);
|
||||
CHECK(nonce_function_ecdsa_adaptor(nonces[1], args[0], args[1], args[2], args[3], algolen, args[4]) == 1);
|
||||
CHECK(secp256k1_memcmp_var(nonces[0], nonces[1], 32) != 0);
|
||||
}
|
||||
@@ -766,10 +766,10 @@ static void run_nonce_function_ecdsa_adaptor_tests(void) {
|
||||
secp256k1_nonce_function_dleq_sha256_tagged(&sha_optimized);
|
||||
ecdsa_adaptor_test_sha256_eq(&sha, &sha_optimized);
|
||||
|
||||
secp256k1_testrand_bytes_test(msg, sizeof(msg));
|
||||
secp256k1_testrand_bytes_test(key, sizeof(key));
|
||||
secp256k1_testrand_bytes_test(pk, sizeof(pk));
|
||||
secp256k1_testrand_bytes_test(aux_rand, sizeof(aux_rand));
|
||||
testrand_bytes_test(msg, sizeof(msg));
|
||||
testrand_bytes_test(key, sizeof(key));
|
||||
testrand_bytes_test(pk, sizeof(pk));
|
||||
testrand_bytes_test(aux_rand, sizeof(aux_rand));
|
||||
|
||||
/* Check that a bitflip in an argument results in different nonces. */
|
||||
args[0] = msg;
|
||||
@@ -802,7 +802,7 @@ static void run_nonce_function_ecdsa_adaptor_tests(void) {
|
||||
/* Different algolen gives different nonce */
|
||||
for (i = 0; i < COUNT; i++) {
|
||||
unsigned char nonce2[32];
|
||||
uint32_t offset = secp256k1_testrand_int(algolen - 1);
|
||||
uint32_t offset = testrand_int(algolen - 1);
|
||||
size_t algolen_tmp = (algolen + offset) % algolen;
|
||||
|
||||
CHECK(nonce_function_ecdsa_adaptor(nonce2, msg, key, pk, algo, algolen_tmp, NULL) == 1);
|
||||
@@ -824,9 +824,9 @@ static void test_ecdsa_adaptor_api(void) {
|
||||
unsigned char deckey[32];
|
||||
|
||||
/** setup **/
|
||||
secp256k1_testrand256(sk);
|
||||
secp256k1_testrand256(msg);
|
||||
secp256k1_testrand256(deckey);
|
||||
testrand256(sk);
|
||||
testrand256(msg);
|
||||
testrand256(deckey);
|
||||
CHECK(secp256k1_ec_pubkey_create(CTX, &pubkey, sk) == 1);
|
||||
CHECK(secp256k1_ec_pubkey_create(CTX, &enckey, deckey) == 1);
|
||||
memset(&zero_pk, 0, sizeof(zero_pk));
|
||||
@@ -877,9 +877,9 @@ static void adaptor_tests(void) {
|
||||
unsigned char zeros64[64] = { 0 };
|
||||
unsigned char big[32];
|
||||
|
||||
secp256k1_testrand256(seckey);
|
||||
secp256k1_testrand256(msg);
|
||||
secp256k1_testrand256(deckey);
|
||||
testrand256(seckey);
|
||||
testrand256(msg);
|
||||
testrand256(deckey);
|
||||
|
||||
CHECK(secp256k1_ec_pubkey_create(CTX, &pubkey, seckey) == 1);
|
||||
CHECK(secp256k1_ec_pubkey_create(CTX, &enckey, deckey) == 1);
|
||||
@@ -1082,19 +1082,19 @@ static void multi_hop_lock_tests(void) {
|
||||
secp256k1_scalar deckey;
|
||||
secp256k1_ecdsa_signature sig_ab, sig_bc;
|
||||
|
||||
secp256k1_testrand256(seckey_a);
|
||||
secp256k1_testrand256(seckey_b);
|
||||
testrand256(seckey_a);
|
||||
testrand256(seckey_b);
|
||||
|
||||
CHECK(secp256k1_ec_pubkey_create(CTX, &pubkey_a, seckey_a));
|
||||
CHECK(secp256k1_ec_pubkey_create(CTX, &pubkey_b, seckey_b));
|
||||
|
||||
/* Carol setup */
|
||||
/* Proof of payment */
|
||||
secp256k1_testrand256(pop);
|
||||
testrand256(pop);
|
||||
CHECK(secp256k1_ec_pubkey_create(CTX, &pubkey_pop, pop));
|
||||
|
||||
/* Alice setup */
|
||||
secp256k1_testrand256(tx_ab);
|
||||
testrand256(tx_ab);
|
||||
rand_scalar(&t1);
|
||||
rand_scalar(&t2);
|
||||
secp256k1_scalar_add(&tp, &t1, &t2);
|
||||
@@ -1110,7 +1110,7 @@ static void multi_hop_lock_tests(void) {
|
||||
|
||||
/* Bob setup */
|
||||
CHECK(secp256k1_ecdsa_adaptor_verify(CTX, asig_ab, &pubkey_a, tx_ab, &l));
|
||||
secp256k1_testrand256(tx_bc);
|
||||
testrand256(tx_bc);
|
||||
CHECK(secp256k1_ecdsa_adaptor_encrypt(CTX, asig_bc, seckey_b, &r, tx_bc, NULL, NULL));
|
||||
|
||||
/* Carol decrypt */
|
||||
|
||||
Reference in new issue
Block a user