X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/5ee4c8931f0cd48cfe38cfc82cdd853f72e60e35..b817bfc642225b8c3c0b6a7e42d1fb949b61a606:/mpcrt.h diff --git a/mpcrt.h b/mpcrt.h index 5474a92..d2e43a8 100644 --- a/mpcrt.h +++ b/mpcrt.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mpcrt.h,v 1.1 1999/11/22 20:50:57 mdw Exp $ + * $Id: mpcrt.h,v 1.3 2004/04/08 01:36:15 mdw Exp $ * * Chinese Remainder Theorem computations (Gauss's algorithm) * @@ -27,16 +27,8 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: mpcrt.h,v $ - * Revision 1.1 1999/11/22 20:50:57 mdw - * Add support for solving Chinese Remainder Theorem problems. - * - */ - -#ifndef MPCRT_H -#define MPCRT_H +#ifndef CATACOMB_MPCRT_H +#define CATACOMB_MPCRT_H #ifdef __cplusplus extern "C" { @@ -46,12 +38,12 @@ #include -#ifndef MP_H +#ifndef CATACOMB_MP_H # include "mp.h" #endif -#ifndef MPMONT_H -# include "mpmont.h" +#ifndef CATACOMB_MPBARRETT_H +# include "mpbarrett.h" #endif /*----- Data structures ---------------------------------------------------*/ @@ -60,12 +52,12 @@ typedef struct mpcrt_mod { mp *m; /* %$n_i$% -- the modulus */ mp *n; /* %$N_i = n / n_i$% */ mp *ni; /* %$M_i = N_i^{-1} \bmod n_i$% */ - mp *nnir; /* %$N_i M_i R \bmod m$% */ + mp *nni; /* %$N_i M_i \bmod m$% */ } mpcrt_mod; typedef struct mpcrt { size_t k; /* Number of distinct moduli */ - mpmont mm; /* Montgomery context for product */ + mpbarrett mb; /* Barrett context for product */ mpcrt_mod *v; /* Vector of information for each */ } mpcrt; @@ -107,6 +99,7 @@ extern void mpcrt_destroy(mpcrt */*c*/); /* --- @mpcrt_solve@ --- * * * Arguments: @mpcrt *c@ = pointer to CRT context + * @mp *d@ = fake destination * @mp **v@ = array of residues * * Returns: The unique solution modulo the product of the individual @@ -121,7 +114,7 @@ extern void mpcrt_destroy(mpcrt */*c*/); * exponentiation. */ -extern mp *mpcrt_solve(mpcrt */*c*/, mp **/*v*/); +extern mp *mpcrt_solve(mpcrt */*c*/, mp */*d*/, mp **/*v*/); /*----- That's all, folks -------------------------------------------------*/