1 Introduction

Let \(\mathbb {F}_p\) be the finite field with p elements and let n be a positive integer, where p is an odd prime. An [nkd] linear code \({\mathcal {C}}\) over \(\mathbb {F}_p\) is a k-dimensional subspace of \(\mathbb {F}_p^n\) with minimum distance d.

Now we recall the definition of the complete weight enumerator of a code [38, 39]. Suppose that the elements of \(\mathbb {F}_p\) are \(0, 1, \ldots , p-1\). The composition of a vector \(\mathbf v =(v_0, v_1, \ldots , v_{n-1}) \in \mathbb {F}_p^n\) is defined to be \(\text{ comp }(\mathbf v )=(t_0, t_1, \ldots , t_{p-1})\), where each \(t_i=t_i(\mathbf v )\) is the number of components \(v_j (0 \le j \le n-1)\) of \(\mathbf v \) that are equal to i. Clearly, we have

$$\begin{aligned} \sum _{i=0}^{p-1} t_i=n. \end{aligned}$$

Definition 1.1

Let \({\mathcal {C}}\) be a code over \(\mathbb {F}_p\) and let \(A(t_0, t_1, \ldots , t_{p-1})\) be the number of codewords \(\mathbf c \in {\mathcal {C}}\) with \(\text{ comp }(\mathbf c )=(t_0, t_1, \ldots , t_{p-1})\). Then the complete weight enumerator of \({\mathcal {C}}\) is the polynomial

$$\begin{aligned} W_{{\mathcal {C}}}(z_0, z_1, \ldots , z_{p-1})= & {} \sum _\mathbf{c \in {\mathcal {C}}}z_0^{t_0(\mathbf c )}z_1^{t_1(\mathbf c )} \cdots z_{p-1}^{t_{p-1}(\mathbf c )} \\= & {} \sum _{(t_0, t_1, \ldots , t_{p-1}) \in B_n} A(t_0, t_1, \ldots , t_{p-1})z_0^{t_0}z_1^{t_1} \cdots z_{p-1}^{t_{p-1}}, \end{aligned}$$

where \(B_n=\{(t_0, t_1, \ldots , t_{p-1}): 0 \le t_i \le n, \sum \limits _{i=0}^{p-1} t_i=n\}\).

For binary linear codes, the complete weight enumerators are just their Hamming weight enumerators. It is not difficult to see that the Hamming weight enumerators, which have been extensively investigated, can follow from the complete weight enumerators. Constant composition codes whose complete weight enumerators have one term have been intensively studied and some families of optimal constant composition codes were presented [6, 9, 17]. Moreover, the complete weight enumerators are applied to study the Walsh transform of monomial functions over finite fields [27] and compute the deception probabilities of certain authentication codes constructed from linear codes [16, 20]. Hence it is interesting to determine the complete weight enumerators of linear codes.

The complete weight enumerators of Reed-Solomon codes were studied by Blake and Kith [4, 29]. Kuzmin and Nechaev [30, 31] presented the complete weight enumerators of the generalized Kerdock code and related linear codes over Galois rings. The complete weight enumerators of cyclic codes or linear codes over finite fields were studied in [1, 2, 17, 32, 34]. In this paper, we shall employ exponential sums and Galois theory to investigate the complete weight enumerators of linear codes constructed from defining sets.

Let \(D=\{d_0, d_1, \ldots , d_{n-1}\} \subset \mathbb {F}_q\), where \(q=p^m\) for a positive integer m. Let \({\text {Tr}}_m\) denote the trace function from \(\mathbb {F}_q\) onto \(\mathbb {F}_p\). Then a linear code of length n over \(\mathbb {F}_p\) can be defined by

$$\begin{aligned} {\mathcal {C}}_D=\big \{\mathbf{c }(x)=({\text {Tr}}_m(xd_0), {\text {Tr}}_m(xd_1), \ldots , {\text {Tr}}_m(xd_{n-1})): x \in \mathbb {F}_q\big \}. \end{aligned}$$
(1.1)

We call D the defining set of the code \({\mathcal {C}}_D\). By definition, the dimension of \({\mathcal {C}}_D\) is at most m. In fact, the dimension of the linear code \({\mathcal {C}}_D\) is equal to the dimension of the \(\mathbb {F}_p\)-linear subspace of \(\mathbb {F}_q\) spanned by D [15].

This construction was proposed by Ding et al. [1015, 21] to present linear codes with a few nonzero weights and optimal codes when the sets D are well chosen. The weight enumerators of these linear codes were also presented. The objective of this paper was to investigate the complete weight enumerators of linear codes \({\mathcal {C}}_D\) in the following three cases:

  1. (1)

    D is a skew Hadamard difference set or Paley type partial difference set in \(\mathbb {F}_q\);

  2. (2)

    \(D=\{f(x): x \in \mathbb {F}_q\}\setminus \{0\}\), where f(x) is a quadratic form over \(\mathbb {F}_q\);

  3. (3)

    \(D=\{x \in \mathbb {F}_q^*: {\text {Tr}}_s(x^{p^s+1})=0\}\), where \(m=2s\) is an even integer.

It should be remarked that the weight enumerators of \({\mathcal {C}}_D\) had been determined [12, 14] for Cases (1) and (2). In this paper, the complete weight enumerators of the linear codes \({\mathcal {C}}_D\) can be explicitly presented in these three cases by using exponential sums and Galois theory. Moreover, we employ the complete weight enumerators to construct constant composition codes which are subcodes of the linear codes \({\mathcal {C}}_D\). Motivated by the original ideas in [16, 20], we also present some authentication codes with new parameters. A new class of optimal constant composition codes and three classes of asymptotically optimal systematic authentication codes are presented.

The rest of this paper is organized as follows. In Sect. 2, we present some preliminaries which are very useful to get our results. In Sects. 34, and 5, we investigate the complete weight enumerators of the linear codes in the three cases. In Sect. 6, we employ the complete weight enumerators of the linear codes to construct constant composition codes and systematic authentication codes. In Sect. 7, we conclude this paper.

2 Preliminaries

Suppose that \(q=p^m\) for an odd prime p and a positive integer m. For \(a \in \mathbb {F}_q\), an additive character \(\psi _a\) of the finite field \({\mathbb {F}}_q\) can be defined as follows:

$$\begin{aligned} \psi _a : {\mathbb {F}}_q \rightarrow {\mathbb {C}}^*, \psi _a(x)=\zeta _p^{{\hbox {Tr}}_m(ax)}, \end{aligned}$$

where \(\zeta _p=e^{\frac{2\pi \sqrt{-1}}{p}}\) is a primitive p-th root of unity and \({\hbox {Tr}}_m\) denotes the trace function from \({\mathbb {F}}_q\) onto \({\mathbb {F}}_p\). It is clear that \(\psi _0(x)=1\) for all \(x \in \mathbb {F}_q\). Then \(\psi _0\) is called the trivial additive character of \(\mathbb {F}_q\). If \(a=1\), we call \(\psi :=\psi _1\) the canonical additive character of \(\mathbb {F}_q\). It is easy to see that \(\psi _a(x)=\psi (ax)\) for all \(a, x \in \mathbb {F}_q\). The orthogonal property of additive characters which can be found in [33] is given by

