1 Introduction

Let \(q\) be a prime power and \(\mathbb{F }_{q}\) be the finite field with \(q\) elements. An \([n,k]\) linear code \(C\) of length \(n\) over \(\mathbb{F }_{q}\) is a \(k\)-dimensional subspace of the vector space \(\mathbb{F }_{q}^{n}\). We call \(\mathbf{c}=(c_{0},c_{1,}\ldots ,c_{n-1})\in C\) a codeword. The Hamming weight \(w(\mathbf{c})\) of \(\mathbf{c}\in \mathbb{F }_{q}^{n}\) is the number of nonzero coordinates of \(\mathbf{c}\). The minimum distance of \(C\) is defined to be \(d=\min \left\{ w(\mathbf{c})\mid 0\ne \mathbf{c}\in C\right\} \). An \([n,k,d]\) code, which is defined to be an \([n,k]\) code with the minimum distance \(d\), is said to be maximum distance separable (MDS) if \(d=n-k+1\). The Euclidean dual code of \(C\) is defined to be \(C^{\perp }=\{\mathbf{x}\in \mathbb{F }_{q}^{n}\mid \sum \nolimits _{i=0}^{n-1}x_{i}y_{i}=0,\forall \mathbf{y}\in C\}\). A code \(C\) is Euclidean self-orthogonal provided \(C\subseteq C^{\perp }\) and Euclidean self-dual provided \(C=C^{\perp }\). Let \(\left( \mathbf{x}, \mathbf{y}\right) _{H}=\sum \nolimits _{i=0}^{n-1}x_{i}y_{i}^{q}\) be the Hermitian inner product of \(\mathbf{x},\mathbf{y}\in \mathbb{F }_{q}^{n}\), and \(C\) be a code of length \(n\) over \(\mathbb{F }_{q^{2}}\). The Hermitian dual code \(C^{\perp H}\) of \(C\) is defined by \(C^{\perp H}=\{\mathbf{x}\in \mathbb{F }_{q^{2}}^{n}\mid \sum \nolimits _{i=0}^{n-1}x_{i}y_{i}^{q}=0,\forall \mathbf{y}\in C\}\). Hermitian self-orthogonality and Hermitian self-duality are defined as follows: \(C\) is Hermitian self-orthogonal if \(C\subseteq C^{\perp H}\) and Hermitian self-dual if \(C=C^{\perp H}\).

Let \(\alpha \in \mathbb{F }_{q}^{*}\). A linear code \(C\) is called \(\alpha \) -constacyclic [2] provided that for each codeword \((c_{0},c_{1,}\ldots ,c_{n-1})\ \)in \(C, (\alpha c_{n-1},c_{0},\ldots ,c_{n-2})\) is also a codeword in \(C\). An \(\alpha \)-constacyclic code of length \(n\) over \(\mathbb F _{q}\) corresponds to the principal ideal \(\left\langle g(x)\right\rangle \) of the quotient ring \(\mathbb{F }_{q}[x]/(x^{n}-\alpha )\), where \(g(x)\) is a divisor of \(x^{n}-\alpha \). Since the cases when the code length \(n\) is divisible by the characteristic of \(\mathbb{F }_{q}\) are cases involving repeated root codes, for the remainder of this paper we assume \(n\) and \(q\) are relatively prime. Because the code length \(n\) must be even if there exist Euclidean or Hermitian self-dual codes, we assume \(q\) is an odd prime power.

Self-dual codes are an important class of codes which have been extensively studied in coding theory. This paper is mainly concerned with self-dual codes that are constacyclic codes. In recent years, many papers, for example [3, 5, 6, 9], have been written on this subject. Aydin et al. [1] dealt with constacyclic codes and a constacyclic BCH bound was given. In 2008, Gulliver et al. [6] showed that there exists a Euclidean self-dual MDS code of length \(q\) over \(\mathbb{F }_{q}\) when \(q=2^{m}\) by using a Reed-Solomon (RS) code and its extension. They also constructed many new Euclidean and Hermitian self-dual MDS codes over finite fields. In the same year, Blackford [3] studied negacyclic codes over finite fields by using multipliers. He gave conditions on the existence of Euclidean self-dual codes. Recently, Guenda [5] generalized Blackford’s work [3]. She constructed MDS Euclidean and Hermitian self-dual codes from extended cyclic duadic or negacyclic codes and gave necessary and sufficient conditions on the existence of Hermitian self-dual negacyclic codes arising from negacyclic codes. In this paper, we extend Guenda’s work to constacyclic codes and study the existence of Hermitian self-dual codes. We give conditions on the existence of MDS Hermitian self-orthogonal and self-dual codes.

2 Preliminaries

Throughout this paper, let \(q\) be an odd prime power and \(n\) be a positive integer relatively prime to \(q\). Let \(C\) be an \([n,k]\, \alpha \)-constacyclic code over \(\mathbb{F }_{q}\); then the code \(C\) is a vector space over \(\mathbb{F }_{q}\) and corresponds to an ideal of \(\mathbb{F } _{q}[x]/(x^{n}-\alpha )\). By abuse of notation, we let \(C\) represent both a set of polynomials and a set of vectors.

