← Back to section · Post-Quantum Cryptography
HQC's Implementation Profile: Where the Cycles Go and Where the Side Channels Hide
Almost all of HQC's computation is spent on decoding, while its secret key is small enough to be a single seed. This article maps its cost structure, the source of its performance gap with ML-KEM, and the side channels implementers must watch.
Cost structure: decoding dominates
Split HQC’s three operations apart and the cost distribution is very uneven. Key generation is mostly sampling sparse vectors plus a few polynomial multiplications; encapsulation is sampling, multiplication, and one pass of inner-code encoding; decapsulation must run the full concatenated-code decoding — correcting the errors back through the Reed–Muller and Reed–Solomon stages (in the specification’s concatenation order). Decoding carries far more computation and combinatorial logic than the other steps, and essentially sets the latency of a single KEM operation.
The polynomial-multiplication part is friendly enough: arithmetic over GF(2) lends itself naturally to bit-slicing and vector instructions, processing dozens of bits in parallel — a traditional advantage of code-based implementations on modern CPUs. The real cost sits in decoding’s table lookups, majority votes, and symbol arithmetic — many steps, many branches, and hard to pipeline as regularly as an NTT.
Where the gap comes from: what to compare against ML-KEM
ML-KEM is fast not because the lattice problem is “simpler” but because its core operation — polynomial multiplication in the NTT domain — is regular arithmetic optimised to the hilt over decades: fixed data flow, predictable memory access, mature paths for SIMD and hardware acceleration. HQC’s decoding is a different class of workload: combinatorial, search-like error correction with data-dependent steps, where optimisation wins constant factors rather than structural ones.
The performance gap between the two is therefore a gap in workload character, not implementation quality. The correct engineering expectation is that HQC on a general-purpose CPU is slower than ML-KEM by a perceptible multiple, which batching and hardware implementations can narrow but not eliminate. For a backup this is entirely acceptable — a backup is not graded on peak throughput but on correctness and trustworthiness, and on the day a switch becomes necessary, being several times slower is far better than having nowhere to retreat to.
Side channels: decoding time talks
The side-channel risk of decoding-based algorithms has a definite shape: if the decoding process contains data-dependent branches, early termination, or a floating iteration count, execution time correlates with the error pattern — and the error pattern correlates statistically with the secret key’s structure. That is the physical-layer cousin of the reaction attack. Even short of full key recovery, timing and power leakage erode the security margin.
The defences are standard engineering discipline, but they must actually be applied: execute the decoding flow in fixed steps with no early exit based on intermediate results; replace table lookups with constant-time access patterns or bit-sliced alternatives; keep critical intermediates out of access paths observable through cache timing. HQC’s algebraic inner-code decoding has essentially deterministic steps, which makes constant-time retrofitting easier than for iterative decoders — a “flip until convergence” loop, as in bit-flipping decoders, is congenitally at odds with constant time. Reviewers and the implementation community generally count this as a quiet point in HQC’s favour over BIKE, for exactly this reason.
Another recurring theme in implementation reviews is the failure-handling path in decapsulation: failure must return the implicit-rejection result along a path indistinguishable from success; any “fast fail” shortcut re-opens the door to the failure oracle. The Fujisaki–Okamoto transform handles this on paper; implementations must not fumble it.
An encapsulation hides inside decapsulation
One more cost item is easily underestimated: the FO transform requires the decapsulator, after recovering the message, to re-run an encapsulation and compare the ciphertext bit by bit, accepting only on a match. HQC decapsulation therefore costs roughly “one decoding plus one encapsulation” in total, and optimisation work cannot stare only at the decoder — the encapsulation path’s sampling and multiplication sit on the critical path too. Nor is this step an optimisation opportunity to be skipped: the re-encryption comparison is a load-bearing wall of CCA security, and any “return the key now, verify asynchronously” shortcut knocks the scheme back to its insecure prototype. The comparison must moreover be constant-time, and the implicit-rejection key on failure must flow through exactly the same derivation as the normal path — the reference implementation handles each of these points; a from-scratch implementation should check them off against the specification rather than simplifying by intuition.
Memory and bandwidth profile
Two further dimensions of the implementation profile are often overlooked. The first is bandwidth: HQC’s public keys and ciphertexts sit in the few-kilobyte range, so their protocol impact falls between ML-KEM (around a kilobyte) and Classic McEliece (hundreds of kilobytes) — bandwidth-sensitive handshakes need measuring, but nothing like the latter’s change to the feasibility boundary of a protocol. The second is memory: quasi-cyclic arithmetic works on a handful of length-n vectors, with decapsulation adding the decoder’s intermediate state — a resident footprint in the tens of kilobytes overall, nothing for servers and desktops, but something to account parameter set by parameter set on the most constrained microcontrollers: the lowest tier is usually feasible, while higher tiers depend on SRAM headroom.
Together these two dimensions fix HQC’s deployable spectrum: full coverage for data centres and ordinary endpoints, per-tier selection for deeply embedded settings. That is also its practical meaning as a backup — on the day a switch is needed, most systems face “swap the algorithm library” rather than “swap the hardware”.
The shape of the secret key: one seed
HQC has an appealing implementation detail: the secret key can be stored as a single short seed, expanded deterministically into the two sparse vectors when needed. Against ML-KEM’s one-to-two-kilobyte secret keys, HQC’s persistent secret is far smaller, easing storage pressure for key escrow, backup, and hardware security modules. The price is the expansion computation on each use, and the expanded copy in memory must be wiped properly afterwards — while the seed itself is the few dozen bytes with the highest confidentiality grade in the whole system, to be stored and backed up with root-key handling.
Overall, HQC’s implementation profile is “heavy in one place, light everywhere else”: heavy in decoding’s compute and its constant-time hardening, light in key storage and distribution. For a crypto-agility architecture reserving it a seat, that means the interface can be reserved early and the performance budget set at “a few times ML-KEM’s” — no existing design needs to be overturned for it.
References
- HQC official website (specification and reference implementation). https://pqc-hqc.org
- NIST, NIST IR 8545: Status Report on the Fourth Round of the NIST Post-Quantum Cryptography Standardization Process, 2025. https://csrc.nist.gov/pubs/ir/8545/final
Tags: HQCImplementationSide ChannelsPerformance