$$\begin{aligned} \sum _{x \in \mathbb {F}_q} \psi _a(x)=\left\{ \begin{array}{ll} q,\quad \text{ if } \,\, a=0; \\ 0,\quad \text{ if } \,\, a \in {\mathbb {F}}_q ^*. \end{array}\right. \end{aligned}$$

Let \(\lambda : \mathbb {F}_q^* \rightarrow \mathbb {C}^*\) be a multiplicative character of \(\mathbb {F}_q^*\). Now we define the Gauss sum over \(\mathbb {F}_q\) by

$$\begin{aligned} G(\lambda )=\sum _{x \in \mathbb {F}_q^*} \lambda (x) \psi (x). \end{aligned}$$

In general, the explicit determination of Gauss sums is a difficult problem. However, they can be explicitly evaluated in a few cases [3, 33, 45]. We state a result on the quadratic Gauss sums here.

Lemma 2.1

[3, 33] Suppose that \(q=p^m\) and \(\eta \) is the quadratic multiplicative character of \(\mathbb {F}_q\), where p is an odd prime and \(m \ge 1\). Then

$$\begin{aligned} G(\eta )=(-1)^{m-1} \sqrt{(p^*)^m}=\left\{ \begin{array}{ll} (-1)^{m-1} \sqrt{q}, &{} \text{ if } \,\, p \equiv 1 \pmod 4, \\ (-1)^{m-1} (\sqrt{-1})^m \sqrt{q}, &{} \text{ if } \,\, p \equiv 3 \pmod 4, \end{array}\right. \end{aligned}$$

where \(p^*=\big (\frac{-1}{p}\big )p=(-1)^{\frac{p-1}{2}}p\).

A polynomial f over \(\mathbb {F}_q\) is called a quadratic form if

$$\begin{aligned} f(x)=\sum _{i \in I} \sum _{j \in J}a_{ij}x^{p^i+p^j}, \end{aligned}$$

where \(a_{ij} \in \mathbb {F}_q\) and \(I, J \subset \{0, 1, 2, \ldots , m-1\}\). The rank of the quadratic form f(x) over \(\mathbb {F}_q\) is defined to be the codimension of the \(\mathbb {F}_p\)-vector space

$$\begin{aligned} V=\big \{x \in \mathbb {F}_q: f(x+z)-f(x)-f(z)=0 \text{ for } \text{ all } z \in \mathbb {F}_q\big \}. \end{aligned}$$

That is, \(|V|=p^{m-r}\), where r is the rank of f(x).

Lemma 2.2

[23, 33] Let f(x) be a quadratic form of rank r over \(\mathbb {F}_q\). Then we have

$$\begin{aligned} \sum _{x \in \mathbb {F}_q} \psi (f(x))=\left\{ \begin{array}{ll} \pm p^{m-\frac{r}{2}}, &{} \text{ if } \,\, p \equiv 1 \pmod 4; \\ \pm (\sqrt{-1})^r p^{m-\frac{r}{2}}, &{} \text{ if } \,\, p \equiv 3 \pmod 4. \end{array}\right. \end{aligned}$$

The following exponential sums will be employed later.

Lemma 2.3

[7] Let \(m=2s\) be an even integer. Assume that \(a \in \mathbb {F}_{p^s}\) and \(b \in \mathbb {F}_{p^m}\). Then

$$\begin{aligned} \sum _{x \in \mathbb {F}_q}\zeta _p^{{\text {Tr}}_s(ax^{p^s+1})+{\text {Tr}}_m(bx)}=-p^s \zeta _p^{-{\text {Tr}}_s(\frac{b^{p^s+1}}{a})}. \end{aligned}$$

We will also use some well-known results on the Galois group of the cyclotomic field \(\mathbb {Q}(\zeta _p)\) [28]. The Galois group of \(\mathbb {Q}(\zeta _p)\) over \(\mathbb {Q}\) is \(\{\sigma _j: 1 \le j \le p-1\}\), where the automorphism \(\sigma _j\) of \(\mathbb {Q}(\zeta _p)\) is defined by

$$\begin{aligned} \sigma _j(\zeta _p)=\zeta _p^j. \end{aligned}$$

Moreover, the unique quadratic subfield of \(\mathbb {Q}(\zeta _p)\) is \(\mathbb {Q}(\sqrt{p^*})\), where \(p^*=\big (\frac{-1}{p} \big )p\). By Lemma 2.1, we have

$$\begin{aligned} \sqrt{p^*}=\sum _{i=1}^{p-1}\bigg (\frac{i}{p}\bigg )\zeta _p^i. \end{aligned}$$

Then

$$\begin{aligned} \sigma _j(\sqrt{p^*})=\sum _{i=1}^{p-1}\bigg (\frac{i}{p}\bigg )\zeta _p^{ij}=\bigg (\frac{j}{p}\bigg )\sum _{i=1}^{p-1}\bigg (\frac{ij}{p}\bigg )\zeta _p^{ij} =\bigg (\frac{j}{p}\bigg )\sqrt{p^*}. \end{aligned}$$
(2.1)

3 The first case

In this section, we present the complete weight enumerator of the linear code \({\mathcal {C}}_D\) when D is a skew Hadamard difference set or Paley type partial difference set in \(\mathbb {F}_q\).

We assume that the reader is familiar with the basic theory of difference sets. A difference set D in \(\mathbb {F}_q\) is called skew Hadamard if \(\mathbb {F}_q\) is the disjoint union of \(D,\,-D\), and \(\{0\}\), where \(-D=\{-d: d \in D\}\). A classical example of skew Hadamard difference sets is the Paley difference set consisting of the nonzero squares of \(\mathbb {F}_q\) when \(q \equiv 3 \pmod 4\). In fact, if D is a skew Hadamard difference set in \(\mathbb {F}_q\), then we must have \(q \equiv 3 \pmod 4\). A subset D of \(\mathbb {F}_q,\,0 \not \in D\), is called a Paley type partial difference sets if D is a \((q, \frac{q-1}{2}, \frac{q-5}{4}, \frac{q-1}{4})\) partial difference sets. It is clear that \(q \equiv 1 \pmod 4\) if D is a Paley type partial difference sets in \(\mathbb {F}_q\). For more details on the skew Hadamard difference sets and the Paley type partial difference sets, we refer the readers to [11, 37, 43].

There is a well-known lemma in the theory of difference sets [24]. Below we denote \(\sum \limits _{d \in D} \psi (d)\) by \(\psi (D)\) and \(\{xd: d \in D\}\) by xD for simplicity.

Lemma 3.1

[24] Let D be a subset of \(\mathbb {F}_q\) with \(|D|=\frac{q-1}{2}\).

  1. (1)

    If \(D \bigcap -D=\emptyset \) and \(0 \not \in D\), then D is a skew Hadamard difference set in \(\mathbb {F}_q\) if and only if

    $$\begin{aligned} \psi _a(D)=\frac{-1 \pm \sqrt{-q}}{2} \text{ for } \text{ all } a \in \mathbb {F}_q^*. \end{aligned}$$
  2. (2)

    If \(D=-D\) and \(0 \not \in D\), then D is a Paley type partial difference set in \(\mathbb {F}_q\) if and only if

    $$\begin{aligned} \psi _a(D)=\frac{-1 \pm \sqrt{q}}{2} \text{ for } \text{ all } a \in \mathbb {F}_q^*. \end{aligned}$$

Let \(D=\{d_0, d_1, \ldots , d_{n-1}\}\), where \(n=\frac{q-1}{2}\). For a codeword \(\mathbf c (x)\) of \({\mathcal {C}}_D,\,x \in \mathbb {F}_q^*\), and \(c \in \mathbb {F}_p\), let \(N_x(c)\) denote the number of components \({\hbox {Tr}}_m(xd_i)\) of \(\mathbf c (x)\) which are equal to c, i.e.,

$$\begin{aligned} N_x(c)= & {} |\{0 \le i \le n-1: {\hbox {Tr}}_m(xd_i)=c\}| \\= & {} |\{0 \le i \le n-1: {\hbox {Tr}}_m(xd_i)-c=0\}|. \end{aligned}$$

By the orthogonal property of additive characters we have

$$\begin{aligned} N_x(c)= & {} \sum _{i=0}^{n-1} \frac{1}{p} \sum _{y \in \mathbb {F}_p} \zeta _p^{y ({\hbox {Tr}}_m(xd_i)-c)} \nonumber \\= & {} \frac{n}{p}+\frac{1}{p} \sum _{i=0}^{n-1}\sum _{j=1}^{p-1} \sigma _j(\zeta _p^{{\hbox {Tr}}_m(xd_i)-c}) \nonumber \\= & {} \frac{n}{p} +\frac{1}{p} \sum _{j=1}^{p-1}\sigma _j(\zeta _p^{-c})\sum _{i=0}^{n-1}\sigma _j(\zeta _p^{{\text {Tr}}_m(xd_i)}) \nonumber \\= & {} \frac{n}{p} +\frac{1}{p} \sum _{j=1}^{p-1}\sigma _j(\zeta _p^{-c})\sigma _j\left( \sum _{i=0}^{n-1}\zeta _p^{{\text {Tr}}_m(xd_i)}\right) \nonumber \\= & {} \frac{n}{p} +\frac{1}{p} \sum _{j=1}^{p-1}\sigma _j(\zeta _p^{-c})\sigma _j(\psi (xD)), \end{aligned}$$
(3.1)

where \(\sigma _j (1 \le j \le p-1)\) is the automorphism of \(\mathbb {Q}(\zeta _p)\) defined by \(\sigma _j(\zeta _p)=\zeta _p^j\).

Theorem 3.2

Let \({\mathcal {C}}_D\) be the linear code defined by (1.1).

  1. (1)

    Suppose that D is a skew Hadamard difference set in \(\mathbb {F}_q\). Then \({\mathcal {C}}_D\) is a \([\frac{p^m-1}{2}, m]\) linear code and its complete weight enumerator is

    $$\begin{aligned}&z_0^{\frac{p^m-1}{2}}+\frac{p^m-1}{2} z_0^{\frac{p^{m-1}-1}{2}}\prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=1 \end{array}}z_c^{\frac{p^{m-1}+p^{\frac{m-1}{2}}}{2}} \prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=-1 \end{array}}z_c^{\frac{p^{m-1}-p^{\frac{m-1}{2}}}{2}} \nonumber \\&\qquad +\, \frac{p^m-1}{2} z_0^{\frac{p^{m-1}-1}{2}}\prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=1 \end{array}}z_c^{\frac{p^{m-1}-p^{\frac{m-1}{2}}}{2}} \prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=-1 \end{array}}z_c^{\frac{p^{m-1}+p^{\frac{m-1}{2}}}{2}}. \end{aligned}$$
    (3.2)
  2. (2)

    Suppose that D is a Paley type partial difference set in \(\mathbb {F}_q\). Then \({\mathcal {C}}_D\) is also a \([\frac{p^m-1}{2}, m]\) linear code. If m is odd, then the complete weight enumerator of \({\mathcal {C}}_D\) is given by (3.2). If m is even, then the complete weight enumerator of \({\mathcal {C}}_D\) is

    $$\begin{aligned}&z_0^{\frac{p^m-1}{2}}+\frac{p^m-1}{2} z_0^{\frac{(p^{\frac{m}{2}}-1)(p^{\frac{m}{2} -1}+1)}{2}}(z_1z_2 \ldots z_{p-1})^{\frac{p^{m-1}-p^{\frac{m}{2} -1}}{2}} \\&\qquad +\, \frac{p^m-1}{2} z_0^{\frac{(p^{\frac{m}{2}}+1)(p^{\frac{m}{2} -1}-1)}{2}}(z_1z_2 \ldots z_{p-1})^{\frac{p^{m-1}+p^{\frac{m}{2} -1}}{2}}. \end{aligned}$$