As mentioned above, a nonzero \([n,k]\, \alpha \)-constacyclic code \(C\) has a unique monic generator polynomial \(g(x)\) of degree \(n-k\), where \(g(x)\mid (x^{n}-\alpha )\). The roots of the code \(C\) are the roots of \(g(x)\). So if \(\eta _{1},\ldots ,\eta _{n-k}\) are the zeros of \(g(x)\) in the splitting field of \(x^{n}-\alpha \), then \(\mathbf{c}=\left( c_{0},c_{1},\ldots ,c_{n-1}\right) \in C\) if and only if \(c(\eta _{1})=\cdots =c(\eta _{n-k})=0\), where \(c(x)=c_{0}+c_{1}x+\cdots +c_{n-1}x^{n-1}\). Let \(h(x)=(x^{n}-\alpha )/g(x)=\sum _{i=0}^{k}h_{i}x^{i}\), then \(h(x)\) is called the check polynomial of \(C\) [7, 10].

Let \(C^{(q)}\) denote the code defined by \(C^{(q)}=\{\mathbf{c}^{q}\mid \forall \mathbf{c}=(c_{0},c_{1},\ldots ,c_{n-1})\in C\}\), where \(\mathbf{c} ^{q}=(c_{0},c_{1},\ldots ,c_{n-1})^{q}=(c_{0}^{q},c_{1}^{q},\ldots ,c_{n-1}^{q})\).

Lemma 2.1

([4, Proposition 2.4]) (i) Let \(C\) be an \(\alpha \)-constacyclic code over \(\mathbb{F }_{q}\), then the Euclidean dual code \(C^{\perp }\) is an \(\alpha ^{-1}\)-constacyclic code generated by \(g^{\perp }(x)=\sum _{i=0}^{k}h_{i}h_{0}^{-1}x^{k-i}\).

(ii) Let \(C\) be an \(\alpha \)-constacyclic code over \(\mathbb{F } _{q^{2}}\), then the Hermitian dual code \(C^{\perp H}\) is an \(\alpha ^{-q}\) -constacyclic code generated by \(g^{\perp (q)}(x)=\sum _{i=0}^{k}h_{i}^{q}h_{0}^{-q}x^{k-i}\).

Proof

(i) The proof can be found in [4, Proposition 2.4].

(ii) \(g^{\perp }(x)\) is the generator polynomial of \(C^{\perp }\). Let \(C^{*}\) denote the code generated by \(g^{\perp (q)}(x)=\sum _{i=0}^{k}h_{i}^{q}h_{0}^{-q}x^{k-i}\) and \(\xi _{1},\ldots ,\xi _{k}\) be the zeros of \(g^{\perp }(x)\), then \(\xi _{1}^{q},\ldots ,\xi _{k}^{q}\) are the zeros of \(g^{\perp (q)}(x)\). Thus if \(\mathbf{c}=\left( c_{0},c_{1},\ldots ,c_{n-1}\right) \) is a codeword in \(C\), then we have \(c_{0}+c_{1}\xi _{i}+\cdots +c_{n-1}\xi _{i}^{n-1}=0\) (\(i=1,\ldots ,k\)). It is obvious that \(c_{0}^{q}+c_{1}^{q}\xi _{i}^{q}+\cdots +c_{n-1}^{q}\left( \xi _{i}^{q}\right) ^{n-1}=0\) (\(i=1,\ldots ,k\)). This implies that \(\left( c_{0}^{q},c_{1}^{q},\ldots ,c_{n-1}^{q}\right) \) is a codeword in \(C^{*}\). So \(C^{\perp H}\subset C^{*}\). Because \(\dim C^{\perp H}=\dim C^{*}=n-k\), we get \(C^{*}=C^{\perp H}\).

Since \(C^{\perp }\) is an \(\alpha ^{-1}\)-constacyclic code generated by \(g^{\perp }(x)\), we have

$$\begin{aligned} \xi _{i}^{n}=\alpha ^{-1}\Longrightarrow \left( \xi _{i}^{q}\right) ^{n}=\left( \alpha ^{q}\right) ^{-1}(i=1,\ldots ,k)\text {.} \end{aligned}$$

So \(\xi _{1}^{q},\ldots ,\xi _{k}^{q}\) are roots of \(x^{n}-\alpha ^{-q}\), which implies \(g^{\perp (q)}(x)\) is a divisor of \(x^{n}-\alpha ^{-q}\). Therefore, the Hermitian dual code \(C^{\perp H}\) is an \(\alpha ^{-q}\)-constacyclic code. \(\square \)

Let \(r=ord_{q}(\alpha )\) (i.e., the smallest integer \(r\) such that \(\alpha ^{r}=1\)) and the multiplicative order of \(q\) modulo \(rn\) be \(m\) [i.e., the smallest integer \(m\) such that \(q^{m}\equiv 1\pmod {rn}\)]. There exists \(\delta \in \mathbb{F }_{q^{m}}^{*}\), called a primitive \(rn\)th root of unity, such that \(\delta ^{n}=\alpha \). Let \(\zeta =\delta ^{r}\), then \(\zeta \) is a primitive \(n\)th root of unity. Therefore, the roots of \(x^{n}-\alpha \) are \(\{\delta ,\delta ^{1+r},\ldots ,\delta ^{1+(n-1)r}\}\) and the roots of \(x^{n}-\alpha ^{-1}\) are \(\{\delta ^{-1},\delta ^{-1+r},\ldots ,\delta ^{-1+(n-1)r}\}\). Define \(O_{r,n}(1)\) and \(O_{r,n}(-1)\) as follows:

