[geeks] Looking for big-integer arithmetic package

der Mouse mouse at Rodents-Montreal.ORG
Sat Oct 11 23:35:39 CDT 2008


I have some code that does arithmetic on large integers (hundreds or
thousands of bits - it's public-key crypto).

Currently I'm using libgmp.  For reasons you can find at this[%]
footnote if you're curious, I'd like to move away from libgmp.  My
question, then, for anyone who cares to offer thoughts on it, is: what
else is out there?  It has to be basically open source (though not
necessarily an OSI-approved license).  Blistering performance might be
nice but is a fairly weak criterion.  Avoiding anything like that damn
GNU "./configure" disaster would be a major plus.  If it includes MD
code (eg, assembly), it needs to either support a moderately wide range
of processors (x86, sparc, sparc64, alpha, strongarm, 68k, powerpc) or
have non-MD backstop available for processors it doesn't have MD code
for.  Needs to be in C.  A saner interface than libgmp's would help
substantially.

Things other than integers - rationals, high-precision floats, etc -
are completely unnecessary.  Modular arithmetic is essential.  (The
calls from libgmp I currently use: mpz_add mpz_add_ui mpz_clear mpz_cmp
mpz_cmp_ui mpz_divexact mpz_get_ui mpz_init mpz_init_set_str
mpz_init_set_ui mpz_invert mpz_mod mpz_mod_ui mpz_mul mpz_mul_2exp
mpz_out_str mpz_powm mpz_probab_prime_p mpz_set mpz_set_ui
mpz_sizeinbase mpz_sub mpz_sub_ui mpz_tdiv_q_2exp mpz_tdiv_q_ui, and I
always pass 2 as the base to mpz_sizeinbase.)

I am prepared to rewrite my software's large-number code, or build a
glue layer, if necessary; API compatability with libgmp is a plus, but
a fairly weak one.

Anyone have anything to suggest?  There seem to be several packages out
there, and I'm hoping someone can steer me towards or away from them as
appropriate.  I did some searching, but either there isn't much that's
very informative out there or I suck at websearching.  (Likely both.)

[%] For the curious: I've been using 2.0.2, and I want to run on
sparc64, which 2.0.2 doesn't really support.  I really don't like the
prospect of doing yet another "read over ./configure" vetting for a
newer version of libgmp, and I seriously dislike libgmp's
sorta-call-by-reference interface, to the point where I currently go
under the hood and use MP_INT; more recent versions of libgmp are
splashed with big warnings about using other than their supported
interface, yet they still don't provide a supported interface that
works in a way unsurprising to the C mindset.  And I try to avoid the
GPL to the extent feasible.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse at rodents-montreal.org
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B



More information about the geeks mailing list