Proof

(1) If D is a skew Hadamard difference set in \(\mathbb {F}_q\), then \(q \equiv 3 \pmod 4\). Thus \(p \equiv 3 \pmod 4\) and m is odd. By Lemma 3.1, we have

$$\begin{aligned} \psi (xD)=\frac{-1 \pm (\sqrt{p*})^m}{2} \text{ for } \text{ all } x \in \mathbb {F}_q^*, \end{aligned}$$

where \(p^*=\big (\frac{-1}{p}\big )p=-p\). If \(c \in \mathbb {F}_p^*\), then

$$\begin{aligned} N_x(c)= & {} \frac{n}{p} +\frac{1}{p} \sum _{j=1}^{p-1}\sigma _j(\zeta _p^{-c})\sigma _j\left( \frac{-1 \pm (\sqrt{p*})^m}{2}\right) \\= & {} \frac{n}{p} +\frac{1}{p} \sum _{j=1}^{p-1}\zeta _p^{-jc}\frac{-1 \pm (\frac{j}{p})(\sqrt{p*})^m}{2} \ \ \ \ \ \ \ \ \ \ \text{(by } \text{(2.1)) } \\= & {} \frac{n}{p} +\frac{1}{2p} \left( -\sum _{j=1}^{p-1}\zeta _p^{-jc} \pm \sum _{j=1}^{p-1}\zeta _p^{-jc} \bigg (\frac{j}{p}\bigg )(\sqrt{p*})^m\right) \\= & {} \frac{n}{p} +\frac{1}{2p} \left( 1 \pm (\sqrt{p*})^m \bigg (\frac{-c}{p}\bigg )\sqrt{p*}\right) \ \ \ \ \ \ \ \ \ \ \text{(by } \text{ Lemma } \text{2.1) } \\= & {} \frac{p^{m-1} \pm (\frac{c}{p})(-p)^{\frac{m-1}{2}}}{2}. \end{aligned}$$