$$\begin{aligned} O_{r,n}(1)&= \left\{ ir+1\mid 0\le i\le n-1\right\} \pmod {rn}\subseteq \mathbb Z _{rn}\text {;} \\ O_{r,n}(-1)&= \left\{ ir-1\mid 0\le i\le n-1\right\} \pmod {rn}\subseteq \mathbb Z _{rn}\text {.} \end{aligned}$$

The defining set of the \(\alpha \)-constacyclic code \(C\) is defined as \(T=\{ir+1\in O_{r,n}(1)\mid \delta ^{ir+1}\) is a root of \(C\}\). It is clear that \(T\subset O_{r,n}(1)\) and the dimension of \(C\) is \(n-\left| T\right| \). Let \(Cl_{q}(s)\) be the \(q\) -cyclotomic coset modulo \(rn\) which contains \(s\), i.e. \(Cl_{q}(s)=\{sq^{j}\pmod {rn}\mid j\in \mathbb Z \}\). Assume the generator polynomial of \(C\) is \(g(x)= \sum _{i=0}^{k}g_{i}x^{i} \), where \(g_{i}\in \mathbb{F }_{q}\). If \(g(\nu )=0\) for some \(\nu \in \mathbb{F }_{q^{m}}\), then

$$\begin{aligned} g(\nu ^{q})=\sum _{i=0}^{k}g_{i}\big (\nu ^{q}\big )^{i}=\sum _{i=0}^{k}g_{i}^{q}\big (\nu ^{i}\big )^{q}=\left( \sum _{i=0}^{k}g_{i}\nu ^{i}\right) ^{q}=(g(\nu ))^{q}=0. \end{aligned}$$

Therefore, the defining set \(T\) is a union of some \(q\)-cyclotomic cosets modulo \(rn\) and a union of some \(q\)-cyclotomic cosets modulo \(rn\) is also the defining set of some \(\alpha \)-constacyclic code.

Proposition 2.2

There exists a Euclidean self-dual \(\alpha \)-constacyclic code over \(\mathbb{F }_{q}\) if and only if \(r=2\).

Proof

By Lemma 2.1, the Euclidean dual code of an \(\alpha \)-constacyclic code is an \(\alpha ^{-1}\)-constacyclic code. To prove that if there is a Euclidean self-dual \(\alpha \)-constacyclic code, we need to verify \(\alpha ^{2}=1\). This indicates that either \(r=1\) or \(r=2\). If \(r=1\), then \(\alpha =1\). It has been proved by Jian et al. [8, Theorem 1] that there exists at least one self-dual cyclic code if and only if \(q\) is a power of 2. Since \(q\) is odd, this leads to the unique solution \(r=2\).

If \(r=2\), then \(\alpha =-1\). Guenda [5] has proved that there exist Euclidean self-dual negacyclic codes over \(\mathbb{F }_{q}\) (i.e. for \(r=2\) there exists a Euclidean self-dual \(\alpha \)-constacyclic code over \(\mathbb{F }_{q}\)). \(\square \)

Proposition 2.3

Let \(\alpha \in \mathbb{F }_{q^{2}}^{*}, r=ord_{q^{2}}(\alpha )\), and \(C\) be an \(\alpha \)-constacyclic code over \(\mathbb{F }_{q^{2}}\). If \(C\) is a Hermitian self-dual code, then \(r\mid q+1\).

Proof

If the \(\alpha \)-constacyclic code \(C\) is a Hermitian self-dual code, then \(C=C^{\perp H}\). By Lemma 2.1, the Hermitian dual code \(C^{\perp H}\) is an \(\alpha ^{-q}\)-constacyclic code. Hence, we have

$$\begin{aligned} C=C^{\perp H}\Longrightarrow \alpha =\alpha ^{-q}\Longrightarrow \alpha ^{q+1}=1. \end{aligned}$$

Since \(r=ord_{q}(\alpha )\), we obtain \(r\mid q+1\). \(\square \)

3 Hermitian self-dual constacyclic codes over \(\mathbb{F }_{q^{2}}\)

This section is devoted to the Hermitian self-dual \(\alpha \)-constacyclic codes over \(\mathbb{F }_{q^{2}}\), where \(\alpha \in \mathbb{F }_{q^{2}}^{*} \). Let \(r=ord_{q^{2}}(\alpha )\), then \(r\mid q^{2}-1 \). By Proposition 2.3, we can further assume \(r\mid q+1\) and \(rs=q+1\) for some integer \(s\). Note that if \(T\subset O_{r,n}(1)\) is a union of some \(q^{2}\)-cyclotomic cosets, \(C_T\) is an \(\alpha \)-constacyclic code over \(\mathbb{F }_{q^{2}}\) with the defining set \(T\).

Lemma 3.1

\(-qO_{r,n}(1)=O_{r,n}(1)\pmod {rn}\).

Proof

Since \(q+1=rs\), for \(ir+1\in O_{r,n}(1)\), we have

$$\begin{aligned} -q(ir+1)\!=\!-qir-(q\!+\!1)\!+\!1\!=\!-qir-rs\!+\!1\!=\!(-qi-s)r\!+\!1\pmod {rn}\in O_{r,n}(1)\text {. } \end{aligned}$$

By this, we have \(-qO_{r,n}(1)=O_{r,n}(1)\pmod {rn}\). \(\square \)

