Block cipher networks: SPNs, unbalanced Feistel networks, periodicity, and Feistel distinguishers #
This module complements CslibFrontier.Crypto.Protocols.Cipher.LubyRackoff with structural and
concrete-security results on block cipher networks from [KL20] and original extensions:
- Substitution–permutation networks (SPNs) ([KL20], Section 7.2.1, Proposition 7.3):
in
Cslib.Crypto.SPN, key mixing (spnKeyMixEquiv), S-box substitution (spnSubstituteEquiv), sub-block and wire permutations (spnPermuteEquiv,spnBitPermuteEquiv), single rounds (spnRoundEquiv), and multi-round SPNs (spnNetworkEquiv) are permutations with an explicit round-by-round inverse (spnRoundEquiv_symm,spnNetworkEquiv_symm_cons,bijective_spnNetworkEquiv). - Unbalanced Feistel networks (original construction generalizing the balanced Feistel network
of [KL20], Section 7.2.2, Proposition 7.4): alternating rounds on
A × B(unbalancedFeistelLeftEquiv,unbalancedFeistelRightEquiv), 2- and 4-round networks (unbalancedFeistel2,unbalancedFeistel4), agreement with balanced Feistel (feistel4), and lifting toEquiv.Perm (BitString n)for any block lengthn(unbalancedFeistel4BitString, through the splitBitString.halfSplitEquiv). - Degenerate round-function periodicity ([KL20], Exercise 7.10(a),(b)): general
periodicity reduction (
feistelNetwork_replicate_mod), period-2 law for0 : G → G(feistelNetwork_replicate_zero), and period-3 law forid : G → Gwhen∀ a : G, -a = a(feistelNetwork_replicate_id). - Explicit 1- and 2-round CPA, 3-round repeated-key CPA, and 3-round CCA distinguishers
(attacks from [KL20], Section 8.6 and Exercises 8.16–8.18; concrete bounds are
original):
- Permutation-fiber counts: the one-, two- and three-point bounds below specialize the
k-point falling-factorial boundRandomPermutation.card_extPerms_ofFn_mul_descFactorial_lefromCslibFrontier.Languages.Probabilistic.RandomPermutation.ExtPermsCard. - 1-round CPA (
feistel1CPAAttack, [KL20], Section 8.6): acceptsfeistelRoundEquiv fw.p.1,randomFunctionGamew.p.|G|⁻¹, andidealPermGamew.p.≤ |G|⁻¹(original advantage bound≥ 1 - |G|⁻¹). - 2-round CPA (
feistel2CPAAttack, [KL20], Exercise 8.16): acceptsfeistelNetwork [f₁, f₂]w.p.1andidealPermGame(|G| ≥ 2) w.p.≤ |G| / (|G| ^ 2 - 1) ≤ 2 / 3(original bound). - 3-round repeated-key (
[f, f, f]) CPA (feistel3RepeatedKeyCPAAttack, [KL20], Exercise 8.18): acceptsfeistel3 f f f(∀ a : G, -a = a) w.p.1andidealPermGame(|G| ≥ 2) w.p.≤ 2 / |G| ^ 2 ≤ 1 / 2(original bound). - Sharper permutation-fiber bound for 3-round CCA (attack from [KL20],
Exercise 8.17; original bound
idealStrongGame_feistel3CCAAttack_true_le_inv_card_sub_one,le_advantage_feistel3CCAAttack_idealStrongGame_of_two_le_card): refines the lazy-sampling bound onfeistel3CCAAttack l₀ l₁ r₀to(|G| + 1) / (|G| ^ 2 - 1) = (|G| - 1)⁻¹.
- Permutation-fiber counts: the one-, two- and three-point bounds below specialize the
Implementation notes #
In [KL20], Section 8.6 and Exercises 8.16–8.18 state the distinguishers against Feistel
networks instantiated with keyed PRFs F_{k_i}. Proving acceptance with probability 1 for every
fixed tuple of round functions f₁, f₂, f₃ : G → G immediately implies acceptance with probability
1 under any key distribution (such as the keys of feistel3Cipher in LubyRackoff).
References #
- J. Katz and Y. Lindell, Introduction to Modern Cryptography, 3rd ed., Sections 7.2.1–7.2.2, Propositions 7.3–7.4, Exercise 7.10, Section 8.6, and Exercises 8.16–8.18.
- D. Boneh and V. Shoup, A Graduate Course in Applied Cryptography, Section 4.5 and Exercise 4.15.
Substitution–permutation networks (SPNs) #
Parallel S-box substitution layer of an SPN: apply a family of bijective S-boxes
sboxes : Fin boxes → Equiv.Perm G independently to each sub-block (i ↦ sboxes i (state i)).
Sub-block permutation layer across Fin boxes: reindex sub-blocks along
σ : Equiv.Perm (Fin boxes).
Wire-level bit-permutation (mixing) layer on SPNState boxes (BitString width):
permute the boxes × width individual bit coordinates according to
mix : Equiv.Perm (Fin boxes × Fin width).
Subkey mixing layer of an SPN: add subkey : SPNState boxes G coordinatewise on the right
(state ↦ state + subkey), with inverse state ↦ state - subkey.
A single round of a substitution–permutation network ([KL20], Section 7.2.1):
mix in subkey, apply parallel S-boxes sboxes, and apply mixLayer.
Explicit inverse of a single SPN round: invert mixLayer, apply inverse S-boxes
(sboxes i).symm, and subtract subkey.
Multi-round substitution–permutation network without final post-whitening:
fold spnRoundEquiv sboxes mixLayer k left-to-right across roundKeys.
Full substitution–permutation network ([KL20], Section 7.2.1, Proposition 7.3):
execute spnRoundsEquiv sboxes mixLayer roundKeys followed by a final post-whitening key-mixing
step spnKeyMixEquiv finalKey.
Decrypting a non-empty SPN (k :: ks) undoes the remaining network (ks, finalKey) first and
then applies the single-round inverse (spnRoundEquiv sboxes mixLayer k).symm.
Proposition 7.3 of [KL20]: for any bijective S-boxes sboxes, any bijective
mixing layer mixLayer, and any subkey schedule (roundKeys, finalKey), the resulting
substitution–permutation network spnNetworkEquiv sboxes mixLayer roundKeys finalKey is a bijection
on SPNState boxes G.
Unbalanced Feistel networks and arbitrary block-length splitting #
Left-updating unbalanced Feistel round bundled as a permutation Equiv.Perm (A × B).
Right-updating unbalanced Feistel round bundled as a permutation Equiv.Perm (A × B).
Swapping the two halves (Equiv.prodComm) conjugates a left-updating unbalanced Feistel round
into a right-updating unbalanced Feistel round.
A balanced Feistel round feistelRoundEquiv f ([KL20], Section 7.2.2,
Proposition 7.4) is a left-updating unbalanced round followed by swapping halves
Equiv.prodComm G G.
Two-round alternating unbalanced Feistel network on A × B (original): update A using
f₁ : B → A, then update B using f₂ : A → B.
When A = B = G, the 2-round alternating unbalanced Feistel network unbalancedFeistel2 f₁ f₂
coincides with the 2-round balanced Feistel network feistelNetwork [f₁, f₂].
Four-round alternating unbalanced Feistel network on A × B (original): alternate f₁ : B → A,
f₂ : A → B, f₃ : B → A, and f₄ : A → B.
When A = B = G, the 4-round alternating unbalanced Feistel network
unbalancedFeistel4 f₁ f₂ f₃ f₄ coincides with the 4-round balanced Feistel network
feistel4 f₁ f₂ f₃ f₄.
Four-round unbalanced Feistel permutation on BitString n for any (even or odd) block size n,
constructed from half-block round functions f₁, f₃ : BitString (n - n / 2) → BitString (n / 2)
and f₂, f₄ : BitString (n / 2) → BitString (n - n / 2) (original).
Degenerate round-function periodicity in Feistel networks #
Replicating a + b copies of a single round function f composes the a-round and b-round
Feistel networks.
If k identical Feistel rounds of f compose to the identity permutation on G × G, then
for every r : ℕ, r rounds of f equal r % k rounds of f.
A single Feistel round with the identically zero function 0 : G → G is
Equiv.prodComm G G.
Two Feistel rounds with the zero round function 0 : G → G compose to the identity.
Period-2 law for zero Feistel rounds ([KL20], Exercise 7.10(a)):
running r Feistel rounds with the identically zero round function 0 : G → G acts as the
identity when r is even and swaps the two halves (l, r) ↦ (r, l) when r is odd.
Over any group of exponent two (∀ a : G, -a = a), three Feistel rounds with the identity
round function id : G → G compose to the identity permutation on G × G
([KL20], Exercise 7.10(b)).
Period-3 law for identity Feistel rounds ([KL20], Exercise 7.10(b)):
over any group of exponent two (∀ a : G, -a = a, such as BitString n), running r Feistel
rounds with the identity round function id : G → G has period 3:
r % 3 = 0:(l, r') ↦ (l, r'),r % 3 = 1:(l, r') ↦ (r', l + r'),r % 3 = 2:(l, r') ↦ (l + r', l).
Extension-cache fiber bounds and explicit Feistel distinguishers #
1-round Feistel CPA distinguisher #
The 1-query chosen-plaintext distinguisher against 1-round Feistel ([KL20],
Section 8.6): query (l₀, r₀) to obtain (v, w) and accept iff v = r₀.
feistel1CPAAttack makes at most 1 oracle query.
Every 1-round Feistel network feistelRoundEquiv f is accepted with probability 1 by
feistel1CPAAttack l₀ r₀ ([KL20], Section 8.6), for any round function
f : G → G.
Against randomFunctionGame, feistel1CPAAttack l₀ r₀ accepts with probability |G|⁻¹
(original bound).
feistel1CPAAttack l₀ r₀ distinguishes any 1-round Feistel network feistelRoundEquiv f from
randomFunctionGame with exact advantage 1 - |G|⁻¹ (original bound).
Against idealPermGame, feistel1CPAAttack l₀ r₀ accepts with probability at most |G|⁻¹
(original bound).
feistel1CPAAttack l₀ r₀ distinguishes any 1-round Feistel network feistelRoundEquiv f from
idealPermGame with advantage at least 1 - |G|⁻¹ (original bound).
2-round Feistel CPA distinguisher #
The 2-query chosen-plaintext distinguisher against 2-round Feistel ([KL20],
Exercise 8.16):
query (l₀, r₀) to obtain (v₀, w₀), query (l₁, r₀) to obtain (v₁, w₁), and accept iff
v₀ - v₁ = l₀ - l₁.
feistel2CPAAttack makes at most 2 oracle queries.
Every 2-round Feistel network feistelNetwork [f₁, f₂] is accepted with probability 1 by
feistel2CPAAttack l₀ l₁ r₀ ([KL20], Exercise 8.16), for any round functions
f₁, f₂ : G → G and any l₀, l₁, r₀ : G.
Against idealPermGame, when l₀ ≠ l₁ and 2 ≤ Fintype.card G, feistel2CPAAttack l₀ l₁ r₀
accepts with probability at most |G| / (|G| ^ 2 - 1) (original bound).
When l₀ ≠ l₁ and 2 ≤ Fintype.card G, feistel2CPAAttack l₀ l₁ r₀ distinguishes any
2-round Feistel network feistelNetwork [f₁, f₂] from idealPermGame with advantage at least
1 - |G| / (|G| ^ 2 - 1) (≥ 1 / 3; attack from [KL20], Exercise 8.16, original
bound).
3-round repeated-key ([f, f, f]) Feistel CPA distinguisher #
The 2-query chosen-plaintext distinguisher against 3-round Feistel with a repeated round
function [f, f, f] ([KL20], Exercise 8.18):
query (x, x) to obtain vw, query vw.swap = (vw.2, vw.1) to obtain lr, and accept iff
lr = (x, x).
feistel3RepeatedKeyCPAAttack makes at most 2 oracle queries.
Over any group of exponent two (∀ a : G, -a = a), every repeated-key 3-round Feistel
network feistel3 f f f is accepted with probability 1 by feistel3RepeatedKeyCPAAttack x
([KL20], Exercise 8.18).
Against idealPermGame, when 2 ≤ Fintype.card G, feistel3RepeatedKeyCPAAttack x accepts
with probability at most 2 / |G| ^ 2 (≤ 1 / 2; original bound).
Over any group of exponent two (∀ a : G, -a = a) with 2 ≤ Fintype.card G,
feistel3RepeatedKeyCPAAttack x distinguishes any repeated-key 3-round Feistel network
feistel3 f f f from idealPermGame with advantage at least 1 - 2 / |G| ^ 2 (≥ 1 / 2; attack
from [KL20], Exercise 8.18, original bound).
Sharper permutation-fiber bound for the 3-round CCA distinguisher #
Sharper permutation-fiber bound for feistel3CCAAttack (attack from [KL20],
Exercise 8.17; original bound): when l₀ ≠ l₁ and 2 ≤ Fintype.card G, the true bidirectional
random-permutation game idealStrongGame accepts feistel3CCAAttack l₀ l₁ r₀ with probability at
most (|G| + 1) / (|G| ^ 2 - 1) = (|G| - 1)⁻¹ (≤ 1 / 2 for |G| ≥ 3).
Sharper chosen-ciphertext advantage lower bound for feistel3CCAAttack (attack from
[KL20], Exercise 8.17; original bound): when l₀ ≠ l₁ and 2 ≤ Fintype.card G,
feistel3CCAAttack l₀ l₁ r₀ distinguishes any 3-round Feistel network feistel3 f₁ f₂ f₃ from
idealStrongGame with advantage at least 1 - (|G| - 1)⁻¹ (≥ 1 / 2 for |G| ≥ 3).