Now we are going to determine the frequency of each composition. Denote

$$\begin{aligned} \begin{aligned} n^+=&{} \Big |\left\{ x \in \mathbb {F}_q^*: \psi (xD)=\frac{-1+\sqrt{-q}}{2}\right\} \Big |,\\ n^-=&{} \Big |\left\{ x \in \mathbb {F}_q^*: \psi (xD)=\frac{-1-\sqrt{-q}}{2}\right\} \Big |. \end{aligned} \end{aligned}$$

It is easy to check that

$$\begin{aligned} \sum _{x \in \mathbb {F}_q^*}\psi (xD)=\sum _{d \in D}\sum _{x \in \mathbb {F}_q^*}\psi (xd)=-|D|. \end{aligned}$$

Thus we have

$$\begin{aligned} n^+ \cdot \frac{-1+\sqrt{-q}}{2}+n^- \cdot \frac{-1-\sqrt{-q}}{2}=-|D|. \end{aligned}$$

Note that \(n^+ + n^-=q-1\) and \(N_x(0)=n-\sum \nolimits _{c \in \mathbb {F}_p^*}N_x(c)\). Then \(n^+=n^-=\frac{q-1}{2}\) and we get the complete weight enumerator of \({\mathcal {C}}_D\).

(2) The proof of (2) is very similar to that of (1) and we omit the details. \(\square \)

It should be remarked that the code \({\mathcal {C}}_D\) and its weight enumerator had been presented in [12] when D is a skew Hadamard difference set or Paley type partial difference set. By Theorem 3.2, we can also obtain the weight enumerator of the code \({\mathcal {C}}_D\), which conforms to the results presented in [12].

The complete weight enumerator of the linear code \({\mathcal {C}}_D\) has been presented if D is a skew Hadamard difference set or Paley type partial difference set. Let \(\alpha \) be a primitive element of \(\mathbb {F}_q\) and let \({\mathcal {C}}\) be an irreducible cyclic code with check polynomial h(x), where h(x) is the minimal polynomial of \(\alpha ^{-2}\) over \(\mathbb {F}_p\). In particular, if \(D=\langle \alpha ^2 \rangle \), then D is a skew Hadamard difference set or Paley type partial difference set. The complete weight enumerators of the linear codes \({\mathcal {C}}_D\) are the same as those of the irreducible cyclic codes \({\mathcal {C}}\) which were presented in [2, 32]. Thus Theorem 3.2 generalizes the results of [2, 32] to some extent.

If D is a multiplicative subgroup in \(\mathbb {F}_q^*\), then determining the complete weight enumerators of the linear codes \({\mathcal {C}}_D\) is equivalent to determining the complete weight enumerators of irreducible cyclic codes which were given in [32], so we will not consider them here. The weight enumerators of the linear codes \({\mathcal {C}}_D\) were investigated in [10, 15, 21] for more general D which may not be a multiplicative subgroup of \(\mathbb {F}_q^*\).

4 The second case

In this section, we present the complete weight enumerator of the linear code \({\mathcal {C}}_D\) when \(D=\{f(x): x \in \mathbb {F}_q\}\setminus \{0\}\), where f(x) is a quadratic form over \(\mathbb {F}_q\). We always assume that the quadratic form f satisfies the following two conditions:

  1. (I)

    \(f(0)=0\) and \(f(x) \ne 0\) for all \(x \in \mathbb {F}_q^*\);

  2. (II)

    f is e-to-1 on \(x \in \mathbb {F}_q^*\), i.e., \(f(x)=u\) has either e solutions \(x \in \mathbb {F}_q^*\) or no solution for each \(u \in \mathbb {F}_q^*\), where e is a positive integer.

There are some quadratic forms f(x) over \(\mathbb {F}_{p^m}\) satisfying Conditions (I) and (II).

Example 4.1

  1. (1)

    \(f(x)=x^{p^l+1}\) is a quadratic form over \(\mathbb {F}_{p^m}\), where \(l \ge 0\) is an integer. In this case, \(e=\gcd (p^l+1, p^m-1)\).

  2. (2)

    \(f(x)=x^{10}-ux^6-u^2x^2\) is a quadratic form over \(\mathbb {F}_{3^m}\), where \(u \in \mathbb {F}_{3^m}\) and m is odd. In this case, \(e=2\).

Let \(D=\{d_0, d_1, \ldots , d_{n-1}\}\), where \(n=\frac{q-1}{e}\). For a codeword \(\mathbf c (x)\) of \({\mathcal {C}}_D,\,x \in \mathbb {F}_q^*\), and \(c \in \mathbb {F}_p^*\), let \(N_x(c)\) denote the number of components \({\hbox {Tr}}_m(xd_i)\) of \(\mathbf c (x)\) which are equal to c. By (3.1) we similarly have

$$\begin{aligned} N_x(c)= & {} \frac{n}{p} +\frac{1}{p} \sum _{j=1}^{p-1}\sigma _j(\zeta _p^{-c})\sigma _j(\psi (xD)) \\= & {} \frac{n}{p} +\frac{1}{p} \sum _{j=1}^{p-1}\sigma _j(\zeta _p^{-c})\sigma _j\left( \frac{1}{e} \sum _{z \in \mathbb {F}_q^*}\psi (xf(z))\right) \\= & {} \frac{n}{p} +\frac{1}{ep} \sum _{j=1}^{p-1}\sigma _j(\zeta _p^{-c})\sigma _j\left( -1+ \sum _{z \in \mathbb {F}_q}\psi (xf(z))\right) , \end{aligned}$$

where \(\sigma _j (1 \le j \le p-1)\) is the automorphism of \(\mathbb {Q}(\zeta _p)\) defined by \(\sigma _j(\zeta _p)=\zeta _p^j\).

In general, the dimension k of \({\mathcal {C}}_D\) is equal to m. When \(e \ge \sqrt{q}+1,\,k\) may be less than m. For example, if m is an even integer and \(f(x)=x^{p^{\frac{m}{2}}+1}\), then we have \(e=\sqrt{q}+1\) and the dimension of the linear code \({\mathcal {C}}_D\) is \(\frac{m}{2}\). However, the complete weight enumerator of \({\mathcal {C}}_D\) can be similarly given by replacing the frequencies. Without loss of generality, we assume that the dimension of \({\mathcal {C}}_D\) is m in this section.

Theorem 4.2

