Skip to content

Commit 7d8d5c8

Browse files
committed
tests: refactor: take use of secp256k1_ge_x_on_curve_var
The recently merged ellswift PR (bitcoin-core#1129) introduced a helper `secp256k1_ge_x_on_curve_var` to check if a given X coordinate is valid (i.e. the expression x^3 + 7 is square, see commit 79e5b2a). This can be used for code deduplication in the `ecmult_const_mult_xonly` test.
1 parent fd491ea commit 7d8d5c8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/tests.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -4611,17 +4611,14 @@ static void ecmult_const_mult_xonly(void) {
46114611

46124612
/* Test that secp256k1_ecmult_const_xonly correctly rejects X coordinates not on curve. */
46134613
for (i = 0; i < 2*COUNT; ++i) {
4614-
secp256k1_fe x, n, d, c, r;
4614+
secp256k1_fe x, n, d, r;
46154615
int res;
46164616
secp256k1_scalar q;
46174617
random_scalar_order_test(&q);
46184618
/* Generate random X coordinate not on the curve. */
46194619
do {
46204620
random_field_element_test(&x);
4621-
secp256k1_fe_sqr(&c, &x);
4622-
secp256k1_fe_mul(&c, &c, &x);
4623-
secp256k1_fe_add_int(&c, SECP256K1_B);
4624-
} while (secp256k1_fe_is_square_var(&c));
4621+
} while (secp256k1_ge_x_on_curve_var(&x));
46254622
/* If i is odd, n=d*x for random non-zero d. */
46264623
if (i & 1) {
46274624
do {

0 commit comments

Comments
 (0)