Private image x (hidden from server) Attacker reconstruction x̂ (evolving)

Gradient Leakage Attack on Federated Learning (2D)

Federated learning promises that a client's raw data never leaves its device — only model gradients are shared. This 2D companion simulator shows why that promise is weaker than it sounds: it implements a real, minimal version of the Deep Leakage from Gradients attack, where an adversary who intercepts a single leaked, batch-averaged gradient runs its own gradient descent to reconstruct the private 8×8 images that produced it, watching random noise grids converge pixel-by-pixel onto the hidden originals. A batch-size slider lets you see the attack's own natural weakness — averaging more private samples into one shared gradient blurs the reconstruction — alongside the differential-privacy defenses real federated systems use: Gaussian noise injection and gradient clipping. Live readouts track the gradient-matching loss, reconstruction error, and the leaked gradient's norm as you dial each defense up or down.