Let \({\mathcal {C}}_D\) be the linear code defined by (1.1) and \(D=\{f(x): x \in \mathbb {F}_q\}\setminus \{0\}\), where f(x) is a quadratic form over \(\mathbb {F}_q\) of rank r satisfying Conditions (I) and (II).

  1. (1)

    If r is odd, then the complete weight enumerator of \({\mathcal {C}}_D\) is

    $$\begin{aligned}&z_0^{\frac{p^m-1}{e}}+\frac{p^m-1}{2} z_0^{\frac{p^{m-1}-1}{e}}\prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=1 \end{array}}z_c^{\frac{p^{m-1}+p^{m-\frac{r+1}{2}}}{e}} \prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=-1 \end{array}}z_c^{\frac{p^{m-1}-p^{m-\frac{r+1}{2}}}{e}} \nonumber \\&\qquad +\, \frac{p^m-1}{2} z_0^{\frac{p^{m-1}-1}{e}}\prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=1 \end{array}}z_c^{\frac{p^{m-1}-p^{m-\frac{r+1}{2}}}{e}} \prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=-1 \end{array}}z_c^{\frac{p^{m-1}+p^{m-\frac{r+1}{2}}}{e}}. \end{aligned}$$
  2. (2)

    If r is even, then the complete weight enumerator of \({\mathcal {C}}_D\) is

    $$\begin{aligned}&z_0^{\frac{p^m-1}{e}}+\frac{p^m-1}{2} z_0^{\frac{p^{m-1}+p^{m-\frac{r}{2}}-p^{m-1-\frac{r}{2}}-1}{e}}(z_1z_2 \ldots z_{p-1})^{\frac{p^{m-1}-p^{m-1- \frac{r}{2}}}{e}} \\&\qquad +\, \frac{p^m-1}{2} z_0^{\frac{p^{m-1}-p^{m-\frac{r}{2}}+p^{m-1-\frac{r}{2}}-1}{e}}(z_1z_2 \ldots z_{p-1})^{\frac{p^{m-1}+p^{m-1- \frac{r}{2}}}{e}}. \end{aligned}$$

Proof

(1) If r is odd, then by Lemma 2.2 we have

$$\begin{aligned} \sum _{z \in \mathbb {F}_q}\psi (xf(z))=\pm p^{m-\frac{r+1}{2}} \sqrt{p*} \text{ for } \text{ all } x \in \mathbb {F}_q^*, \end{aligned}$$

where \(p^*=\big (\frac{-1}{p}\big )p\). If \(c \in \mathbb {F}_p^*\), then

$$\begin{aligned} N_x(c)= & {} \frac{n}{p} +\frac{1}{ep} \sum _{j=1}^{p-1}\sigma _j(\zeta _p^{-c})\sigma _j(-1 \pm p^{m-\frac{r+1}{2}} \sqrt{p*}) \\= & {} \frac{n}{p} +\frac{1}{ep} \sum _{j=1}^{p-1}\zeta _p^{-jc}\left( -1 \pm p^{m-\frac{r+1}{2}} \bigg (\frac{j}{p}\bigg ) \sqrt{p*}\right) \ \ \ \ \ \ \ \ \ \ \text{(by } \text{(2.1)) } \\= & {} \frac{n}{p} +\frac{1}{ep} \left( -\sum _{j=1}^{p-1}\zeta _p^{-jc} \pm p^{m-\frac{r+1}{2}} \sqrt{p*}\sum _{j=1}^{p-1}\zeta _p^{-jc} \bigg (\frac{j}{p}\bigg )\right) \\= & {} \frac{n}{p} +\frac{1}{ep} \left( 1 \pm p^{m-\frac{r+1}{2}} \sqrt{p*} \bigg (\frac{-c}{p}\bigg )\sqrt{p*}\right) \ \ \ \ \ \ \ \ \ \ \text{(by } \text{ Lemma } \text{2.1) } \\= & {} \frac{p^{m-1} \pm (\frac{c}{p})p^{m-\frac{r+1}{2}}}{e}. \end{aligned}$$

Now we are going to determine the frequency of each composition. Denote

$$\begin{aligned} n^+= & {} \left| \left\{ x \in \mathbb {F}_q^*: \sum _{z \in \mathbb {F}_q}\psi (xf(z))=p^{m-\frac{r+1}{2}} \sqrt{p*}\right\} \right| ,\\ n^-= & {} \left| \left\{ x \in \mathbb {F}_q^*: \sum _{z \in \mathbb {F}_q}\psi (xf(z))=-p^{m-\frac{r+1}{2}} \sqrt{p*}\right\} \right| . \end{aligned}$$

By Condition (I) we have

$$\begin{aligned} \sum _{x \in \mathbb {F}_q^*}\sum _{z \in \mathbb {F}_q}\psi (xf(z))=q-1+(q-1)\cdot (-1)=0. \end{aligned}$$

Thus

$$\begin{aligned} n^+ \cdot p^{m-\frac{r+1}{2}}-n^- \cdot p^{m-\frac{r+1}{2}}=0. \end{aligned}$$

Note that \(n^+ + n^-=q-1\) and \(N_x(0)=n-\sum \limits _{c \in \mathbb {F}_p^*}N_x(c)\). Then \(n^+=n^-=\frac{q-1}{2}\) and we get the complete weight enumerator of \({\mathcal {C}}_D\).

(2) If r is even, then by Lemma 2.2 we have

$$\begin{aligned} \sum _{z \in \mathbb {F}_q}\psi (xf(z))=\pm p^{m-\frac{r}{2}} \in \mathbb {Q} \text{ for } \text{ all } x \in \mathbb {F}_q^*. \end{aligned}$$

Thus \(\sigma _j(\sum \limits _{z \in \mathbb {F}_q}\psi (xf(z)))=\pm p^{m-\frac{r}{2}}\) for all \(j=1, 2, \ldots , p-1\). The remainder of the proof is very similar to that of (1) and we omit it here. \(\square \)

We remark that the weight enumerator of \({\mathcal {C}}_D\) has been presented in [12]. By Theorem 4.2, we can also obtain the weight enumerator of the code \({\mathcal {C}}_D\), which conforms to the results presented in [12].

5 The third case

In this section, we present the complete weight enumerator of the linear code \({\mathcal {C}}_D\) when \(D=\{z \in \mathbb {F}_{p^m}^*: {\text {Tr}}_s(z^{p^s+1})=0\}\), where m is even and \(m=2s\).

We begin to determine the length of the linear code \({\mathcal {C}}_D\). By the orthogonal property of additive characters we have

