Linear Cryptanalysis Visualizer

Developed by: Mohammad Razzaghi

PhD Student in Network Security, Shahed University

Student ID: 4049170010 | Professor: Dr. Najafi

Theory Overview (Stinson)

Goal: Find a linear approximation for the S-box where the XOR sum of specific input bits (selected by mask α) equals the XOR sum of specific output bits (selected by mask β) with high probability.

Equation: (α ⋅ x) ⊕ (β ⋅ S[x]) = 0


Bias Calculation: For each pair (α, β), we check all possible inputs x. If the equation holds, it's a "Match".
Bias = (Number of Matches) - (Total Inputs / 2).
Values covering the "Linear Approximation Table" below are these Biases. High magnitude values (e.g. +/- 6 or 8) indicate a weakness.

Example 4x4 S-box from Stinson's Cryptography (Heys tutorial). Good for demonstrating high bias (-6).
Linear S-box ($S[x]=x$). Results in perfect bias (+8) on diagonal.
Sample row from AES S-box (highly non-linear, low bias).