Let \(T^{\bot }=-\left[ O_{r,n}(1)\backslash T\right] \subset O_{r,n}(-1)\) be the defining set of code \(C_{T^{\bot }}\). Then

$$\begin{aligned} x^{n}-\alpha =\prod \limits _{i\in O_{r,n}(1)}(x-\delta ^{i})=\prod \limits _{i\in T}(x-\delta ^{i})\cdot \prod \limits _{i\in T^{\bot }}(x-\delta ^{-i})=g(x)h(x), \end{aligned}$$

where \(g(x)\) is the generator polynomial of \(C_{T}\). By Lemma 2.1, \(g^{\bot }(x)=\prod \limits _{i\in T^{\bot }}(x-\delta ^{i})\). Therefore, \(T^{\bot }\) is the defining set of the \(\alpha ^{-1}\)-constacyclic code \(C_{T}^{\bot }\) (i.e. the Euclidean dual code of \(C_{T}\)). Thus we have \(C_{T^{\bot }}=C_{T}^{\bot }\).

Let \(\bar{T}=-q\left[ O_{r,n}(1)\backslash T\right] =qT^{\bot }\). According to Lemma 3.1, \(\bar{T}\subset O_{r,n}(1)\). It is clear that \(\bar{T}\) is a union of some \(q^{2}\)-cyclotomic cosets and \(\left| T\right| +\left| \bar{T}\right| =n\). Similarly, \(g^{\bot (q)}(x)=\prod \limits _{i\in T^{\bot }}(x-\delta ^{iq})\). Therefore, \(\bar{T}\) is the defining set of the \(\alpha ^{-q}\)-constacyclic code \(C_{T}^{\bot H}\). Thus we have the following theorem.

Theorem 3.2

\(C_{\bar{T}}\) is the Hermitian dual code of \(C_{T}\).

Based on Theorem 3.2, two necessary and sufficient conditions are given as follows:

Corollary 3.3

Let \(T\subset O_{r,n}(1)\) be the defining set of code \(C_{T}\) and let \(\bar{T }=-q\left[ O_{r,n}(1)\backslash T\right] \). Then

  1. (i)

    \(C_{T}\) is a Hermitian self-orthogonal constacyclic code if and only if \(\bar{T}\subset T\);

  2. (ii)

    \(C_{T}\) is a Hermitian self-dual constacyclic code if and only if \(\bar{T}=T\).

Example 3.4

Let \(q=5, n=4\), and \(r=2\), then \(q^{2}=25\). Consider the \(\alpha \)-constacyclic code of length 4 over \(\mathbb{F }_{25}\) with \(\alpha =-1\).

We notice that \(r\mid q+1\) and \(O_{2,4}(1)=\left\{ 1,3,5,7\right\} \). Let \(T=\{3,5\}\), then \(\bar{T}=-5\left[ O_{2,4}(1)\backslash T\right] =\left\{ 3,5\right\} \pmod {8}\). By Corollary 3.3, the code \(C_{T}\) with defining set \(T=\{3,5\}\) is a Hermitian self-dual negacyclic code.

Example 3.5

Let \(q^{2}=31^{2}, n=16\), and \(r=4\). Now we consider the \(\alpha \)-constacyclic code of length 16 over \(\mathbb{F }_{31^{2}}\) with \(\alpha \) a primitive 4th root of unity.

Clearly, \(O_{4,16}(1)=\{1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61 \}\) and \(r\mid q+1\). Let \(T=\{33,37,41,45,49,53,57,61\}\), then

$$\begin{aligned} \bar{T}=-31\left[ O_{4,16}(1)\backslash T\right] =\left\{ 33,37,41,45,49,53,57,61\right\} \pmod {64}. \end{aligned}$$

Hence, \(\bar{T}=T\). By Corollary 3.3, \(C_{T}\) is a Hermitian self-dual \(\alpha \)-constacyclic code.

Lemma 3.6

Let \(n\) be an odd integer with \(n\mid q+1\), then there exists an integer \(m\) such that \(n\mid \frac{q^{2m+1}+1}{q+1}\) and \(n\mid 2m+1\).

Proof

$$\begin{aligned} \frac{q^{2m+1}+1}{q+1}&= \sum _{j=0}^{2m}(-1)^{j}q^{j}=\sum _{i=0}^{2m} \sum _{j=i}^{2m}\genfrac(){0.0pt}1{j}{i}(q+1)^{i}(-1)^{i} \\&= \sum _{i=0}^{2m}(q+1)^{i}(-1)^{i}\sum _{j=i}^{2m}\genfrac(){0.0pt}1{j}{i} =\sum _{i=0}^{2m}(q+1)^{i}(-1)^{i}\genfrac(){0.0pt}1{2m+1}{i+1} \\&= \left( \sum _{i=1}^{2m}(q+1)^{i-1}(-1)^{i}\genfrac(){0.0pt}1{2m+1}{i+1}\right) (q+1)+(2m+1). \end{aligned}$$

We can choose an integer \(m\) such that \(n\mid 2m+1\), which further implies that \(n\mid \frac{q^{2m+1}+1}{q+1}\).

\(\square \)

Lemma 3.7

