Newsgroups: sci.math From: "David M. Einstein" Subject: Re: calculating a*b mod c Date: Tue, 6 Aug 1996 03:54:22 GMT Jeroen C. van Gelderen wrote: > > Hello, > > Lately I have studied the sources of PGP and I'm looking for more > information on 'mulmod' functions. Can anyone tell me: > > - What the most efficient function for calculating (a*b) mod c is > (especcially when doing Public Key operations on long (>=1024 bits) on > a PC (Intel / Macintosh PPC)? > > - Where to find background information about (fast) (a*b) mod c > algorithms? Montgomery, Peter L, "Modular Multiplication Without Trial Division", _Mathematics of Computation_, Vol 44 #170, April 1995, pp 519-521. * Crandall R E 1995; "Topics in Advanced Scientific Computation," * TELOS/Springer-Verlag > > Any pointers will be greatly appreciated. > > > Jeroen C. van Gelderen > gelderen@mediaport.org ============================================================================== From: rgep@cam.ac.uk (Richard Pinch) Newsgroups: sci.math,sci.crypt Subject: Re: calculating a*b mod c Date: 6 Aug 1996 13:30:32 GMT Keywords: Montgomery multiplication In article <4u4nae$1bm@mars.worldonline.nl>, gelderen@mediaport.org (Jeroen C. van Gelderen) writes: |> Lately I have studied the sources of PGP and I'm looking for more |> information on 'mulmod' functions. Can anyone tell me: |> - Where to find background information about (fast) (a*b) mod c |> algorithms? Try looking at "Montgomery multiplication". Here's the Latex source of a brief description \newcommand{\congruent}{\equiv} \subsection{Montgomery multiplication} Multiplication modulo $N$ in practice requires a division by $N$ to reduce the product. The technique of {\em Montgomery} multiplication \cite{Mon:multmod} \label{Montgomery-mult} speeds up this step by replacing the modulus $N$ by another divisor $R$ for which the division step may be faster: for example, a shift operation if $R$ is a power of 2. Fix $R > N$ and find $R', N'$ such that $RR' - NN' = 1$. Numbers $x$ modulo $N$ will be represented by $\bar x = Rx \bmod N$. Addition and tests for equality are unchanged by replacing $x$ by $\bar x$. Initial conversion of values $x$ into $\bar x$ requires multiplication modulo $N$ and a division. Define a function $REDC(x)$, for $x < N^2$, as follows. \begin{tabular}{r l} $y \leftarrow$ & $xN' \bmod R$ \\ $z \leftarrow$ & $(x + yN) / R$ \\ {\bf if} $z