Masking-aware 2-bit weights: making side-channel-protected neural accelerators affordable

Neural network weights deployed on edge chips can be stolen by recording the chip's power draw or electromagnetic emissions while it runs. The standard defense, masking, splits every secret value into random shares, so that no single internal wire reveals anything. Physical logic undermines this. Signals arrive at gates at slightly different times, and a gate can briefly compute on an unmasked combination of shares. These brief spurious transitions, called glitches, leak the secret. The only defenses proven on hardware are expensive, because they add registers that force shares to arrive together. A fully masked binarized network needs 5.3x more lookup tables and 6.8x more flip-flops than an unprotected one (BoMaNet). Masking also multiplies weight memory by the number of shares. This is why protected accelerators so far exist only for 1-bit networks and small multilayer perceptrons, and neither class can do the multi-step reasoning that modern models need.

Ordinary model compression has separately found a way across the "2-bit cliff", the point below 3 bits where models usually collapse. The method splits each 2-bit weight into two binary "bit-planes", each with its own per-group scale factor (BPDQ). This note argues that the format is unusually well matched to glitch-robust masking. The expensive operations in masked hardware are the share-mixing products and the activation thresholds. The bit-plane format costs about the same as plain uniform 2-bit on those operations. Its extra flexibility, the free scale factors, can be applied with arithmetic that never mixes shares, so it cannot glitch. If this holds, the accuracy that BPDQ recovers at 2 bits comes almost free in a protected accelerator. The extra ingredients are the scale factors, applied at a cost amortized over a group of weights, and halved masked weight memory compared with 4-bit.

Core Claim

Under glitch-robust masking, a quantization format should be chosen by a different cost than the one used for unprotected chips. In an unprotected design, cost tracks multiplier area and memory bandwidth. In a masked design, linear operations on shares are cheap and glitch-safe. This holds for additions under arithmetic masking, where a value is split into shares that sum to it modulo $2^k$, and for multiplication by a public constant. The reason is that each share is processed in its own logic cone, so no gate ever sees two shares of the same secret. Glitch-safety is then automatic, in the non-completeness sense used by threshold implementations (Pushing the Limits).

What costs area, registers and fresh randomness are the nonlinear operations. The first is the product of a masked weight bit with a masked activation, which needs a multiplication gadget with registers. The second is activation requantization, which needs a conversion from arithmetic shares to bit-wise (Boolean) shares followed by masked comparisons.

For a dot product of length $N$, take binary weight planes $B$, activation bit-width $b_a$, scale groups of size $G$, and $T$ requantization thresholds. The masked cost per output is then roughly

$$C \approx N\, B\, b_a\, c_{\text{and}} \;+\; T\, c_{\text{cmp}}(k) \;+\; \tfrac{N}{G} B\, c_{\text{scale}},$$

where $c_{\text{and}}$ is the cost of one registered masked AND gadget, $c_{\text{cmp}}(k)$ is the cost of one masked comparison on a $k$-bit accumulator, and $c_{\text{scale}}$ is the cost of one per-group scaling.

Two consequences follow. First, a uniform 2-bit weight is itself two bit-planes with scales locked at $2s$ and $s$. Variable-grid 2-bit therefore has the same first two terms as uniform 2-bit and differs only in the third term, which is divided by $G=256$ in BPDQ's W2-G256 setting. Second, the scales $c_k$ can be treated as public. If so, the third term becomes multiplication of each arithmetic share by a constant, which needs no gadget at all. Whether publishing per-group scales leaks meaningful weight information is an empirical question this proposal must answer, not assume.

On accuracy, the stakes come from the file's 70B-scale numbers. On Qwen2.5-72B, GSM8K accuracy is 83.85% for BPDQ at 2.19 bits, against roughly 40% for 2-bit GPTQ/AWQ and 90.83% for FP16 (BPDQ). Masking is exact arithmetic, so a masked model's accuracy equals the accuracy of the quantized model it implements. Accuracy and protection cost can therefore be measured separately and then combined.

Research Program

The work has three parts.

Gadget library. We build a masked dot-product lane with first-order, two-share protection in the glitch-extended probing model, which is the threat model used by the RISC-V coprocessor of Hardware-Software Co-design for Side-Channel Protected Neural Network Inference. Binary weight planes are stored as Boolean shares, and activations and accumulators as arithmetic shares. Each weight-bit-times-activation product is a registered masked select gadget. Accumulation and public-scale multiplication are performed share-wise. Requantization uses an arithmetic-to-Boolean conversion and masked threshold comparisons. Inside this one lane we can swap in uniform INT4, uniform INT2, bit-plane W2 with secret scales, bit-plane W2 with public scales, and a binary lane in the BoMaNet style. All variants share the same activation path, so the comparison isolates the weight format.

Formal verification of the small components. We verify the select gadget, one accumulator slice and the comparison gadget with the Walsh-Fourier/SMT method of Formal Verification of Masked Hardware Implementations in the Presence of Glitches. That tool verified an AES S-box in about 10 hours, so we limit it to single lanes at small widths and do not attempt a whole accelerator. This matters because From theory to practice of private circuit showed that circuits whose masking is mathematically correct still fail TVLA after synthesis. TVLA is the standard statistical leakage test, which flags leakage when its t-statistic exceeds 4.5 in absolute value. In that paper, a design with synthesis-tool constraints scored 12, and only gate-level synchronization brought the score down to 3.5.