Let \(n\) be an odd integer with prime decomposition \(n=p_{1}^{t_{1}}p_{2}^{t_{2}}\cdots p_{s}^{t_{s}}\), where \(p_{i}\) are such that \(p_{i}\mid q+1, p_{i}\ne p_{j}, t_{i}>0\, (1\le i\le s)\). Then there exists an integer \(m\) such that \(n\mid \frac{q^{2m+1}+1}{q+1}\).

Proof

First, let \(n_{1}=p_{_{1}}^{t_{1}}\). We use induction to prove that there exists \(m_{t}\) such that \(n_{1}\mid \frac{q^{2m_{t}+1}+1 }{q+1}\) and \(p_{1}\mid 2m_{t}+1\).

When \(t_{1}=1\), by Lemma 3.6, there exists \(m_{1}\) such that \(p_{1}\mid \frac{q^{2m_{1}+1}+1}{q+1}\) and \(p_{1}\mid 2m_{1}+1\). When \(t_{1}\ge 2\), assume there exists \(m_{t-1}\) such that \(p_{1}^{t_{1}-1}\mid \frac{q^{2m_{t-1}+1}+1}{q+1}\) and \(p_{1}\mid 2m_{t-1}+1\). Then by the proof of Lemma 3.6, we know

$$\begin{aligned} \frac{q^{(2m_{t-1}+1)(2m_{t-1}+1)}+1}{q+1}&= \frac{q^{2m_{t-1}+1}+1}{q+1}\frac{\left( q^{2m_{t-1}+1}\right) ^{2m_{t-1}+1}+1}{q^{2m_{t-1}+1}+1} \\&= \frac{q^{2m_{t-1}+1}+1}{q+1}\left[ \left( \sum _{i=1}^{2m_{t-1}}(q^{2m_{t-1}+1}+1)^{i-1}(-1)^{i}\genfrac(){0.0pt}1{2m_{t-1}+1}{i+1}\right) \right. \\&\left. \qquad \qquad \qquad \qquad (q^{2m_{t-1}+1}+1)+(2m_{t-1}+1) \right] . \end{aligned}$$

According to the assumption, we have

$$\begin{aligned} p_{1}\mid \left[ \left( \sum _{i=1}^{2m_{t-1}}(q^{2m_{t-1}+1}+1)^{i-1}(-1)^{i}\genfrac(){0.0pt}1{2m_{t-1}+1}{i+1}\right) (q^{2m_{t-1}+1}+1)+(2m_{t-1}+1)\right] \end{aligned}$$

and \(p_{1}^{t_{1}-1}\mid \frac{q^{2m_{t-1}+1}+1}{q+1}\), thus \(p_{_{1}}^{t_{1}}\mid \frac{ q^{(2m_{t-1}+1)(2m_{t-1}+1)}+1}{q+1}\). Let \(2m_{t}+1=(2m_{t-1}+1)^2\). It follows that \(p_{_{1}}^{t_{1}}\mid \frac{q^{2m_{t}+1}+1}{q+1}\) and \(p_{1}\mid 2m_{t}+1\).

Next, we prove there exists some \(m\) such that \(n\mid \frac{ q^{2m+1}+1}{q+1}\).

Let \(n_{i}=p_{i}^{t_{i}}\) for \(1\le i\le s\). The case \(s=1\) has been proven above. Similarly, there exists \(m_{s}^{^{\prime }}\) such that \(n_{s}\mid \frac{q^{2m_{s}^{^{\prime }}+1}+1}{q+1}\). Let \(n^{\prime }=n_{1}n_{2}\cdots n_{s-1}\). We assume that there exists \(m^{\prime }\) such that \(n^{\prime }\mid \frac{ q^{2m^{\prime }+1}+1}{q+1}\). Let \(2m+1=(2m^{\prime }+1)(2m_{s}^{^{\prime }}+1)\). Then

$$\begin{aligned} \frac{q^{2m+1}+1}{q+1}&= \frac{q^{(2m^{\prime }+1)(2m_{s}^{^{\prime }}+1)}+1}{q+1} \\&= \frac{q^{2m^{^{\prime }}+1}+1}{q+1}\left[ \left( \sum _{i=1}^{2m_{s}^{^{ \prime }}}(q^{2m_{s}^{^{\prime }}+1}+1)^{i-1}(-1)^{i}\genfrac(){0.0pt}1{2m_{s}^{^{\prime }}+1 }{i+1}\right) \right. \\&\left. \qquad \qquad \qquad \qquad (q^{2m_{s}^{^{\prime }}+1}+1)+(2m_{s}^{^{\prime }}+1)\right] \!. \end{aligned}$$

Because \(n^{^{\prime }}\mid \frac{q^{2m^{^{\prime }}+1}+1}{q+1}\), we have \(n^{^{\prime }}\mid \frac{q^{2m+1}+1}{q+1}\). Similarly, we have \(n_{s}\mid \frac{q^{2m+1}+1}{q+1}\). Since \((n^{\prime },n_{s})=1\), we obtain \(n^{\prime }n_{s}\mid \frac{q^{2m+1}+1}{q+1}\), i.e., \(n\mid \frac{q^{2m+1}+1}{q+1}\). \(\square \)

Proposition 3.8

Hermitian self-dual \(\alpha \)-constacyclic codes over \(\mathbb{F }_{q^{2}}\) of length \(n\) exist if and only if \(Cl_{q^{2}}(j)\ne Cl_{q^{2}}(-qj)\) for any \(j\in O_{r,n}(1)\).

