Fail-Closed Encryption as an Erasure Map for Generative Image Recovery

When an encrypted image crosses a noisy wireless link, the receiver gets either a perfect image or garbage. Ciphers are built so that one wrong bit scrambles the whole decrypted block, the property called the avalanche effect. Once channel noise exceeds what the error-correcting code can repair, nothing usable is left for a restoration network to work with. Generative image restorers have the opposite need: a corrupted input that is still partly meaningful. Unencrypted semantic communication systems, which map images straight to channel signals, degrade smoothly, but they leak content to eavesdroppers. Nothing in their output separates what was received from what the generator invented.

This note proposes treating the avalanche effect as a feature. We use an integrated cipher-and-code layer, a block cipher whose mixing step is itself an error-correcting code. Each block then either decrypts exactly or fails in a way the receiver can detect. With an image codec whose latent tokens sit at fixed positions in fixed blocks, channel noise becomes a known set of erased tokens. Every surviving token is certified authentic. Two further steps follow. Stronger protection goes to the few tokens carrying high-level semantics, and weaker protection goes to texture tokens. A generative model then fills only the erased tokens, guided by the certified semantic ones. The result is secure transmission that degrades gradually in perceptual quality instead of collapsing, plus a per-pixel provenance map that says where the image is invented. The perception-distortion tradeoff gives a sharp, testable prediction for how much fidelity that invention costs.

Core Claim

We claim three things. First, hard-decision decoding of an integrated cipher-code yields an exact erasure mask over latent tokens. Second, allocating the code's strength unequally across a semantic hierarchy, followed by guided generative inpainting of the erased tokens, gives a better perception-distortion curve at equal transmitted bits than uniform protection. Third, the cost of realism on erased regions is predictable: if the inpainter samples from the true posterior, its squared error there is exactly twice the minimum achievable.

The integrated layer comes from the high diffusion (HD) cipher of High Diffusion Cipher: Encryption and Error Correction in a Single Cryptographic Primitive and On the Design of Error-Correcting Ciphers. Those papers replace the AES mixing step with a maximum-distance-separable (MDS) code, a code meeting the Singleton bound $d_{\min} = n-k+1$, where $n$ is the codeword length, $k$ the message length, and $d_{\min}$ the minimum distance. The same number is the cipher's branch number $B$, which sets security: at least $B(\theta^1)B(\theta^2)$ active S-boxes over four rounds. Those papers treat every block alike, are agnostic to the source, and stop at decoding failure. Our proposal starts where they stop.

Research Program

The source side is a learned codec with fixed-length quantized latents, so a lost cipher block erases a known set of tokens and causes no entropy-decoder desynchronization. For faces we reuse the hierarchical split of Hierarchical Semantic Compression for Consistent Image Semantic Restoration. It separates core semantics $s$, which preserve identity down to 0.003 bits per pixel (bpp), from mid-level features $f$. For general scenes we use a two-level token codec in the same spirit. HSC itself assumes a clean bitstream, and its latents are corrupted unpredictably by bit flips. That is the gap we close.

The channel side assigns $[n,k]$ HD-cipher parameters per tier. Lowering $d_{\min}$ for texture tokens also lowers the branch number, so the cipher's security margin shrinks with it. We compensate with extra rounds, and we report the active-S-box bound for every configuration so that no tier falls below the Rijndael-equivalent level. For a given channel model and bit budget, the allocation is found by search over a small grid of tier rates.

Failure detection has two candidate mechanisms, and we will compare them. A short message authentication tag per block is the conventional choice. The alternative exploits the avalanche effect: a miscorrected block decrypts to near-uniform random tokens, which should have very low likelihood under the codec's token prior. If the likelihood test matches the tag's false-accept rate, the tag bits can be returned to the source.

The receiver side inpaints erased tokens with a diffusion model, meaning a generator that produces samples by repeatedly denoising random noise. It is conditioned on all certified tokens. Certified tokens are clamped at every sampling step. This is a hard data-consistency projection, unlike the physics-operator consistency of DiracDiffusion, which must be retrained for each degradation. Semantic conditioning follows the feature-modulation approach of InstantIR and Learning Diffusion Texture Priors, with one difference. Here the semantic guide is verified, so the "semantic misguidance" failure those methods face under corrupted inputs cannot arise from the channel. Following DiracDiffusion's observation that early stopping moves along the tradeoff, one sampler can output anything from the conditional mean to a full posterior sample.

The analysis rests on one identity. Let $X$ be the true erased content, $Y$ the certified tokens, and $X'$ an independent draw from $p(X\mid Y)$. Then

$$\mathbb{E}\|X - X'\|^2 = 2\,\mathbb{E}\|X - \mathbb{E}[X\mid Y]\|^2 .$$

