Recursive Double-Size Fixed Precision Arithmetic

We propose a new fixed precision arithmetic package called RecInt. It uses a recursive double-size data-structure. Contrary to arbitrary precision packages like GMP, that create vectors of words on the heap, RecInt large integers are created on the stack. The space allocated for these integers is a power of two and arithmetic is performed modulo that power. Operations are thus easily implemented recursively by a divide and conquer strategy. Among those, we show that this packages is particularly well adapted to Newton-Raphson like iterations or Montgomery reduction. Recursivity is implemented via doubling algorithms on templated data-types. The idea is to extend machine word functionality to any power of two and to use template partial specialization to adapt the implemented routines to some specific sizes and thresholds. The main target precision is for cryptographic sizes, that is up to several tens of machine words. Preliminary experiments show that good performance can be attained when comparing to the state of art GMP library: it can be several order of magnitude faster when used with very few machine words. This package is now integrated within the Givaro C++ library and has been used for efficient exact linear algebra computations.

[1]  Tommy Färnqvist Number Theory Meets Cache Locality – Efficient Implementation of a Small Prime FFT for the GNU Multiple Precision Arithmetic Library , 2005 .

[2]  P. L. Montgomery Modular multiplication without trial division , 1985 .

[3]  Jean-Guillaume Dumas,et al.  On Efficient Sparse Integer Matrix Smith Normal Form Computations , 2001, J. Symb. Comput..

[4]  Eric Senn,et al.  ∂ GAUT: A High-Level Synthesis Tool for DSP applications , 2008 .

[5]  Jean-Guillaume Dumas,et al.  Dense Linear Algebra over Word-Size Prime Fields: the FFLAS and FFPACK Packages , 2006, TOMS.

[6]  Hairong Qi,et al.  On Calculating Multiplicative Inverses Modulo $2^{m}$ , 2008, IEEE Transactions on Computers.

[7]  Erich Kaltofen,et al.  Quadratic-time certificates in linear algebra , 2011, ISSAC '11.

[8]  Jean-Michel Muller,et al.  Modern Computer Arithmetic , 2016, Computer.

[9]  Richard P. Brent,et al.  Modern Computer Arithmetic , 2010 .

[10]  Jean-Guillaume Dumas On Newton–Raphson Iteration for Multiplicative Inverses Modulo Prime Powers , 2014, IEEE Transactions on Computers.

[11]  Martin Berggren,et al.  Hybrid differentiation strategies for simulation and analysis of applications in C++ , 2008, TOMS.

[12]  Erich Kaltofen,et al.  LINBOX: A GENERIC LIBRARY FOR EXACT LINEAR ALGEBRA , 2002 .

[13]  Joachim Ziegler,et al.  Fast recursive division , 1998 .

[14]  Pierrick Gaudry,et al.  The mpFq library and implementing curve-based key exchanges , 2007 .

[15]  Rusins Freivalds,et al.  Fast Probabilistic Algorithms , 1979, MFCS.