Manuscript Offprint
arXiv:2610.08664Algorithms for Sampling Self-Orthogonal and Totally Self-Orthogonal Codes in Odd Characteristic
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
We give an algorithm that samples uniformly random linear codes of any hull dimension and type over finite fields of odd characteristic, implying the first algorithm for sampling uniformly random self-orthogonal codes of any rate, including self-dual codes. Our algorithm is a re-visitation of the algorithm given by Albrecht, Benčina and Lai (EC'25), using the mass formulae proven by Li, Shi and Ling (IEEE Trans. Inf. Theory 71(1)). This allows us to instantiate code-based cryptographic schemes that rely on the hardness of Permutation Code Equivalence (PCE) on 'random' self-dual codes for security and that were previously unable to sample them. Building on the observation by Bardet, Otmani and Saeed-Taha (ISIT'19) that Euclidean orthogonality is insufficient when considering PCE over finite extension fields due to non-trivial Galois automorphisms, we study the behaviour of what we call total orthogonality, that is orthogonality with respect to all induced Galois geometries simultaneously. We characterise total orthogonality of vectors and codes, and give an algorithm that samples linear codes with a total hull of a prescribed dimension; a subcode that acts as the hull in all Galois geometries of the ambient space. The algorithm incurs a rate decrease by a factor equal to the extension degree, however, we argue why this may be necessary in the context of PCE and explore how it limits the practicality of our algorithm. We consider the notion of Galois type of a linear code when Galois hulls are symmetric and show that all linear codes have constant Hermitian type.
Index Terms
Self-orthogonal codes, self-dual codes, Galois geometries, permutation equivalence over finite extension fields.
However, the question of how to sample from the distribution of uniformly random self-orthogonal codes with given parameters remained largely unanswered until recently. While the authors of [ABL25] gave the first known algorithm for sampling uniformly random linear codes over odd prime fields with a desired hull dimension, the nature of their sampling algorithm limited them to codes with hulls of co-dimension at least A second attempt was made in their follow-up work [ABL26], which indirectly gives a sampling algorithm for codes over odd prime fields of any hull dimension, including self-orthogonal codes, but again of rate below (up to duality). They also show in [ABL26] that PCE over finite extension fields is significantly easier than PCE over prime fields when other parameters remain the same – for an extension field of degree , the Frobenius structure of the extension field allows the adversary to construct PCE samples from a single sample, allowing them to use a linearisation algorithm [BCD 24] to solve PCE.
A. Our Contributions
In this work we give algorithms for sampling self-orthogonal codes of any rate over a field of odd characteristic. For finite extension fields, we define and explore a more appropriate notion of orthogonality, give the corresponding sampling algorithms, and discuss hard PCE instances.
Albrecht is at King's College London and SandboxAQ.
Benčina is at Royal Holloway, University of London, and Aalto University. Corresponding author: benjamin.bencina@aalto.fi.
Lai is at Aalto University.
The research of Albrecht, Benčina and Lai was supported by UKRI Grant EP/Y02432X/1, by UKRI Grant EP/S021817/1, and by the Research Council of Finland grant 358951 and the Future Makers Program of the Technology Industries of Finland Centennial Foundation via the project SPICED, respectively.
This was not a problem for them, as they also needed a lattice problem to be hard simultaneously, which depended on the co-dimension of the hull.
Sampling self-orthogonal and self-dual codes: Our algorithm is, essentially, the slightly modified algorithm SampleCode from [ABL25, Def. 11] for sampling close to the uniform distribution on the set of -linear codes over with a prescribed hull dimension . We provide a formal analysis of this algorithm using the mass formulae from [LSL25] that allow us to prove it is correct, and that its output distribution conditioned on not aborting is exactly (not just close to as claimed in [ABL25]) the uniform distribution on the set of -linear codes over with a prescribed hull dimension and square class . The parameters of our algorithm have no restriction (bar the obvious conditions on the dimension), in particular implying the first known algorithm that samples uniformly from the set of self-dual codes of any admissible dimension over for any odd prime power . Our algorithm can thus be used to formally instantiate multiple code-based primitives that use ‘random self-dual codes’, such as the LESS signature scheme [BBPS21] in the PCE regime and the recently proposed SPECK signature scheme [BBM 25].
Total orthogonality over finite extension fields: While our algorithms for sampling self-orthogonal codes work over any field of odd characteristic, the simple notion of Euclidean orthogonality is insufficient for many applications, such as generating plausibly hard PCE instances. As noted briefly in [BOST19, Sec. IV.A], it is necessary to consider other ‘inner products’ besides the Euclidean form, namely the sesquilinear Galois inner products given by non-trivial automorphisms of the extension field, introduced in [FZ17], [FL22]. Indeed, for each for and prime we consider the sesquilinear forms . Each of these forms induces its own dual and hence its own hull, which could be trivial even for Euclidean self-orthogonal codes. After giving algorithms to compute Galois duals and Galois hulls (these are duals and hulls with respect to Galois inner products), we set out to explore total orthogonality, that is orthogonality with respect to all degree-many Galois inner products simultaneously. We show in Theorem 43 that two vectors (and hence any subcodes) are totally orthogonal over if and only if the codes obtained by a naturally defined coefficient projection are orthogonal over , ignoring the multiplication structure of and only considering it as an -vector space.
Sampling totally hollow codes: We are particularly interested in codes with a large total hull, that is the intersection of all Galois hulls, giving plausibly hard PCE instances over extension fields. Using our above characterisation of total orthogonality, we give in Theorem 48 an algorithm sampling -linear codes over with total hull dimension and a fixed square class for any odd prime , provided there exists an algorithm sampling -linear codes over with hull dimension . Instantiating this with our algorithm for sampling codes of any type, we obtain an algorithm for sampling codes of any total hull dimension with rate at most for odd prime . This rate loss is motivated by the Frobenius sample amplification technique from [ABL26] – if the rate is not divided by , there exists a linearisation algorithm akin to solving PCE over . In other words, even if there exists an algorithm for sampling totally self-orthogonal codes (or any lower total hull dimension) that circumvents the rate loss, such codes may not be cryptographically useful as they yield easy PCE instances. Combining our rate bound of with the recently proposed algorithm for PCE with small rates [BMS26] yields a limit on the hardness of PCE over extension fields – unless , there exists an efficient heuristic distinguisher for PCE on totally hollow codes of rate , which is an upper bound up to duality for codes produced by our algorithm.
B. Open Problems
The main open problem in this area is extending our results to the one remaining case, that is (totally) hollow codes over fields of characteristic 2, which per Theorems 28 and 48 reduces to giving an algorithm that samples binary codes of any hull dimension and ‘type’ (cf. [LSL25]). Another possible future direction is quantifying totally hollow codes, that is how many there are for particular parameters, describing the exact output distribution of our algorithm in Definition 47, and how totally hollow codes relate to equivalence classes in different variants of code equivalence. The Galois square classes in Section V-C (and by extension Galois types) need to be further explored as they provide another easy avenue to deciding PCE akin to [Ben26] – an instance pair needs to have matching Galois hull dimensions and Galois square classes in order to be plausibly hard.
II. PRELIMINARIES
We write for , that is stacking on . Denote for and for with . For a vector we denote by its -th entry and by the vector with entries that are the entries of at indices . The same notation for a matrix denotes the -th row and a range of consecutive rows, respectively. We call a -algorithm if it terminates in time and has success probability (otherwise it aborts with ). An algorithm is Probabilistic Polynomial Time (PPT), or simply efficient, if is a polynomial in its inputs. Logarithms have base 2.
A. Finite Fields
Let for be a finite field of prime characteristic and degree , and its group of units. It is constructed as for an irreducible polynomial over of degree , which always exists but is not necessarily unique. A root of when viewed over its splitting field yields a basis for as a -dimensional vector space
The version submitted to NIST [BBB 24] only includes the LCE regime.
over of the form . The polynomial determines how this basis behaves under field multiplication in , namely how the element wraps around.
The Galois group of automorphisms of is generated by the -Frobenius map , that is each automorphism of is of the form for . The isomorphism with simply maps each to , thus we sometimes denote . We extend each automorphism to vectors entry-wise, that is , and likewise to matrices.
Denote by the quadratic character, which is the multiplicative homomorphism that maps quadratic residues to 1 and non-residues to -1.
We call the affine conic over for odd smooth, or non-degenerate, if its discriminant is non-zero. We have the following statement on the number of points.
Proposition 1 ([BDR]). Let with be a smooth affine conic over for odd prime power. Then
where .
B. Linear Codes
An -linear code over is an -vector subspace of dimension and length . A code is represented by a full-rank row-basis matrix over , denoted here as , which is unique only up to multiplication from the left with a basis change matrix . We normally take the canonical representative that is row-reduced. Traditionally, a linear code (especially over a prime field) is equipped with the Euclidean inner product defined as the bilinear . Its dual is defined as its orthogonal complement, that is . Calling it a complement is misleading, however, since the intersection may be non-trivial. This intersection is a subspace of and is called the hull of [AJK90], and has been subject to extensive investigation [Sen97], [Sen00], [SS13], [BOST19] due to its important role in determining whether two codes are permutation equivalent. For completeness, we include the algorithms for computing the Euclidean dual and hull in Figure 1. A vector is called self-orthogonal if , a code is called self-orthogonal if , and self-dual if . Recall self-dual codes have and exist if and only if (that is ) or even). Codes with a trivial hull for which holds, and so , are called Linear Complementary Dual (LCD) codes [Mas92]. More generally, a code with hull dimension will be called -hollow as in [ABL25]. There is an efficient algorithm given in [Ben26] for ‘dehulling’ a linear code, that is finding a matrix called an LCD component that modulo hull( ) spans . For completeness we include it in Figure 1. The square class of , introduced in [Ben26], is for any LCD component of and is, essentially, the discriminant of any Gram matrix of modulo the hull. The pair (dim(hull( )), ) is called its type (cf. [LSL25]). Let , , and denote the set of all -linear codes over , those with respect to hull dimension , and additionally with respect to square class , respectively. The uniform distribution on the set of generator matrices of codes in , and is denoted by , and , respectively. All self-orthogonal codes have square class 1, and we have [LSL25, Prop. 5]. The square class and hull dimension can be seen as arithmetic invariants by assigning to a code generator matrix the quadratic space and computing its Witt decomposition, as done in [Ben26]. Types of codes then correspond (up to dimension parity) to types of finite geometry [Art57, Sec. III.6].
The first progress since [Sen97] in obtaining a usable and precise mass formula for linear codes with a particular hull dimension other than for self-orthogonal codes was made in [CMTQ19] for the case of LCD codes.
Proposition 2 ([CMTQ19, Thm. 25, Thm. 31 & Cor. 32]). Let with and odd prime power. Denote by (resp. ) the set of all -linear LCD codes over with a basis whose Gram matrix is (resp. for some quadratic non-residue ), and as before by the set of all -linear LCD codes over . Then , and we have
Figure 1. The algorithms Dual, Hull, and Dehull. Given a code generator matrix , they compute the dual, the hull, and a ‘dehulling’ of , respectively. All algorithms are deterministic if they return row-reduced bases.
where , , , , hence
This was recently extended in [LSL25] to codes of any hull dimension, a concurrent work to [ABL25]. It uses a similar technique to our procedure for sampling uniformly random codes with a prescribed hull dimension which we present in Theorem 28 to instead count them. Using this, they recursively extend the result of [CMTQ19] into the following general statement.
Proposition 3 ([LSL25, Thm. 5 & 6]). Let with and odd prime power. Denote by (resp. ) the set of all -linear codes over with hull dimension and a basis whose Gram matrix is (resp. for some quadratic non-residue ), the number of 0s being , and as before by the set of all -linear codes over with hull dimension . Denote also . Then (where is empty when ), and we have
where and for , hence using Proposition 2 we have
where and .
C. Sesquilinear Forms
A map additive in both components is called a sesquilinear form if there exists an automorphism such that and further Hermitian if also for any and . Orthogonality will be defined analogously to the case of bilinear forms. We thus consider the following.
Definition 4 (Galois inner products [FZ17]). For define the -th Galois inner product as
The basic properties of these forms are immediate.
Proposition 5. Each form for is -sesquilinear, -linear in the first argument, -linear in the second argument, and admits . In particular, it is a Hermitian form if and only if either or is even and .
Due to the asymmetric nature of Galois inner products, they are sometimes defined as left and right Galois inner product, depending on which component of the inner product is twisted (ours being right). However, as we will only be interested in the orthogonality relation induced by the inner products and we have that for all and , we without loss of generality only focus on right Galois inner products.
D. The Moore Matrix
We require the following special family of matrices.
Definition 6 (Moore matrix and determinant [Moo96]). Let and . For , the Moore matrix is defined as
When and the Moore matrix is square, the Moore determinant is equal to
The Moore determinant is non-zero if and only if are -linearly independent.
III. SAMPLING CODES FROM A TYPE, UNIFORMLY
A. Additional Geometry over Finite Fields
We consider two geometric objects over finite fields that we will use when constructing our sampling algorithm for uniformly random linear codes with a prescribed type. We first derive a simple lower bound on the probability that a linear code over is LCD that depends only on the field , then interpret the set of self-orthogonal vectors of a linear code as a variety over and consider when a linear code contains non-degenerate planes.
- The LCD Factor:
Lemma 7. Let with and odd prime power. The probability that a uniformly random -linear code over has a trivial hull is bounded from below by . In particular, this is always at least .
Proof. The codes and are always LCD, hence we assume . Since is LCD if and only if is LCD, we may further assume . We use the mass formula from [CMTQ19, Thm. 31 & Cor. 32]. Denote the probability in question by . We use the standard fact that and the analogous formula for . We will bound the denominators simply using for and the numerators by observing that for any we have
by the Weierstrass product inequality. We need to consider the four cases of Proposition 2.
Case odd and odd: We write and . Proposition 2 gives and we have . Since , the positive power of cancels in , and so do the factors for even , so we get
where for we bound the numerators and denominators as discussed above.
Case even and odd: We write and . Proposition 2 gives and we have . Since , the positive power of cancels in , and so do the factors for even , so we get
where for • we bound the numerators and denominators as discussed above.
Case even and even: We write and . Proposition 2 gives and we have . The positive power of cancels in , and so do the factors for even , so we get
where for • we bound the numerators and denominators as discussed above.
Case odd and even: This is the only anomalous case, as we have the additional factor . We write and . Proposition 2 gives and we have . We use to get
When , we have and bound as in the other cases. Otherwise and we have for that . When , we have . The product of odd negative powers in the numerator can be better bounded by , and we finally get
Since the above probability bound will arise many times during our algorithmic treatment and depends only on the underlying field, we introduce notation for it.
Definition 8 (LCD factor). For a finite field denote its LCD factor by .
By Lemma 7, the LCD factor of a field is thus a rough but useful lower bound on the probability that a uniformly random full-rank matrix over of appropriate dimensions is 0-hollow. In other words, we have the following.
Corollary 9. Let with and prime power. Then .
- The Variety of Self-Orthogonal Vectors: While the hull is the largest self-orthogonal subcode of a linear code, the set of self-orthogonal vectors without any linear structure is much greater in size and has the structure of a variety in the coefficient vector space .
Proposition 10. Let with and prime power. Given a generator matrix for an -linear code over , a vector is self-orthogonal in if and only if is a root of the polynomial where is a vector of variables over .
The variety of course depends on the generator matrix for , however, we care less about the coefficient vectors but rather the self-orthogonal vectors , the set which does not depend on .
Definition 11. Denote by the set of self-orthogonal vectors in a linear code . For any generator matrix for we have .
Regardless of the hull dimension of C, the set contains exponentially many vectors in the dimension of C.
Lemma 12. For every -linear code over we have .
Proof. Let generate and assume notation of Proposition 10. The -variate polynomial of degree 2 over is homogeneous, hence it has a root . If , by Warning's Second Theorem [War35, Satz 3] then and hence by Definition 11 also . For it follows from that .
SampleLCD(n, k, q, ) if : return for do if rank( ) k: continue if rank( ) k: continue if : continue return return
Figure 2. The algorithm SampleLCD that, given outputs a matrix with .
B. Regular Planes
While a linear code spanned by A possesses many self-orthogonal vectors, which can be seen as self-orthogonal lines, there are also non-degenerate subspaces of higher dimensions if the hull is not too big, such as non-degenerate planes.
Definition 13 (Regular plane). Let with and prime power. A regular plane is an LCD code over of dimension 2 and length . A regular plane generated by is hyperbolic if is isometric to a hyperbolic plane, equivalently .
Lemma 14. A linear code over for odd prime power contains a regular plane if and only if it has hull co-dimension at least 2, and further contains a hyperbolic plane if and only if it has hull co-dimension at least 3 or hull co-dimension 2 and square class .
Proof. Direct corollary of [Art57, Sec. III.6]. Any linear code with hull co-dimension at least 3 has an LCD component T such that is regular. Then is isometric to an orthogonal sum of subspaces with at least one hyperbolic plane, which corresponds to a basis change of T that has the first two rows spanning a hyperbolic plane. When hull co-dimension is 2, we have that is either isometric to a hyperbolic plane, when , or to an anisotropic space, which corresponds to a non-hyperbolic regular plane. When hull co-dimension is 1 there are no regular planes, only one regular line for each hull vector.
We consider hyperbolic planes in particular because they always contain a non-zero self-orthogonal vector, which will be useful when trying to sample such vectors.
Proposition 15. A regular plane over for odd q contains a non-zero self-orthogonal vector if and only if it is hyperbolic.
Proof. Let T span the plane. By [Art57, Sec. III.6], there are exactly two possibilities for up to isometry, these are either the hyperbolic plane when , or the anisotropic representative. Since anisotropic spaces contain no non-zero isotropic vectors and isotropic vectors in are in bijective correspondence with self-orthogonal vectors in through , the conclusion follows.
C. How to Sample a Hull
We provide an explicit algorithm for finding regular planes in linear codes, use it to construct an algebraic sampling algorithm that samples uniformly random self-orthogonal vectors of a code, and then iteratively build a sampling algorithm for uniformly random linear codes of a given hull dimension and square class.
- Sampling LCD Codes: We start with LCD codes, which are easy to sample using rejection sampling, since most linear codes are LCD by Corollary 9. Without loss of generality, we only deal with codes of rate at most , since a code is LCD if and only if its dual is LCD. This makes the analysis significantly easier.
Definition 16 (Algorithm SampleLCD). Let with , , and odd prime power. Consider the algorithm in Figure 2 that on input outputs a code generator matrix with or aborts with . If , the algorithm always outputs the zero code .
Lemma 17. Assume the notation of Definition 16. The algorithm SampleLCD runs in time , succeeds with probability overwhelming in , and its output distribution conditioned on not aborting is .
Proof. The algorithm is in Figure 2 and is clearly correct if it succeeds with a matrix , as we are simply rejecting generator matrices with . The running time is immediate, since residue testing takes by [Coh93], so we focus on the success probability. The probability that a uniformly random matrix is full-rank is ,
FindPlane(A, i*, j*)
G := AA^T; assert rank(G) ≥ 2; assert i* ≠ j*
if G_{i,i} = 0 for i = 1, ..., k: pick any (i, j) such that G_{i,j} ≠ 0 return A permuted s.t. i ↔ i* and j ↔ j*
pick any i such that G_{i,i} ≠ 0
A := A with transposed rows 1 and i
for i = 2, ..., k do A[i] := A[i] - A[1] A' := A[2, k]; G' := A'A'^T if G'{i,i} = 0 for i = 1, ..., k - 1: pick any (i, j) such that G'{i,j} ≠ 0 return A permuted s.t. i + 1 ↔ i* and j + 1 ↔ j* pick any i such that G'_{i,i} ≠ 0 return A permuted s.t. 1 ↔ i* and i + 1 ↔ j*
Figure 3. The algorithm FindPlane that, given any -hollow with finds generating the same code such that and span a regular plane.
bound by the Weierstrass product inequality. Next, the probability that a uniformly random full-rank matrix generates an LCD code is at least by Corollary 9. The probability that a uniformly random 0-hollow matrix generates a code with square class is by [Ben26, Thm. 1] at least . The algorithm fails if in every one of the repetitions at least one of these events does not happen. Using that by Lemma 7 for , this probability is at most
Remark 18. An algorithm that samples uniformly random LCD codes without considering the square class can be obtained by removing the line that checks the square class. Alternatively we can instead sample instead of taking it as input and obtain an algorithm whose output distribution is negligibly close in to the uniform distribution on LCD codes.
- Finding LCD Planes: Our sampler will start with a uniformly random LCD code of a desired square class and endow it with a hull of the specified dimension. We sample the hull by iteratively sampling the next hull vector as a uniformly random self-orthogonal vector from the dual of the current linear code. Adding hull vectors of course preserves the square class, so the resulting code will indeed be of the correct type. Sampling self-orthogonal vectors will prove to be easy and efficient, all we need to do is find an appropriate parametrisation of the variety of a linear code . The parametrisation will come in the form of a family of smooth conics, where the non-degeneracy condition will be fulfilled by first finding a regular plane on which to base our sampler.
Definition 19 (Algorithm FindPlane). Let with , odd prime power, and additionally . Consider the algorithm FindPlane in Figure 3 that on input an -hollow matrix and indices in , outputs a matrix such that , and and span a regular plane.
Lemma 20. The algorithm FindPlane runs in time and always succeeds.
Proof. Without loss of generality, suppose in this proof and . Suppose for all rows of we have . Then there must exist two rows of such that , otherwise spans a self-orthogonal code. Thus and span a regular plane, so our algorithm simply permutes the rows of into such that starts with and , and clearly .
Otherwise let be the first row of with . Compute a basis for the orthogonal complement of in , that is, a generator matrix for using the usual projections. Again, if for all rows of we have then find any two rows of that are not orthogonal, since it spans a code of hull co-dimension at least 1, and return permuted such that the two non-orthogonal rows of are first. Otherwise let be the first row that is not self-orthogonal in . Then and span a regular plane, hence return permuted such that starts with .
FindPlaneH(A, i*, j*)
assert i* ≠ j*; T, H := Dehull(A); t := rank(T)
assert t ≥ 2; if t = 2 and : return ⊥
T' := FindPlane(T, t - 1, t)
if :
return [T' || H] permuted s.t. and
f := x^T T' T'^T x; for i := 1, ..., k - 2 do
F(x, y) := f(c_1, ..., c_{k-2}, x, y)
; c := ; v := T'^T c
pick y s.t. v^T T'^T y = 1; z := y - c
w := T'^T z; basis change T' s.t. it starts with [v | w]^T
return [T' || H] permuted s.t. and
Figure 4. The algorithm FindPlaneH attempts to change the output of FindPlane in Figure 3 to a hyperbolic plane.
The first condition can be checked with linear algebra by computing the Gram matrix and checking whether it has all 0s on the diagonal, and if so, finding such that and permuting accordingly. Since we already have all the inner products from computing the Gram matrix, orthogonalisation costs vector additions in .
While any regular plane would allow us to sample uniformly random self-orthogonal vectors from a fixed linear code, our plan is to iteratively increase the dimension of our code. Thus our sampling algorithm needs to be independent of the linear code. We ensure this by always picking a hyperbolic plane. A hyperbolic plane always exists by Lemma 14 as long as there are self-orthogonal vectors outside of the hull, otherwise we simply sample from the hull directly.
Definition 21 (Algorithm FindPlaneH). Let with , odd prime power, and additionally . Consider the algorithm FindPlaneH in Figure 4 that on input an -hollow matrix and indices in , outputs a matrix such that , and and span a hyperbolic plane, or aborts with .
Lemma 22. The algorithm FindPlaneH runs in time and always succeeds, except when the input matrix has hull co-dimension 2 and , in which case it always aborts.
Proof. The algorithm first finds any LCD component T of the input A, runs FindPlane and checks whether the obtained regular plane is already hyperbolic. Otherwise, we use the obtained regular plane to find any self-orthogonal vector in the span of T that is not already in the hull, for which it suffices to sample non-zero coefficients and pick any solution of the obtained affine conic, which exists by Proposition 1. Once we have a self-orthogonal vector outside of the hull, constructing a hyperbolic plane is simple: pick any coefficient vector such that using linear algebra, orthogonally project it using and compute . It is immediate that both and are self-orthogonal, we have , and so generates a hyperbolic plane. Then simply compute a basis change of T such that it starts with and , append the missing hull rows and permute the basis appropriately.
- Sampling Self-Orthogonal Vectors: Now that we know how to find hyperbolic planes, we will use them to construct a family of smooth conics whose points correspond bijectively to elements of for a given linear code . This will directly mirror how we construct a self-orthogonal vector in Definition 21, except that we use Proposition 1 to weight the output of our algorithm appropriately to sample the uniform distribution on with rejection.
Definition 23 (Algorithm SSO). Let with , , and odd prime power. Consider the algorithm in Figure 5 that on input an -hollow outputs a self-orthogonal vector from or aborts with .
Lemma 24. Assume the notation of Definition 23 with both . The algorithm SSO runs in time , aborts with probability negligible in , and for any full-rank input its output distribution conditioned on not aborting is .
Proof. The high-level proof idea is the following. The algorithm will first transform its input matrix such that its last two rows span a hyperbolic plane using Lemma 22. Let be variables over . Every vector defines a smooth conic , where , whose points are in bijection with elements of by Proposition 10. All conics in the family share the same discriminant independent of , since we always pick a hyperbolic plane. Then by Proposition 1 each of these conics has a non-empty zero set, however, they may be of two different possible sizes (for a fixed discriminant), thus we weight these points differently depending on which conic they lie on, allowing us to sample uniformly
SSO(A) A' := FindPlaneH(A, k - 1, k) if A' = ⊥: return v ← hull(A) else: A := A' f := x^T A A^T x; M := 2q - 1 for _ := 1, ..., n do [c_1, ..., c_{k-2}]^T ← ; F(x, y) := f(c_1, ..., c_{k-2}, x, y) rs := V_F; u ← ; if u > : continue (c_{k-1}, c_k) ← ; x := [c_i]_{i=1}^k; return y := A^T x return ⊥
Figure 5. The algorithm SSO (SampleSelfOrthogonal) that, given a code generator matrix , outputs a self-orthogonal vector in . The algorithm FindPlaneH is in Figure 4.
from by simply sampling and sampling from the set of points on with potential rejection to correct the distribution. We discuss efficiency and correctness, failure probability, and uniformity of the output.
Efficiency and correctness: Assume the algorithm SSO returns a vector , then by Proposition 10. Denote by the maximal number of loop repetitions. The algorithm first uses linear algebra (Lemma 20) to find a hyperbolic plane in the code generated by and compute the discriminant , then samples at most elements from , solves conic equations over , samples once from a set with at most elements, and computes one multiplication of with the vector . Computing the solutions to the conic equation naïvely requires the computation of the Jacobi symbol, a square root and an inverse , each times, together costing . The worst-case cost of running the algorithm is therefore , and we may fold the term into .
Failure probability: Since , there either exists a hyperbolic plane in by Lemma 14 and we may find it efficiently using Lemma 22, or all self-orthogonal vectors lie in hull( ). In the latter case, we return a uniformly random element of hull( ). In the former case, assume without loss of generality that . For every choice of , the function defines a smooth affine conic. Indeed, the coefficient of is , the coefficient of is , the coefficient of is , hence the discriminant of is
which is non-zero in since is odd. Recall that since we chose a hyperbolic plane, we have from Proposition 1 that and so the number of conic solutions is . The algorithm can only return if for each of the halt repetitions the conic has solutions and the algorithm sampled such that each time. Hence the failure probability is at most
Uniform output distribution: To show this algorithm samples from , assume again that it did not halt with . We must show that every self-orthogonal vector is sampled with the same probability. Since a smooth affine conic always has at least 1 solution, we have by Definition 11 that SSO samples each vector in with non-zero probability. Let be the maximum number of solutions to the obtained conic, which is since . Regardless of the number of solutions to the obtained conic, the probability of each vector being sampled is
Since is fixed at the beginning of execution by the parametrisation of as a family of conics, the probability of each self-orthogonal vector being sampled must be the same, that is, SSO conditioned on not aborting samples from .
Remark 25. For each of the cases in Proposition 1 it is possible to parametrise the solution set of the conic instead of naïvely iterating through it. The complexity of SSO is then polynomial in instead of in q and we can relax our previous requirement that . The same holds for SampleCode in Definition 27. We do not address this further in this thesis.
- Sampling Hollow Codes: We finally assemble the above algorithms to sample linear code generator matrices from . We first sample an LCD code of the appropriate dimension and square class, then use the above algorithm iteratively on the dual code to construct a hull of the desired dimension. Uniformity is due to the following statement.
Lemma 26. Let with , and odd prime power. Suppose , and , then is distributed according to .
SampleCode(n, k, h, q, )
; for do
if : break else:
if : return else: continue
for do
; for do
; if or :
if : return else: continue
; break
; ; return
Figure 6. The algorithm SampleCode. The algorithm SampleLCD is in Figure 2, the algorithm SSO is in Figure 5, the algorithms Dual and Hull are in Figure 1.
Proof. The proof is essentially one recursive step in the proof of [LSL25, Thm. 5]. By [LN97, Thm. 6.26] the number of self-orthogonal vectors in does not depend on but only on the parameters . Indeed, as derived in [LSL25, Prop. 6 & 7], an LCD code of square class contains non-zero vectors if is odd and if is even (and if ). Thus an -linear -hollow code over of square class has vectors in , indeed many for each non-zero self-orthogonal vector of its LCD component.
The square class of , denoted by , is by [LSL25, Prop. 5], thus from hull( ) = hull( ) we get independently of . This number is 0 if and only if the set is empty (see [Ben26, Rem. 3]), so our statement is vacuously true – there is no to sample from and there is no . Otherwise, the code (as any of type ) is by [LSL25, Prop. 2] obtained from different -linear -hollow codes over with square class by appending a self-orthogonal vector from its dual. Thus for any -hollow code of square class we have
where for • we use [LSL25, Thm. 5], so the distribution of is indeed that of a uniformly random -linear -hollow code over with square class . Multiplying by then translates this statement to generator matrices, that is, is distributed according to .
The algorithm we give will (contrary to the claims of [ABL25]) sample from , where whenever , for any rate and hull dimension. Indeed the only exception is the self-dual parameter regime of , and thus , where according to [Mas98] self-dual codes exist if and only if . Our algorithm will naturally arrive at this edge-case and successfully finish sampling with overwhelming probability if and only if this criterion is satisfied. Hence our algorithm implies, to the best of our knowledge, the first algorithm that samples uniformly random self-dual codes.
Definition 27 (Algorithm SampleCode). Let with , , , where necessarily when , and odd prime power. Consider the algorithm in Figure 6 that on input outputs an -hollow matrix with or aborts with .
Theorem 28. Assume the notation of Definition 27 with both . The algorithm SampleCode runs in time , it succeeds with probability unless , and , in which case it always aborts, and its output distribution conditioned on not aborting is .
Proof. We discuss efficiency and correctness, failure probability and uniformity of the output distribution.
Efficiency and correctness: First assume the algorithm SampleCode successfully outputs a matrix A. If then the algorithm outputs a full-rank matrix over , since we start with a full-rank matrix and append rows that increment the rank, otherwise we return . The starting matrix is 0-hollow, otherwise we return , and each appended row increments the hull dimension. Indeed, is by Lemma 24 orthogonal to itself and every vector in the code , since it belongs to the dual code of . Since we exclude vectors that are in hull , the vector is not already in , thus adding it increments the rank. Clearly is also in the hull of , hence also the hull dimension increments. Thus is -hollow. Since is an LCD component of , we have that , thus . The argument for is identical by remarking that the zero code is LCD as its dual is and spanned by . Hence in the first iteration we have and we sample a uniformly random self-orthogonal vector from . The condition that is not in the hull of is in this case equivalent to linear independence, that is, the rank increases at every iteration and we end up with an -linear self-orthogonal code. Every step of the algorithm is efficient by Lemmas 17 and 24.
Failure probability: The algorithm SampleLCD on input always succeeds if and otherwise succeeds with probability and outputs a (uniformly random) 0-hollow matrix with by Lemma 17. Observe that by repeating (at most) times, the success probability rises to by the same argument as in Lemma 17.
Next, SSO returns a uniformly random self-orthogonal vector in except with negligible probability in by Lemma 24. If is already in then it must by construction be in hull( ) and we reject it as it does not produce a new linear code. Using Lemma 12 for , we have that
This leads us to the following two cases.
If it is not the case that and , then the above is further bounded from above by and after repeating at most times by using the union bound, which is negligible in . The probability that we succeed in sampling the hull generators is then bounded from below by the Weierstrass product inequality as , since we need to be successful all times, otherwise we abort with . Thus, the probability that the algorithm successfully outputs a code generator matrix (rather than ) is overwhelming in .
The one remaining case is that of self-dual codes, that is and , where the above estimate collapses. Until the last iteration, the argument is identical to the former case; we must show that the last vector can be chosen with overwhelming probability. In the last iteration we have a -linear self-orthogonal code spanned by and compute a generator of its dual -linear code. Since is -hollow, its hull co-dimension is precisely 2, thus we may run SSO on it. By [CMTQ19, Prop. 5]. we have that , hence by Proposition 15 the code contains self-orthogonal vectors not already in hull( ) if and only if it is a hyperbolic plane with , that is if and only if . Recall that this is precisely when self-dual codes exist, thus we rightly always abort with when they do not. Every self-orthogonal vector in is of the form with and a self-orthogonal vector of the chosen hyperbolic plane. By Proposition 15, the chosen regular plane contains a non-zero self-orthogonal , hence it contains the line spanned by , which itself contains at least self-orthogonal vectors. Thus
We can now repeat the argument from above: after at most repetitions, the probability of SSO failing by sampling a known hull vector is bounded by from above, which is negligible in . Hence the probability that we succeed in sampling the self-orthogonal code generators is bounded from below by the Weierstrass product inequality as , since we need to be successful all times, otherwise we abort with .
Uniform sampling: Conditioned on SampleCode succeeding, we simply apply Lemma 26 iteratively times. Indeed, since is distributed according to by Lemma 17 (otherwise we abort), we have that is distributed according to (up to re-randomisation by a random basis change, which we apply at the end). Further, is distributed according to , so the output for is distributed according to .
Using the fact that square classes of random hollow codes behave essentially like random bits [Ben26, Thm. 1], we directly obtain an algorithm whose output distribution conditioned on succeeding is negligibly close in to .
Definition 29 (Algorithm SampleHollow). Let with , and odd prime power. Consider the algorithm in Figure 7 that on input outputs an -hollow matrix or aborts with .
Corollary 30. Assume the notation of Definition 29 with both . The algorithm SampleHollow runs in time , succeeds with probability unless , and in which case it always aborts, and its output distribution conditioned on not aborting satisfies unless in which case .
SampleHollow(n, k, h, q) if h = k: return A ← SampleCode(n, k, h, q, 1) else: return A ← SampleCode(n, k, h, q, )
Figure 7. The algorithm SampleHollow that, given , outputs an -hollow matrix . The algorithm SampleCode is in Figure 6.
Proof. Clearly the algorithm SampleHollow inherits correctness, efficiency and success probability from the algorithm SampleCode in Definition 27. The distributions D and clearly have the same support that is the set of all generator matrices of codes in . The case is immediate. Otherwise, for the total variation distance we have
where for • we use [Ben26, Thm. 1].
For close to this can of course be improved by replacing by a better estimate, for example by working with the mass formulae in [LSL25] for the desired parameters directly.
IV. On Total Orthogonality over Finite Extension Fields
The algorithm from Definition 27 allows us to sample codes of any hull dimension over fields of any odd prime power size. However, the notion of a (Euclidean) hull may be insufficient over non-prime fields in certain contexts, for example when considering permutation equivalence, as noticed already in [BOST19, Sec. IV.A] and later in [ABL26, Sec. 6]. Indeed, each automorphism of the field induces its own ‘inner product’ and a separate notion of orthogonality and, by extension, hull. In this section and the next, we explore a much stricter variant of orthogonality we call total orthogonality, meaning orthogonality with respect to every one of the degree-many sesquilinear forms induced by field automorphisms simultaneously. This section is reserved for characterising total orthogonality of vectors, while the next section shows how to sample ‘random’ codes with a particularly large total hull, that is a subcode that acts as the hull in every geometry.
A. Total Orthogonality
It will prove useful to think of for as a -dimensional vector space over . In particular, for a fixed field generator of we will think of a vector as giving vectors by decomposing each entry according to the basis and considering vectors over given by coefficients at a single degree.
Definition 31 (Coefficient projection). Denote by for the -th coefficient projection that maps . When the polynomial and the root are fixed, we will often omit the superscript. We extend these maps to vectors coordinate-wise, that is , and likewise to matrices.
Denote by : the -vector space isomorphism that maps (cf. coefficient embedding), and by its inverse we call the coefficient lift. We extend these maps to vectors and matrices, that is maps a matrix from to a vector in .
Besides the usual Euclidean inner product, recall from Definition 4 that over an extension field there are degree-many Galois inner products on , one for each automorphism, where the Euclidean inner product corresponds to the identity map (the 0-th automorphism).
Definition 32 (Galois and total orthogonality of vectors). Vectors are -orthogonal if , sometimes denoted as . Two vectors that are -orthogonal for every will be called totally orthogonal. A vector is -self-orthogonal if it is -orthogonal to itself. We call a vector totally self-orthogonal, if it is -self-orthogonal for every .
Let us check that orthogonality between vectors translates to orthogonality between the spaces they span for each Galois inner product, despite Galois inner products not being -linear in the second component in general (see Proposition 5).
Figure 8. The -th Galois dual and hull of a code.
Proposition 33. Let , and for . Then we have that for every and it holds if and only if for every and every it holds .
Proof. The if direction is clear, let us show the only if direction. It is clear from -linearity in the first argument of that if for , then also for every . For the second argument, where we only have -linearity in general, observe that if for then
Thus -orthogonality of bases translates to -orthogonality of their spans.
Each of the Galois inner products endows with a different geometry, and in particular changes the notion of orthogonality. By Proposition 33, it makes sense to speak of Galois duals and hulls in terms of their generator matrices.
Definition 34 (Galois dual and hull [BOST19, IV.A]). For a linear code and we define its -th Galois dual as
and its i-th Galois hull as
We give explicit algorithms to compute them in Figure 8.
Definition 35 (Galois and total orthogonality of codes). Two linear codes are -orthogonal if , or equivalently if . A linear code is -self-orthogonal if , and further totally self-orthogonal if this holds for every .
Remark 36. Note that Definition 35 of total (self-)orthogonality can be seen as a slight generalisation of [NRS06, Def. 1.2.1], if we considered codes more broadly over rings. In [NRS06, Def. 1.2.1] codes over rings are endowed with a set of bilinear forms M, and orthogonality is considered with respect to all forms in M, much like our total orthogonality. The difference is that our forms are generally not bilinear but -sesquilinear.
Definition 37 (Total hull). For a linear code over define its total hull as the vector subspace
Over prime fields hull* coincides with the Euclidean hull.
B. The Coefficient Code and the Frobenius Closure
We start by defining two codes that are naturally associated to a vector , and will later assist us in characterising total orthogonality.
Definition 38 (Coefficient code). Let for prime and , and fix irreducible of degree and . For define its coefficient code as
It is defined over , has length and dimension at most .
Since different pairs and of an irreducible polynomial over of degree and its root in correspond to an -basis change, the choice of the field generator does not matter and we omit the superscript.
Definition 39 (Moore code). Let and . The Moore code of is defined as
It is defined over , has length and dimension at most .
The Moore code is essentially the Frobenius closure of a single vector, so called because it is spanned by the Moore matrix of the vector's entries.
Proposition 40. The following are equivalent: (i) the code has dimension over , (ii) the code has dimension over , and (iii) the entries of span as a -vector space.
Proof. The code is generated by the matrix where is viewed as a list of elements in . By Definition 6, the determinant of is non-zero if and only if the elements are -linearly independent, that is they form a basis for the -vector space . This immediately implies that if and contains at least -linearly independent entries, which necessarily span as an -vector space, then is full-rank and thus an -linear code over . The entries of span precisely when the coefficient projection matrix spanning has full rank . When all statements are false, completing the proof.
C. Characterisations of Total (Self-)Orthogonality
Fix an irreducible polynomial of degree over and its root . Let us first compute what it means for two vectors to be -orthogonal for in terms of their coefficients with respect to the basis .
Proposition 41. For every two vectors with for prime and , and every , we have
Proof. Write vectors as
and compute
We may ignore how the generator wraps around by simply setting each coefficient in the sum in Proposition 41 to 0, hence the following lemma is immediate.
Lemma 42. A sufficient condition that the vectors and are totally orthogonal is that and are orthogonal codes over (that is one is in the dual of the other). In particular, if is a self-orthogonal code over , then is totally self-orthogonal.
We can imagine that for a polynomial with many non-zero coefficients, the generator wraps around in a way that creates a condition on non-trivial sums of being 0, even when some , complicating the analysis of total orthogonality. Yet, the above sufficient condition is also necessary.
Theorem 43. Two vectors are totally orthogonal if and only if and are orthogonal codes over . In particular, is totally self-orthogonal if and only if is a self-orthogonal code over .
Proof. Let us write for brevity. Observe that setting the -orthogonality sums from Proposition 41 for to 0 yields a homogeneous system of linear equations in the variables , one equation per automorphism and per degree.
Concretely, the system is the following. Order the pairs and the pairs lexicographically, these will number our columns and rows, respectively. Then the system of equations we are considering is the following:
In words, we have collections of successive rows, the -th collection corresponding to the automorphism for . Within each collection, the -th row corresponds to the coefficient of degree , we call these the degree- rows. Our goal is to prove that the matrix in the above equation is full-rank, meaning the only solution is for all . We use the following trick.
Instead of considering A directly, consider the non-projected matrix . Each entry in corresponds to a -entry sub-column in . Observe that performing rank-preserving row operations on corresponds to rank-preserving row operations , that is they factor through the coefficient projection. Indeed, adding a row to another in corresponds to adding rows to another rows in , and swapping two rows of corresponds to swapping two collections of rows of . The last ingredient is that multiplying a row of with a non-zero field element corresponds to a basis change when viewing as a vector space, thus it corresponds to multiplying a matrix to the matching rows of .
Now we compute
Now recall that the Moore matrix is full-rank since the elements form an -basis for as a vector space. Thus the above matrix can be transformed with row operations (by multiplying from the left with ) into
Projecting this matrix back to a matrix over using coefficient embeddings yields a matrix that is clearly full-rank as it has precisely one 1 per row and per column, thus its determinant is . Hence A is full-rank.
Remark 44. What may be surprising about Theorem 43 is that the crude method of setting every coefficient of the sum in Proposition 41 to 0 is the best we can do. In particular, this method ignores the multiplication structure of , described by how the generator wraps around, and only treats as an -vector space.
Theorem 43 gives us a precise characterisation of total orthogonality of vectors in based on their coefficient codes over the base field . We also characterise total orthogonality of vectors using their Moore codes over the extension field , but we did not find the result as useful.
Lemma 45. Let be any prime power. The following are equivalent: (i) the vectors are totally orthogonal, (ii) the codes are totally orthogonal, and (iii) the codes are Euclidean orthogonal. In particular, is totally self-orthogonal if and only if is totally self-orthogonal, equivalently Euclidean self-orthogonal.
Proof. Suppose for all . Then also
The converse is trivial. The equivalence of total orthogonality and Euclidean orthogonality of and follows from conjugate symmetry and the fact that and are closed under action with any automorphism .
Remark 46. Theorem 43 can now be restated as
V. How To Sample a Total Hull
In this section, we give an algorithm to generate a -linear code over that is totally h-hollow, that is has a total hull of dimension , provided there is an algorithm to sample -hollow codes over . The cost we incur is non-trivial, however, since the rate of codes our algorithm can output is bounded by from above.
SampleTotal(n, k, h, p, d, )
assert and ; for do
T ← SampleLCD(n, k - h, , )
if T ≠ ⊥ : break else :
if i = k : return ⊥ else : continue
A := ; H := [·]
for i := 1, ..., dh do
G := Dual(A ); for j := 1, ..., dk do
y_i ← SSO(G); if y_i = ⊥ or y_i ∈ hull(C(A )):
if j = dk : return ⊥ else : continue
A := [A ∥ y_i^T]; H := [H ∥ y_i^T]; break
A := [·]; U ←
for i := 1, ..., h do A[i] :=
A[h + 1, k] := T; return UA
Figure 9. The algorithm SampleTotal. The algorithm SampleLCD is in Figure 2, the algorithm SampleCode is in Figure 6, the algorithm Hull is in Figure 1.
A. Our Algorithm
Our algorithm is based on the characterisation of total orthogonality in terms of coefficient codes from Theorem 43. By the results of the previous section, it suffices to generate linear codes over of dimension for and lift them to vectors over using , such that for all and . If are jointly linearly independent, this will yield vectors over for generating a code , such that the first of them generate a subspace that is -orthogonal to for every and thus totally orthogonal to , hence .
Definition 47 (Algorithm SampleTotal). Let with , (where when ), odd prime and for . Consider the algorithm in Figure 9 that on input outputs a generator matrix for a totally -hollow -linear code over with Euclidean square class or aborts with .
Theorem 48. Assume the notation of Definition 47. The algorithm SampleTotal runs in time , it succeeds with probability unless , and in which case it always aborts, and samples totally h-hollow -linear codes over with Euclidean square class .
Proof. The algorithm mimics SampleCode but projects to to sample total hull vectors. Indeed, we first sample a uniformly random (Euclidean) LCD code of dimension and square class over identically to SampleCode. We then project to a matrix over of rank . We continue running the code of SampleCode but over and with a fixed (though may have a hull over ). This produces hull vectors over , which we then lift at a time using to to obtain total hull vectors. Denote by for disjoint groups of consecutive rows of and the same for and . Denote also . By construction, the codes are jointly linearly independent and we have for and , hence immediately from Theorem 43 and Proposition 33 the algorithm SampleTotal is correct. Note that it is possible that the projected matrix has rank smaller than , or that it has a hull. However, the algorithm is still correct, since the only vectors that get lifted back to are the generated hull vectors which are by Theorem 43 totally orthogonal to and each other, and linearly independent of . Observe also that the output generates precisely a totally -hollow code, not some larger total hull dimension, since spans an LCD code and so the Euclidean hull dimension cannot be larger than . It is possible for an individual Galois hull to have dimension larger than . Running time and success probability follow from Theorem 28.
Remark 49. We make no claims in Theorem 48 about the output distribution of SampleTotal (conditioned on not aborting), except that its support is a subset of all totally h-hollow -linear codes over with Euclidean square class , though we suspect it is close to the uniform distribution on the whole set.
We would like to conjecture that the algorithm SampleTotal outputs hard instances of PCE (and its signed variant) in the following sense. Let , parametrised by satisfy the constraints of Theorem 48 with . Then we want that for any PPT algorithm A we have that
\begin{aligned}&\Pr\left[b=b^{\prime}\left|\begin{matrix}\mathbf{A}\leftarrow SampleTotal(\lambda)\\\mathbf{B}_{0}\leftarrow SampleTotal(\lambda)\\\mathbf{P}\leftarrow\\ \mathcal{P}_{n};\mathbf{U}\leftarrow\\ \mathcal{G}\mathcal{L}_{k}(\mathbb{F}_{q})\\\mathbf{B}_{1}:=\mathbf{U}\mathbf{A}\mathbf{P}\\b\leftarrow\\ \{0,1\};b^{\prime}\leftarrow\mathcal{A}^{\lambda}(\mathbf{A},\mathbf{B})\end{matrix}\right.\right]-\frac{1}{2}\right]\leq negl(\lambda).\end{aligned}However, the price we pay by decreasing the rate also has consequences for security, which we discuss in the next subsection.
B. Limits of PCE over Extension Fields
As mentioned at the top of this section, the cost we pay is in terms of decreased rate. That is, up to duality, SampleTotal can only sample codes of rate bounded by from above (in the best case where SampleCode samples codes of rate ). A recent algorithm by Battagliola, Mora, and Santini [BMS26] shows that codes whose rate is at most inverse-quadratic cannot yield hard permutation equivalence instances, up to some heuristics. Thus the following is the case, showing the cost we pay is indeed non-trivial.
Corollary 50. Let odd prime and with and . Under the assumptions of the attack from [BMS26], a necessary condition for codes sampled using SampleTotal from Definition 47 forming hard (search or distinguish) PCE instances is that , that is roughly .
Proof. Without loss of generality, we may assume , since the algorithm from [BMS26] depends on the rate of the hull. Because the rate of SampleCode is bounded by from above, we must have . On the other hand, to thwart the algorithm from [BMS26], it is required that for the coefficient lifted code over . Combining these, we obtain that , which implies . Multiplying by and rearranging the inequality we get that
The last inequality is implied by the inequality where we replace 4d - 1 with 4d, giving the estimate .
What is perhaps worse is that paying the cost of limiting the maximal rate to seems actually necessary when we consider linearisation algorithms for code equivalence [BCD 24]. The authors of [BCD 24] prove, under assumptions they experimentally verify, that code equivalence can be solved in time as soon as we have at least samples sharing the same isometry, where is the code rate, and moreover it is even enough to have for large enough and , and running time . The authors of [ABL26] introduced a technique they call Frobenius sample amplification, using the automorphisms of to create linearly independent (under a mild assumption they experimentally verify) PCE samples from each PCE sample over , leading to a linearisation algorithm for PCE over extension fields.
Corollary 51. Under the Assumption 1 in [ABL26], a necessary condition for the hardness of (S)PCE of rate r over for p prime is .
The Frobenius sample amplification technique from [ABL26] suggests that the rate limitation of in Theorem 48 is sufficient for security, but it may not be strictly necessary for large lengths . Recall the minimum number of required samples to solve PCE using linearisation in is for codes of rate , and that the rate increment for codes of length is . The following lemma states that the samples we obtain through Frobenius amplification do not break PCE if we limit the rate with from above as in Theorem 48, but that we may increase the code dimension slightly and still stay below the sample bound (though it is unclear how to construct such codes algorithmically).
Lemma 52. Let for and . Then , and moreover, for as soon as .
Proof. Observe that is strictly convex with the only minimum at . Consider the equation , that is , equivalently on . Then is strictly convex and has the only minimum at . We have if and only if .

Figure 10. The plot of for on from the proof of Lemma 52. The point is marked on each curve, the gray area is the slack of the rate condition.
For the first claim notice that . For the second claim, consider
Solving this quadratic inequality for n we get
and the conclusion follows. Illustrated in Figure 10.
Remark 53. Notice that the condition from Corollary 50 (if we view it as a condition on for a fixed instead of the other way around) implies the condition in Lemma 52, thus our reduction in Theorem 48 is not tight for any satisfying the necessary condition for security as outlined in Corollary 50.
C. Towards Galois Square Classes
It was recently shown in [Ben26] that the hull dimension naturally arises as an invariant for PCE when studying linear codes through arithmetic properties of their Gram matrices, along with a previously unrecognised invariant the author calls the square class of a code that corresponds to a generalised notion of the discriminant of a quadratic form. It is shown that for a linear code , the square class of the determinant of the Gram matrix of any generator of is invariant under (signed) permutation equivalence. In odd characteristic, this divides codes of every hull dimension into two classes of roughly the same size [LSL25], while self-orthogonal codes with lie in a single class.
Given that the notion of the hull of a linear code generalises to Galois geometries, it seems natural that the same would be the case for square classes. In this section, we attempt to generalise square classes to Galois geometries, but leave the formal treatment of this subject analogous to [LSL25], [Ben26] for future work.
Proposition 54. For every and for odd prime power, is a quadratic residue.
Proof. We have with even.
The following statement generalises the square class invariant [Ben26] to Galois geometries for Galois LCD codes. As in the Euclidean case, a linear code is Galois LCD [LFL18] with respect to if .
Proposition 55. Let and let generate signed permutation equivalent Galois LCD codes with respect to . Then .
Proof. There exist and such that , hence it holds for Gram matrices that since . Then use Proposition 54 for .
DehullGalois(A, i)
H := HullGalois(A, i); V := basis of
T := lift V to ; return (T, H)
Figure 11. The algorithm DehullGalois. We may also return a hull generator matrix for convenience. The algorithm HullGalois is in Figure 8.
To define the invariant for non-LCD codes (where the determinant of the skewed Gram matrix is 0), codes must be ‘dehulled’, analogously to [Ben26]. However, a Galois LCD component is in general not well-defined, because the inner product need not be symmetric. Indeed, an LCD component with respect to the Euclidean inner product has the property that it remains an LCD component even if we add to its rows linear combinations of hull vectors, which is not the case here. If and is in the span of some matrix that modulo generates , we have that , and the additional term may flip the square class of as defined in Proposition 55. However, this strategy does work for with . We focus on this symmetric case for the rest of this section and leave investigating the general case for future work.
Proposition 56 (Galois dehulling). Let A generate an -linear code over for odd prime power, and suppose that for some we have that and has dimension . The algorithm in Figure 11 runs in time and dehulls A with respect to , that is, finds a matrix that generates a Galois LCD code such that .
Proof. Using linear algebra, find representatives in for the basis of the quotient -dimensional -vector space and store them as . Every is (left and right) -orthogonal to all of and to , hence is (left and right) -orthogonal to all of . Thus , and implies .
Definition 57 (Galois square class). Let be an -linear code over for odd prime power, and suppose that for some we have that and has dimension . The Galois square class of with respect to is for any Galois LCD component with respect to . When , all codes have square class 1.
Proposition 58. Assume the notation of Definition 57. There is a deterministic algorithm that, given any generator matrix A for C and admissible , computes in time .
Proof. If is -self-orthogonal, then output . Otherwise, dehulling and computing the determinant each take by Proposition 56, and applying takes by [Coh93, 1.4.12].
Corollary 59. Assume the notation of Definition 57. The function that maps for admissible is an efficiently computable invariant for (signed) permutation equivalence.
Proof. Invariance is immediate from Propositions 55 and 56 and for a signed permutation, efficiency from Proposition 58.
Since we have assumed hull , it is easy to see that Galois square classes share a similar symmetry.
Proposition 60. For every linear code over for odd prime power we have that if is such that , then .
Proof. Without loss of generality, we may assume is Galois LCD with respect to , since a Galois LCD component is well-defined (Proposition 56). Then . By Proposition 54, is a quadratic residue if and only if is a quadratic residue, hence .
In particular, the Galois square class should work in the Hermitian case of even and ; however, the invariant is constant in this case.
Proposition 61. Assume the notation of Definition 57, and additionally suppose is even and fix . Then for every linear code we have .
Proof. Let generate and let . Since the form is Hermitian, we have . Hence , so lies in the subfield fixed by . Now observe that every element of
is a quadratic residue in ; if is embedded into , then .
Using either SampleCode in Definition 27 or SampleTotal in Definition 47, it is easy to generate linear codes of a prescribed (total) hull dimension whose square classes match, yet some of their Galois square classes differ, meaning it is easy to decide that such codes are not (signed) permutation equivalent. The advantage we wished for above when proposing SampleTotal, which like SampleCode only prescribes the Euclidean square class, cannot be negligible, though this does not affect permutation equivalence over finite extension field of degree 2 by Proposition 61. Investigating the exact behaviour of Galois square classes in relation to (signed) permutation equivalence analogously to [Ben26] would require adapting the mass formulae in [LSL25] to Galois geometries, which we consider future work.
VI. IMPLEMENTATION
Our SageMath [The26] implementation of the algorithms in Section III-C is provided in hollow.py. We also provide in galois.py a proof-of-concept implementation of the sampler from Figure 9, along with all the auxiliary functions for dealing with different geometries. Both depend on lincodes.py and util.py, which provide functions for dealing with linear codes (including dehulling and computing the type) and general utility functions, respectively.
REFERENCES
[ABL25] Martin R. Albrecht, Benjamin Benčina, and Russell W. F. Lai. Hollow LWE: A new spin - unbounded updatable encryption from LWE and PCE. In Serge Fehr and Pierre-Alain Fouque, editors, Advances in Cryptology – EUROCRYPT 2025, Part VIII, volume 15608 of Lecture Notes in Computer Science, pages 363–392, Madrid, Spain, May 4–8, 2025. Springer, Cham, Switzerland. https://doi.org/10.1007/978-3-031-91101-9_13.
[ABL26] Martin R. Albrecht, Benjamin Benčina, and Russell W. F. Lai. On the Limits of LWE and PCE based UPKE. Cryptology ePrint Archive, Paper 2026/995, 2026. https://eprint.iacr.org/2026/2164. In submission.
[AJK90] Edward F. Assmus Jr. and Jennifer D. Key. Affine and projective planes. Discrete Mathematics, 83(2):161–187, 1990. https://doi.org/10.1016/0012-365X(90)90003-Z.
[Art57] Emil Artin. Geometric Algebra, volume 3 of Interscience Tracts in Pure and Applied Mathematics. Interscience Publishers, Inc., 1957.
[BBB 24] Marco Baldi, Alessandro Barenghi, Luke Beckwith, Jean-François Biasse, Tung Chou, Andre Esser, Kris Gaj, Patrick Karl, Kamyar Mohajerani, Gerardo Pelosi, Edoardo Persichetti, Markku-Juhani O. Saarinen, Paolo Santini, Robert Wallace, and Floyd Zweydinger. LESS — Linear Equivalence Signature Scheme. Technical report, National Institute of Standards and Technology, 2024. available at https://csrc.nist.gov/Projects/pqc-dig-sig/round-2-additional-signatures.
[BBM 25] Marco Baldi, Michele Battagliola, Rahmi El Mechri, Paolo Santini, Riccardo Schiavoni, and Davide De Zuane. SPECK: Signatures from permutation equivalence of codes and kernels. Cryptology ePrint Archive, Report 2025/923, 2025. https://eprint.iacr.org/2025/923.
[BBPS21] Alessandro Barenghi, Jean-François Biasse, Edoardo Persichetti, and Paolo Santini. LESS-FM: Fine-tuning signatures from the code equivalence problem. In Jung Hee Cheon and Jean-Pierre Tillich, editors, Post-Quantum Cryptography - 12th International Workshop, PQCrypto 2021, pages 23–43, Daejeon, South Korea, July 20–22, 2021. Springer, Cham, Switzerland. https://doi.org/10.1007/978-3-030-81293-5_2.
[BCD 24] Alessandro Budroni, Jesús-Javier Chi-Domínguez, Giuseppe D'Alconzo, Antonio J. Di Scala, and Mukul Kulkarni. Don't use it twice! Solving relaxed linear equivalence problems. In Kai-Min Chung and Yu Sasaki, editors, Advances in Cryptology – ASIACRYPT 2024, Part VIII, volume 15491 of Lecture Notes in Computer Science, pages 35–65, Kolkata, India, December 9–13, 2024. Springer, Singapore, Singapore. https://doi.org/10.1007/978-981-96-0944-4_2.
[BDR] Jongmin Baek, Anand Deopurkar, and Katherine Redfield. Points on Conics Modulo p. https://cs.stanford.edu/people/jbaek/18.821.paper3.pdf.
[Ben26] Benjamin Benčina. On Arithmetic Invariants for Permutation Equivalence. Cryptology ePrint Archive, Paper 2026/995, 2026. https://eprint.iacr.org/2026/995. Presented at CBCrypto'26, in submission elsewhere.
[BMS26] Michele Battagliola, Rocco Mora, and Paolo Santini. Using the Schur Product to Solve the Code Equivalence Problem. IEEE Transactions on Information Theory, 72(7):4675–4694, 2026. https://doi.org/10.1109/TIT.2026.3694630.
[BOST19] Magali Bardet, Ayoub Otmani, and Mohamed Saeed-Taha. Permutation Code Equivalence is Not Harder Than Graph Isomorphism When Hulls Are Trivial. In 2019 IEEE International Symposium on Information Theory (ISIT), pages 2464–2468. IEEE, 2019. https://doi.org/10.1109/ISIT.2019.8849855.
[CMTQ19] Claude Carlet, Sihem Mesnager, Chunming Tang, and Yanfeng Qi. New Characterization and Parametrization of LCD Codes. IEEE Transactions on Information Theory, 65(1):39–49, 2019. https://doi.org/10.1109/TIT.2018.2829873.
[Coh93] Henri Cohen. A Course in Computational Algebraic Number Theory. Graduate Texts in Mathematics. Springer, 1993. https://doi.org/10.1007/978-3-662-02945-9. Third, Corrected Printing 1996.
[FL22] Yuqing Fu and Hongwei Liu. Galois self-orthogonal constacyclic codes over finite fields. Designs, Codes and Cryptography, 90(11):2703–2733, 2022. https://doi.org/10.1007/s10623-021-00957-6.
[FZ17] Yun Fan and Liang Zhang. Galois self-dual constacyclic codes. Designs, Codes and Cryptography, 84(3):473–492, 2017. https://doi.org/10.1007/s10623-016-0282-8.
[LFL18] Xiusheng Liu, Yun Fan, and Hualu Liu. Galois LCD codes over finite fields. Finite Fields and Their Applications, 49:227–242, 2018. https://doi.org/10.1016/j.ffa.2017.10.001.
[LN97] Rudolf Lidl and Harald Niederreiter. Finite Fields, volume 20 of Encyclopedia of Mathematics and its Applications. Cambridge University Press, 2nd edition, 1997. https://doi.org/10.1017/CBO9780511525926.
[LSL25] Shitao Li, Minjia Shi, and San Ling. A Mass Formula for Linear Codes With Prescribed Hull Dimension and Related Classification. IEEE Transactions on Information Theory, 71(1):273–286, 1025. https://doi.org/10.1109/TIT.2024.3425058.
[Mas92] James L. Massey. Linear codes with complementary duals. Discrete Mathematics, 106/107:337–342, 1992. https://doi.org/10.1016/0012-365X(92)90563-U.
[Mas98] James L. Massey. On Antiorthogonal Matrices and Their Codes. In 1998 IEEE International Symposium on Information Theory (ISIT), page 64, Cambridge, MA, USA, 1998. IEEE. https://doi.org/10.1109/ISIT.1998.708647.
[Moo96] Eliakim Hastings Moore. A two-fold generalization of Fermat's theorem. Bulletin of the American Mathematical Society, 2:189–199, 1896. https://doi.org/10.1090/S0002-9904-1896-00337-2.
[NRS06] Gabriele Nebe, Eric M. Rains, and Neil J.A. Sloane. Self-Dual Codes and Invariant Theory, volume 17 of Algorithms and Computation in Mathematics. Springer, 2006. https://doi.org/10.1007/3-540-30731-1.
[PR97] Erez Petrank and Ron M. Roth. Is code equivalence easy to decide? IEEE Transactions on Information Theory, 43(5):1602–1604, 1997. https://doi.org/10.1109/18.623157.
[Sen97] Nicolas Sendrier. On the Dimension of the Hull. SIAM Journal on Discrete Mathematics, 10(2):282–293, 1997. https://doi.org/10.1137/S0895480195294027.
[Sen00] Nicolas Sendrier. Finding the permutation between equivalent linear codes: the support splitting algorithm. IEEE Transactions on Information Theory, 46(4):1193–1203, 2000. https://doi.org/10.1109/18.850662.
[SS13] Nicolas Sendrier and Dimitris E. Simos. The hardness of code equivalence over and its application to code-based cryptography. In Philippe Gaborit, editor, Post-Quantum Cryptography - 5th International Workshop, PQCrypto 2013, pages 203–216, Limoges, France, June 4–7, 2013. Springer Berlin Heidelberg, Germany. https://doi.org/10.1007/978-3-642-38616-9_14.
[The26] The Sage Developers. SageMath, the Sage Mathematics Software System (Version 10.9), 2026. https://www.sagemath.org.
[War35] Ewald Warning. Bemerkung zur vorstehenden Arbeit von Herrn Chevalley. Abhandlungen aus dem Mathematischen Seminar der Universität Hamburg, 11(1):76–83, 1935. https://doi.org/10.1007/BF02940715.
APPENDIX
ACKNOWLEDGMENT
We thank Paolo Santini for pointing us towards [BOST19, Prop. 8].