Module crypto_bigint::modular::constant_mod

source ·
Expand description

Implements Residues, supporting modular arithmetic with a constant modulus.

Macros§

  • Creates a Residue with the given value for a specific modulus. For example, residue!(U256::from(105u64), MyModulus); creates a Residue for 105 mod MyModulus. The modulus must be odd, or this will panic.
  • Implements a modulus with the given name, type, and value, in that specific order. Please use crypto_bigint::traits::Encoding to make this work. For example, impl_modulus!(MyModulus, U256, "73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"); implements a 256-bit modulus named MyModulus. The modulus must be odd, or this will panic.

Structs§

  • A residue mod MOD, represented using LIMBS limbs. The modulus of this residue is constant, so it cannot be set at runtime. Internally, the value is stored in Montgomery form (multiplied by MOD::R) until it is retrieved.

Traits§

  • The parameters to efficiently go to and from the Montgomery form for a given odd modulus. An easy way to generate these parameters is using the impl_modulus! macro. These parameters are constant, so they cannot be set at runtime.