Documentation

Complexity.Crypto.Computational.Homomorphic.GSW.Decoding

Scalar decoding for GSW ciphertexts #

For modulus 2 ^ w, a bit is represented by zero or 2 ^ (w - 1), with an integer error. The decoder selects the half-open middle half of the canonical residue interval. Thus the lower quarter boundary decodes to true and the upper quarter boundary to false. Correctness uses a strict error bound, which excludes both ties and handles negative errors by modular wraparound.

Main definitions #

Main results #

References #

Decode the half-open middle half of the canonical residue interval as true.

Instances For
    @[simp]
    theorem Cslib.Crypto.Homomorphic.GSW.decode_eq_true_iff (w : ℕ) (x : ZMod (2 ^ w)) :
    decode w x = true ↔ 2 ^ w ≤ 4 * x.val ∧ 4 * x.val < 3 * 2 ^ w
    @[simp]

    Width zero has only the zero residue, which decodes to false.

    At width one, the single bit is already the decoded message.

    theorem Cslib.Crypto.Homomorphic.GSW.decode_eq_xor_highBits {w : ℕ} (hw : 2 ≤ w) (x : ZMod (2 ^ w)) :
    decode w x = (x.val.testBit (w - 1) ^^ x.val.testBit (w - 2))

    The half-open middle interval is exactly the set where the two highest bits differ. This identity holds on every residue, including both quarter-boundary ties.

    theorem Cslib.Crypto.Homomorphic.GSW.decode_eq_of_error {w : ℕ} (hw : 0 < w) (μ : Bool) (error : ℤ) (herror : 4 * error.natAbs < 2 ^ w) :
    decode w ↑(↑μ.toNat * 2 ^ (w - 1) + error) = μ

    Decoding recovers a bit whenever its integer error has magnitude strictly below one quarter of the modulus. The strict inequality excludes the decoder's asymmetric ties.