← Back to section · Post-Quantum Cryptography

Quasi-Cyclic Codes: How HQC Squeezes Its Public Key into a Few Kilobytes

Classic McEliece's public key runs to hundreds of kilobytes; HQC's is a few kilobytes. The difference is quasi-cyclic structure: describing a whole parity-check matrix by cyclic shifts. This article unpacks how the compression works and what it costs.

Published 22 November 2026 · 5 min read · PQ Frontier

Quasi-Cyclic Codes: How HQC Squeezes Its Public Key into a Few Kilobytes
AI-generated site artwork
Video explainer · HQC and backup candidates

Cyclic structure: one row generates a whole matrix block

Start with a simple idea. If every row of a matrix is the previous row shifted cyclically one position to the right, the matrix needs no element-by-element storage — store the first row, and every other row can be generated on the spot. Codes with this property are cyclic codes, and their algebraic face is the polynomial ring GF(2)[x]/(xⁿ − 1): a length-n vector corresponds to a polynomial, “cyclic shift” corresponds to multiplying by x, and “matrix times vector” corresponds to polynomial multiplication. Storage drops from n² to n — a difference of orders of magnitude.

The original McEliece scheme uses a fully random parity-check structure with no such symmetry to exploit, so its public key honestly stores the entire matrix, ending up at hundreds of kilobytes to over a megabyte — in many settings a disqualifying property by itself. For code-based cryptography to become practical, the code needs compressible structure, and cyclicity is the most natural kind.

Quasi-cyclic: blocks joined side by side

The structure HQC uses is slightly more elaborate than a pure cyclic code; it is called quasi-cyclic: the parity-check matrix is assembled from several cyclic blocks joined horizontally (in HQC, a [2n, n]-type structure of two blocks side by side). Intuitively, the whole code is defined by two length-n vectors: a random vector h fixes the parity-check structure, and the public key additionally carries a syndrome s. The public key’s size is therefore proportional to n rather than n² — HQC-128’s public key of about 2.2 KB comes about exactly this way.

In the construction, the secret key is a pair of sparse vectors (x, y), and the public syndrome s = x + h·y hides the secret inside a syndrome decoding problem: anyone who wants to recover the secret from (h, s) faces the quasi-cyclic version of the decoding problem. Computationally, polynomial multiplication replaces dense matrix multiplication, saving storage and computation alike; key generation, encapsulation, and decapsulation are all built on this ring arithmetic.

What is actually stored in the public key

Taking HQC-128’s public key apart shows where the few kilobytes go. The bulk of the key is the syndrome s itself — a vector of length n accounting for a little over 2,200 bytes; beyond that there is only a short seed: the random vector h is not stored bit by bit but expanded deterministically from the seed, recomputed on demand by whoever needs it. In other words, the whole public key ≈ one seed + one vector — a two-orders-of-magnitude contrast with a McEliece-style public key that stores the entire parity-check matrix.

The ciphertext is composed the same way: it consists of two vectors — one a quasi-cyclic combination of the encapsulator’s randomness, the other the inner-code codeword protected by the mask. Both parts are “vectors”, not “matrices”, which is the same reason the ciphertext stays in the few-kilobyte range. From public key to ciphertext, all of HQC’s size performance flows from a single design discipline: any matrix-shaped object must be generatable on the spot from a vector plus cyclic shifts, and is never stored as-is.

How the structure differs from the MDPC route

BIKE-style QC-MDPC schemes also use quasi-cyclic structure, but they use it differently. The MDPC route puts sparsity in the parity-check matrix itself: the check matrix is a sparse quasi-cyclic matrix, decoding is iterative bit-flipping, and the secret key is that sparse check structure. HQC is different: its parity-check structure is a dense random quasi-cyclic vector, and the sparse objects are the secret vector pair (x, y) and the encapsulation error vector; security is phrased as “recover the sparse vector from the syndrome”, and decoding is delegated to the deterministic algebraic inner code. This difference explains why the two schemes’ failure behaviour diverges so much: one comes from the convergence statistics of iterative decoding, the other from the tail probability of an algebraic correction radius — the latter admits a formula, the former only simulation. It is also a key to the fourth-round reviewers’ disagreement: quasi-cyclic in both cases, but where the structure parks the risk decides how complete the evidence chain can be made.

The price of structure: symmetry is open to both sides

There is no free structure. The same cyclic symmetry that makes storage and computation cheap hands the attacker the same handle: decoding attacks against quasi-cyclic codes can exploit shift-equivalence classes, shrinking the effective search space by a factor — roughly speaking, the n cyclic shifts provide equivalent instances, letting an attacker “attack once, benefit in many places”, so the security margin must be estimated on the discounted basis.

The cryptographic-engineering response is not to abandon structure but to price it: when choosing parameters, compute the discount the structure grants, then compensate with slightly larger n and error weight until the target security level is met again. This is where HQC’s specification spends most of its parameter-justification effort, and it is what separates HQC from amateur “add structure and hope” designs. It is worth stressing that this discount is polynomial (a factor on the order of the code length) against an exponential security body — entirely controllable, and nothing like structured schemes where a deeper exploitation of the structure collapses the whole construction at once.

Why not stronger structure

Module-LWE in lattice cryptography can be read as the same philosophy: use structured algebraic objects (quotient polynomial rings) to buy efficiency and size. HQC’s quasi-cyclic structure is actually quite restrained by comparison: it keeps the syndrome-decoding core of a random code and wraps only a layer of cyclic symmetry around it for storage. That restraint is forty years of code-based experience speaking — every increment of structure demands an increment of scrutiny, and for a backup algorithm, keeping structure within the range where “the discount can be computed exactly” matters more than chasing the smallest possible key. The end result is a public key of a few kilobytes: larger than ML-KEM’s, but perfectly usable in most scenarios outside certificate chains in TLS handshakes — which is exactly what a backup should look like.

References

  1. HQC official website (specification and parameters). https://pqc-hqc.org
  2. C. Aguilar Melchor et al., HQC: Hamming Quasi-Cyclic, NIST PQC submission document.
  3. 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: HQCQuasi-Cyclic CodesKey SizesCode-Based Cryptography