Add cyclic group abstraction, with test code. Separate off exponentation
[u/mdw/catacomb] / ec-bin.c
index 0efb72f..36c5098 100644 (file)
--- a/ec-bin.c
+++ b/ec-bin.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: ec-bin.c,v 1.5 2004/03/27 17:54:11 mdw Exp $
+ * $Id: ec-bin.c,v 1.6 2004/04/01 12:50:09 mdw Exp $
  *
  * Arithmetic for elliptic curves over binary fields
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: ec-bin.c,v $
+ * Revision 1.6  2004/04/01 12:50:09  mdw
+ * Add cyclic group abstraction, with test code.  Separate off exponentation
+ * functions for better static linking.  Fix a buttload of bugs on the way.
+ * Generally ensure that negative exponents do inversion correctly.  Add
+ * table of standard prime-field subgroups.  (Binary field subgroups are
+ * currently unimplemented but easy to add if anyone ever finds a good one.)
+ *
  * Revision 1.5  2004/03/27 17:54:11  mdw
  * Standard curves and curve checking.
  *
@@ -322,6 +329,7 @@ static int eccheck(ec_curve *c, const ec *p)
   int rc;
   mp *u, *v;
 
+  if (EC_ATINF(p)) return (0);
   v = F_SQR(f, MP_NEW, p->x);
   u = F_MUL(f, MP_NEW, v, p->x);
   v = F_MUL(f, v, v, c->a);
@@ -393,12 +401,12 @@ ec_curve *ec_binproj(field *f, mp *a, mp *b)
 }
 
 static const ec_ops ec_binops = {
-  ecdestroy, ec_idin, ec_idout, ec_idfix,
+  ecdestroy, ec_stdsamep, ec_idin, ec_idout, ec_idfix,
   ecfind, ecneg, ecadd, ec_stdsub, ecdbl, eccheck
 };
 
 static const ec_ops ec_binprojops = {
-  ecdestroy, ec_projin, ec_projout, ec_projfix,
+  ecdestroy, ec_stdsamep, ec_projin, ec_projout, ec_projfix,
   ecfind, ecprojneg, ecprojadd, ec_stdsub, ecprojdbl, ecprojcheck
 };