The duplicated first-order Reed–Muller code used by HQC #
HQC uses the binary first-order Reed–Muller code RM(1, 7), with parameters
[128, 8, 64], as its inner code. Each encoded byte is repeated μ times; the HQC-1
parameter set uses μ = 3, while HQC-3 and HQC-5 use μ = 5. This gives the
[384, 8, 192] and [640, 8, 320] duplicated codes [HQC2026, §3.5.3, pp. 32–37].
The source decoder sums the repeated received bits, applies the Walsh–Hadamard transform,
subtracts 64 * μ from its constant coefficient, and scans the coefficient magnitudes using a
strict comparison. Consequently the first (smallest) index wins a tie. A positive selected
coefficient sets the most significant message bit.
The byte layout is the one specified immediately before RM.Encode on p. 32 and in its lines
2–5 on p. 34: byte bit 7 is the affine constant and byte bits 0,…,6 are the coefficients of
the corresponding binary column bits. drmEncode matches the repetition in dRM.Encode,
lines 2–6 (p. 33); drmExpandAndSum matches
dRM.Decode.ExpandAndSum, lines 2–6 (p. 35); drmHadamardTransform and the zero-coefficient
correction match dRM.Decode.Hadamard, lines 4–15 (p. 36); and drmFindPeak/drmDecode match
the strict scan and sign step in dRM.Decode.FindPeaks, lines 4–12 (p. 37).
This module exposes the typed bit-word and source-byte-layout mathematics of that codec. Packing whole messages into byte arrays and the shortened Reed–Solomon outer code are separate layers. In particular, it does not yet compose the actual outer decoder or establish the Model-2 calculation in §6.1.4, Equation (9), or the numerical failure probabilities in Table 16.
Main definitions #
Cslib.Code.RMMessage: one source byte as a sign bit and seven-bit slope.Cslib.Code.rmMessageByteEquiv: the exact source-byte layout.Cslib.Code.rmEncode: theRM(1, 7)affine evaluation word.Cslib.Code.drmEncode: multiplicity-parameterized duplication.Cslib.Code.drmExpandAndSum,Cslib.Code.drmHadamardTransform,Cslib.Code.drmHadamardCoeff: the source decoder's summed bits, staged transform and corrected coefficients.Cslib.Code.drmDecode: the deterministic smallest-peak decoder.
Main results #
Cslib.Code.drmDecode_isNearestDecoder: the source decoder chooses a nearest duplicated Reed–Muller codeword.Cslib.Code.drmDecode_add_eq_of_two_mul_weight_lt: errors of weightedecode correctly when2 * e < 64 * μ.
References #
- HQC specification, version 5.1, §3.5.3, pp. 32–37.
The exact source-byte layout: the sign is bit 7 (the most significant bit), while slope
coordinate i is byte bit i for 0 ≤ i < 7.
A Reed–Muller word repeated μ times.
The source's RM.Encode: evaluate the affine Boolean function named by the byte.
The source generator-matrix multiplication, stated in byte coordinates: byte bit 7
multiplies the all-one row, while byte bit i multiplies coordinate i of the binary column.
Thus this also records the reversal between the source's top-to-bottom matrix rows and its
least-significant-bit-first byte indices.
The source's dRM.Encode: repeat the same RM(1, 7) word μ times.
A duplicated word has 128 * μ bits.
A Walsh character, represented by +1 for Boolean inner product zero and -1 for one.
The in-place butterfly computation in dRM.Decode.Hadamard, expressed recursively: first
combine adjacent entries (coordinate 0, the least significant index bit), then perform the
remaining stages on the two resulting halves. At width 7 this is exactly the source's seven
Walsh–Hadamard rounds.
The staged transform computes the direct Walsh correlation. This pins the source's butterfly implementation to the mathematical transform used in the decoder proof.
The corrected coefficient at a is the distance from the received word to the unsigned
affine word of slope a, centered at half the duplicated block length.
The largest absolute corrected Hadamard coefficient.
The source's strict left-to-right peak scan: the smallest slope attaining maximum absolute coefficient.
If slope zero attains the maximum magnitude, the strict left-to-right scan returns it, including when other slopes tie it.
The selected peak has coefficient magnitude at least that of every slope.
At the encoded slope, the corrected coefficient is -64 * μ for a clear source sign bit and
64 * μ for a set sign bit. This pins the source decoder's coefficient-sign convention.
The source's deterministic best-effort duplicated Reed–Muller decoder.
The source decoder chooses a nearest duplicated Reed–Muller codeword. Its strict peak update fixes one deterministic member when several messages are tied.
Distinct affine RM(1, 7) messages have Hamming distance at least 64.
Duplication multiplies the inner Reed–Muller distance by its parameter μ.
Distinct messages in the multiplicity-μ code are at distance at least 64 * μ.
Unique decoding below half distance. The actual HQC duplicated Reed–Muller decoder
recovers a message after adding any error word whose weight e satisfies 2 * e < 64 * μ.
For every positive multiplicity, decoding is a left inverse to duplicated encoding.