modmath 0.5.0

Modular math implemented with traits.
Documentation

Modular math functions

Build crate documentation Coverage Status

Yet another mod math implementation, but written for traits. Everything is constrained by core::ops:: and const-num-traits traits.

Implements:

  • Unsigned modular addition and subtraction
  • Unsigned modular multiplication
  • Unsigned modular exponentiation
  • Unsigned modular inverse
  • Unsigned modular Montgomery multiply
  • Unsigned modular Montgomery exponentiation
  • Constant-time variants of the Montgomery and inverse paths, behind a Ct typestate

The code isn't intended to be fast or efficient, just as generic as possible to work with multiple implementations.

Note: While const traits are not yet stable and commonplace, this cannot be very efficient. In almost all real world code you'll want to directly use crates that implement big integers with const functions.