Module ring::arithmetic::bigint

source ·
Expand description

Multi-precision integers.

§Modular Arithmetic.

Modular arithmetic is done in finite commutative rings ℤ/mℤ for some modulus m. We work in finite commutative rings instead of finite fields because the RSA public modulus n is not prime, which means ℤ/nℤ contains nonzero elements that have no multiplicative inverse, so ℤ/nℤ is not a finite field.

In some calculations we need to deal with multiple rings at once. For example, RSA private key operations operate in the rings ℤ/nℤ, ℤ/pℤ, and ℤ/qℤ. Types and functions dealing with such rings are all parameterized over a type M to ensure that we don’t wrongly mix up the math, e.g. by multiplying an element of ℤ/pℤ by an element of ℤ/qℤ modulo q. This follows the “unit” pattern described in Static checking of units in Servo.

Elem also uses the static unit checking pattern to statically track the Montgomery factors that need to be canceled out in each value using it’s E parameter.

Modules§

Structs§

  • Elements of ℤ/mℤ for some modulus m.

Traits§

Functions§