libtom/libtommath logo

libtom/libtommath

Free

LibTomMath is a free open source portable number theoretic multiple-precision integer library written entirely in C.

FreeFree tier
Type
Open Source

About libtom/libtommath

LibTomMath is a free, open-source, portable number theoretic multiple-precision integer (MPI) library written entirely in C. It provides a comprehensive set of functions for arbitrary-precision arithmetic, including addition, subtraction, multiplication, division, modular exponentiation, greatest common divisor (GCD), least common multiple (LCM), and number theory operations. The library is designed for easy integration into C projects and supports multiple build systems (CMake, makefiles). Documentation is built from LaTeX source. The project is hosted on GitHub under libtom/libtommath, with stable releases tagged on the develop branch. It is widely used in cryptography and other applications requiring high-precision integer math.

Key Features

Multiple-precision integer arithmetic (addition, subtraction, multiplication, division)
Modular arithmetic (exponentiation, reduction, inverses)
Number theory functions (GCD, LCM, Jacobi symbol, Kronecker symbol, square root detection)
Montgomery and Barrett reduction support
Portable C code with no external dependencies
Multiple build systems (CMake, makefile.unix, makefile.mingw, makefile.msvc)
Documentation generated from LaTeX source
Stable releases and active development on GitHub

Pros & Cons

Pros
  • Free and open source (public domain or similar license)
  • Written entirely in portable C, easy to integrate
  • Comprehensive set of arithmetic and number theory operations
  • Well-documented with LaTeX-generated manual
  • Supports multiple build systems for cross-platform development
Cons
  • Primarily C-based, no native C++ or other language binding
  • May not be optimized for extremely large numbers compared to GMP
  • Limited to integer arithmetic (no floating-point or complex numbers)

Best For

Cryptographic algorithm implementations (RSA, Diffie-Hellman, ECC)Arbitrary-precision calculations in scientific computingEmbedded systems requiring efficient integer mathEducational projects and number theory experiments

FAQ

What license is LibTomMath released under?
The project is free open source; the specific license is not detailed in the scraped content, but the README indicates it is a free open source library.
Where can I find the documentation?
Documentation is built from the LaTeX file doc/bn.tex, available in the repository.
How can I install LibTomMath?
The repository includes various makefiles and CMakeLists.txt for building; pre-built deb packages are sometimes uploaded to packagecloud.io for the develop branch.