X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/5ee4c8931f0cd48cfe38cfc82cdd853f72e60e35..2bdb833f485d3c985a0f930865452fcaafdf95dd:/mpcrt.h diff --git a/mpcrt.h b/mpcrt.h index 5474a92..a5dd71c 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.2 1999/12/10 23:22:32 mdw Exp $ * * Chinese Remainder Theorem computations (Gauss's algorithm) * @@ -30,13 +30,16 @@ /*----- Revision history --------------------------------------------------* * * $Log: mpcrt.h,v $ + * Revision 1.2 1999/12/10 23:22:32 mdw + * Interface changes for suggested destinations. Use Barrett reduction. + * * 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 +49,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 +63,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 +110,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 +125,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 -------------------------------------------------*/