Skip to content

Commit db424ef

Browse files
theStackdderjoel
authored andcommitted
tests: add checks for scalar constants secp256k1_scalar_{zero,one}
1 parent e11cdc3 commit db424ef

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/tests.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,6 +2354,20 @@ static void run_scalar_tests(void) {
23542354
run_scalar_set_b32_seckey_tests();
23552355
}
23562356

2357+
{
2358+
/* Check that the scalar constants secp256k1_scalar_zero and
2359+
secp256k1_scalar_one contain the expected values. */
2360+
secp256k1_scalar zero, one;
2361+
2362+
CHECK(secp256k1_scalar_is_zero(&secp256k1_scalar_zero));
2363+
secp256k1_scalar_set_int(&zero, 0);
2364+
CHECK(secp256k1_scalar_eq(&zero, &secp256k1_scalar_zero));
2365+
2366+
CHECK(secp256k1_scalar_is_one(&secp256k1_scalar_one));
2367+
secp256k1_scalar_set_int(&one, 1);
2368+
CHECK(secp256k1_scalar_eq(&one, &secp256k1_scalar_one));
2369+
}
2370+
23572371
{
23582372
/* (-1)+1 should be zero. */
23592373
secp256k1_scalar o;

0 commit comments

Comments
 (0)