Accuracy measured separately from hardware. We evaluate each format's accuracy in software, using the BPDQ and GPTQ quantizers. We combine these numbers with measured per-lane cost into accuracy-versus-protected-cost curves. We also run the model-extraction question for public scales, described below.

Baselines

Do nothing. The naive reference is an unprotected lane in each format. It sets the overhead denominator and confirms that our measurement setup detects leakage at all. Prior work found that unprotected or partially masked designs leak within 40,000 traces (BoMaNet). Our unprotected lane should fail TVLA similarly fast. If it does not, the setup is too insensitive to support any security claim.

BoMaNet. This is the strongest proven glitch-resistant neural design: modified Trichina gates with pipelining registers in a fully masked binarized network. It reports no TVLA leakage after 2 million traces, at 5.3x LUTs, 6.8x flip-flops and 3.5% latency overhead. We reimplement its binary lane on the same FPGA with the same accumulator width, interleaving depth and trace budget as our lanes. This makes it the B=1 point on our curve. To beat it, our bit-plane lane must pass TVLA at the same trace count with a per-weight cost at most about twice BoMaNet's, the cost of two planes. At that cost it must deliver the 2-bit accuracy regime rather than the binary one.

The RISC-V hybrid-masking coprocessor. This design (Hardware-Software Co-design) uses arithmetic masking for linear layers, Boolean masking for ReLU and max-pooling, and conversions between the two. It reports 4,797 LUTs and 3,981 flip-flops on Spartan-6, no leakage after 1 million traces, and 2x latency. It is the strongest competitor for multi-bit protection. We configure it, or our faithful lane equivalent of it, at INT4 weights, which is the precision reported within 2% of FP16 by Evaluating Quantized Large Language Models. We run it on the same device with the same randomness source and the same TVLA protocol. Beating it means reaching lower cost per weight and half the masked weight memory, while staying within a stated accuracy gap that we measure rather than assume.

Ablations. Two ablations isolate the key ingredient. The first is uniform INT2 in the identical lane, which should match our cost but lose accuracy at the cliff. The second is bit-plane W2 with secret, masked scales, which measures what treating scales as public actually saves.

Why not just…?

Why not just mask a standard INT4 model with the existing hybrid coprocessor? This is the real threat. INT4 is near-lossless and that design is already proven. Two things work against it. Masking doubles weight storage, so masked INT4 occupies as much memory as unprotected INT8. And product gadgets scale with the number of weight bits, so INT4 needs about twice the gadgets of 2-bit planes. Whether this outweighs the accuracy gap is unknown. At 72B scale the file reports 83.85% for BPDQ against 90.83% for FP16 on GSM8K, and we found no reported Lacuna result for BPDQ on models small enough for an edge FPGA. The cost-accuracy curve decides the matter. If masked INT4 dominates at every memory budget, we will report that the bit-plane advantage does not survive.

Why not just use binarized networks with BoMaNet's masking? Protection is solved there, but accuracy is not. One-bit and uniform 2-bit quantization deform the network's likelihood function (Jian Cheng et al.), and reasoning degrades first (Evaluating Quantized Large Language Models). Our B=1 point quantifies exactly how much the second plane costs in hardware against what it buys in accuracy.

Why not just protect only the sensitive layers and leave the rest unmasked? Selective masking (Hardware-Software Co-design) is complementary rather than competing. The protected layers still need a format, and our result tells them which one. We will not claim that selective masking is inferior.

Why not just pick bit-widths with an ordinary mixed-precision cost model? Standard counts of bit operations treat additions and multiplications as comparable. Our claim is that masking makes share-wise linear operations nearly free and nonlinear gadgets dominant. The test is direct: rank the formats by both cost models and check whether the rankings disagree on measured FPGA cost. If they agree, the masking-aware model adds nothing.

Decisive Experiments

Hardware. All lanes are implemented on one FPGA. Spartan-6 matches the coprocessor baseline, and the Virtex-5/SASEBO-GII setup used by From theory to practice is an alternative. We report LUTs, flip-flops, fresh random bits per output, latency, and fixed-versus-random TVLA at first and second order up to 2 million traces. As a stress test, we also build the same lanes with synthesis-tool constraints but without gadget registers. These should fail TVLA, repeating the score-of-12 lesson.

Formal checks. Every gadget, and one accumulator slice at reduced width, must pass verification under the glitch model. Any counterexample is reported as a design failure.

Accuracy. We run WikiText2 perplexity and GSM8K across model sizes from small to the scales in the file, plus MNIST for continuity with BoMaNet. The anchor numbers are QuIP's 2-bit Llama 2 70B WikiText2 perplexity of 6.33 against 123.91 for OPTQ (QuIP), and BPDQ's GSM8K figures. QuIP's random rotations are a second route across the cliff. Their dense mixing would put nonlinear masked products into every coordinate, so we include QuIP only as an accuracy reference.

Public scales. We give an attacker the exact per-group scales plus black-box query access. We measure how much this improves weight-extraction fidelity, in agreement with the true bit-planes and in task accuracy of a cloned model, over an attacker without scales. If publishing the scales lets the attacker recover substantially more of the bit-planes, they must be masked, and the third cost term returns.

Overall verdict. The thesis holds if bit-plane W2 matches uniform INT2 in masked cost within the amortized scaling term, passes TVLA at 2 million traces, and lies on the Pareto front against masked INT4 at some memory budget. It fails if any of these does not hold.