/* -*-c-*-
*
- * $Id: ec.c,v 1.3 2002/01/13 13:48:44 mdw Exp $
+ * $Id: ec.c,v 1.4 2003/05/15 23:25:59 mdw Exp $
*
* Elliptic curve definitions
*
/*----- Revision history --------------------------------------------------*
*
* $Log: ec.c,v $
+ * Revision 1.4 2003/05/15 23:25:59 mdw
+ * Make elliptic curve stuff build.
+ *
* Revision 1.3 2002/01/13 13:48:44 mdw
* Further progress.
*
*
* Arguments: @ec *p@ = pointer to an elliptic-curve point
*
- * Returns: ---
+ * Returns: The argument @p@.
*
* Use: Initializes a new point. The initial value is the additive
* identity (which is universal for all curves).
*/
-void ec_create(ec *p) { EC_CREATE(p); }
+ec *ec_create(ec *p) { EC_CREATE(p); return (p); }
/* --- @ec_destroy@ --- *
*
*
* Arguments: @ec *p@ = pointer to a point
*
- * Returns: ---
+ * Returns: The argument @p@.
*
* Use: Sets the given point to be the point %$O$% at infinity.
*/
-void ec_setinf(ec *p) { EC_SETINF(p); }
+ec *ec_setinf(ec *p) { EC_SETINF(p); return (p); }
/* --- @ec_copy@ --- *
*
* Arguments: @ec *d@ = pointer to destination point
* @const ec *p@ = pointer to source point
*
- * Returns: ---
+ * Returns: The destination @d@.
*
* Use: Creates a copy of an elliptic curve point.
*/
-void ec_copy(ec *d, const ec *p) { EC_COPY(d, p); }
+ec *ec_copy(ec *d, const ec *p) { EC_COPY(d, p); return (d); }
/*----- Standard curve operations -----------------------------------------*/
*
* Arguments: @ec_curve *c@ = pointer to an elliptic curve
* @ec *d@ = pointer to the destination
- * @const ec *a, *b@ = the operand points
+ * @const ec *p, *q@ = the operand points
*
* Returns: The destination @d@.
*
* subtraction operator.
*/
-ec *ec_stdsub(ec_curve *c, ec *d, const ec *a, const ec *b)
+ec *ec_stdsub(ec_curve *c, ec *d, const ec *p, const ec *q)
{
ec t = EC_INIT;
- EC_NEG(c, &t, b);
- EC_SUB(c, d, a, &t);
+ EC_NEG(c, &t, q);
+ EC_ADD(c, d, p, &t);
EC_DESTROY(&t);
return (d);
}
+/*----- Creating curves ---------------------------------------------------*/
+
+/* --- @ec_destroycurve@ --- *
+ *
+ * Arguments: @ec_curve *c@ = pointer to an ellptic curve
+ *
+ * Returns: ---
+ *
+ * Use: Destroys a description of an elliptic curve.
+ */
+
+void ec_destroycurve(ec_curve *c) { c->ops->destroy(c); }
+
/*----- Real arithmetic ---------------------------------------------------*/
/* --- @ec_find@ --- *
if (MP_LEN(n) == 0)
;
else if (MP_LEN(n) < EXP_THRESH)
- EXP_SIMPLE(&d, t, n);
+ EXP_SIMPLE(*d, t, n);
else
- EXP_WINDOW(&d, t, n);
+ EXP_WINDOW(*d, t, n);
return (d);
}