/* -*-c-*-
*
- * $Id: field.h,v 1.10 2004/04/01 21:28:41 mdw Exp $
+ * $Id$
*
* Definitions for field arithmetic
*
* MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: field.h,v $
- * Revision 1.10 2004/04/01 21:28:41 mdw
- * Normal basis support (translates to poly basis internally). Rewrite
- * EC and prime group table generators in awk, so that they can reuse data
- * for repeated constants.
- *
- * Revision 1.9 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.8 2004/03/27 17:54:11 mdw
- * Standard curves and curve checking.
- *
- * Revision 1.7 2004/03/27 00:04:46 mdw
- * Implement efficient reduction for pleasant-looking primes.
- *
- * Revision 1.6 2004/03/23 15:19:32 mdw
- * Test elliptic curves more thoroughly.
- *
- * Revision 1.5 2004/03/23 12:08:26 mdw
- * Random field-element selection.
- *
- * Revision 1.4 2004/03/21 22:52:06 mdw
- * Merge and close elliptic curve branch.
- *
- * Revision 1.3.4.2 2004/03/21 22:39:46 mdw
- * Elliptic curves on binary fields work.
- *
- * Revision 1.3.4.1 2004/03/20 00:13:31 mdw
- * Projective coordinates for prime curves
- *
- * Revision 1.3 2002/01/13 13:48:44 mdw
- * Further progress.
- *
- * Revision 1.2 2001/05/07 17:30:13 mdw
- * Add an internal-representation no-op function.
- *
- * Revision 1.1 2001/04/29 18:12:33 mdw
- * Prototype version.
- *
- */
-
#ifndef CATACOMB_FIELD_H
#define CATACOMB_FIELD_H
mp *m; /* Modulus (prime and binary) */
unsigned long nbits; /* Length of field element in bits */
size_t noctets; /* Length of element in octets */
+ mp *q; /* Number of elements in field */
} field;
enum {
extern int field_stdsamep(field */*f*/, field */*g*/);
+/*----- Arithmetic --------------------------------------------------------*/
+
+/* --- @field_exp@ --- *
+ *
+ * Arguments: @field *f@ = pointer to field
+ * @mp *d@ = fake destination
+ * @mp *a@ = base
+ * @mp *e@ = exponent
+ *
+ * Returns: Result, %$a^e$%.
+ *
+ * Use: Exponentiation in a finite field. Note that all quantities
+ * are in internal format. This is a generic implementation
+ * suitable for use with all fields and is not intended to be
+ * optimal.
+ */
+
+extern mp *field_exp(field */*f*/, mp */*d*/, mp */*a*/, mp */*e*/);
+
/*----- Creating fields ---------------------------------------------------*/
/* --- @field_prime@ --- *
*
* Arguments: @mp *p@ = the characteristic of the field
*
- * Returns: A pointer to the field.
+ * Returns: A pointer to the field, or null.
*
* Use: Creates a field structure for a prime field of size %$p$%,
* using efficient reduction for nice primes.