Skip to content

Commit f37f620

Browse files
committed
add mp_hash doc
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
1 parent f12c2ab commit f37f620

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/bn.tex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,20 @@ \section{Integer Division and Remainder}
14441444
such that $bc + d = a$. Note that either of $c$ or $d$ can be set to \texttt{NULL} if their value
14451445
is not required. If $b$ is zero the function returns \texttt{MP\_VAL}.
14461446

1447+
\section{Hashing}
1448+
To get a non-cryptographic hash of an \texttt{mp\_int} use the following function.
1449+
1450+
\index{mp\_hash}
1451+
\begin{alltt}
1452+
mp_err mp_hash (mp_int *a, mp_hval *hash);
1453+
\end{alltt}
1454+
1455+
This will create the hash of $a$ following the \mbox{FNV-1a} algorithm as described on
1456+
\url{http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-1a}. With the
1457+
help of this function one can use an \texttt{mp\_int} as a key in a hash table.
1458+
1459+
NB: The hashing is not stable over different widths of an \texttt{mp\_digit}.
1460+
14471461
\chapter{Multiplication and Squaring}
14481462
\section{Multiplication}
14491463
A full signed integer multiplication can be performed with the following.

0 commit comments

Comments
 (0)