Proof

Assume the \(q^2\)-cyclotomic cosets of \(O_{r,n}(1)\) are

$$\begin{aligned} Cl_{q^{2}}(j_{1}),Cl_{q^{2}}(j_{2}),\ldots ,Cl_{q^{2}}(j_{t}) \end{aligned}$$

denoted simply by \(Cl_{1},Cl_{2},\ldots ,Cl_{t}\) for convenience. By Lemma 3.1, \(-qCl_{i}, i\in \{1,2,\ldots ,t\}\), is also a \(q^2\)-cyclotomic coset of \(O_{r,n}(1)\). Let \(Cl_{\bar{i}}=-qCl_{i}\) and \(\sigma \) be a permutation of \(\{1,2,\ldots ,t\}\) which satisfies \(\sigma (i)=\bar{i}\) for any \(i\in \{1,2,\ldots ,t\}\). Because \(q^{2}Cl_{i}=Cl_{i}\) for any \(i\in \{1,2,\ldots ,t\}\), we obtain \(Cl_{\sigma (\bar{i} )}=Cl_{\sigma ^{2}(i)}=Cl_{i}\). This implies \(\sigma ^{2}(i)=i\), i.e., \(\sigma ^{2}\) is the identity permutation of \(\{1,2,\ldots ,t\}\).

Now we prove necessity. Assume there exists a Hermitian self-dual code \(C_{T}\) with defining set \(T\subset O_{r,n}(1)\). Then by Corollary 3.3, \(\bar{T}=-q[O_{r,n}(1)\backslash T] =T\). Therefore, if there exists \(j\) such that \(Cl_{q^{2}}(j)=Cl_{q^{2}}(-qj)\), we will have the following two cases.

Case 1: If \(j\in T\), then \(-qj\in T\). By the fact that \(\bar{T} =-q[O_{r,n}(1)\backslash T] =T\), there exists some \(i\notin T\) such that \(-qi=j\). Thus \(q^{2}i=-qj\notin T\). This is a contradiction.

Case 2: If \(j\notin T\), by the fact that \(\bar{T}=-q[O_{r,n}(1)\backslash T] =T\), we have \(-qj\in T\). Because \(Cl_{q^{2}}(j)=Cl_{q^{2}}(-qj)\subset T\), we have \(j\in T\) which contradicts the assumption.

Next, we prove the sufficiency. We assume \(Cl_{q^{2}}(j)\ne Cl_{q^{2}}(-qj)\) for any \(j\in O_{r,n}(1)\). This implies \(\sigma (i)\ne i\) for any \(i\in \{1,2,\ldots ,t\}\). Since \(\sigma ^{2}(i)=i, \sigma \) must be a product of mutually disjoint transpositions like \((a_{1}\, b_{1})(a_{2}\, b_{2})\cdots (a_{k}\, b_{k})\). We might assume \(t=2k\) and let \(\sigma (i)=k+i\) and \(\sigma (k+i)=i\) for \(1\le i\le k\). If we let \(T=Cl_{1}\cup Cl_{2}\cup \cdots \cup Cl_{k}\), then the code \(C_{T}\) with defining set \(T\) is a Hermitian self-dual code. Therefore, if \(Cl_{q^{2}}(j)\ne Cl_{q^{2}}(-qj)\) for \(\forall j\in O_{r,n}(1)\), there exist Hermitian self-dual codes. \(\square \)

Based on this proposition, we have the following theorem. This theorem is an extension of Theorem 3 in [3] (the case of \(b=1\) and \(r^{\prime }=1\)).

Theorem 3.9

Let \(n=2^{a}n^{\prime }\left( a>0\right) \) and \(r=2^{b}r^{\prime }\) be integers such that \(2\not \mid n^{\prime }\) and \(2\not \mid r^{\prime }\). Let \(q\) be an odd prime power such that \((n,q)=1\) and \(r\mid q+1\), and let \(\alpha \in \mathbb{F }_{q^{2}}^{*}\) has order \(r\). Then Hermitian self-dual \(\alpha \) -constacyclic codes over \(\mathbb{F }_{q^{2}}\) of length \(n\) exist if and only if \(b>0\) and \(q+1\not \equiv 0\pmod {2^{a+b}}\).

Proof

\(n^{\prime }\) can be written as \(n^{\prime }=r_{1}^{t_{1}}\cdots r_{j}^{t_{j}}r_{j+1}^{t_{j+1}}\cdots r_{s}^{t_{s}}\), where \(r_{1},\ldots ,r_{s}\) are distinct primes, \(r_{1},\ldots ,r_{j}\mid r\), and \(r_{j+1},\ldots ,r_{s}\not \mid r\). Assume \(n_{1}=r_{1}^{t_{1}} \cdots r_{j}^{t_{j}}, n_{2}=r_{j+1}^{t_{j+1}}\cdots r_{s}^{t_{s}}\), and \(n^{\prime }=n_{1}n_{2}\). Since \(r_{j+1},\ldots ,r_{s}\not \mid r\), it follows \((n_{2},r)=1\). Because \(r_{1},\ldots ,r_{j}\mid r\), we know \(r_{1},\ldots ,r_{j}\mid q+1\). By Lemma 3.7, there exists \(m\) such that \(n_{1}\mid \frac{ q^{2m+1}+1}{q+1}\).

