X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/bc985cefafea2e1b02095a2ff2a9982c4c647d17..a6864ad907239985bd1f6eab414cec6171930d46:/calc/ecp.cal diff --git a/calc/ecp.cal b/calc/ecp.cal index 3834359..4fedccf 100644 --- a/calc/ecp.cal +++ b/calc/ecp.cal @@ -1,13 +1,13 @@ /* -*-apcalc-*- * - * $Id: ecp.cal,v 1.3 2004/03/23 15:19:32 mdw Exp $ + * $Id: ecp.cal,v 1.5 2004/04/08 01:36:15 mdw Exp $ * * Testbed for elliptic curve arithmetic over prime fields * * (c) 2000 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,38 +15,18 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: ecp.cal,v $ - * Revision 1.3 2004/03/23 15:19:32 mdw - * Test elliptic curves more thoroughly. - * - * Revision 1.2 2004/03/21 22:52:06 mdw - * Merge and close elliptic curve branch. - * - * Revision 1.1.4.2 2004/03/20 00:13:31 mdw - * Projective coordinates for prime curves - * - * 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 }; @@ -94,7 +74,7 @@ define ecp_pt_add(a, b) e = a.e; if (a.x == b.x) { if (a.y != b.y) { - return (0); + return (0); } alpha = (3 * a.x^2 + e.a) * minv(2 * a.y, e.p) % e.p; } else @@ -126,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); }