Documentation

CslibFrontier.Foundations.Data.ZMod.CRTUnits

The Chinese remainder theorem on units, and squares modulo a prime #

For coprime p and q, the Chinese remainder isomorphism ZMod (p * q) ≃+* ZMod p × ZMod q restricts to the unit groups. A unit modulo p * q is a square exactly when both of its components are, and half of the units modulo an odd prime are squares. These facts underlie the quadratic residuosity assumption and Goldwasser–Micali decryption ([KL20], Section 15.4).

Main definitions #

Main results #

References #

def ZMod.unitsChineseRemainder {p q : ℕ} (h : p.Coprime q) :
(ZMod (p * q))ˣ ≃* (ZMod p)ˣ × (ZMod q)ˣ

The Chinese remainder theorem on unit groups: (ZMod (p * q))ˣ ≃* (ZMod p)ˣ × (ZMod q)ˣ for coprime p and q.

theorem ZMod.coe_unitsChineseRemainder_fst {p q : ℕ} (h : p.Coprime q) (u : (ZMod (p * q))ˣ) :
↑((unitsChineseRemainder h) u).1 = ((chineseRemainder h) ↑u).1

The first component of unitsChineseRemainder h u is the first component of the Chinese remainder image of u.

theorem ZMod.coe_unitsChineseRemainder_snd {p q : ℕ} (h : p.Coprime q) (u : (ZMod (p * q))ˣ) :
↑((unitsChineseRemainder h) u).2 = ((chineseRemainder h) ↑u).2

The second component of unitsChineseRemainder h u is the second component of the Chinese remainder image of u.

theorem ZMod.natCast_val_eq_unitsChineseRemainder_fst {p q : ℕ} [Fact (Nat.Prime p)] [Fact (Nat.Prime q)] (h : p.Coprime q) (u : (ZMod (p * q))ˣ) :
↑(↑u).val = ↑((unitsChineseRemainder h) u).1

Casting the canonical natural-number representative u.val.val to ZMod p gives the first component of unitsChineseRemainder h u.

theorem ZMod.natCast_val_eq_unitsChineseRemainder_snd {p q : ℕ} [Fact (Nat.Prime p)] [Fact (Nat.Prime q)] (h : p.Coprime q) (u : (ZMod (p * q))ˣ) :
↑(↑u).val = ↑((unitsChineseRemainder h) u).2

Casting the canonical natural-number representative u.val.val to ZMod q gives the second component of unitsChineseRemainder h u.

A unit modulo p * q is a square iff both of its Chinese remainder components are.

theorem ZMod.two_mul_card_squares_units (p : ℕ) [Fact (Nat.Prime p)] (hp : 2 < p) :
2 * {u : (ZMod p)ˣ | IsSquare u}.card = Fintype.card (ZMod p)ˣ

Half of the units modulo an odd prime are squares.

theorem ZMod.card_nonsquares_units (p : ℕ) [Fact (Nat.Prime p)] (hp : 2 < p) :
{u : (ZMod p)ˣ | ¬IsSquare u}.card = {u : (ZMod p)ˣ | IsSquare u}.card

An odd prime has as many nonsquare units as square units.

theorem ZMod.isSquare_mul_of_not_isSquare_units {p : ℕ} [Fact (Nat.Prime p)] {u v : (ZMod p)ˣ} (hu : ¬IsSquare u) (hv : ¬IsSquare v) :
IsSquare (u * v)

The product of two nonsquare units modulo a prime is a square: the quadratic character takes the value -1 on each factor.