X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/b817bfc642225b8c3c0b6a7e42d1fb949b61a606..1d7857e79cfb9d5b41fe13935b0a0bf68f6049f5:/field.h diff --git a/field.h b/field.h index 5790284..4164bce 100644 --- a/field.h +++ b/field.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: field.h,v 1.11 2004/04/08 01:36:15 mdw Exp $ + * $Id$ * * Definitions for field arithmetic * @@ -56,6 +56,7 @@ typedef struct field { 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 { @@ -170,6 +171,25 @@ extern int field_samep(field */*f*/, field */*g*/); 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@ --- *