$$\begin{aligned} n= & {} |\{z \in \mathbb {F}_q^*: {\text {Tr}}_s(z^{p^s+1})=0\}| \nonumber \\= & {} \sum _{z\in \mathbb {F}_q^*} \frac{1}{p} \sum _{y \in \mathbb {F}_p} \zeta _p^{y {\hbox {Tr}}_s(z^{p^s+1})} \nonumber \\= & {} \frac{q-1}{p}-\frac{p-1}{p} +\frac{1}{p} \sum _{y \in \mathbb {F}_p^*}\sum _{z\in \mathbb {F}_q}\zeta _p^{y {\hbox {Tr}}_s(z^{p^s+1})} \nonumber \\= & {} \frac{q-p}{p} +\frac{1}{p} \sum _{j=1}^{p-1}\sigma _j\left( \sum _{z\in \mathbb {F}_q}\zeta _p^{{\hbox {Tr}}_s(z^{p^s+1})}\right) \nonumber \\= & {} \frac{q-p}{p} +\frac{1}{p} \sum _{j=1}^{p-1}\sigma _j(-p^s) \ \ \ \ \ \ \ \ \ \ \text{(by } \text{ Lemma } \text{2.3) } \nonumber \\= & {} (p^s+1)(p^{s-1}-1), \end{aligned}$$
(5.1)

where \(\sigma _j (1 \le j \le p-1)\) is the automorphism of \(\mathbb {Q}(\zeta _p)\) defined by \(\sigma _j(\zeta _p)=\zeta _p^j\).

For a codeword \(\mathbf c (x)\) of \({\mathcal {C}}_D,\,x \in \mathbb {F}_q^*\), and \(c \in \mathbb {F}_p^*\), let \(N_x(c)\) denote the number of components \({\hbox {Tr}}_m(xd)\) of \(\mathbf c (x)\) which are equal to c when d runs over D. Then

$$\begin{aligned} N_x(c)= & {} |\{z \in \mathbb {F}_q^*: {\text {Tr}}_s(z^{p^s+1})=0 \text{ and } {\text {Tr}}_m(xz)=c\}| \nonumber \\= & {} \sum _{z \in \mathbb {F}_q^*} \left( \frac{1}{p} \sum _{y_1 \in \mathbb {F}_p} \zeta _p^{y_1 {\text {Tr}}_s(z^{p^s+1})}\right) \left( \frac{1}{p} \sum _{y_2 \in \mathbb {F}_p} \zeta _p^{y_2 ({\text {Tr}}_m(xz)-c)}\right) \nonumber \\= & {} \frac{q-1}{p^2}+ \frac{1}{p^2}\sum _{y_1 \in \mathbb {F}_p^*}\sum _{z\in \mathbb {F}_q^*}\zeta _p^{y_1 {\hbox {Tr}}_s(z^{p^s+1})}+\frac{1}{p^2}\sum _{y_2 \in \mathbb {F}_p^*}\sum _{z \in \mathbb {F}_q^*}\zeta _p^{y_2 ({\hbox {Tr}}_m(xz)-c)} \nonumber \\&+\, \frac{1}{p^2}\sum _{y_1 \in \mathbb {F}_p^*}\sum _{y_2 \in \mathbb {F}_p^*}\sum _{z\in \mathbb {F}_q^*}\zeta _p^{y_1 {\hbox {Tr}}_s(z^{p^s+1})+y_2 ({\hbox {Tr}}_m(xz)-c)}. \end{aligned}$$
(5.2)

Theorem 5.1

Let \({\mathcal {C}}_D\) be the linear code defined by (1.1) and \(D=\{z \in \mathbb {F}_{p^m}^*: {\text {Tr}}_s(z^{p^s+1})=0\}\), where m is even and \(m=2s\) for an integer \(s>1\). Then \({\mathcal {C}}_D\) is a \([(p^s+1)(p^{s-1}-1), m]\) linear code and its complete weight enumerator is

$$\begin{aligned}&z_0^{(p^s+1)(p^{s-1}-1)}+(p^s+1)(p^{s-1}-1)z_0^{p^{m-2} -p^s+p^{s-1}-1}(z_1z_2\ldots z_{p-1})^{p^{m-2}} \\&\qquad +\,(p^s+1)(p^s-p^{s-1})z_0^{p^{m-2}-1}(z_1z_2\ldots z_{p-1})^{p^{m-2}-p^{s-1}}. \end{aligned}$$

Proof

Note that \(n=(p^s+1)(p^{s-1}-1)> p^s+1\). Then the dimension of \({\mathcal {C}}_D\) is m. By (5.1) we have

$$\begin{aligned} \sum _{y_1 \in \mathbb {F}_p^*}\sum _{z\in \mathbb {F}_q^*}\zeta _p^{y_1 {\hbox {Tr}}_s(z^{p^s+1})}=-(p-1)(p^s+1). \end{aligned}$$

It is easily checked that

$$\begin{aligned} \sum _{y_2 \in \mathbb {F}_p^*}\sum _{z \in \mathbb {F}_q^*}\zeta _p^{y_2 ({\hbox {Tr}}_m(xz)-c)}=\sum _{j=1}^{p-1}\zeta _p^{-jc}\sigma _j\left( \sum _{z \in \mathbb {F}_q^*}\zeta _p^{{\hbox {Tr}}_m(xz)}\right) =1. \end{aligned}$$

We are now ready to compute the third sum of (5.2).

