]> Git Repo - secp256k1.git/commitdiff
Use secp256k1_fe_equal_var in secp256k1_fe_sqrt_var.
authorGregory Maxwell <[email protected]>
Wed, 31 Dec 2014 13:56:00 +0000 (05:56 -0800)
committerGregory Maxwell <[email protected]>
Wed, 31 Dec 2014 13:56:00 +0000 (05:56 -0800)
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.

src/field_impl.h

index 484e67310c572241d5abff27d3716555ba63300a..4e2c24aa153541ed754106c31eb77eb3fcfbe670 100644 (file)
@@ -135,10 +135,7 @@ static int secp256k1_fe_sqrt_var(secp256k1_fe_t *r, const secp256k1_fe_t *a) {
     /* Check that a square root was actually calculated */
 
     secp256k1_fe_sqr(&t1, r);
-    secp256k1_fe_negate(&t1, &t1, 1);
-    secp256k1_fe_add(&t1, a);
-    secp256k1_fe_normalize_var(&t1);
-    return secp256k1_fe_is_zero(&t1);
+    return secp256k1_fe_equal_var(&t1, a);
 }
 
 static void secp256k1_fe_inv(secp256k1_fe_t *r, const secp256k1_fe_t *a) {
This page took 0.027151 seconds and 4 git commands to generate.