Linear cryptanalysis by majority vote #
A keyed function E : BitString h → BitString n → BitString n satisfies a linear relation for
masks (S₀, S₁, S₂) and bias ε ([BS23], Section 4.3.1, eq. (4.14)) when for every key
k : BitString h, the parity relation parityOn S₀ m ^^ parityOn S₁ (E k m) = parityOn S₂ k holds
with probability at least 1 / 2 + ε over uniform plaintexts m : BitString n. Evaluating
linearKeyBitEstimate on t independent uniform plaintext/ciphertext pairs recovers
parityOn S₂ k with probability at least 1 - Real.exp (-2 * t * ε ^ 2)
(HasLinearRelation.prob_linearKeyBitEstimate_ge), strengthening the printed bound
1 - Real.exp (-(t * ε ^ 2 / 2)) of Lemma 4.3 / eq. (4.15).
Differences from the book. Boneh–Shoup does not say how Majority resolves a tied vote (its two
examples have three bits); linearKeyBitEstimate uses Cslib.ProbComp.plurality false, which
returns the majority bit whenever one bit has more than t / 2 votes, the first vote on a tie,
and false when t = 0. The function E need not be a permutation, and decryption is not used.
The book's attack assumes ε > 0; here 0 ≤ ε is a hypothesis of
HasLinearRelation.prob_linearKeyBitEstimate_ge rather than part of HasLinearRelation, and the
bound fails for negative ε. The module makes no running-time or query-cost claim and recovers
only the single key parity bit parityOn S₂ k.
Main definitions #
Cslib.Crypto.LinearCryptanalysis.HasLinearRelation: linear approximation condition (4.14).Cslib.Crypto.LinearCryptanalysis.linearKeyBitEstimate: majority-vote estimator forparityOn S₂ k.
Main results #
Cslib.Crypto.LinearCryptanalysis.HasLinearRelation.prob_linearKeyBitEstimate_ge: recovery lower bound1 - Real.exp (-2 * t * ε ^ 2)(strengthening Boneh–Shoup Lemma 4.3 / eq. (4.15)).
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 4.3.1 (eq. (4.14), Lemma 4.3 and eq. (4.15), pp. 123–124).
A keyed function E : BitString h → BitString n → BitString n satisfies a linear relation with
masks (S₀, S₁, S₂) and bias ε ([BS23], Section 4.3.1, eq. (4.14)) if for every key
k : BitString h, parityOn S₀ m ^^ parityOn S₁ (E k m) = parityOn S₂ k holds for at least
1 / 2 + ε of plaintexts m : BitString n.
Majority-vote estimator for the key parity bit parityOn S₂ k from t plaintext/ciphertext
pairs, implemented with Cslib.ProbComp.plurality false. It returns the majority bit whenever one
bit has more than t / 2 votes, the first vote on a tie, and false when t = 0.
Linear cryptanalysis key-bit recovery ([BS23], Section 4.3.1, Lemma 4.3 /
eq. (4.15), sharpened with Hoeffding exponent -2 * t * ε ^ 2). When 0 ≤ ε,
linearKeyBitEstimate on t independent uniform plaintext/ciphertext pairs recovers
parityOn S₂ k with probability at least 1 - Real.exp (-2 * t * ε ^ 2), implying the printed
bound 1 - Real.exp (-(t * ε ^ 2 / 2)).