$$\begin{aligned}&\sum _{y_1 \in \mathbb {F}_p^*}\sum _{y_2 \in \mathbb {F}_p^*}\sum _{z\in \mathbb {F}_q^*}\zeta _p^{y_1 {\hbox {Tr}}_s(z^{p^s+1})+y_2 ({\hbox {Tr}}_m(xz)-c)}\\&\quad = \sum _{y_2 \in \mathbb {F}_p^*}\zeta _p^{-y_2c}\sum _{y_1 \in \mathbb {F}_p^*}\sum _{z\in \mathbb {F}_q^*}\zeta _p^{{\hbox {Tr}}_s(y_1z^{p^s+1})+{\hbox {Tr}}_m(y_2 xz)} \\&\quad = \sum _{y_2 \in \mathbb {F}_p^*}\zeta _p^{-y_2c}\sum _{y_1 \in \mathbb {F}_p^*}\left( -1+\sum _{z\in \mathbb {F}_q}\zeta _p^{{\hbox {Tr}}_s(y_1z^{p^s+1})+{\hbox {Tr}}_m(y_2 xz)}\right) \\&\quad = \sum _{y_2 \in \mathbb {F}_p^*}\zeta _p^{-y_2c}\left( -(p-1)-p^s\sum _{y_1 \in \mathbb {F}_p^*}\zeta _p^{-{\text {Tr}}_s(\frac{(y_2x)^{p^s+1}}{y_1})}\right) \ \ \ \ \ \ \ \ \ \ \text{(by } \text{ Lemma } \text{2.3) } \\&\quad = -(p-1)\sum _{y_2 \in \mathbb {F}_p^*}\zeta _p^{-y_2c}-p^s\sum _{y_2 \in \mathbb {F}_p^*}\zeta _p^{-y_2c}\sum _{y_1 \in \mathbb {F}_p^*}\zeta _p^{-y_1y_2^2{\text {Tr}}_s(x^{p^s+1})} \\&\quad = \left\{ \begin{array}{ll} p-1-p^s(p-1)\sum \limits _{y_2 \in \mathbb {F}_p^*}\zeta _p^{-y_2c}=(p-1)(p^s+1), &{} \text{ if } {\text {Tr}}_s(x^{p^s+1})=0; \\ p-1+p^s\sum \limits _{y_2 \in \mathbb {F}_p^*}\zeta _p^{-y_2c}=p-1-p^s, &{} \text{ if } {\text {Tr}}_s(x^{p^s+1})\ne 0. \end{array}\right. \end{aligned}$$

Then, for \(c \in \mathbb {F}_p^*\), by (5.2) we have

$$\begin{aligned} N_x(c)=\left\{ \begin{array}{ll} p^{m-2}, &{} \text{ if } {\text {Tr}}_s(x^{p^s+1})=0; \\ p^{m-2}-p^{s-1}, &{} \text{ if } {\text {Tr}}_s(x^{p^s+1})\ne 0. \end{array}\right. \end{aligned}$$

Now we are going to determine the frequency of each composition. It is well-known that the norm function \(N: \mathbb {F}_{p^{2s}} \rightarrow \mathbb {F}_{p^s}\) defined by \(N(x)=x^{p^s+1}\) is \((p^s+1)\)-to-1 except for \(N(0)=0\) and \({\text {Tr}}_s:\mathbb {F}_{p^s} \rightarrow \mathbb {F}_p\) is \(p^{s-1}\)-to-1. Then

$$\begin{aligned} |\{x \in \mathbb {F}_{p^m}^*: {\text {Tr}}_s(x^{p^s+1})=0\}|=(p^s+1)|\{x \in \mathbb {F}_{p^s}^*: {\text {Tr}}_s(x)=0\}|=(p^s+1)(p^{s-1}-1) \end{aligned}$$

and

$$\begin{aligned} \big |\big \{x \in \mathbb {F}_{p^m}^*: {\text {Tr}}_s(x^{p^s+1})\ne 0\big \}\big |=(p^s+1)(p^s-p^{s-1}). \end{aligned}$$

Therefore, we can get the complete weight enumerator of \({\mathcal {C}}_D\) and this completes the proof. \(\square \)

From Theorem 5.1, we can see that the values of \(N_x(c)\) are independent of \(c \in \mathbb {F}_p^*\). In addition, the weight enumerator of \({\mathcal {C}}_D\) can be determined and \({\mathcal {C}}_D\) is a two-weight linear code.

It is clear that Lemma 2.3 plays a key role in the proof of Theorem 5.1. In fact, the exponential sums determined by Coulter [7] are more general. It will be nice if the complete weight enumerators of more linear codes \({\mathcal {C}}_D\) can be given by using the general exponential sums.

6 Applications

In this section, we employ the complete weight enumerators of the linear codes \({\mathcal {C}}_D\) to construct constant composition codes and systematic authentication codes.

6.1 Constant composition codes

Let \(S=\{s_0, s_1, \ldots , s_{p-1}\}\) be an alphabet of size p, where p is a positive integer (not necessarily a prime). An \((n, M, d, (t_0, t_1, \ldots , t_{p-1}), p)\) constant composition code over S is a subset \({\mathcal {C}} \subset S^n\) of size M and minimum Hamming distance d such that each codeword has the same composition \((t_0, t_1, \ldots , t_{p-1})\). Thus the complete weight enumerator of the constant composition code has only one term.

The constant composition codes have many applications in communications engineering [6, 40]. Many elegant methods are proposed to construct constant composition codes with excellent parameters in recent years [5, 6, 8, 9, 16, 18, 19, 22, 25, 26, 3436, 44]. The LFVC bound of constant composition codes is described in the following lemma.

Lemma 6.1

[36] If \(nd-n^2+(t_0^2+t_1^2+\cdots +t_{p-1}^2) >0\), then

$$\begin{aligned} M \le \frac{nd}{nd-n^2+(t_0^2+t_1^2+\cdots +t_{p-1}^2)}. \end{aligned}$$

Now we begin to construct several constant composition codes which are subcodes of the linear codes \({\mathcal {C}}_D\). A new class of optimal constant composition codes with respect to the LFVC bound are presented. In fact, every term of the complete weight enumerators gives a constant composition code.

Let \({\mathcal {C}}_D\) be a linear code defined by (1.1) and \(D=\{f(x): x \in \mathbb {F}_q\}\setminus \{0\}\), where f(x) is a quadratic form of rank r over \(\mathbb {F}_q\) satisfying Conditions (I) and (II). By Theorem 4.2, we can get the following constant composition codes \({\mathcal {C}}\) over \(\mathbb {F}_p\) which contain a new class of optimal constant composition codes with respect to the LFVC bound.

Theorem 6.2

Let p be an odd prime and m a positive integer. There exist the following \((n, M, d, (t_0, t_1, \ldots , t_{p-1}), p)\) constant composition codes \({\mathcal {C}}\).

  1. (1)

    \(n=\frac{p^m-1}{e},\,M=\frac{p^m-1}{2},\,d=\frac{(p-1)p^{m-1}}{e},\,t_0=\frac{p^{m-1}-1}{e},\,t_c=\frac{p^{m-1}+p^{\frac{m-1}{2}}}{e}\) for \(\big (\frac{c}{p}\big )=1\), and \(t_c=\frac{p^{m-1}-p^{\frac{m-1}{2}}}{e}\) for \(\big (\frac{c}{p}\big )=-1\), where m is odd. This is an optimal constant composition code with respect to the LFVC bound.

  2. (2)

    \(n=\frac{p^m-1}{e},\,M=\frac{p^m-1}{2},\,d=\frac{(p-1)(p^{m-1}-p^{m-1-\frac{r}{2}})}{e},\,t_0=\frac{p^{m-1}+p^{m-\frac{r}{2}}-p^{m-1-\frac{r}{2}}-1}{e}\), and \(t_c=\frac{p^{m-1}-p^{m-1- \frac{r}{2}}}{e}\) for \(c \ne 0\), where r is even.

  3. (3)

    \(n=\frac{p^m-1}{e},\,M=\frac{p^m-1}{2},\,d=\frac{(p-1)(p^{m-1}-p^{m-1-\frac{r}{2}})}{e},\,t_0=\frac{p^{m-1}-p^{m-\frac{r}{2}}+p^{m-1-\frac{r}{2}}-1}{e}\), and \(t_c=\frac{p^{m-1}+p^{m-1- \frac{r}{2}}}{e}\) for \(c \ne 0\), where r is even.

Proof

We can immediately get (2) and (3), so we only need to prove (1). If r is odd, by Theorem 4.2, an \((n, M, d, (t_0, t_1, \ldots , t_{p-1}), p)\) constant composition code \({\mathcal {C}}\) over \(\mathbb {F}_p\) can be given, where \(n=\frac{p^m-1}{e},\,M=\frac{p^m-1}{2},\,d=\frac{(p-1)p^{m-1}}{e},\,t_0=\frac{p^{m-1}-1}{e},\,t_c=\frac{p^{m-1}+p^{m-\frac{r+1}{2}}}{e}\) for \(\big (\frac{c}{p}\big )=1\), and \(t_c=\frac{p^{m-1}-p^{m-\frac{r+1}{2}}}{e}\) for \(\big (\frac{c}{p}\big )=-1\). In this case, we have \(nd-n^2+(t_0^2+t_1^2+\cdots +t_{p-1}^2) >0\) and

$$\begin{aligned} \frac{nd}{nd-n^2+(t_0^2+t_1^2+\cdots +t_{p-1}^2)}=\frac{p^m-1}{p^{m-r}+1}. \end{aligned}$$

Then

$$\begin{aligned} M=\frac{p^m-1}{2} \le \frac{p^m-1}{p^{m-r}+1} \end{aligned}$$

by Lemma 6.1, so \(p^{m-r}+1 \le 2\) and this leads to \(m=r\). Thus we can get the desired conclusions and this completes the proof. \(\square \)

By the proof of Theorem 6.2, if r is odd, then \(m=r\) and the complete weight enumerator of the linear code \({\mathcal {C}}_D\) presented in Theorem 4.2 is

$$\begin{aligned}&z_0^{\frac{p^m-1}{e}}+\frac{p^m-1}{2} z_0^{\frac{p^{m-1}-1}{e}}\prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=1 \end{array}}z_c^{\frac{p^{m-1}+p^{\frac{m-1}{2}}}{e}} \prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=-1 \end{array}}z_c^{\frac{p^{m-1}-p^{\frac{m-1}{2}}}{e}} \nonumber \\&\qquad +\, \frac{p^m-1}{2} z_0^{\frac{p^{m-1}-1}{e}}\prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=1 \end{array}}z_c^{\frac{p^{m-1}-p^{\frac{m-1}{2}}}{e}} \prod _{\begin{array}{c} c \in \mathbb {F}_p^* \\ (\frac{c}{p})=-1 \end{array}}z_c^{\frac{p^{m-1}+p^{\frac{m-1}{2}}}{e}}. \end{aligned}$$

