Skip to content

Commit 70ae0d2

Browse files
committed
Use secp256k1_fe_equal_var in secp256k1_fe_sqrt_var.
In theory this should be faster, since secp256k1_fe_equal_var is able to shortcut the normalization. On x86_64 the improvement appears to be in the noise for me. At least it makes the code cleaner.
1 parent 7767b4d commit 70ae0d2

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/field_impl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ static int secp256k1_fe_sqrt_var(secp256k1_fe_t *r, const secp256k1_fe_t *a) {
135135
/* Check that a square root was actually calculated */
136136

137137
secp256k1_fe_sqr(&t1, r);
138-
secp256k1_fe_negate(&t1, &t1, 1);
139-
secp256k1_fe_add(&t1, a);
140-
secp256k1_fe_normalize_var(&t1);
141-
return secp256k1_fe_is_zero(&t1);
138+
return secp256k1_fe_equal_var(&t1, a);
142139
}
143140

144141
static void secp256k1_fe_inv(secp256k1_fe_t *r, const secp256k1_fe_t *a) {

0 commit comments

Comments
 (0)