Abstract
Orthogonal direct sum masking (ODSM) protects embedded cryptographic implementations against side-channel attacks by splitting the ambient space into a source code C carrying sensitive data and a complementary masking code D carrying fresh randomness; when , C must be a linear complementary dual (LCD) code. Much of the literature evaluates the masking code primarily through the minimum distance of its dual, treating this parameter as the quantitative summary of leakage resistance under a Hamming-weight leakage model. We show, first computationally and then via a general algebraic theorem, that this one parameter does not determine the variance of the masking code’s Hamming-weight distribution: cyclic codes with identical can differ by close to an order of magnitude in this variance. We prove, for an arbitrary cyclic code with nonzero dual and defining set T (the LCD property is not required for this algebraic result and is invoked only for the ODSM application), a closed-form theorem expressing exactly as , where is an intrinsically defined, representative-independent arithmetic invariant of T, computable via a single least-common-multiple of greatest-common-divisors and requiring no exponential-sum or Gauss-period evaluation. We verify the formula, with an explicit worked example, reproducible from the displayed defining sets, and zero discrepancies, against 64 independently constructed LCD cyclic codes spanning two finite fields and three code lengths. We are explicit that this variance is a second-order algebraic descriptor of leakage dispersion under an idealized leakage model, not a complete side-channel security metric; the connection to physical Hamming-weight leakage is direct for ; for , the result stands as an exact coding-theoretic characterization whose relevance to physical bit-level leakage depends on an explicit bit-encoding model not developed here. We discuss its role as a design diagnostic for ODSM masking codes. This paper is, at its core, a contribution to the algebraic theory of cyclic codes: the reduction of the variance to a weight-two-codeword count is the classical Pless moment identity, and our closed-form arithmetic characterization of that count via is algebraically equivalent, on its domain, to a 2024 result of Coelho and Brochero Martínez; we extend it to arbitrary cyclic length and arbitrary prime-power base fields, and position it as a complement to, not a replacement for, the more operational dual-distance/kissing-number methodology already used in the code-based masking literature.
1. Introduction
Side-channel attacks exploit the statistical dependence between the physical behavior of a cryptographic implementation (its instantaneous power consumption, electromagnetic emission, or execution timing) and the secret data it processes. Differential and correlation power analysis (DPA/CPA) recover secret keys by correlating many such physical traces against hypotheses about intermediate computations, and they remain one of the most practical threats to embedded and smartcard implementations of otherwise mathematically sound ciphers. Masking is the standard algorithmic countermeasure: sensitive data is randomized before it ever touches the physical device, so that, under an idealized leakage model and correct implementation assumptions, low-order observations are intended to reveal no exploitable statistical dependence on the secret, and the dependence only reappears when an attacker combines information from multiple, ideally independent, shares.
Linear complementary dual (LCD) codes occupy a central role in one influential family of masking schemes. Introduced by Massey [1] as a solution to an information-theoretic coding problem unrelated to cryptography, an LCD code is a linear code whose intersection with its dual is trivial. Massey showed that LCD codes are asymptotically good and give an optimum solution to the two-user binary adder channel. Decades later, Carlet and Guilley [2] observed that this same algebraic property makes LCD codes ideal building blocks for masking countermeasures against side-channel and fault-injection attacks because the trivial intersection with the dual guarantees that source data and mask can be recovered unambiguously and securely combined. Bringer, Carlet, Chabanne, Guilley, and Maghrebi [3] formalized this into orthogonal direct sum masking (ODSM): the protected representation of a sensitive word is , where G generates a code C carrying the source data, H generates a complementary code D carrying a fresh random mask , and the direct-sum structure guarantees that and can be projected out unambiguously from . When , the direct-sum condition is exactly the statement that C is LCD. The security intuition is standard: an attacker observing a physical leakage function of should learn as little as possible about . Two distinct leakage models are used in this literature, and we are precise about which one this paper adopts. The Hamming distance model takes leakage to be proportional to the number of bit transitions between two successive states of a data bus or register (the mechanism most directly tied to CMOS switching power); the Hamming weight model, which we adopt throughout, takes leakage to be proportional to the number of nonzero (set) bits of a single state, with no reference to a previous state. The two coincide, up to an additive constant, precisely when the bus or register is systematically precharged to the all-zero state before every new value is loaded (a common assumption for precharged buses and certain register-transfer-level designs), so that each transition is effectively a transition from zero; outside that implementation condition, Hamming distance leakage need not reduce to Hamming weight leakage, and our results should be read as applying to the Hamming-weight model specifically. This is achieved, in either model, by making as large as possible, so that low-weight leakage differences cannot be attributed to any single bit of . Since throughout this paper, : the classical “dual distance of the mask” referenced in the ODSM literature is, in our notation, simply , the minimum distance of the source code. We fix this convention precisely in Section 3 to avoid the ambiguity that can arise between , , and , three generally distinct quantities.
Much of the literature that followed has optimized distance parameters such as , , or , with little explicit analysis of higher moments. Carlet, Li, and Mesnager [4] constructed optimal pairs of linear codes maximizing and jointly subject to length and dimension constraints. A large and still very active line of work constructs explicit families of cyclic and constacyclic LCD codes: via Galois inner products [5,6], BCH-type defining sets of length [7,8], and algebraic-geometry or subspace codes [9,10]. Each new family is reported essentially by its parameters. Even papers whose stated motivation is precisely side-channel resistance stop at this level: constructions of LCD codes from algebraic curves are explicitly justified as resistant to side-channel attacks, yet the quantitative verification of that resistance is left as declared future work rather than carried out.
This is the gap this paper addresses. The dual distance is a worst-case descriptor: it certifies that no single low-weight leakage event can occur, but it says nothing about the shape of the leakage distribution above that floor. Two masking codes with the same can have weight distributions that look almost binomial (the behavior of a “generic” random code) or, instead, concentrate substantial probability mass on a handful of extreme weights far from the mean, a difference with direct consequences for the variance of any Hamming-weight leakage model built on top of the mask. We stress at the outset, and return to at length in Section 7 and Section 8, that this variance is a second-order algebraic descriptor of leakage dispersion under an idealized Hamming-weight leakage model. It should not be interpreted as a complete side-channel security metric: it does not by itself determine attack success probability, signal-to-noise ratio, mutual information, guessing entropy, or the number of traces an attacker would require, none of which are analyzed in this paper. What we show is narrower and, we believe, still useful: that this specific, well-defined algebraic quantity is not determined by alone, and that it is determined exactly by a simple, new invariant of the cyclic code’s defining set, one that requires no character-sum or Gauss-period evaluation whatsoever. This stands in contrast to the classical literature on cyclic-code weight distributions, which reaches for exactly this machinery to determine full weight enumerators, a strictly harder target than the single moment we compute here.
Contributions. (1) We give a covariance decomposition for , , valid for an arbitrary cyclic code C (the LCD property is not used in the algebraic derivation). (2) We characterize dependent coordinate pairs of D through an intrinsically defined subgroup of attached to the cyclotomic defining set of C and prove this characterization is independent of any choice of coset representatives. (3) We obtain a closed-form formula for in terms of this invariant. (4) We prove that, while the LCD property leaves the numeric value of this invariant unchanged, it forces every dependent coordinate pair to be related by a sign () rather than a general nonzero scalar, precisely delimiting what LCD does and does not contribute to the result. (5) We verify the formula computationally, with an explicit worked example exhibiting the defining sets used, reproducible from the values displayed, on 64 independently constructed cyclic LCD codes, and give a concrete instance within the actively studied length- family. (6) We discuss the formula’s use, with appropriate caveats, as a second-order design diagnostic for ODSM masking codes.
The remainder of the paper is organized as follows. Section 2 reviews the four strands of the literature this work connects. Section 3 fixes notation and the source/mask distance convention. Section 4 states the non-degeneracy hypothesis used throughout. Section 5 states and proves the main algebraic results, separating the general cyclic-code statement from its LCD/ODSM application. Section 6 reports the computational verification with a reproducible worked example. Section 7 discusses design implications, with explicit caveats on the scope of the variance metric. Section 8 states limitations, and Section 9 concludes.
2. Literature Review
2.1. LCD Codes: Definition and Cyclic Characterization
An LCD code is a linear code with . Massey [1] introduced the class, proved the existence of asymptotically good LCD codes, and connected them to the two-user binary adder channel. Sendrier [11] later strengthened the existence result, showing LCD codes meet the Gilbert–Varshamov bound. For cyclic codes specifically, Yang and Massey [12] gave the classical characterization used throughout this paper: a cyclic code with defining set T is LCD if and only if T is closed under negation modulo the code length n. Equivalently, if and only if the Gram matrix of any generator matrix G of C is nonsingular over , a criterion that generalizes beyond the cyclic case and is the one we use computationally.
2.2. LCD Codes and Side-Channel Countermeasures
Carlet and Guilley [2] first connected LCD codes to countermeasures against side-channel and fault-injection attacks, giving explicit binary constructions. Bringer et al. [3] introduced orthogonal direct sum masking (ODSM), the concrete masking architecture this paper targets, and derived its security threshold in terms of and . Carlet, Li, and Mesnager [4] then optimized pairs of codes jointly for these two parameters. This entire line treats as the complete quantitative description of resistance; no paper in this line examines higher moments of the masking code’s weight distribution.
2.3. Cyclic and Constacyclic LCD Codes: Recent Constructions
Building on the Yang–Massey characterization, a substantial and currently very active literature constructs explicit families of cyclic and constacyclic LCD codes: Galois-LCD codes and their Hermitian-LCD MDS constacyclic subfamilies [5,6]; BCH-type LCD codes of length , a construction under active development through 2026, with a complete enumeration of LCD cyclic codes of this length given very recently by Liu, Wu, and Zhu [7] and a detailed parameter study for the related family published by Zhang [8]; and linear complementary pairs of algebraic-geometry and subspace codes [9,10]. These papers report parameters and, where possible, optimality, but, consistent with the pattern noted above, do not examine the shape of the dual code’s weight distribution beyond its minimum. Section 6.4 gives a concrete instance of the length- family, showing what the variance formula of Theorem 1 adds beyond the parameters already reported for such constructions.
2.4. Weight Distributions of Cyclic Codes via Exponential Sums
A separate and much older literature determines the full weight distribution of cyclic codes (primarily irreducible or few-zero cyclic codes) via evaluation of exponential sums, Gauss periods, and quadratic forms. Moisio [13] gave a general evaluation of a broad family of exponential sums, subsequently used by Vega [14] to characterize all semiprimitive irreducible cyclic codes by length and by Zhu, Shi, and Özbudak [15] to determine complete b-symbol weight distributions of certain irreducible cyclic codes. This machinery is powerful but heavy: determining a full weight enumerator for a cyclic code whose dual has more than two or three zeros remains, in general, a hard open problem tackled case-by-case. Our results show that the specific second moment (variance) needed for the diagnostic proposed here does not require this machinery at all, for cyclic codes with an arbitrary number of zeros.
2.5. Quantitative Confusion-Coefficient Metrics in S-Box Design
Independently, the S-box design literature quantifies DPA resistance via the confusion coefficient and its variance (CCV): de la Cruz Jiménez [16] and Picek et al. [17] studied the CCV property of S-boxes as a finer-grained resistance metric than worst-case nonlinearity measures. This is the kind of second-moment, variance-based diagnostic we import into the code-based masking setting; within the search described below, we did not find prior work applying a CCV-style variance analysis to the masking code of an ODSM scheme or connecting it to the cyclotomic-coset structure of a cyclic LCD code’s defining set.
Synthesis and search protocol. The literature review above, and the novelty claim it supports, rest on a targeted search rather than a systematic one, conducted through a general-purpose web search interface (not a single bibliographic database such as Scopus or Web of Science) in July 2026, using queries combining terms from {LCD codes, cyclic codes, orthogonal direct sum masking, code-based masking, dual distance, kissing number, weight distribution, cyclotomic coset, confusion coefficient variance} in pairs and triples, together with forward and backward citation chasing from the papers so identified (Section 7 documents one correction that resulted from this chasing after initial submission). No formal inclusion or exclusion criteria, database export, or PRISMA-style protocol were used, and no fixed cutoff date bounded the search beyond the time of writing. Within this search, we did not find published work at the intersection of Section 2.3 and Section 2.4 (algebraic machinery for cyclic-code weight structure) and Section 2.5 (a variance-based diagnostic); we state this as the outcome of the specific search described, not as a claim that no such work exists.
3. Notation and the Source/Mask Distance Convention
Throughout, q is a prime power and n a positive integer with . Let m be the multiplicative order of q modulo n, and fix a primitive n-th root of unity . A cyclic code of defining set (a union of q-cyclotomic cosets modulo n) is . We write , also cyclic, for the code used as the ODSM masking code when C is LCD.
We fix a single notational convention to avoid ambiguity: , , and denote three a priori distinct quantities. Since and for finite fields, we have the identity
The quantity the ODSM literature calls the “dual distance of the mask” is , which by this identity equals , the minimum distance of the source code, not a property of D in isolation. All theorems in Section 5 are stated in terms of , consistent with this identity; itself (the mask’s own minimum distance, relevant to a different property, e.g., error detection in the mask) plays no role in our results and is not used.
Remark 1
(Symbol-wise versus bit-level Hamming weight). Throughout this paper, denotes the standard symbol-wise Hamming weight over : the number of nonzero coordinates of c, counting each nonzero symbol as 1 regardless of its value. This is the quantity Theorem 1 characterizes exactly. For , this symbol-wise weight coincides exactly with the physical bit-transition weight that correlates with CMOS power consumption, so the variance formula bears directly on the Hamming-weight leakage model motivating ODSM. For , this coincidence need not hold: if a field symbol is represented in hardware by a vector of bits (e.g., elements encoded as ), the physical bit-level Hamming weight of a codeword depends on the specific bit-encoding of each symbol and is generally not equal to, nor an affine function of, the symbol-wise weight ; for instance, under the encoding above, nonzero symbols 1 and 2 both contribute bit-weight 1, while our symbol-wise count treats them identically as contributing 1 regardless of encoding, but a different (equally natural) encoding could make them contribute differently, and the aggregate distribution over a full codeword depends on this choice in a way the present paper does not model. Consequently, for , Theorem 1 should be read as an exact result about a coding-theoretic quantity of independent interest, whose direct relevance to physical Hamming-weight leakage requires an additional, explicit bit-encoding model that we do not develop here; the case remains the setting in which the connection to physical leakage is immediate. We return to this point in the Limitations.
4. Non-Degeneracy Hypothesis
The main results assume and use throughout that no coordinate of D is identically zero. We record this as a lemma rather than an unstated assumption.
Lemma 1
(Non-degeneracy). Let be a nonzero cyclic code. Then, for every , the coordinate projection , , is surjective.
Proof.
Suppose for some i, i.e., for every . Since D is cyclic, the cyclic shift (sending to ) maps D onto itself. For any , as well, and ; since this holds for every and , we get as well. Iterating, for every j, i.e., every coordinate of every codeword is zero, so , contradicting the hypothesis. Hence every is a nonzero -linear functional on D, hence surjective (its image is a nonzero -subspace of , i.e., all of ). □
In particular, each is a well-defined Bernoulli random variable with parameter when c is drawn uniformly from D, and .
5. Main Results
We emphasize, per the discussion in Section 3, that the results in this section are stated for an arbitrary cyclic code C and its dual ; the LCD property of C is not used in their proofs. LCD enters only in Remark 3 below, where it licenses the ODSM interpretation of D as a masking code.
Lemma 2
(Generic case). If , then
exactly, independent of any other structural property of D.
Proof.
Fix and let H be a generator matrix of D, with columns , , so that a codeword satisfies for the message . If and were linearly dependent, there would exist , not both zero, with ; the vector v with , , and zeros elsewhere then satisfies for every m, so is a nonzero codeword of weight , contradicting . Hence every pair of columns of H is linearly independent, so the map is a surjective linear map with constant fiber size : is uniform on over . This gives for every pair , so
by Lemma 1, since each is Bernoulli with parameter . □
Remark 2.
This lemma is a reformulation of the classical fact that if and only if is an orthogonal array of strength t [18]; we need only . Its novelty here is not the fact itself but its application below (Theorem 1) to the full range , and, with appropriate caveats (Section 7), to ODSM masking-code design.
We now turn to the case , where Lemma 2 does not apply. The next lemma establishes, independently of any choice of coset representatives, that the relevant dependency structure is governed by a canonically defined subgroup of ; this addresses directly the representative-dependence concern that a definition through an arbitrarily chosen representative would otherwise leave open.
Lemma 3
(Canonical dependency subgroup). Let be the defining set of C. Define
Then is a subgroup of . Consequently there is a unique divisor of n with .
Proof.
with witness . If with witnesses , then for every , and since is a group; hence, . If with witness , then for every , so . Thus is closed under addition and inverses and contains 0: it is a subgroup of the cyclic group . Every subgroup of has the form for a unique divisor L of n, giving the stated form. □
The invariant in Lemma 3 is defined purely in terms of T and involves no choice of representative; the following proposition shows it can nonetheless be computed via any choice of one representative per coset in T, which is what our verification algorithm (Section 6) uses.
Proposition 1
(Computation of ). Let be any representatives of the cosets comprising T (one per coset, any choice). Then
with the convention , and this value is independent of the choice of .
Proof.
Fix a base representative . Within its coset , the defining condition (for the fixed witness of ) applied at gives for every ; taking gives , and then forces , i.e., , equivalently , i.e., . For each other representative , the defining condition forces , i.e., . Conversely, once d satisfies all these congruences, one checks by induction (using integer linear combinations, e.g., ) that holds for every element of every coset in T with the same ; so iff d is a common multiple of the listed moduli, i.e., a multiple of their lcm. By Lemma 3, is intrinsic to T, so this lcm—computed from any valid choice of representatives—must equal in every case, establishing representative-independence as a corollary of intrinsic well-definedness rather than as a separate combinatorial verification. □
Lemma 4
(Proportional columns and weight-two dual words). Let H be a generator matrix of , with nonzero columns . For , the columns are proportional over if and only if contains a weight-two codeword with support exactly .
Proof.
Suppose are proportional. Since both columns are nonzero, there exist such that . Let have , , and zeros elsewhere. For any , , so ; since , v is a weight-two codeword of C with support exactly . Conversely, if C contains a weight-two codeword v with support exactly , write , (both in , and zero elsewhere); means for every , i.e., for every . Since H is a generator matrix, its rows are linearly independent, so H has full row rank and m ranges over the entire message space as ranges over D; in particular, the linear functional vanishing on all of forces , i.e., proportional. □
Theorem 1
(Closed-form variance formula). Let be a cyclic code with defining set T, , and as in Lemma 3. Then
exactly.
Proof.
By Lemma 4, columns of a generator matrix of D are proportional iff contains a weight-two word with support exactly . A weight-two word with support exactly , , lies in C iff there exist with for every , i.e., iff (with witness ). By Lemma 3, the set of such d (excluding 0) is exactly the nonzero part of , of size . The n coordinates partition into cosets of , each of size ; by Lemma 4, two coordinates have dependent (proportional) columns iff , i.e., iff lie in the same coset of . The number of dependent pairs is therefore
As in Lemma 2, independent pairs contribute zero covariance, and each dependent pair contributes (since for a fixed nonzero scalar forces identically, by Lemma 1). Hence
Corollary 1
(Domain of variation). If , choosing in Proposition 1 gives trivially, and reduces to . If, moreover, , then and Theorem 1 reduces exactly to Lemma 2. At the opposite extreme, gives (an empty lcm), C the single parity-check code, and D the q-ary repetition code generated by the all-ones vector, for any q. Here takes the value 0 with probability and n with probability , giving directly, matching the formula and the largest value it attains, a boundary case consistent with D being maximally structured (a single nonzero direction). Consequently, for a nonzero, proper cyclic code C, (and hence ) can differ from the generic value only when : whenever , Lemma 2 forces regardless of any other structural feature of T, so cannot distinguish among ODSM candidates with —it distinguishes only among candidates with . This delimitation is discussed further, together with its practical relevance, in Section 7.
The algebraic results above make no use of the LCD property: , and hence , is determined by T alone, whether or not . This raises a natural question: does the LCD condition constrain the variance formula in any way, or does it play no algebraic role beyond licensing the ODSM interpretation of Remark 3? The next proposition shows that LCD leaves the numeric value of unconstrained but does impose a genuine, previously unremarked structural restriction on how dependent coordinates are related.
Proposition 2
(LCD restricts dependency type, not ). Suppose (i.e., C is LCD). Then for every , the witness with for all satisfies . Consequently, every pair of dependent coordinates (columns of a generator matrix of D) satisfies with : LCD forces every dependency in the masking code to be a pure sign relation, never a general nonzero scalar multiple, even though the numeric value of itself (and hence ) is unaffected.
Proof.
Fix with witness , so for every . Since , for every we also have , and the same single witness must satisfy as well. But , so , i.e., . From the proof of Lemma 4 and Theorem 1, the proportionality constant between dependent columns satisfies (the witness of the underlying weight-two codeword and the column relation are reciprocal), so as well. □
For , and automatically, so Proposition 2 is vacuous; the restriction is genuinely informative only for , where can have elements of order greater than 2. We verified this contrast computationally over , : a non-LCD defining set (not closed under negation) has dependent-pair witnesses as d ranges over the nonzero elements of , with for ; the LCD-symmetrized set has a single dependent gap with witness , consistent with Proposition 2, while changes as a byproduct of enlarging the defining set, not because of the symmetry itself. This confirms both halves of the claim: symmetrizing T does not, by itself, preserve or fix ’s numeric value, but whenever a d is dependent under an LCD-symmetric T, its witness is forced to .
Remark 3
(LCD/ODSM application). Theorem 1 places no requirement on C beyond being cyclic. If, in addition, C is LCD (equivalently, by Yang–Massey [12], T is closed under negation modulo n), then , and can serve as the masking code in an ODSM scheme with C as the source code. All computational examples in Section 6 are additionally restricted to LCD C for this reason, even though Theorem 1 itself does not require it.
Relation to the Pless Moment Identity and to Coelho–Brochero Martínez
We now position Theorem 1 precisely against two bodies of prior work, separating what is classical from what is new.
The classical part. For any nonzero, nondegenerate linear code with , the identity
follows directly from the Pless power moments relating the weight distribution of a code to that of its dual [18], where denotes the number of weight-two codewords of C; it requires neither C nor D to be cyclic. Indeed, this identity is exactly what the covariance decomposition in the proof of Theorem 1 recovers: since each of the dependent coordinate pairs contributes exactly weight-two codewords (one for each nonzero scalar in the pair , ). Substituting recovers , matching Theorem 1 exactly. The reduction of the variance computation to counting weight-two words of C is therefore classical, not new.
What Theorem 1 adds. The contribution is an exact, closed-form arithmetic formula for (equivalently, for ) in terms of the cyclotomic defining set T, valid for cyclic codes of arbitrary length n coprime to q and arbitrary prime-power q, together with the representative-independence result of Lemma 3 and the LCD-specific Proposition 2. This is where the present paper’s novelty is concentrated, and we delimit it further against the closest prior result below.
Coelho and Brochero Martínez (2024) [19] independently derive, for cyclic codes of the special length over a prime field (where ), a necessary and sufficient condition for and an exact count
This is algebraically equivalent to our formula on the domain where both apply. Writing and to match our notation, the classical identity for divisors of n gives
where , () are exactly the arguments of both and . Hence , and substituting into their formula gives , matching the relation above exactly. On the domain , q prime, our closed-form and their are reciprocal reparametrizations of the same arithmetic quantity.
We flag plainly that every numerical example in this paper (Section 6.2, Section 6.3 and Section 6.4) falls inside this domain: , , and are all of the form for a prime base field, and the length-20 example of Section 6.4 similarly reduces to it. What remains new relative to [19], and is not illustrated by these particular examples, is the extension to (i) arbitrary length n coprime to q, not restricted to for the specific extension degree , and (ii) arbitrary prime-power base fields q, not restricted to q prime. Both extensions follow from the same proof (Proposition 1), which never uses or q prime, and we verify each concretely rather than merely asserting them. For the extension to : with , (here , but , so is a proper divisor of and not of the form addressed in [19]), the defining set gives an LCD code with (so ) and , confirmed by direct brute-force enumeration of D. For the extension to non-prime q, which [19] excludes by construction (their base field is for p prime): with and (so q itself is a prime power, not a prime, and for any m), factoring directly over gives five irreducible factors of degrees ; taking the defining set (the three linear factors) gives an LCD code with , , (so ), and , again confirmed by direct brute-force enumeration of D. Both instances lie outside the domain of [19] — the first through n, the second through q — and both are correctly predicted by Theorem 1 nonetheless.
6. Computational Verification
We verified Theorem 1 by exhaustive enumeration within each tested configuration (results in Table 1): for each below, every cyclic code obtainable as a union of q-cyclotomic cosets modulo n was constructed and tested for the LCD property via the Gram-matrix criterion of Yang–Massey [12]; among the resulting LCD codes, those whose dual dimension was small enough for brute-force enumeration of all codewords of D (we used a threshold of for and for ) had their exact weight distribution and variance computed directly and compared against the closed-form prediction of Theorem 1, computed independently via Proposition 1.
Table 1.
Exhaustive verification of Theorem 1 within each tested configuration.
6.1. Algorithm
- (1)
- Enumerate the q-cyclotomic cosets of .
- (2)
- For each nonempty proper union T of cosets, form the generator polynomial , where is the minimal polynomial of over , and build the corresponding cyclic generator matrix G for C.
- (3)
- Test the LCD criterion: C is LCD iff has full rank over .
- (4)
- Compute via Proposition 1, and record directly from it: if , and if (Corollary 1). This step, recomputing explicitly for every instance rather than inferring it indirectly, was added after an earlier draft’s worked example conflated with for two codes that in fact had different ; see Section 6.3.
- (5)
- If is below the brute-force threshold, enumerate (the null space of G) exhaustively, compute and the empirical weight variance directly, and compute from (Section Relation to the Pless Moment Identity and to Coelho–Brochero Martínez).
- (6)
- Compare the predicted variance against the empirical value.
For every instance below the brute-force threshold across all three tested configurations (64 instances total), we recorded n, q, the full defining set T, , , , , , , the predicted and empirical variances, and the comparison result, in a Supplementary CSV file (supplementary_instance_data.csv) accompanying this submission; Table 1 reports only the aggregate counts. Source code implementing this algorithm (Python 3, using the galois library, version 0.4.11) accompanies this submission as Supplementary Materials and is also available from the corresponding author upon reasonable request; see also the Data Availability Statement.
6.2. Results
Across all three tested configurations, the closed-form prediction of Theorem 1 matched the brute-force empirical variance exactly, with zero discrepancies among the 64 LCD codes below the enumeration threshold (Table 1). No instance required any adjustment to the formula or its underlying assumptions; the agreement is exact to machine precision in every case, not merely close. The full per-instance data (defining set, dimensions, , , , , predicted and empirical variance) is provided as Supplementary Material rather than reproduced in full here, since Table 1 already reports the aggregate counts relevant to the reader. Section 6.3 presents one such instance in full detail, chosen specifically because it also corrects an error present in an earlier version of this manuscript.
6.3. Reproducible Worked Example
An earlier version of this example incorrectly reported both codes below as having . That value is in fact , the minimum distance of the mask code D itself (a quantity Theorem 1 does not use); the two codes have different , and we had conflated with despite the notational distinction fixed in Section 3. We are grateful to a reviewer for identifying this error. Here we give a corrected, independently verified example, shown in Table 2: two LCD cyclic codes of length over with identical , , and, most importantly, identical (the only regime in which , and hence the variance, can differ; see Corollary 1 below), yet with different and variance. Write cosets by their smallest element: denotes the 2-cyclotomic coset of t modulo 63.
Table 2.
Two length-63 LCD cyclic codes with equal , , and equal , but different and .
Here , , , and (all reduced modulo 63). For the first code, the generator polynomial is itself a weight-2 codeword, giving directly. For the second, has weight 6, but is a codeword of (one verifies ), giving , and by non-degeneracy, so . Both codes thus lie in the single regime, established in Corollary 1, where can be a proper divisor of n; here it takes two different values (7 and 9), giving variances in ratio . also differs between the two codes (9 versus 14); this underscores that neither alone nor alone determines the variance, and that , computed from the full arithmetic structure of T, is required. In both rows, was computed both by brute-force enumeration of D and by direct evaluation of from Theorem 1, and independently cross-checked against the classical identity (Section Relation to the Pless Moment Identity and to Coelho–Brochero Martínez); all three agree exactly, as recorded in the table. The ratio of this matched-dimension pair understates the range achievable at : among the LCD codes with enumerated for Table 1, gives , , , versus , , , , a ratio, both instances again verified by brute-force enumeration of D.
6.4. Application to the BCH-Type Length- Family
Section 2.3 surveys BCH-type LCD cyclic codes of length , [7,8], without indicating how the variance formula of Theorem 1 bears on this specific family. We give a concrete instance here. Take , , (so ), giving . The 3-cyclotomic cosets modulo 20 are , , , , , and the negation-paired block ; the first five are each individually closed under negation modulo 20, so any union of them yields an LCD code by Yang–Massey [12].
Table 3 exhibits two such LCD codes with identical dimension pair and identical (as it must be, since both have ; see Corollary 1), obtained from different coset combinations, yet with differing by a factor of 2.
Table 3.
Two length-20 LCD cyclic codes (the family, , , ) with equal dimension and equal , but different .
For the first code, has weight 6, but is a codeword (verified by polynomial division), giving ; for the second, is itself a weight-two codeword.
Both codes belong to the length- family surveyed in Section 2.3, both are LCD, and both have the same parameters , the level of detail at which such families are typically reported in the literature. Theorem 1 distinguishes them further: the second code’s masking-code variance is exactly twice the first’s. This is the kind of re-evaluation the variance formula offers for constructions of this type: it supplies, at negligible computational cost, a second-order distinguishing statistic among LCD codes of this family that share identical conventional parameters, without requiring a full weight-enumerator computation for either.
7. Discussion: Scope and Design Implications for ODSM
Theorem 1 shows that the invariant governing whether a cyclic masking code’s Hamming-weight variance can deviate from the generic value is , and, by Corollary 1, exactly when . We state this domain restriction explicitly since it delimits the entire practical scope of the result: for a nonzero, proper cyclic code, can differ from n, and can differ from the generic value, only when . Among candidates with , is identically n and provides no further distinguishing information whatsoever; the entire distinguishing power of Theorem 1 is concentrated in the regime, where it refines (equivalently ) beyond the mere fact that a weight-two word exists. Since is a parameter of the source code, already maximized in standard ODSM design for error-correction reasons unrelated to side-channel resistance, this exposes a design tension: pushing up for error-correction capacity simultaneously forces the masking code’s Hamming-weight variance to its unique minimum-variance value, collapsing any distinguishing power of , while permitting opens access to a computable range of variances via .
On the practical relevance of the case : in ODSM designs that maximize purely for combined error-correction and leakage-floor reasons, Theorem 1 contributes nothing beyond Lemma 2’s single generic value, and the reader may reasonably ask what the theorem adds outside that regime. Three points bear on this. First, Theorem 1 is a complete characterization across all , not one restricted to : it shows that this is the only regime where variance-based comparison among candidate codes is possible at all, a boundary fact not previously stated in the literature we surveyed (Section 2.2 and Section 2.3). Second, not every legitimate design constraint forces : a designer working under a fixed rate , a specific structural requirement (e.g., a prescribed automorphism group or compatibility with an existing hardware datapath), or a deliberate choice to trade distance for a different property may end up with candidates that Theorem 1 lets the designer immediately evaluate rather than treat as unanalyzable. Third, and more modestly, the formula serves an auditing role: given any candidate LCD code with , whatever its provenance, lets one check in closed form, without brute-force enumeration or full weight-enumerator computation, exactly how far its masking-code variance sits from the generic value.
On the ODSM security interpretation. We restrict the claims above to an algebraic invariant of the masking code D itself and deliberately stop short of a direct side-channel security interpretation for a specific reason worth stating precisely. In ODSM, the leaked quantity for a fixed secret is the physical function of , and is uniformly distributed over the coset , not over D itself; Theorem 1 characterizes for , which is the special case . Whether, and how, this coset-zero variance relates to the variance of for a general nonzero secret is a separate question this paper does not answer; more importantly, so is whether it relates to an attacker’s ability to distinguish between the leakage distributions of different values of , which is what actually governs side-channel security. We have not established a conditional-moment analysis across the cosets , nor any bound relating to a concrete attack metric. Consequently, we present here strictly as an algebraic invariant of the masking code, useful for comparing candidate masking codes’ zero-secret leakage dispersion under an idealized model, and not as a direct descriptor of ODSM security in the sense of secret-distinguishing advantage; establishing that connection rigorously is left to future work.
On the state of the code-based masking literature. An earlier version of this manuscript stated that the literature optimizes only distance parameters, with no examination of higher moments. This was incorrect, and we correct it here. A substantial and directly relevant line of work, comprising Guilley, Heuser, and Rioul [20]; Poussier, Guo, Standaert, Carlet, and Guilley [21]; Cheng, Guilley, Carlet, Mesnager, and Danger [22]; Cheng, Liu, Guilley, and Rioul [23]; and, most recently, Chen, Fan, Cheng, and Zhou [24], already goes beyond the dual distance alone, jointly optimizing it together with the kissing number (the number of minimum-weight codewords in the dual, a close relative of our when the minimum weight is 2), and validates the resulting ordering with simulated attack experiments (success rate versus number of traces) rather than distance parameters alone. This body of work is a materially different, more mature undertaking than a distance-tuple comparison, and we no longer claim otherwise. Our contribution relative to it is narrower and more specific: an exact, closed-form arithmetic characterization of (equivalently ) for cyclic codes via their cyclotomic defining set, requiring no enumeration of the kissing number, together with its precise algebraic relationship to via the classical Pless moment identity (Section Relation to the Pless Moment Identity and to Coelho–Brochero Martínez): a complementary, purely algebraic tool that could in principle feed into the kissing-number-based design methodology of this literature for the cyclic case, rather than a competing or more complete security framework.
On the relation to Coelho and Brochero Martínez. As detailed in Section Relation to the Pless Moment Identity and to Coelho–Brochero Martínez, the special case of our result where for Q a power of the prime q is algebraically equivalent to the formula of Coelho and Brochero Martínez [19], published in 2024. All numerical examples in this paper (Section 6.2, Section 6.3 and Section 6.4) happen to fall inside this special case since , , , and are all of this restricted form or reducible to it; we flag this explicitly rather than let the examples imply a broader novelty than the arithmetic warrants. The generalization that remains new is to arbitrary length n coprime to q (not necessarily of the form ) and to arbitrary prime-power base fields q (not necessarily prime), together with the reformulation via the canonical subgroup , the connection to and ODSM, and the LCD-specific Proposition 2.
We emphasize throughout that is a second-order algebraic descriptor of leakage dispersion under an idealized Hamming-weight leakage model with no measurement noise, computed for the zero-secret coset. It does not by itself determine DPA/CPA success probability, signal-to-noise ratio [25], mutual information, guessing entropy, or the number of traces required for a successful attack [26]; none of these quantities are analyzed in this paper, and none should be inferred from alone without a fully specified attack model, noise model, and empirical validation against real or simulated traces. Nor does equal variance imply equal leakage security in a stronger sense: two masking codes with identical can still differ substantially in higher moments or in the full shape of the weight distribution, a limitation we return to in Section 8. With all these caveats, is best read as a low-cost, exactly computable algebraic quantity for the regime: for a target dimension pair with forced or accepted, a designer can enumerate the cyclotomic-coset combinations achieving that dimension and directly compute for each, without ever evaluating a full weight enumerator or kissing number by brute force.
8. Limitations
This work is restricted to cyclic codes; the extension to constacyclic codes (), which underlies the actively studied LCD BCH constructions of length [7,8], is not addressed here. A preliminary check shows the extension is not a routine substitution: for -constacyclic codes the relevant root of unity has order (for ) rather than n, which changes the dependency condition at the core of the proof of Theorem 1 and requires a separate derivation.
As detailed in Remark 1, is computed with respect to the symbol-wise Hamming weight over . This equals the physical bit-transition weight relevant to CMOS power leakage only for . For , the relationship between symbol-wise weight and physical bit-level leakage depends on an explicit encoding of field symbols into bit vectors, which this paper does not model; the instances of Theorem 1 (including the worked example of Section 6.4) should accordingly be read as exact results of independent coding-theoretic interest, whose side-channel relevance for hardware requires this additional, unaddressed modeling step.
The variance metric used here is, as stressed in Section 7, a simplified algebraic proxy under an idealized Hamming-weight leakage model. It does not incorporate measurement noise, higher-order masking, non-Hamming-weight leakage functions, or any of the standard quantitative side-channel metrics (success rate, signal-to-noise ratio, mutual information, guessing entropy); no experimental or simulated side-channel evaluation (DPA/CPA traces) was performed, and none of the claims in this paper should be read as a substitute for one. Relatedly, equal variance does not imply equal leakage security: two masking codes can share while differing substantially in higher moments or in the full shape of their weight distribution, which Theorem 1 does not characterize.
Finally, the literature search supporting the novelty claims in Section 2 was targeted rather than systematic (protocol described in Section 2.5), which limits the strength of broad bibliographic claims; the correction of the literature narrative in Section 7 (regarding the state of the art in dual-distance/kissing-number optimization) illustrates this limitation concretely.
9. Conclusions
This paper is, at its core, a contribution to the algebraic theory of cyclic codes, motivated by but ultimately separable from its cryptographic application. As Section Relation to the Pless Moment Identity and to Coelho–Brochero Martínez makes precise, the reduction of to counting weight-two codewords of C is the classical Pless moment identity, and the closest existing result, Coelho and Brochero Martínez’s 2024 formula for on primitive-length codes over prime fields [19], is algebraically equivalent to ours on its domain. What we contribute is the extension of that arithmetic characterization, via the canonically defined subgroup and the invariant , to cyclic codes of arbitrary length n coprime to q and arbitrary prime-power base fields (both verified concretely in Section Relation to the Pless Moment Identity and to Coelho–Brochero Martínez, including a non-prime-field instance over ), together with the LCD-specific Proposition 2 showing that the LCD property, while leaving ’s numeric value unchanged, forces every dependent coordinate pair to be related by a sign rather than a general scalar. These are coding-theoretic results, verified without exception against 64 independently constructed cyclic codes across three finite fields and four lengths, and they stand on their own within that discipline.
The motivating application, orthogonal direct sum masking, is where is interpreted as a masking code and as the dominant distance-based descriptor used in much of the current LCD/ODSM literature; we showed that this descriptor alone does not determine , and that does so exactly, within the narrow regime where such distinction is possible at all (Corollary 1). We have been explicit that this variance, computed for the zero-secret coset of the masking code, is a second-order algebraic descriptor under an idealized leakage model, not a complete side-channel security metric, and that a substantial existing literature (Section 7) already evaluates code-based masking through the more operational combination of dual distance and kissing number, validated by simulated attacks, a materially more complete methodology than the one presented here. We position as a low-cost, closed-form algebraic quantity that could complement that methodology for the cyclic case, not as a replacement for it. Constacyclic extension, a systematic literature review, and empirical side-channel validation remain as future work before any such complementary role could be established in practice.
Supplementary Materials
The following supporting information can be downloaded at https://www.mdpi.com/article/10.3390/cryptography10040056/s1.
Funding
This research received no external funding.
Data Availability Statement
The Python source code implementing the verification algorithm of Section 6.1, together with its output logs, accompanies this submission as Supplementary Materials and is also available from the corresponding author upon reasonable request.
Conflicts of Interest
The author declares no conflicts of interest.
References
- Massey, J.L. Linear codes with complementary duals. Discret. Math. 1992, 106/107, 337–342. [Google Scholar] [CrossRef] [Scilit]
- Carlet, C.; Guilley, S. Complementary dual codes for counter-measures to side-channel attacks. Adv. Math. Commun. 2016, 10, 131–150. [Google Scholar] [CrossRef] [Scilit]
- Bringer, J.; Carlet, C.; Chabanne, H.; Guilley, S.; Maghrebi, H. Orthogonal direct sum masking, a smartcard friendly computation paradigm in a code, with builtin protection against side-channel and fault attacks. In Information Security Theory and Practice (WISTP 2014); Springer: Cham, Switzerland, 2014; Volume 8501, pp. 40–56. [Google Scholar]
- Carlet, C.; Li, C.; Mesnager, S. Two constructions of optimal pairs of linear codes for resisting side channel and fault injection attacks. arXiv 2018, arXiv:1808.04577. [Google Scholar]
- Fan, Y.; Zhang, L. Galois LCD codes over finite fields. Finite Fields Appl. 2018, 49, 227–242. [Google Scholar] [CrossRef] [Scilit]
- Verma, G.K.; Agrawal, A.; Sharma, R.K. Construction methods for Galois LCD codes over finite fields. J. Appl. Math. Comput. 2023, 69, 4023–4043. [Google Scholar] [CrossRef] [Scilit]
- Liu, J.; Wu, H.; Zhu, L. BCH and LCD cyclic codes of length n = λ(qm + 1) over finite fields. arXiv 2026, arXiv:2603.07688. [Google Scholar]
- Zhang, Y. On the parameters of some LCD BCH codes over with length (qm + 1)/λ. Cryptogr. Commun. 2024, 16, 745–765. [Google Scholar] [CrossRef] [Scilit]
- Bhowmick, S.; Dalai, D.K.; Mesnager, S. On linear complementary pairs of algebraic geometry codes over finite fields. Discret. Math. 2024, 347, 114193. [Google Scholar] [CrossRef] [Scilit]
- Crnković, D.; Švob, A. LCD subspace codes. Des. Codes Cryptogr. 2023, 91, 3215–3226. [Google Scholar] [CrossRef] [Scilit]
- Sendrier, N. Linear codes with complementary duals meet the Gilbert–Varshamov bound. Discret. Math. 2004, 285, 345–347. [Google Scholar] [CrossRef] [Scilit]
- Yang, X.; Massey, J.L. The condition for a cyclic code to have a complementary dual. Discret. Math. 1994, 126, 391–393. [Google Scholar] [CrossRef] [Scilit]
- Moisio, M. A note on evaluations of some exponential sums. Acta Arith. 2000, 93, 117–119. [Google Scholar] [CrossRef] [Scilit]
- Vega, G. A characterization of all semiprimitive irreducible cyclic codes in terms of their lengths. Appl. Algebra Eng. Commun. Comput. 2019, 30, 441–452. [Google Scholar] [CrossRef] [Scilit]
- Zhu, H.; Shi, M.; Özbudak, F. Complete b-symbol weight distribution of some irreducible cyclic codes. Des. Codes Cryptogr. 2022, 90, 1113–1125. [Google Scholar] [CrossRef] [Scilit]
- de la Cruz Jiménez, R.A. On Some Methods for Constructing Almost Optimal S-Boxes and Their Resilience Against Side-Channel Attacks. IACR Cryptol. ePrint Arch. 2018, 2018/618. Available online: https://eprint.iacr.org/2018/618 (accessed on 6 July 2026).
- Picek, S.; Papagiannopoulos, K.; Ege, B.; Batina, L.; Jakobović, D. Confused by confusion: Systematic evaluation of DPA resistance of various S-boxes. In Progress in Cryptology—INDOCRYPT 2014; Springer: Cham, Switzerland, 2014; Volume 8885, pp. 374–390. [Google Scholar]
- MacWilliams, F.J.; Sloane, N.J.A. The Theory of Error-Correcting Codes; North-Holland: Amsterdam, The Netherlands, 1977. [Google Scholar]
- Coelho, J.G.; Brochero Martínez, F.E. Low-weight codewords in cyclic codes. arXiv 2024, arXiv:2407.18398. [Google Scholar]
- Guilley, S.; Heuser, A.; Rioul, O. Codes for side-channel attacks and protections. In Codes, Cryptology and Information Security (C2SI 2017); Springer: Cham, Switzerland, 2017; Volume 10194, pp. 35–55. [Google Scholar]
- Poussier, R.; Guo, Q.; Standaert, F.-X.; Carlet, C.; Guilley, S. Connecting and improving direct sum masking and inner product masking. In Smart Card Research and Advanced Applications (CARDIS 2017); Springer: Cham, Switzerland, 2018; Volume 10728, pp. 123–141. [Google Scholar]
- Cheng, W.; Guilley, S.; Carlet, C.; Mesnager, S.; Danger, J.-L. Optimizing inner product masking scheme by a coding theory approach. IEEE Trans. Inf. Forensics Secur. 2020, 16, 220–235. [Google Scholar] [CrossRef] [Scilit]
- Cheng, W.; Liu, Y.; Guilley, S.; Rioul, O. Toward finding best linear codes for side-channel protections (extended version). J. Cryptogr. Eng. 2024, 14, 131–145. [Google Scholar] [CrossRef] [Scilit]
- Chen, X.; Fan, J.; Cheng, W.; Zhou, Y. Optimizing linear codes for code-based masking against side-channel attacks. Tsinghua Sci. Technol. 2026. [Google Scholar] [CrossRef] [Scilit]
- Mangard, S. Hardware countermeasures against DPA—A statistical analysis of their effectiveness. In Topics in Cryptology—CT-RSA 2004; Springer: Berlin/Heidelberg, Germany, 2004; Volume 2964, pp. 222–235. [Google Scholar]
- Standaert, F.-X.; Malkin, T.G.; Yung, M. A unified framework for the analysis of side-channel key recovery attacks. In Advances in Cryptology—EUROCRYPT 2009; Springer: Berlin/Heidelberg, Germany, 2009; Volume 5479, pp. 443–461. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.