Implement efficient reduction for pleasant-looking primes.
[u/mdw/catacomb] / ec-prime.c
index 827c0f2..7712bbf 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: ec-prime.c,v 1.5 2004/03/22 02:19:10 mdw Exp $
+ * $Id: ec-prime.c,v 1.7 2004/03/27 00:04:46 mdw Exp $
  *
  * Elliptic curves over prime fields
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: ec-prime.c,v $
+ * Revision 1.7  2004/03/27 00:04:46  mdw
+ * Implement efficient reduction for pleasant-looking primes.
+ *
+ * Revision 1.6  2004/03/23 15:19:32  mdw
+ * Test elliptic curves more thoroughly.
+ *
  * Revision 1.5  2004/03/22 02:19:10  mdw
  * Rationalise the sliding-window threshold.  Drop guarantee that right
  * arguments to EC @add@ are canonical, and fix up projective implementations
@@ -427,17 +433,17 @@ extern ec_curve *ec_primeproj(field *f, mp *a, mp *b)
 
 static const ec_ops ec_primeops = {
   ecdestroy, ec_idin, ec_idout, ec_idfix,
-  0, ecneg, ecadd, ec_stdsub, ecdbl, eccheck
+  ecfind, ecneg, ecadd, ec_stdsub, ecdbl, eccheck
 };
 
 static const ec_ops ec_primeprojops = {
   ecdestroy, ec_projin, ec_projout, ec_projfix,
-  0, ecneg, ecprojadd, ec_stdsub, ecprojdbl, ecprojcheck
+  ecfind, ecneg, ecprojadd, ec_stdsub, ecprojdbl, ecprojcheck
 };
 
 static const ec_ops ec_primeprojxops = {
   ecdestroy, ec_projin, ec_projout, ec_projfix,
-  0, ecneg, ecprojadd, ec_stdsub, ecprojxdbl, ecprojcheck
+  ecfind, ecneg, ecprojadd, ec_stdsub, ecprojxdbl, ecprojcheck
 };
 
 /*----- Test rig ----------------------------------------------------------*/
@@ -461,7 +467,7 @@ int main(int argc, char *argv[])
   p = MP(6277101735386680763835789423207666416083908700390324961279);
   r = MP(6277101735386680763835789423176059013767194773182842284080);
 
-  f = field_prime(p);
+  f = field_niceprime(p);
   c = ec_primeproj(f, a, b);
   
   g.x = MP(0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012);