Further progress.
[u/mdw/catacomb] / f-prime.c
index 1a7b9e8..a9673b8 100644 (file)
--- a/f-prime.c
+++ b/f-prime.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: f-prime.c,v 1.1 2001/04/29 18:12:33 mdw Exp $
+ * $Id: f-prime.c,v 1.2 2002/01/13 13:48:44 mdw Exp $
  *
  * Prime fields with Montgomery arithmetic
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: f-prime.c,v $
+ * Revision 1.2  2002/01/13 13:48:44  mdw
+ * Further progress.
+ *
  * Revision 1.1  2001/04/29 18:12:33  mdw
  * Prototype version.
  *
@@ -72,6 +75,12 @@ static mp *fout(field *ff, mp *d, mp *x)
   return (mpmont_reduce(&f->mm, d, x));
 }
 
+static mp *fneg(field *ff, mp *d, mp *x)
+{
+  fctx *f = (fctx *)ff;
+  return (mp_sub(d, f->mm.m, x));
+}
+
 static mp *fadd(field *ff, mp *d, mp *x, mp *y)
 {
   return (mp_add(d, x, y));
@@ -137,7 +146,7 @@ static mp *fsqrt(field *ff, mp *d, mp *x)
 static field_ops fops = {
   fdestroy,
   fin, fout,
-  fadd, fsub, fmul, fsqr, finv, freduce,
+  fneg, fadd, fsub, fmul, fsqr, finv, freduce,
   fdbl, ftpl, fsqrt
 };