The proof consists of two parts. First we prove the necessity. If \(r\) is odd, which is equivalent to \(b=0\), clearly, we have \((r,2^{a}n_{2})=1\). There exists \(i\in \mathbb Z \) such that \(2^{a}n_{2}\mid ir+1\). Thus by \(n_{1}\mid \frac{q^{2m+1}+1}{q+1}\), we have

$$\begin{aligned}&(q+1)2^{a}n_{1}n_{2}\mid (q^{2m+1}+1)(ir+1)\Longrightarrow (q+1)n\mid (q^{2m+1}+1)(ir+1)\\&\quad \Longrightarrow rn\mid (q^{2m+1}+1)(ir+1). \end{aligned}$$

Therefore, \(ir+1=q^{2m}(-q(ir+1))\pmod {rn}\). This implies \(Cl_{q^{2}}(ir+1)=Cl_{q^{2}}(-q(ir+1))\). Since \(ir+1\in O_{r,n}(1)\), by Proposition 3.8, there is no Hermitian self-dual \(\alpha \) -constacyclic code over \(\mathbb{F }_{q^{2}}\), which contradicts the assumption. Therefore, \(r\) must be even, i.e., \(b>0\).

Let \(q+1=2^{c}rt\) with \(c\ge 0\) and \((t,2)=1\). If \(q+1\equiv 0\pmod {2^{a+b}}\), then \(c\ge a\). Because \((n_{2},r)=1\), there exists \(i^{\prime }\in \mathbb Z \) such that \(n_{2}\mid i^{\prime }r+1\). Since \(n_{1}\mid \frac{q^{2m+1}+1}{ q+1}\), we have

$$\begin{aligned} (q+1)n_{1}n_{2}\mid (q^{2m+1}+1)(i^{\prime }r+1)&\Longrightarrow&2^{c}rtn_{1}n_{2}\mid (q^{2m+1}+1)(i^{\prime }r+1)\\&\Longrightarrow&rn\mid (q^{2m+1}+1)(i^{\prime }r+1). \end{aligned}$$

Similarly, we have \(Cl_{q^{2}}(i^{\prime }r+1)=Cl_{q^{2}}(-q(i^{\prime }r+1))\). By Proposition 3.8, we get a contradiction. So it is necessary to have \(q+1\not \equiv 0\pmod {2^{a+b}}\).

Now we prove the sufficiency. Assume \(b>0\) and \(q+1\not \equiv 0\pmod {2^{a+b}}\). If there is no Hermitian self-dual code, by Proposition 3.8, there exists \(ir+1\in O_{r,n}(1)\) such that \(Cl_{q^{2}}(ir+1)=Cl_{q^{2}}(-q(ir+1))\). Therefore, for some \(m\in \mathbb Z ^{+}\),

$$\begin{aligned} rn\mid (q^{2m+1}+1)(ir+1)\Longrightarrow 2^{a+b}r^{\prime }n^{\prime }\mid \frac{q^{2m+1}+1}{q+1}(q+1)(ir+1). \end{aligned}$$

Since \(b>0, ir+1\) must be odd. Together with the fact that \(\frac{ q^{2m+1}+1}{q+1}\) is odd, we get \(2^{a+b}\mid q+1\), which contradicts the assumption that \(q+1\not \equiv 0\pmod {2^{a+b}}\). \(\square \)

4 MDS hermitian self-dual constacyclic codes over \(\mathbb{F }_{q^{2}}\)

We study MDS Hermitian self-dual constacyclic codes over \(\mathbb{F }_{q^{2}}\) in this section. The following theorem will give the BCH bound for constacyclic codes (cf. [1, Theorem 2.2]).

Theorem 4.1

Let \(C\) be an \(\alpha \)-constacyclic code of length \(n\) over \(\mathbb{F }_{q^2}\). Let \(r=ord_{q^{2}}(\alpha )\). Let \(\delta \) be a primitive \(rn\)th root of unity in an extension field of \(\mathbb{F }_{q^2}\) such that \(\delta ^{n}=\alpha \), and let \(\zeta =\delta ^r\). Assume the generator polynomial of \(C\) has roots that include the set \(\{\delta \zeta ^{^{i}}\mid i_{1}\le i\le i_{1}+d-1\}\). Then the minimum distance of \(C\ge d\).

Example 4.2

Let \(q^{2}=17^{2}, n=8\) and \(r=18\). We consider the \(\alpha \)-constacyclic code of length 8 over \(\mathbb{F }_{17^{2}}\) with \(\alpha \) a primitive 18th root of unity.

Obviously, we have \(O_{18,8}(1)=\{1,19,37,55,73,91,109,127\}\) and \(r\mid q+1\). Let \(T=\{73,91,109,127\}\), then \(\bar{T}=-17\left[ O_{18,8}(1)\backslash T\right] =\left\{ 73,91,109,127\right\} \pmod {144}\). Thus \(\bar{T}=T\). By Corollary 3.3, \(C_{T}\) is a Hermitian self-dual \(\alpha \)-constacyclic code.

Furthermore, we notice that the generator polynomial of \(C_{T}\) has roots:

$$\begin{aligned} \delta ^{1+4r}, \delta ^{1+5r}, \delta ^{1+6r}, \delta ^{1+7r}. \end{aligned}$$

By Theorem 4.1, the minimum distance \(d\) is at least 5. Since \(n-k+1=8-4+1=5, C_{T}\) is an [3, 4, 7] MDS Hermitian self-dual \(\alpha \)-constacyclic code.

