Documentation

CslibFrontier.Crypto.Computational.BlumGoldwasser

Blum–Goldwasser Algebraic Decryption Correctness #

Explicit Blum-modulus square-root exponentiation and deterministic algebraic decryption correctness for the Goldreich–Levin inner-product variant of Blum–Goldwasser public-key encryption.

Original algebraic formalization: bgPadBit extracts one pad bit per squaring step via the Goldreich–Levin Boolean inner product (Cslib.BitString.listDot) against the variable-length binary expansion Nat.bits of the canonical residue of the state, rather than Blum–Goldwasser (1984)'s least-significant-bit extraction. For a k-bit message m, encryption uses pad states s_1, …, s_k and transmits the terminal state s_{k + 1} = s_k^2 = s_0 ^ (2 ^ (k + 1)) so that s_k is not exposed in the ciphertext.

This module proves deterministic algebraic decryption correctness only; probabilistic key generation, randomized encryption, and IND-CPA security are not formalized here.

Main definitions #

Main results #

Blum-integer quadratic-residue exponent t = (p - 1) * (q - 1) / 4.

Explicit modular square-root exponent u = (t + 1) / 2 on Q_{p * q}.

theorem Cslib.Crypto.pow_blumSqrtExp_eq_blumSqrt (p q : ℕ) (y : (ZMod (p * q))ˣ) :
y ^ blumSqrtExp p q = blumSqrt p q y

Raising a unit modulo p * q to blumSqrtExp p q equals blumSqrt p q.

theorem Cslib.Crypto.blum_sq_inv_explicit {p q : ℕ} [NeZero (p * q)] (h : IsBlumModulus p q) :
Odd (blumOrder p q) ∧ 2 * blumSqrtExp p q = blumOrder p q + 1 ∧ ∀ x ∈ quadResidueSet p q, x ^ blumOrder p q = 1 ∧ (x ^ 2) ^ blumSqrtExp p q = x

Explicit Blum-integer exponent inversion: for any Blum modulus n = p * q, t = (p - 1)(q - 1) / 4 is odd, u = (t + 1) / 2 satisfies 2 * u = t + 1, and every quadratic residue x ∈ quadResidueSet p q satisfies x ^ t = 1 and (x ^ 2) ^ u = x.

def Cslib.Crypto.bgState (n : ℕ) (s₀ : (ZMod n)ˣ) :
ℕ → (ZMod n)ˣ

Squaring sequence s_0, s_1 = s_0^2, ..., s_i = s_{i - 1}^2 modulo n in Blum–Goldwasser.

def Cslib.Crypto.bgPadBit (n : ℕ) (x : List Bool) (s : (ZMod n)ˣ) :

Inner-product hard-core pad bit ⟨x, bits(s)⟩ mod 2, computed with Cslib.BitString.listDot against the variable-length binary expansion Nat.bits of the canonical residue of s (rather than Blum–Goldwasser 1984's LSB extraction). Original algebraic variant for this library.

A Blum–Goldwasser ciphertext for a k-bit message under modulus n, carrying the inner-product mask mask, the terminal squaring state finalState = s_{k + 1} = s₀ ^ (2 ^ (k + 1)) (one squaring past the last pad state s_k), and the masked message bits.

  • mask : List Bool

    Inner-product mask x for the Goldreich–Levin pad bits.

  • finalState : (ZMod n)ˣ

    Terminal squaring state s_{k + 1} = s₀ ^ (2 ^ (k + 1)) mod n.

  • bits : Fin k → Bool

    Masked message bits m_i ⊕ bgPadBit n x s_{i + 1} for 0 ≤ i < k.

def Cslib.Crypto.bgEncrypt {k : ℕ} (n : ℕ) (x : List Bool) (s₀ : (ZMod n)ˣ) (m : Fin k → Bool) :

Deterministic algebraic encryption map for the Goldreich–Levin inner-product variant of Blum–Goldwasser encryption: given modulus n, mask x, seed s₀ ∈ (ZMod n)ˣ, and k-bit message m, outputs BGCiphertext n k with finalState = s_{k + 1} and pad states s_1, …, s_k. Original algebraic formalization; no probabilistic key generation or IND-CPA security is formalized here.

def Cslib.Crypto.bgDecrypt {k : ℕ} (p q : ℕ) (ct : BGCiphertext (p * q) k) :
Fin k → Bool

Deterministic algebraic decryption map for the Goldreich–Levin inner-product variant of Blum–Goldwasser encryption: given Blum primes (p, q) and ct : BGCiphertext (p * q) k, computes t = (p - 1)(q - 1) / 4, u = (t + 1) / 2, v = u ^ k % t, recovers s₁ = ct.finalState ^ v from s_{k + 1}, regenerates the pad bits on s_1, …, s_k, and outputs ct.bits ⊕ pad.

theorem Cslib.Crypto.bgState_recover_s1 {p q k : ℕ} (h : IsBlumModulus p q) (s₀ : (ZMod (p * q))ˣ) :
bgState (p * q) s₀ (k + 1) ^ (blumSqrtExp p q ^ k % blumOrder p q) = bgState (p * q) s₀ 1

Blum–Goldwasser seed recovery: for any Blum modulus n = p * q, any message length k : ℕ, and any initial seed s₀ ∈ (ZMod (p * q))ˣ, raising s_{k + 1} to v = u ^ k % t recovers s₁ = s₀ ^ 2 exactly.

theorem Cslib.Crypto.bgDecrypt_bgEncrypt {p q k : ℕ} (h : IsBlumModulus p q) (x : List Bool) (s₀ : (ZMod (p * q))ˣ) (m : Fin k → Bool) :
bgDecrypt p q (bgEncrypt (p * q) x s₀ m) = m

Deterministic algebraic decryption correctness for the inner-product Blum–Goldwasser variant: for every Blum modulus n = p * q, message length k : ℕ, mask x, seed s₀, and message m : Fin k → Bool, bgDecrypt p q (bgEncrypt (p * q) x s₀ m) = m.