Skip to content

Commit 4494a36

Browse files
Merge #1357: tests: refactor: take use of secp256k1_ge_x_on_curve_var
7d8d5c8 tests: refactor: take use of `secp256k1_ge_x_on_curve_var` (Sebastian Falbesoner) Pull request description: The recently merged ellswift PR (#1129) introduced a helper `secp256k1_ge_x_on_curve_var` to check if a given X coordinate is on the curve (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. (Found this instance via `$ git grep add_int.*SECP256K1_B`, I think it's the only one where the helper can be used.) ACKs for top commit: sipa: utACK 7d8d5c8 real-or-random: utACK 7d8d5c8 Tree-SHA512: aebff9b5ef2f6f6664ce89e4e1272cb55b6aac81cfb379652c4b7ab30dd1d7fd82a2c3b47c7b7429755ba28f011a3a9e2e6d3aa5c77d3b105d159104c24b89f3
2 parents 799f4ee + 7d8d5c8 commit 4494a36

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/tests.c

Lines changed: 2 additions & 5 deletions
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)