This is the per-instance version of the factor-of-two result in Rethinking Lossy Compression. It holds because two independent posterior draws each sit one posterior variance from the mean. On erased regions, perfect realism should therefore cost exactly 3 dB in peak signal-to-noise ratio (PSNR) relative to the mean estimate. The measured ratio becomes a diagnostic of how well the sampler matches the posterior.

Baselines

The naive reference is the HD cipher with uniform protection and no recovery: failed blocks are filled with mid-gray latent tokens. This shows the cliff the proposal is meant to remove.

The strongest secure competitor is the modular stack: a symbol-level code, then per-packet authenticated AES, then the same tiered token layout and the same diffusion inpainter. The code is Reed-Solomon, optionally in the cheaper cyclic-ring form of Reed-Solomon Codes over Cyclic Polynomial Ring. This baseline isolates whether integration matters. It receives the same total transmitted bits, the same codec and inpainter checkpoints, and the same grid search over per-tier rates. The integrated cipher's claimed edge is purely in expansion. The HD cipher papers report that matching its error resilience with Rijndael plus Reed-Solomon needs 89% more data expansion. On the Additive Markov Channel the HD cipher spends 147 bits per 27 plaintext bits. Beating this baseline means a perception-distortion curve that dominates it at equal channel bits. We will measure PSNR and LPIPS jointly, LPIPS being a learned perceptual distance.

The strongest unencrypted competitor is Joint Source-Channel-Generation Coding. It maps channel symbols to a diffusion generator through learned adapters and is evaluated on Kodak under AWGN and Rayleigh fading. No reported result found on Lacuna for JSCGC's Kodak numbers, so we retrain it on our data. We do not expect to beat it on perceptual quality at the lowest signal-to-noise ratios, because it pays no security cost. The comparison measures the price of confidentiality and certification. Winning there means a gap of under 1 dB at matched LPIPS, with zero semantic errors in certified regions.

As a noiseless reference on faces, HSC reports a Fréchet Inception Distance (FID) of 12.93 on CelebA-HQ at ultra-low bitrate. Our system on a clean channel should approach this figure.

Two ablations isolate the key ingredients. The first uses uniform protection with the inpainter, which tests unequal allocation. The second uses unequal protection with a mean-only inpainter, which tests the generative step and locates the operating point on the tradeoff.

Why not just…?

Why not just use AES with a strong channel code and inpaint lost packets? This is the real threat, and the proposal does not claim the modular stack cannot carry the erasure-map idea. Authenticated encryption also fails closed. If the modular baseline matches us at equal bits, the integration claim is falsified. The tiered certified inpainting design would still stand as the contribution. The matched-bits comparison above decides the question.

Why not just give everything a lower-rate code to avoid the cliff? Over-provisioning moves the cliff but does not remove it, and it spends bits that could go to the source. The uniform-protection ablation at equal budget measures exactly this cost. The HSC result, that core semantics survive at 0.003 bpp, suggests protecting only $s$ heavily is far cheaper.

Why not just send an unencrypted generative semantic signal? JSCGC degrades smoothly, but its own analysis shows semantic drift as signal-to-noise ratio falls. It also has no mechanism to tell received content from generated content, and it offers no cryptographic resistance. Our comparison quantifies what the certified provenance map and confidentiality cost in perceptual quality.

Why not just run a strong generative restorer on whatever decrypts? Avalanche makes failed blocks uniformly random, so no prior can recover them. Unconstrained generative recovery also swaps identities, as documented for face restorers like VQFR.

Proposed Experiments

We test on Kodak, CelebA-HQ at 256 pixels, and Cityscapes. The channels are the Additive Markov Channel used in the HD cipher papers, plus AWGN and Rayleigh fading with hard-decision demodulation. We sweep channel quality from well above to well below the decoding threshold. Fidelity metrics are PSNR and LPIPS. Realism is measured by FID. For faces we add identity similarity, and for Cityscapes we add segmentation mIoU on the reconstructions; the clean Dilated10 reference is 67.1%, from The Cityscapes Dataset.

We also introduce a certified-region hallucination rate. It is computed by segmenting or identity-matching certified regions against ground truth, and it should equal the source codec's own error.

Three checks decide the proposal. The first is whether the integrated layer beats the modular stack at equal bits. The second is whether the measured ratio of posterior-sample to mean-estimate squared error on erased tokens stays near 2 across erasure rates; a ratio well above 2 means the sampler is off-posterior. The third is whether prior-likelihood detection of miscorrected blocks reaches a false-accept rate comparable to a tag. If all three fail, the cipher layer is unnecessary, and the work reduces to a study of certified inpainting.