Generalized Reed-Solomon Codes
This page covers the generalized Reed-Solomon (GRS) codes and the families obtained from them by taking subfield subcodes: alternant, Goppa, Srivastava, and generalized BCH codes. The twisted Reed-Solomon codes and the rank-metric Gabidulin codes, both evaluation-code variants, are at the end.
The cyclic presentation of a Reed-Solomon code lives with the cyclic codes; GeneralizedReedSolomonCode accepts a ReedSolomonCode and returns the equivalent evaluation presentation.
Generalized Reed-Solomon codes
Given $n$ distinct evaluation points $\gamma_1, \dots, \gamma_n$ in $\mathbb{F}_q$ and nonzero scalars $v_1, \dots, v_n$, the dimension-$k$ GRS code is
\[\mathrm{GRS}_k(v, \gamma) = \{(v_1 f(\gamma_1), \dots, v_n f(\gamma_n)) : f \in \mathbb{F}_q[x], \deg f < k\}.\]
These codes are MDS, so $d = n - k + 1$ and the distance is set at construction without a search. The dual is again a GRS code on the same evaluation points; its scalars are computed by Lagrange interpolation and are returned by dual_scalars. Because the length cannot exceed $q$, a GRS code over a small field is short, which is what motivates the subfield subcodes below.
The generator and parity-check matrices are evaluated lazily and cached.
Alternant codes
Fix a subfield $\mathbb{F} \subseteq \mathbb{E}$. The alternant code $A_r(v, \gamma)$ is the subfield subcode over $\mathbb{F}$ of the GRS code over $\mathbb{E}$ with redundancy $r$, that is, the codewords of the $\mathbb{E}$-code whose coordinates all lie in $\mathbb{F}$. In practice the $r \times n$ parity-check matrix of the parent is expanded over $\mathbb{F}$, so the length is unchanged while the dimension satisfies $k \geq n - rm$ for $m = [\mathbb{E} : \mathbb{F}]$. The exact dimension requires the rank of the expanded matrix and so is computed eagerly. The designed distance is $r + 1$, which is stored as a lower bound; the true distance is generally unknown.
A generalized BCH code is the alternant code with $r = \delta - 1$ and scalars $v_i = \gamma_i^b$ for offset $b$.
Since an alternant code is defined through a parent GRS code, syndromes are computed over the extension field by mapping back to that parent.
Goppa codes
The Goppa code $\Gamma(L, g)$ is the alternant code determined by a polynomial $g$ over $\mathbb{E}$ and a support $L \subseteq \mathbb{E}$ containing no root of $g$, via the parity-check entries $L_j^{i-1} / g(L_j)$. With $t = \deg g$ the designed distance is $t + 1$. Over $\mathbb{F}_2$ the constructor sharpens this using the factorization of $g$, which recovers the familiar $2t + 1$ for a separable binary Goppa polynomial.
Goppa codes are the codes underlying the McEliece cryptosystem, which is why RandomGoppaCode exists: it samples a random support and a random irreducible Goppa polynomial, the usual private key.
Srivastava codes
Generalized Srivastava codes are the alternant codes whose parity-check blocks are $z_j (a_j - w_l)^{-i}$ for $i = 1, \dots, t$ and $l = 1, \dots, s$, giving designed distance $st + 1$. A Srivastava code is the case $t = 1$.
CodingTheory.AlternateCode — Method
AlternateCode(
F::AbstractAlgebra.FinField,
r::Int64,
v::Vector{<:AbstractAlgebra.FinFieldElem},
γ::Vector{<:AbstractAlgebra.FinFieldElem}
) -> AlternateCode
Return the alternant code $A_r(v, \gamma)$ over the subfield F, the subfield subcode of the generalized Reed-Solomon code over E with redundancy r.
CodingTheory.GeneralizedReedSolomonCode — Method
GeneralizedReedSolomonCode(
C::AbstractAlternateCode
) -> GeneralizedReedSolomonCode
Return the generalized Reed-Solomon code associated with the alternant code C.
CodingTheory.GeneralizedReedSolomonCode — Method
GeneralizedReedSolomonCode(
C::AbstractGoppaCode
) -> GeneralizedReedSolomonCode
Return the generalized Reed-Solomon code associated with the Goppa code C.
CodingTheory.GeneralizedReedSolomonCode — Method
GeneralizedReedSolomonCode(
k::Int64,
v::Vector{<:AbstractAlgebra.FinFieldElem},
γ::Vector{<:AbstractAlgebra.FinFieldElem}
) -> GeneralizedReedSolomonCode
Return the dimension k generalized Reed-Solomon code with scalars v and evaluation points γ.
Notes
- The vectors
vandγmust have the same length and every element must be over the same field. - The elements of
vneed not be distinct but must be nonzero. - The elements of
γmust be distinct.
CodingTheory.GeneralizedReedSolomonCode — Method
GeneralizedReedSolomonCode(
C::ReedSolomonCode
) -> GeneralizedReedSolomonCode
Return the GeneralizedReedSolomonCode representation of the cyclic ReedSolomonCode C.
CodingTheory.GeneralizedSrivastavaCode — Method
GeneralizedSrivastavaCode(
F::AbstractAlgebra.FinField,
a::Array{T<:AbstractAlgebra.FinFieldElem, 1},
w::Array{T<:AbstractAlgebra.FinFieldElem, 1},
z::Array{T<:AbstractAlgebra.FinFieldElem, 1},
t::Int64
) -> GeneralizedSrivastavaCode
Return the generalized Srivastava code over F. Evaluates lazily.
CodingTheory.GeneralizedBCHCode — Function
GeneralizedBCHCode(
F::AbstractAlgebra.FinField,
γ::Vector{<:AbstractAlgebra.FinFieldElem},
δ::Int64
) -> AlternateCode
GeneralizedBCHCode(
F::AbstractAlgebra.FinField,
γ::Vector{<:AbstractAlgebra.FinFieldElem},
δ::Int64,
b::Int64
) -> AlternateCode
Return the Generalized BCH code over F with evaluation points γ, design distance δ, and offset b.
CodingTheory.RandomGeneralizedReedSolomonCode — Method
RandomGeneralizedReedSolomonCode(
F::AbstractAlgebra.FinField,
n::Int64,
k::Int64
) -> GeneralizedReedSolomonCode
Return a random Generalized Reed-Solomon code of length n and dimension k over F. Generates random distinct evaluation points and random non-zero scalars.
CodingTheory.SrivastavaCode — Method
SrivastavaCode(
F::AbstractAlgebra.FinField,
a::Array{T<:AbstractAlgebra.FinFieldElem, 1},
w::Array{T<:AbstractAlgebra.FinFieldElem, 1},
z::Array{T<:AbstractAlgebra.FinFieldElem, 1}
) -> GeneralizedSrivastavaCode
Return the Srivastava code over F given a, w, and z.
Notes
- These inputs are defined on page 357 of MacWilliams & Sloane
CodingTheory.dual_scalars — Method
dual_scalars(
C::GeneralizedReedSolomonCode
) -> Vector{<:AbstractAlgebra.FinFieldElem}
Return the scalars of the dual of the generalized Reed-Solomon code C.
CodingTheory.evaluation_points — Method
evaluation_points(
C::GeneralizedReedSolomonCode
) -> Vector{<:AbstractAlgebra.FinFieldElem}
Return the evaluation points γ of the generalized Reed-Solomon code C.
CodingTheory.scalars — Method
scalars(
C::GeneralizedReedSolomonCode
) -> Vector{<:AbstractAlgebra.FinFieldElem}
Return the scalars v of the generalized Reed-Solomon code C.
CodingTheory.syndrome_polynomial — Method
syndrome_polynomial(
C::GeneralizedReedSolomonCode,
y::Union{Vector{Int64}, Vector{<:AbstractAlgebra.FinFieldElem}}
) -> Any
Return the syndrome polynomial $S(z)$ for the received vector y with respect to the generalized Reed-Solomon code C. This polynomial is the standard input for the Berlekamp-Massey or Sugiyama Euclidean decoding algorithms.
CodingTheory.syndromes — Method
syndromes(
C::GeneralizedReedSolomonCode,
y::Union{Vector{Int64}, Vector{<:AbstractAlgebra.FinFieldElem}}
) -> Any
Return the sequence of syndromes for the received vector y with respect to the generalized Reed-Solomon code C.
Hecke.extension_field — Method
extension_field(C::AbstractAlternateCode) -> Any
Return the extension field over which the parent generalized Reed-Solomon code of C is defined. For a Goppa code this is the field of the Goppa polynomial.
Hecke.is_primitive — Method
is_primitive(C::AbstractGeneralizedSrivastavaCode) -> Any
Return whether C is primitive.
CodingTheory.GoppaCode — Method
GoppaCode(
F::AbstractAlgebra.FinField,
L::Vector{<:AbstractAlgebra.FinFieldElem},
g::AbstractAlgebra.PolyRingElem{<:AbstractAlgebra.FinFieldElem}
) -> GoppaCode
Return the Goppa code Γ(L, g) over F.
AbstractAlgebra.is_irreducible — Method
is_irreducible(C::AbstractGoppaCode) -> Any
Return whether the Goppa polynomial is irreducible.
AbstractAlgebra.is_separable — Method
is_separable(C::AbstractGoppaCode) -> Any
Return whether the Goppa polynomial is separable, that is square-free.
CodingTheory.Goppa_polynomial — Method
Goppa_polynomial(C::AbstractGoppaCode) -> Any
Return the Goppa polynomial of C.
CodingTheory.RandomGoppaCode — Method
RandomGoppaCode(
F::AbstractAlgebra.FinField,
E::AbstractAlgebra.FinField,
n::Int64,
t::Int64
) -> GoppaCode
Return a random Goppa code of length n and Goppa polynomial degree t over the base field F, using the extension field E.
Notes
- This is heavily used to generate public/private keypairs for McEliece cryptosystems.
CodingTheory.is_cumulative — Method
is_cumulative(C::AbstractGoppaCode) -> Any
Return whether the Goppa polynomial is of the form $g(z) = (z - \beta)^r$.
CodingTheory.nonzeros — Method
nonzeros(C::AbstractGoppaCode) -> Any
Return the set L of the Goppa code $\Gamma(L, g)$.
Twisted Reed-Solomon codes
Twisted Reed-Solomon codes perturb the monomial basis of a Reed-Solomon code by adding higher-degree terms at selected hooks, which generally produces non-MDS codes that are not equivalent to any Reed-Solomon code. A code is specified by the evaluation points, the twist vector $t$, the hook vector $h$, and the coefficient vector $\eta$. Taking the dual is an $O(1)$ operation that tracks the twists, hooks, and coefficients exactly.
CodingTheory.TwistedReedSolomonCode — Method
TwistedReedSolomonCode(
k::Int64,
α::Array{T<:AbstractAlgebra.FinFieldElem, 1},
t::Vector{Int64},
h::Vector{Int64},
η::Array{T<:AbstractAlgebra.FinFieldElem, 1}
) -> TwistedReedSolomonCode
Return the twisted Reed-Solomon code defined in https://arxiv.org/abs/2107.06945. Evaluates lazily.
CodingTheory.RandomTwistedReedSolomonCode — Method
RandomTwistedReedSolomonCode(
F::AbstractAlgebra.FinField,
n::Int64,
k::Int64,
l::Int64
) -> TwistedReedSolomonCode
Return a random Twisted Reed-Solomon code of length n, dimension k, and l twists over F.
CodingTheory.coefficient_vector — Method
coefficient_vector(C::AbstractTwistedReedSolomonCode) -> Any
Return the coefficient vector of C.
CodingTheory.hook_vector — Method
hook_vector(C::AbstractTwistedReedSolomonCode) -> Any
Return the hook vector of C.
CodingTheory.number_of_twists — Method
number_of_twists(C::AbstractTwistedReedSolomonCode) -> Any
Return the number of twists of C.
CodingTheory.twist_vector — Method
twist_vector(C::AbstractTwistedReedSolomonCode) -> Any
Return the twist vector of C.
Hecke.dual — Method
dual(
C::AbstractTwistedReedSolomonCode
) -> TwistedReedSolomonCode
Return the dual of the Twisted Reed-Solomon code C. This operation is O(1) and perfectly tracks the dual's twists, hooks, and coefficients.
Gabidulin codes
Gabidulin codes are the rank-metric analogue of Reed-Solomon codes, evaluating linearized rather than ordinary polynomials at points that are linearly independent over the base subfield. Note that the distances reported by the accessors are Hamming distances, not rank distances.
CodingTheory.GabidulinCode — Method
GabidulinCode(
F::AbstractAlgebra.FinField,
eval_pts::Vector{<:AbstractAlgebra.FinFieldElem},
k::Int64;
parity
) -> GabidulinCode
Return the dimension k Gabidulin code given the evaluation points eval_pts with respect to the subfield F.
CodingTheory.GeneralizedGabidulinCode — Method
GeneralizedGabidulinCode(
F::AbstractAlgebra.FinField,
eval_pts::Vector{<:AbstractAlgebra.FinFieldElem},
k::Int64,
s::Int64;
parity
) -> GabidulinCode
Return the dimension k generalized Gabidulin code given the evaluation points eval_pts with respect to the subfield F of the base ring of eval_pts.
Notes
- Distances are reported with respect to the Hamming metric.
CodingTheory.RandomGabidulinCode — Function
RandomGabidulinCode(
F::AbstractAlgebra.FinField,
E::AbstractAlgebra.FinField,
n::Int64,
k::Int64
) -> GabidulinCode
RandomGabidulinCode(
F::AbstractAlgebra.FinField,
E::AbstractAlgebra.FinField,
n::Int64,
k::Int64,
s::Int64
) -> GabidulinCode
Return a random generalized Gabidulin code of length n, dimension k, and twist s over the base field F, using the extension field E.
Notes
- Generates evaluation points that are strictly linearly independent over
F.
Hecke.dual — Method
dual(C::GabidulinCode) -> GabidulinCode
Return the dual of the generalized Gabidulin code C. The dual of a Gabidulin code is also a Gabidulin code, generated by a complementary set of evaluation points derived from the shifted Moore matrix.