Documentation

CslibFrontier.Foundations.Data.ZMod.SquareModulus

Residues modulo a square #

In ZMod (N ^ 2) the residue N squares to zero. So 1 + N behaves like 1 + ε with ε ^ 2 = 0: (1 + N) ^ a = 1 + a * N, and 1 + N has order exactly N for positive N. An N-th power modulo N ^ 2 depends only on its base modulo N, and the units satisfy Euler's theorem with exponent φ(N ^ 2) = N * φ(N). These facts underlie Paillier encryption ([KL20], Claim 15.8 and the proof of Claim 15.9).

Main results #

References #

theorem ZMod.natCast_mul_self_eq_zero (N : ℕ) :
↑N * ↑N = 0

N * N vanishes modulo N ^ 2.

theorem ZMod.one_add_natCast_pow (N a : ℕ) :
(1 + ↑N) ^ a = 1 + ↑a * ↑N

(1 + N) ^ a = 1 + a * N in ZMod (N ^ 2) ([KL20], Claim 15.8).

theorem ZMod.val_one_add_natCast_mul {N : ℕ} (hN : 1 < N) (k : ℕ) :
(1 + ↑k * ↑N).val = 1 + k % N * N

For 1 < N, the least representative of 1 + k * N modulo N ^ 2 is 1 + (k % N) * N.

theorem ZMod.one_add_natCast_pow_self (N : ℕ) :
(1 + ↑N) ^ N = 1

(1 + N) ^ N = 1 in ZMod (N ^ 2) ([KL20], Claim 15.8).

theorem ZMod.orderOf_one_add_natCast {N : ℕ} (hN : 0 < N) :
orderOf (1 + ↑N) = N

For positive N, the residue 1 + N has order exactly N in ZMod (N ^ 2) ([KL20], Claim 15.8).

theorem ZMod.add_natCast_mul_pow_self (N : ℕ) (v k : ZMod (N ^ 2)) :
(v + ↑N * k) ^ N = v ^ N

Adding a multiple of N does not change an N-th power in ZMod (N ^ 2).

theorem ZMod.natCast_pow_self_mod (N m : ℕ) :
↑m ^ N = ↑(m % N) ^ N

The N-th power of a natural number in ZMod (N ^ 2) depends only on its residue modulo N.

theorem ZMod.natCast_pow_mul_totient {N r : ℕ} (hr : r.Coprime N) :
↑r ^ (N * N.totient) = 1

A natural number coprime to N has N * φ(N)-th power 1 modulo N ^ 2.