Expunge revision histories in files.
[u/mdw/catacomb] / calc / ecp.cal
index 82600f5..0163d5e 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-apcalc-*-
  *
- * $Id: ecp.cal,v 1.1.4.1 2003/06/10 13:43:53 mdw Exp $
+ * $Id: ecp.cal,v 1.5 2004/04/08 01:36:15 mdw Exp $
  *
  * Testbed for elliptic curve arithmetic over prime fields
  *
  * MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: ecp.cal,v $
- * Revision 1.1.4.1  2003/06/10 13:43:53  mdw
- * Simple (non-projective) curves over prime fields now seem to work.
- *
- * Revision 1.1  2000/10/08 16:01:37  mdw
- * Prototypes of various bits of code.
- *
- */
-
 /*----- Object types ------------------------------------------------------*/
 
 obj ecp_curve { a, b, p };
@@ -103,6 +92,8 @@ define ecp_pt_dbl(a)
 {
   local e, alpha;
   local obj ecp_pt d;
+  if (istype(a, 1))
+    return (0);
   e = a.e;
   alpha = (3 * a.x^2 + e.a) * minv(2 * a.y, e.p) % e.p;
   d.x = (alpha^2 - 2 * a.x) % e.p;
@@ -115,7 +106,7 @@ define ecp_pt_neg(a)
 {
   local obj ecp_pt d;
   d.x = a.x;
-  d.y = -a.y;
+  d.y = a.e.p - a.y;
   d.e = a.e;
   return (d);
 }