Correctness of eight-limb CIOS Montgomery multiplication #
A CIOS round is the composition of an accumulation and a reduction step:
mulAccum a bi taccumulatesa * biinto the accumulator without losing information,⟦mulAccum a bi t⟧ = ⟦t⟧ + ⟦a⟧ * bi;mulReduce q negInv sadds the multiplem * qof the modulus that cancels the low limb and drops that limb,2 ^ 32 * ⟦mulReduce q negInv s⟧ = ⟦s⟧ + m * q.
Composing them gives the round invariant 2 ^ 32 * ⟦mulRound⟧ = ⟦t⟧ + ⟦a⟧ * bi + m * q, and
folding eight rounds gives 2 ^ 256 * ⟦t₈⟧ = ⟦a⟧ * ⟦b⟧ + M * q, so the accumulator is the
Montgomery product up to the final conditional subtraction.
Main results #
mulAccum_spec,mulReduce_spec— the two halves of a roundmulRound_spec— the round invariant, with limb bounds and the2 * qboundmul_spec—mulis canonical and satisfies2 ^ 256 * ⟦mul a b⟧ ≡ ⟦a⟧ * ⟦b⟧ [MOD q]
Arithmetic helpers #
Scalar multiplication distributes over a limb recomposition.
Scalar multiplication distributes over a limb recomposition, from the left.
The accumulator #
The value of an accumulator in terms of its limbs.
The accumulation step #
The reduction step #
mulReduce adds the multiple of the modulus that cancels the low limb, and the division
by 2 ^ 32 performed by dropping that limb is exact.
The round invariant #
The CIOS round invariant: one round accumulates a * bi and cancels the low limb against
a multiple m of the modulus; the accumulator stays limbwise bounded and below 2 * q.
The eight-round fold #
Montgomery multiplication is canonical and computes a * b * (2 ^ 256)⁻¹ mod q.