1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Schoolbook modular arithmetic for `Copy`-bound types.
//!
//! Use this module when the operand type satisfies `T: Copy + ...` —
//! primitive integers (`u8`, `u16`, `u32`, `u64`, `u128`) and
//! stack-allocated bigints that impl `Copy`.
//!
//! For backends that don't impl `Copy`, see
//! [`modmath::constrained`](crate::constrained) (`Clone`-bound,
//! mixed value/reference parameters) or [`modmath::strict`](crate::strict)
//! (reference-based throughout).
//!
//! A pre-reduced value (already in `[0, m)`) is a residue in a fixed ring;
//! establish it once through [`SchoolbookField`](crate::SchoolbookField) /
//! [`FieldOps`](crate::FieldOps) rather than threading raw `T` past the `% m`
//! boundary — that surface carries the ring width as a type invariant and
//! cannot seed a narrow value.
pub use cratebasic_mod_add as add;
pub use cratebasic_mod_exp as exp;
pub use cratebasic_mod_inv as inv;
pub use cratebasic_mod_mul as mul;
pub use cratebasic_mod_sub as sub;
/// Non-zero-modulus variants. Caller provides `m: T::NonZero` (one
/// boundary-time `m.into_nonzero()?` proof); every `% m` reduction
/// inside collapses to `rem_nonzero` with no divide-by-zero panic
/// path when the carrier's `DivNonZero` impl elides the underlying
/// zero-check.