modmath

Crates.iomodmath
lib.rsmodmath
version0.1.2
created_at2025-02-15 21:23:19.441531+00
updated_at2025-08-11 05:08:43.882161+00
descriptionModular math implemented with traits.
homepage
repositoryhttps://github.com/kaidokert/modmath-rs
max_upload_size
id1557102
size221,683
Kaido Kert (kaidokert)

documentation

README

Modular math functions

Build crate documentation Coverage Status

Yet another mod math implementation, but written for traits. All functions are free functions that are constrainted by core::ops:: and 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

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 verify efficient. In almost all real world code you'll want to direcyl use crates that implement big integers with const functions.

Tested with

Tested with num-bigint, crypto-bigint, bnum, ibig and fixed-bigint crates.

Commit count: 0

cargo fmt