A Hybrid Approach to Formal Verification of Higher-Order Masked Arithmetic Programs

Pengfei Gao, Hongyi Xie, Fu Song, Taolue Chen

In the world of cryptography, a mathematically perfect algorithm can still be broken if its physical implementation "leaks" information. Side-channel attacks (SCAs) exploit physical signals like power consumption or electromagnetic radiation to steal secret keys. To defend against this, engineers use masking—splitting secret data into multiple random "shares." However, implementing masking correctly is notoriously difficult and error-prone.

TL;DR

This paper introduces HOME (Higher-Order Masking vErifier), a hybrid framework that combines a sound type system with GPU-accelerated model counting to formally verify masked arithmetic programs. It achieves up to a 110x speedup over previous state-of-the-art tools and can verify complex higher-order implementations that were previously out of reach.

What Problem Does This Paper Address?

The core challenge is verifying higher-order masking in arithmetic programs. While Boolean masking (using XOR) is well-studied, arithmetic masking (using addition, multiplication, and finite-field operations) is much harder to verify.

Existing tools often "bit-blast" arithmetic programs into Boolean ones, but this causes a massive explosion in the number of variables, making verification crawl to a halt. Furthermore, as the "order" of masking increases (to defend against more sophisticated attackers), the number of variable combinations to check grows combinatorially. Researchers have been stuck between fast but inaccurate "type systems" (which produce many false alarms) and accurate but painfully slow "model counters."

Methods

The authors propose a multi-stage hybrid approach to get the best of both worlds:

  1. Sound Type System: They developed a type system based on the concept of dominant variables—random variables that "smother" the secret data, making it statistically independent of the secret. This step quickly clears most of the program.
  2. Pattern Matching: Before resorting to heavy math, the tool looks for "isomorphisms" (structural similarities) between code blocks. If a new piece of code is structurally identical to one already verified, the result is reused.
  3. GPU-Accelerated Model Counting: For the "tough" cases that the type system can't resolve, the authors use model counting to check for statistical independence. Their breakthrough here is automated CUDA kernel synthesis: instead of a generic solver, HOME generates a custom GPU program specifically tailored to the mathematical expression it needs to check. This allows massive parallelization of the brute-force search for leaks.

Datasets

The authors evaluated HOME on a wide range of cryptographic benchmarks, including:

  • Standard Ciphers: Full implementations of AES and MAC-Keccak.
  • Lightweight Ciphers: The round functions of Simon.
  • Masking Conversions: Algorithms that switch between Boolean and Arithmetic masking (A2B and B2A), which are common "weak links" in crypto implementations.
  • High-Order Sboxes: 4th and 5th-order masked Sboxes (the non-linear parts of ciphers), which are traditionally very difficult to verify.

Key Insights and Ideas

  • Direct Arithmetic Verification: By treating arithmetic operations as first-class citizens rather than breaking them into bits, the tool avoids the "variable explosion" that plagues Boolean-only verifiers.
  • The "Aha" of GPU Synthesis: Most GPU solvers are "control-flow intensive," which slows them down. By synthesizing a unique, straight-line CUDA kernel for every potential leak, the authors maximize the GPU's raw throughput.
  • Resolving Spurious Leaks: Type systems are often too conservative, flagging "potential" leaks that aren't actually dangerous. HOME uses its model counter to automatically prove these are false alarms, saving developers from tedious manual inspection.

Key Results

  • Massive Speedups: Compared to the previous state-of-the-art (the BBDFGS algorithm), HOME achieved a 110x speedup on the AES Key Schedule and a 31x speedup on 4th-order Sboxes.
  • New Capabilities: HOME successfully verified a 5th-order Sbox, a feat that previous tools could not accomplish within reasonable time limits.
  • Precision: In several benchmarks where previous tools reported potential leaks, HOME was able to definitively prove whether those leaks were genuine or spurious. For example, it identified 98,176 potential leaks in a 4th-order Sbox as genuine in just 4 minutes.

Limitations and Future Work

While powerful, HOME currently focuses on straight-line code (programs without complex branching or loops). While they handle loops by "unfolding" them, this doesn't scale to programs with dynamic control flow.

The authors suggest that future work should extend these techniques to:

  • Hardware Glitches: Physical hardware often has "glitches" (transient signals) that can bypass masking; verifying against these requires even more complex models.
  • Inherent Branching: Developing ways to handle conditional logic without full unfolding.
  • Stronger Leakage Models: Moving beyond the "probing model" to more realistic (but harder to verify) models like "strong non-interference" (d-SNI).

Summary updated

BibTeX
@article{gao2021hybrid,
  author = {Pengfei Gao and Hongyi Xie and Fu Song and Taolue Chen},
  title = {{A Hybrid Approach to Formal Verification of Higher-Order Masked Arithmetic Programs}},
  journal = {ACM Trans. Softw. Eng. Methodol.},
  year = {2021},
  doi = {10.1145/3428015},
}
Figure