mirror of
https://github.com/status-im/secp256k1.git
synced 2025-02-23 11:18:15 +00:00
Add tests for _gej_cmov
This commit is contained in:
parent
8c13a9bfe1
commit
40b624c90b
38
src/tests.c
38
src/tests.c
@ -100,6 +100,12 @@ void random_group_element_jacobian_test(secp256k1_gej *gej, const secp256k1_ge *
|
||||
gej->infinity = ge->infinity;
|
||||
}
|
||||
|
||||
void random_gej_test(secp256k1_gej *gej) {
|
||||
secp256k1_ge ge;
|
||||
random_group_element_test(&ge);
|
||||
random_group_element_jacobian_test(gej, &ge);
|
||||
}
|
||||
|
||||
void random_scalar_order_test(secp256k1_scalar *num) {
|
||||
do {
|
||||
unsigned char b32[32];
|
||||
@ -3341,6 +3347,37 @@ void run_ge(void) {
|
||||
test_intialized_inf();
|
||||
}
|
||||
|
||||
void test_gej_cmov(const secp256k1_gej *a, const secp256k1_gej *b) {
|
||||
secp256k1_gej t = *a;
|
||||
secp256k1_gej_cmov(&t, b, 0);
|
||||
CHECK(gej_xyz_equals_gej(&t, a));
|
||||
secp256k1_gej_cmov(&t, b, 1);
|
||||
CHECK(gej_xyz_equals_gej(&t, b));
|
||||
}
|
||||
|
||||
void run_gej(void) {
|
||||
int i;
|
||||
secp256k1_gej a, b;
|
||||
|
||||
/* Tests for secp256k1_gej_cmov */
|
||||
for (i = 0; i < count; i++) {
|
||||
secp256k1_gej_set_infinity(&a);
|
||||
secp256k1_gej_set_infinity(&b);
|
||||
test_gej_cmov(&a, &b);
|
||||
|
||||
random_gej_test(&a);
|
||||
test_gej_cmov(&a, &b);
|
||||
test_gej_cmov(&b, &a);
|
||||
|
||||
b = a;
|
||||
test_gej_cmov(&a, &b);
|
||||
|
||||
random_gej_test(&b);
|
||||
test_gej_cmov(&a, &b);
|
||||
test_gej_cmov(&b, &a);
|
||||
}
|
||||
}
|
||||
|
||||
void test_ec_combine(void) {
|
||||
secp256k1_scalar sum = SECP256K1_SCALAR_CONST(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
secp256k1_pubkey data[6];
|
||||
@ -6808,6 +6845,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
/* group tests */
|
||||
run_ge();
|
||||
run_gej();
|
||||
run_group_decompress();
|
||||
|
||||
/* ecmult tests */
|
||||
|
Loading…
x
Reference in New Issue
Block a user