Merge branch 'feature/doc' into develop
Signed-off-by: Tom St Denis <tstdenis82@gmail.com>
This commit is contained in:
commit
4a63ec534e
67
bn.tex
67
bn.tex
|
@ -735,6 +735,42 @@ This should output the following if the program succeeds.
|
|||
number == 654321
|
||||
\end{alltt}
|
||||
|
||||
\subsection{Long Constants - platform dependant}
|
||||
|
||||
\index{mp\_set\_long}
|
||||
\begin{alltt}
|
||||
int mp_set_long (mp_int * a, unsigned long b);
|
||||
\end{alltt}
|
||||
|
||||
This will assign the value of the platform-dependant sized variable $b$ to the mp\_int $a$.
|
||||
|
||||
To get the ``unsigned long'' copy of an mp\_int the following function can be used.
|
||||
|
||||
\index{mp\_get\_long}
|
||||
\begin{alltt}
|
||||
unsigned long mp_get_long (mp_int * a);
|
||||
\end{alltt}
|
||||
|
||||
This will return the least significant bits of the mp\_int $a$ that fit into an ``unsigned long''.
|
||||
|
||||
\subsection{Long Long Constants}
|
||||
|
||||
\index{mp\_set\_long\_long}
|
||||
\begin{alltt}
|
||||
int mp_set_long_long (mp_int * a, unsigned long long b);
|
||||
\end{alltt}
|
||||
|
||||
This will assign the value of the 64-bit variable $b$ to the mp\_int $a$.
|
||||
|
||||
To get the ``unsigned long long'' copy of an mp\_int the following function can be used.
|
||||
|
||||
\index{mp\_get\_long\_long}
|
||||
\begin{alltt}
|
||||
unsigned long long mp_get_long_long (mp_int * a);
|
||||
\end{alltt}
|
||||
|
||||
This will return the 64 least significant bits of the mp\_int $a$.
|
||||
|
||||
\subsection{Initialize and Setting Constants}
|
||||
To both initialize and set small constants the following two functions are available.
|
||||
\index{mp\_init\_set} \index{mp\_init\_set\_int}
|
||||
|
@ -1040,7 +1076,9 @@ If this program is successful it will print out the following text.
|
|||
2*number/2 < 7
|
||||
\end{alltt}
|
||||
|
||||
Since $10 > 7$ and $5 < 7$. To multiply by a power of two the following function can be used.
|
||||
Since $10 > 7$ and $5 < 7$.
|
||||
|
||||
To multiply by a power of two the following function can be used.
|
||||
|
||||
\index{mp\_mul\_2d}
|
||||
\begin{alltt}
|
||||
|
@ -1048,7 +1086,8 @@ int mp_mul_2d(mp_int * a, int b, mp_int * c);
|
|||
\end{alltt}
|
||||
|
||||
This will multiply $a$ by $2^b$ and store the result in ``c''. If the value of $b$ is less than or equal to
|
||||
zero the function will copy $a$ to ``c'' without performing any further actions.
|
||||
zero the function will copy $a$ to ``c'' without performing any further actions. The multiplication itself
|
||||
is implemented as a right-shift operation of $a$ by $b$ bits.
|
||||
|
||||
To divide by a power of two use the following.
|
||||
|
||||
|
@ -1058,7 +1097,8 @@ int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d);
|
|||
\end{alltt}
|
||||
Which will divide $a$ by $2^b$, store the quotient in ``c'' and the remainder in ``d'. If $b \le 0$ then the
|
||||
function simply copies $a$ over to ``c'' and zeroes $d$. The variable $d$ may be passed as a \textbf{NULL}
|
||||
value to signal that the remainder is not desired.
|
||||
value to signal that the remainder is not desired. The division itself is implemented as a left-shift
|
||||
operation of $a$ by $b$ bits.
|
||||
|
||||
\subsection{Polynomial Basis Operations}
|
||||
|
||||
|
@ -1546,12 +1586,29 @@ slower than mp\_dr\_reduce but faster for most moduli sizes than the Montgomery
|
|||
|
||||
\chapter{Exponentiation}
|
||||
\section{Single Digit Exponentiation}
|
||||
\index{mp\_expt\_d\_ex}
|
||||
\begin{alltt}
|
||||
int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
|
||||
\end{alltt}
|
||||
This function computes $c = a^b$.
|
||||
|
||||
With parameter \textit{fast} set to $0$ the old version of the algorithm is used,
|
||||
when \textit{fast} is $1$, a faster but not statically timed version of the algorithm is used.
|
||||
|
||||
The old version uses a simple binary left-to-right algorithm.
|
||||
It is faster than repeated multiplications by $a$ for all values of $b$ greater than three.
|
||||
|
||||
The new version uses a binary right-to-left algorithm.
|
||||
|
||||
The difference between the old and the new version is that the old version always
|
||||
executes $DIGIT\_BIT$ iterations. The new algorithm executes only $n$ iterations
|
||||
where $n$ is equal to the position of the highest bit that is set in $b$.
|
||||
|
||||
\index{mp\_expt\_d}
|
||||
\begin{alltt}
|
||||
int mp_expt_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
\end{alltt}
|
||||
This computes $c = a^b$ using a simple binary left-to-right algorithm. It is faster than repeated multiplications by
|
||||
$a$ for all values of $b$ greater than three.
|
||||
mp\_expt\_d(a, b, c) is a wrapper function to mp\_expt\_d\_ex(a, b, c, 0).
|
||||
|
||||
\section{Modular Exponentiation}
|
||||
\index{mp\_exptmod}
|
||||
|
|
19
changes.txt
19
changes.txt
|
@ -1,3 +1,22 @@
|
|||
XXX, 2014
|
||||
v0.43.0
|
||||
-- Dirkjan Bussink provided a faster version of mp_expt_d()
|
||||
-- Moritz Lenz contributed a fix to mp_mod()
|
||||
and provided mp_get_long() and mp_set_long()
|
||||
-- Fixed bugs in mp_read_radix(), mp_radix_size
|
||||
Thanks to shameister, Gerhard R,
|
||||
-- Christopher Brown provided mp_export() and mp_import()
|
||||
-- Improvements in the code of mp_init_copy()
|
||||
Thanks to ramkumarkoppu,
|
||||
-- lomereiter provided mp_balance_mul()
|
||||
-- Alexander Boström from the heimdal project contributed patches to
|
||||
mp_prime_next_prime() and mp_invmod() and added a mp_isneg() macro
|
||||
-- Fix build issues for Linux x32 ABI
|
||||
-- Added mp_get_long_long() and mp_set_long_long()
|
||||
-- Carlin provided a patch to use arc4random() instead of rand()
|
||||
on platforms where it is supported
|
||||
|
||||
|
||||
July 23rd, 2010
|
||||
v0.42.0
|
||||
-- Fix for mp_prime_next_prime() bug when checking generated prime
|
||||
|
|
|
@ -299,13 +299,13 @@ void mp_rshd(mp_int *a, int b);
|
|||
/* left shift by "b" digits */
|
||||
int mp_lshd(mp_int *a, int b);
|
||||
|
||||
/* c = a / 2**b */
|
||||
/* c = a / 2**b, implemented as c = a >> b */
|
||||
int mp_div_2d(mp_int *a, int b, mp_int *c, mp_int *d);
|
||||
|
||||
/* b = a/2 */
|
||||
int mp_div_2(mp_int *a, mp_int *b);
|
||||
|
||||
/* c = a * 2**b */
|
||||
/* c = a * 2**b, implemented as c = a << b */
|
||||
int mp_mul_2d(mp_int *a, int b, mp_int *c);
|
||||
|
||||
/* b = a*2 */
|
||||
|
|
Loading…
Reference in New Issue