Ding and Yin [17] presented a class of optimal constant composition codes with following parameters: \(n=\frac{p^m-1}{2},\,M=\frac{p^m-1}{2},\,d=\frac{(p-1)p^{m-1}}{2},\,t_0=\frac{p^{m-1}-1}{2},\,t_c=\frac{p^{m-1}+p^{\frac{m-1}{2}}}{2}\) for \(\big (\frac{c}{p}\big )=1\), and \(t_c=\frac{p^{m-1}-p^{\frac{m-1}{2}}}{2}\) for \(\big (\frac{c}{p}\big )=-1\), where m is odd. In addition, the known optimal constant composition codes were shown in a table [22]. Therefore, Theorem 6.2 generalizes the results of [17] and gives a new class of optimal constant composition codes.

If D is a skew Hadamard difference set or Paley type partial difference set in \(\mathbb {F}_q\) and \({\mathcal {C}}_D\) is a linear code defined by (1.1), then the constant composition codes \({\mathcal {C}}\) over \(\mathbb {F}_p\) which are subcodes of \({\mathcal {C}}_D\) can also be given by Theorem 3.2. In fact, the parameters of these codes are contained in Theorem 6.2 and we omit them here.

6.2 Systematic authentication codes

A systematic authentication code is a four-tuple \(({\mathcal {S}}, {\mathcal {T}}, {\mathcal {K}}, \{E_\kappa : \kappa \in {\mathcal {K}}\})\), where \({\mathcal {S}}\) is the source state space associated with a probability distribution, \({\mathcal {T}}\) is the tag space, \({\mathcal {K}}\) is the key space, and \(E_\kappa : {\mathcal {S}} \rightarrow {\mathcal {T}}\) is called an encoding rule. For more details on the authentication codes, we refer the readers to [16, 20, 42]. Below we denote the maximum success probability of the impersonation attack and the substitution attack by \(P_I\) and \(P_S\), respectively. For the systematic authentication codes, there are two lower bonds on \(P_I\) and \(P_S\) [16, 41]:

$$\begin{aligned} P_I \ge \frac{1}{|{\mathcal {T}}|} \text{ and } P_S \ge \frac{1}{|{\mathcal {T}}|}. \end{aligned}$$

It is desired that \(P_I\) and \(P_S\) must be as small as possible.

Let \({\mathcal {C}}\) be an [nkd] linear code over \(\mathbb {F}_p\) and let \(\mathbf c _i=(c_{i,0}, c_{i,1}, \ldots , c_{i, n-1})\) be a codeword of \({\mathcal {C}},\,0 \le i \le p^k-1\). Define a systematic authentication code as follows:

$$\begin{aligned} ({\mathcal {S}}, {\mathcal {T}}, {\mathcal {K}}, \{E_\kappa : \kappa \in {\mathcal {K}}\})=(\mathbb {Z}_{p^k}, \mathbb {F}_p, \mathbb {Z}_n \times \mathbb {F}_p, \{E_\kappa : \kappa \in {\mathcal {K}}\}), \end{aligned}$$
(6.1)

where \(E_\kappa (s)=c_{s,\kappa _1}+\kappa _2\) for any \(s \in {\mathcal {S}}\) and \(\kappa =(\kappa _1, \kappa _2) \in {\mathcal {K}}\).

Lemma 6.3

[20] For the authentication code of (6.1), we have

$$\begin{aligned} P_{I}=\frac{1}{p} \text{ and } P_S=\max _{0 \ne \mathbf c \in {\mathcal {C}}}\max _{u \in \mathbb {F}_p} \frac{N_\mathbf{c }(u)}{n}, \end{aligned}$$

where \(N_\mathbf{c }(u)\) denotes the number of components of \(\mathbf c \) that are equal to u.

It is clear that the values of \(P_I\) and \(P_S\) are closely related to the complete weight enumerators of linear codes. There are three classes of authentication codes which are obtained from Theorems 3.2, 4.2, and 5.1 directly. By Lemma 6.3, we easily get the following result.

Theorem 6.4

If \(p^m\) is large enough, then we have \(P_{I}=\frac{1}{p}\) and \(P_S \approx \frac{1}{p}\) for all authentication codes obtained from Theorems 3.2, 4.2, and 5.1. Therefore, these authentication codes are asymptotically optimal.

7 Concluding remarks

In this paper, we used exponential sums and Galois theory to investigate the complete weight enumerators of the linear codes constructed from the defining sets D in the three cases. Furthermore, the explicit complete weight enumerators of the linear codes were employed to construct constant composition codes and systematic authentication codes. We obtained a new class of optimal constant composition codes and three classes of asymptotically optimal systematic authentication codes.