Example 4.2 shows that there exist MDS Hermitian self-dual constacyclic codes. The following theorem is a generalization of Example 4.2.

Theorem 4.3

Let \(\alpha \in \mathbb{F }_{q^{2}}^{*}\) have order \(r\) with \(rs=q+1\) for some positive integer \(s\). Let \(n\) be even and \(n\mid q-1\). Let

$$\begin{aligned} T=O_{r,n}(1)\backslash \left\{ ir+1\mid -[\frac{s-1}{2}]\le i\le [\frac{n-1-s}{2}]\right\} \pmod {rn}. \end{aligned}$$

Then the following holds.

  1. (i)

    If \(s\) is odd, then \(C_{T}\) is a Hermitian self-dual \(\alpha \) -constacyclic MDS code with parameters \([n,\frac{n}{2},\frac{n}{2}+1]\);

  2. (ii)

    If \(s\) is even, then \(C_{T}\) is a Hermitian self-orthogonal \(\alpha \)-constacyclic MDS code with parameters \([n,\frac{n}{2}-1,\frac{n}{2} +2]\).

Proof

Let \(T_{1}=\left\{ ir+1\mid -[\frac{s-1}{2}]\le i\le [\frac{ n-1-s}{2}]\right\} \pmod {rn}\). If \(s\) is odd, then \(T_{1}\) has \(\frac{n}{2}\) elements, and therefore, the dimension of \(C_{T}\) is \(\frac{n}{2}\); if \(s\) is even, then \(T_{1}\) has \(\frac{n}{2}-1\) elements, and therefore, the dimension of \(C_{T}\) is \(\frac{n}{2}-1\). Let \(I_{1}=\left\{ i\mid -[\frac{s-1}{2} ]\le i\le [\frac{n-1-s}{2}]\right\} \pmod {n}\). The set \(\{0,1,\ldots ,n-1\}\backslash I_{1}\) has \(\frac{n}{2}\) consecutive elements (modulo \(n\)) when \(s\) is odd and \(\frac{ n}{2}+1\) consecutive elements when \(s\) is even. Using the Singleton Bound and Theorem 4.1, the minimum distance of \(C_{T}\) is \(\frac{n}{2}+1\) when \(s\) is odd and \(\frac{n}{2}+2\) when \(s\) is even, making \(C_{T}\) MDS.

The proof is complete if we show that \(C_{T}\) is Hermitian self-orthogonal. By Corollary 3.3, this can be verified if we show \(T_{1}\cap (-qT_{1})=\varnothing \) where we reduce the entries in \(T_{1}\) and \(-qT_{1}\) modulo \(rn\) before taking the intersection. Since \(n\mid q-1\), we know \(-q\equiv -1\pmod {n}\), which implies that \(-qr\equiv -r\pmod {rn}\). So \(-q(ir+1)\equiv -ir-q\equiv -ir-(q+1)+1\equiv (-i-s)r+1\equiv (n-i-s)r+1\pmod {rn}\). Therefore, showing that \(T_{1}\cap (-qT_{1})=\varnothing \) is equivalent to showing that \(I_{1}\cap I_{2}=\varnothing \), where \(I_{2}=\left\{ n-i-s\mid i\in I_{1}\right\} \pmod {n}\) and the intersection \(I_{1}\cap I_{2}\) is taken after reducing modulo \(n\). Consider the case that \(s\) is odd. The elements of \(I_{1}\) are the \(\frac{n}{2}\) consecutive integers \(-(\frac{s-1}{2}),\ldots , \frac{n-1-s}{2}\). Using this, the elements of \(I_{2}\) are the \(\frac{n}{2}\) consecutive integers \(\frac{n+1-s}{2},\ldots ,n-(\frac{ s+1}{2})\). These two lists together make up \(n\) consecutive integers, and hence, when reducing modulo \(n, I_{1}\cap I_{2}=\varnothing \). Consider the case that \(s\) is even. The elements of \(I_{1}\) are the \(\frac{n}{2}-1\) consecutive integers \(-\frac{s}{2}+1,\ldots ,\frac{n-s}{2}-1\). Using this, the elements of \(I_{2}\) are the \(\frac{n}{2}-1\) consecutive integers \(\frac{n-s}{2}+1,\ldots ,n-\frac{s}{2}-1\). These two lists together make up \(n-1\) consecutive integers, excluding the single integer \(\frac{n-s}{2}\). Therefore, when reducing modulo \(n, I_{1}\cap I_{2}=\varnothing \). \(\square \)

Table 1 gives some Hermitian self-dual codes over \(\mathbb{F }_{q^{2}}\) for \(q\le 19\) with lower bounds on the minimum distance \(d\).

Table 1 \([n,k,d]\) Hermitian self-dual codes over \(\mathbb{F }_{q^{2}}\) (where \(q\le 19\))

5 Conclusion

We have studied Hermitian self-dual codes arising from constacyclic codes in this paper. In Sect. 3, necessary and sufficient conditions have been given for the existence of Hermitian self-dual constacyclic codes over \(\mathbb{F }_{q^{2}}\) of length \(n\). In Sect. 4, we have given conditions for the existence of MDS Hermitian self-orthogonal and self-dual constacyclic codes over \(\mathbb{F }_{q^{2}}\).