← Back to section · Post-Quantum Cryptography
HQC's Inner Code: One Code for Hardness, One Code for Correctness
HQC contains two codes with a clean division of labour: the quasi-cyclic code makes decoding hard for attackers, while a concatenated inner code makes decoding succeed for legitimate receivers, virtually every time. This article explains the design logic.
Division of labour: decoupling hardness from reliability
HQC’s construction presents an apparent paradox: its security comes from “decoding is hard”, yet its usability demands “decoding succeeds every time”. The same operation must be both hard and easy — how? The answer is to split the two requirements between two different codes.
The outer code is the quasi-cyclic random code, carrying confidentiality: without the secret key, an attacker faces the syndrome decoding problem and cannot decode. The inner code is a carefully chosen error-correcting code, carrying correctness: the message is first encoded with the inner code into a heavily redundant codeword, which then enters the outer structure; the legitimate receiver, having stripped the mask with the secret key, is left with “correct the errors in this codeword” — the inner code’s home turf, which its correction capability makes succeed with overwhelming probability.
This decoupling is the standard pattern for code-based KEMs (McEliece, where a Goppa code carries both duties, is the exception); HQC’s two-code split is arguably cleaner: security parameters are governed by the outer code, reliability parameters by the inner code, and tuning one does not entangle the other.
Contrast with the single-code route
The control group is McEliece’s single-code route: one Goppa code is simultaneously the source of the hard problem and the correction tool — the secret-key holder corrects errors using the code’s algebraic structure (Patterson decoding), while the attacker faces the same code masked by a random permutation. The single-code route is elegant in its few components, at the price of tying correction capability and security parameters to the same code: tuning one drags the other, and the code length must reach the million-bit order for security — which is exactly how the public key grows so large.
HQC’s two-code division essentially trades component complexity for parameter freedom: the outer code is sized purely for security, the inner code’s correction radius purely for reliability, and the two curves are optimised separately, meeting only in the total size. The modularity is also an engineering blessing: if the inner code ever needs replacing or strengthening (a better algebraic combination, say), the outer code’s security argument is untouched, and vice versa. In standardisation review, this separability lets each part’s evidence be audited on its own, rather than confronting one entangled whole.
Concatenated construction: two classical algebraic codes combined
The inner code chosen in the HQC specification is a concatenated code: a combination of a Reed–Solomon code and a Reed–Muller code (in the reference specification the Reed–Muller component is duplicated/expanded to match lengths). Both are classical algebraic codes from the 1950s–60s, chosen for practical reasons:
Reed–Solomon codes correct errors symbol by symbol and excel at bursty error patterns, with an exact formula relating correction capability to redundancy. Reed–Muller codes have simple structure and decoders (such as majority-logic decoding) whose steps are deterministic and easy to implement. Concatenated — encode with one code, then encode the result with the other — the pair achieves a large total correction radius while keeping decoding algebraic and deterministic: given an input, the decoder’s computation path is essentially fixed and does not depend on iterative convergence.
Why not LDPC or polar codes, whose raw correction strength looks better on paper? Because a KEM needs not just “strong on average” correction but a characterisable failure rate: the failure behaviour of iterative decoding depends on graph structure and iteration dynamics, and its tail probabilities resist credible rigorous estimation — while HQC’s failure-rate argument must compute probabilities down to extremely small magnitudes and survive NIST’s scrutiny. Algebraic codes have combinatorial formulas for their failure probabilities that can be computed, extrapolated, and independently rechecked. In this setting, “can be calculated” beats “slightly stronger”.
How decoding proceeds, step by step
Walk through what the inner code does during decapsulation: after the receiver strips the mask with the secret key, what remains is an “inner-code codeword plus superimposed error” vector. Decoding runs the concatenation in reverse: first the Reed–Muller layer, whose structure corrects part of the errors and strips that layer’s redundancy; then the intermediate result goes to the Reed–Solomon layer, which corrects the remaining errors symbol by symbol. If both layers succeed, the original message is fully recovered, and the process moves to the Fujisaki–Okamoto re-encryption check — encapsulate once more and compare ciphertexts, accepting only on a match and implicitly rejecting otherwise.
Two properties of this flow are worth noting. First, every step is a deterministic algebraic operation, with no “iterate until convergence” loop; the number of steps depends on the code length, not on where the errors happen to sit — the source of the constant-time friendliness mentioned earlier. Second, the failure mode is clean: either both layers correct successfully, or some step finds the errors beyond correction and the whole thing fails; there is no intermediate state of “correcting into a plausible-looking wrong result without noticing” — and the re-encryption check of the FO transform backstops even that residual risk.
How the correction radius decides success or failure
There is a direct causal chain between the inner code’s parameters and the failure rate: the distribution of the injected error weight plus the additional mask weight determines the probability that the total error weight exceeds the correction radius — that probability is the failure rate. Designing the inner code means balancing three constraints: the correction radius must be large enough to make overflow negligible; the code rate cannot be too low, or codeword expansion inflates the ciphertext; and decoding complexity must stay manageable, since every decapsulation pays for it.
Each of HQC’s three parameter sets has its own inner-code configuration, with higher levels carrying larger correction margins. The specification devotes substantial space to these parameter derivations and failure-rate simulations for a simple reason: this is the foundation of the scheme’s correctness, and foundation numbers must withstand anyone’s recomputation.
What it means for implementations
The inner code’s deterministic decoding brings an implementation bonus: constant time. Side-channel defence requires execution time independent of secret data; iterative decoding’s “early convergence” leaks the error pattern directly through timing, whereas algebraic decoding’s fixed procedure is naturally close to constant-time, with the remaining branches and table lookups handled by standard techniques. This is one reason HQC is considered comparatively implementation-friendly in reviews: its reliability mechanism and its side-channel posture come from the same design choice.
In hindsight, the inner code is the least “cryptographic” part of HQC — it provides no confidentiality at all, only a correction machine tuned to the extreme. But it is precisely this machine’s precision that determines whether the security proof above it stands. The romance of code-based cryptography is half in the hard problem, and half in this engineering that presses a failure rate down into the dust.
References
- HQC official website (specification, inner-code construction and parameters). https://pqc-hqc.org
- I. S. Reed, G. Solomon, Polynomial codes over certain finite fields, Journal of the Society for Industrial and Applied Mathematics, 1960.
- 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: HQCError-Correcting CodesConcatenated CodesReliability