1 Introduction

Throughout this paper, let p be an odd prime and r = p m for an integer \(m\geqslant 2\). Denote by \(\mathbb {F}_{r}\) a finite field with r elements. An [n, κ, δ] linear code C over \(\mathbb {F}_{p}\) is a κ-dimensional subspace of \(\mathbb {F}_{p}^{n}\) with minimum distance δ (see [8, 27]).

Let A i denote the number of codewords with Hamming weight i in a linear code C of length n. The weight enumerator of C is defined by A 0 + A 1 z + A 2 z 2+⋯ + A n z n, where A 0 = 1. The sequence (1, A 1, A 2,⋯ , A n ) is called the weight distribution of the code C.

The complete weight enumerator of a code C over \(\mathbb {F}_{p}\) enumerates the codewords according to the number of symbols of each kind contained in each codeword. Denote elements of the field by \(\mathbb {F}_{p}=\{w_{0},w_{1},\cdots ,w_{p-1}\}\), where w 0 = 0. For a vector \(\mathsf {v}=(v_{0},v_{1},\cdots ,v_{n-1})\in \mathbb {F}_{p}^{n}\), the composition of v, denoted by comp(v), is defined as

$$\text{comp}(\mathsf{v})=(k_{0},k_{1},\cdots,k_{p-1}),$$

where k j is the number of components v i (0 ≤ in−1) of v that equal to w j . It is easy to see that \({\sum }_{j=0}^{p-1}k_{j}=n\). Let A(k 0, k 1,⋯ , k p−1) be the number of codewords cC with comp(c)=(k 0, k 1,⋯ , k p−1). Then the complete weight enumerator of the code C is the polynomial

$$\begin{array}{@{}rcl@{}} \text{CWE}(C) &=&\sum\limits_{\mathsf{c}\in C}w_{0}^{k_{0}}w_{1}^{k_{1}}{\cdots} w_{p-1}^{k_{p-1}}\\ &=&\sum\limits_{(k_{0},k_{1},\cdots,k_{p-1})\in B_{n}}A(k_{0},k_{1},\cdots,k_{p-1})w_{0}^{k_{0}}w_{1}^{k_{1}}{\cdots} w_{p-1}^{k_{p-1}}, \end{array} $$

where \( B_{n}=\left \{(k_{0},k_{1},\cdots ,k_{p-1}): 0 \leqslant k_{j} \leqslant n, {\sum }_{j=0}^{p-1}k_{j}=n \right \} \).

The weight distributions of linear codes have been well studied in the literature (see [12, 16, 17, 26, 29, 31, 32, 3538] and references therein). The information of the complete weight enumerators of linear codes is of vital use because they not only give the weight enumerators but also show the frequency of each symbol appearing in each codeword. Therefore, they have many applications. Blake and Kith investigated the complete weight enumerator of Reed-Solomon codes and showed that they could be helpful in soft decision decoding [4, 20]. In [18], the study of the monomial and quadratic bent functions was related to the complete weight enumerators of linear codes. It was illustrated by Ding et al. [10, 11] that complete weight enumerators can be applied to the calculation of the deception probabilities of certain authentication codes. In [6, 7, 13], the authors studied the complete weight enumerators of some constant composition codes and presented some families of optimal constant composition codes.

However, it is extremely difficult to evaluate the complete weight enumerators of linear codes in general and there is little information on this topic in the literature besides the above mentioned [4, 6, 7, 13, 20]. Kuzmin and Nechaev investigated the generalized Kerdock code and related linear codes over Galois rings and determined their complete weight enumerators in [21] and [22]. Further recent progress on the complete weight enumerators of linear codes can be found in [1, 2, 19, 23, 24, 33]. The results of [1] and [2] can be viewed as generalizations of [34] and [15], respectively. In [19, 23, 24, 33], the authors treated the complete weight enumerators of some linear or cyclic codes using exponential sums and Galois theory. Recently Tang et al. constructed linear codes with two or three weights from weakly regular bent functions in [30]. We shall extend this construction to non-bent functions.

The authors of [9, 14, 15] gave the generic construction of linear codes. Set \(\bar {D}=\{d_{1},d_{2},\cdots ,d_{n}\}\subseteq \mathbb {F}_{r}\). Denote by Tr the absolute trace function. A linear code associated with \(\bar {D}\) is defined by

$$ C_{\bar{D}}=\{(\text{Tr}(ad_{1}),\text{Tr}(ad_{2}),\cdots,\text{Tr}(ad_{n})): a\in \mathbb{F}_{r}\}. $$

Then \(\bar {D}\) is called the defining set of this code \(C_{\bar {D}}\).

Motivated by the above construction and the idea of [30], we define linear codes C D and \(C_{D_{1}}\) by

$$\begin{array}{@{}rcl@{}} &C_{D}&=\{(\text{Tr}(ax^{2}))_{x\in D}: a\in \mathbb{F}_{r}\},\\ &C_{D_{1}}&=\{(\text{Tr}(ax^{2}))_{x\in D_{1}}: a\in \mathbb{F}_{r}\}, \end{array} $$
(1)

where

$$\begin{array}{@{}rcl@{}} &D &=\{x\in \mathbb{F}_{r}^{*}:\text{Tr}(x)\in Sq\},\\ &D_{1}&=\{x\in \mathbb{F}_{r}^{*}:\text{Tr}(x)\in Nsq\}, \end{array} $$

which are called defining sets. Here Sq and Nsq denote the set of all squares and non-squares in \(\mathbb {F}_{p}^{*}\), respectively. By definition, these codes have length n = (p−1)p m−1/2 and dimension at most m. Further, we will demonstrate that C D is equal to \(C_{D_{1}}\). Actually, for a fixed bNsq, there exists a mapping ϕ b such that

$$\begin{array}{@{}rcl@{}} \phi_{b} : &D &\rightarrow D_{1}\\ &x& \mapsto bx \end{array} $$

which implies that Tr(a(ϕ b (x))2)=Tr(ab 2 x 2) for all xD and \(a\in \mathbb {F}_{r}\) . As a runs through \(\mathbb {F}_{r}\), so does ab 2. This means they have the same codewords. Hence, we only describe all the information of C D . In this paper, the complete weight enumerator of C D is investigated by employing exponential sums and Gauss periods. This gives its weight enumerator immediately. As it turns out, this code is a three-weight linear code which will be of special interest in authentication codes [11] and secret sharing schemes [5].

The remainder of this paper is organized as follows. In Section 2, we describe the main results of this paper and give some examples. Section 3 briefly recalls some definitions and results on Gauss periods and Gauss sums, then proves the main results. Finally, Section 4 is devoted to conclusions.

2 Main results

In this section, we only introduce the complete weight enumerator and weight enumerator of C D described in (1). The main results of this paper are presented below, whose proofs will be given in Section 3.

First of all, we establish the complete weight enumerator of C D in the following three theorems, then we give some examples to illustrate these results.

Theorem 1

Let p≡3 mod 4 and ρ,z be elements in \(\mathbb {F}_{p}\) . Then the code C D defined by ( 1 ) is a \(\left [\frac {p-1}{2}p^{m-1},m\right ]\) three-weight linear code and we have the following assertions.

  1. (i)

    If m is even, then the complete weight enumerator of C D is given by

    $$\begin{array}{@{}rcl@{}} &&w_{0}^{\frac{p-1}{2}p^{m-1}}+(p^{m-1}-1)\prod\limits_{\rho\in \mathbb{F}_{p}}w_{\rho}^{\frac{p-1}{2}p^{m-2}}\\ &&+\frac{p-1}{4}\left( p^{m-1}\,+\,p^{\frac{m-2}{2}}\right)w_{0}^{\frac{p-1}{2}\left( p^{m-2}-p^{\frac{m-2}{2}}\right)} \sum\limits_{i\in \{1,-1\}}{\prod}_{\left( \frac{\rho}{p}\right)=i}w_{\rho}^{\frac{p-1}{2}p^{m-2}} {\prod}_{\left( \frac{z}{p}\right)=-i}w_{z}^{A_{1}}\\ &&+\frac{p-1}{4}\left( p^{m-1}\,-\,p^{\frac{m-2}{2}}\right)w_{0}^{\frac{p-1}{2}(p^{m-2}+p^{\frac{m-2}{2}})} \sum\limits_{i \in \{1,-1\}}\prod\limits_{\left( \frac{\rho}{p}\right)=i}w_{\rho}^{\frac{p-1}{2}p^{m-2}} \prod\limits_{\left( \frac{z}{p}\right)=-i}w_{z}^{A_{-1}}, \end{array} $$

    where, for ε∈{1,−1},

    $$\begin{array}{@{}rcl@{}} A_{\varepsilon}=\frac{p-1}{2}p^{m-2}+\varepsilon p^{\frac{m-2}{2}}. \end{array} $$
  2. (ii)

    If m is odd, then the complete weight enumerator of C D is given by

    $$\begin{array}{@{}rcl@{}} &&w_{0}^{\frac{p-1}{2}p^{m-1}}+(p^{m-1}-1)\prod\limits_{\rho\in \mathbb{F}_{p}}w_{\rho}^{\frac{p-1}{2}p^{m-2}}\\ &&+\frac{p-1}{4}\left( p^{m-1}\,+\,p^{\frac{m-1}{2}}\right)w_{0}^{\frac{p-1}{2}\left( p^{m-2}-p^{\frac{m-3}{2}}\right)} \sum\limits_{i\in\{1,-1\}}\prod\limits_{\left( \frac{\rho}{p}\right)=i}w_{\rho}^{A_{1}}\prod\limits_{\left( \frac{z}{p}\right)=-i}w_{z}^{B_{1}}\\ &&+\frac{p-1}{4}\left( p^{m-1}\,-\,p^{\frac{m-1}{2}}\right)w_{0}^{\frac{p-1}{2}\left( p^{m-2}+p^{\frac{m-3}{2}}\right)} \sum\limits_{i\in\{1,-1\}}{\prod}_{\left( \frac{\rho}{p}\right)=i}w_{\rho}^{A_{-1}} \prod\limits_{\left( \frac{z}{p}\right)=-i}w_{z}^{B_{-1}}, \end{array} $$

    where, for ε∈{1,−1},

    $$\begin{array}{@{}rcl@{}} A_{\varepsilon} &=&\frac{p-1}{2}\left( p^{m-2}-\varepsilon p^{\frac{m-3}{2}}\right),\\ B_{\varepsilon} &=&\frac{p-1}{2}p^{m-2}+\varepsilon\frac{p+1}{2}p^{\frac{m-3}{2}}. \end{array} $$

Example 1

  1. (i)

    Let (p, m)=(3,5). Then by Theorem 1, the code C D has parameters [81,5,51] and complete weight enumerator

    $$\begin{array}{@{}rcl@{}} w_{0}^{81}&+&36w_{0}^{30}w_{1}^{30}w_{2}^{21}+36w_{0}^{30}w_{1}^{21}w_{2}^{30}+80w_{0}^{27}w_{1}^{27}w_{2}^{27}\\ &+&45w_{0}^{24}w_{1}^{33}w_{2}^{24}+45w_{0}^{24}w_{1}^{24}w_{2}^{33}, \end{array} $$

    which is confirmed by Magma. This is a three-weight linear code.

  2. (ii)

    Let (p, m)=(7,2). Then by Theorem 1, the code C D is a [21,2,15] three-weight linear code with complete weight enumerator

    $$\begin{array}{@{}rcl@{}} w_{0}^{21}&+&6(w_{0}w_{1}w_{2} w_{3}w_{4} w_{5}w_{6})^{3}+9{w_{0}^{6}}(w_{1}w_{2}w_{4})^{3}(w_{3}w_{5}w_{6})^{2}\\ &+&9{w_{0}^{6}}(w_{1}w_{2}w_{4})^{2}(w_{3}w_{5}w_{6})^{3}+12(w_{1}w_{2}w_{4})^{4}(w_{3}w_{5}w_{6})^{3}\\ &+&12(w_{1}w_{2}w_{4})^{3}(w_{3}w_{5}w_{6})^{4}, \end{array} $$

    which is confirmed by Magma.

Let p≡1 mod 4. For i = 0,1,2,3, we denote the cyclotomic classes of order 4 in \(\mathbb {F}_{p}\) by \(C_{i}^{(4,p)}\), which is simplified as C i in the sequel and defined in Section 3.1.

Theorem 2

Let p≡1 mod 4 and m be odd. Then the code C D of ( 1 ) is a \(\left [\frac {p-1}{2}p^{m-1},m\right ]\) three-weight linear code with complete weight enumerator

$$\begin{array}{@{}rcl@{}} &&w_{0}^{\frac{p-1}{2}p^{m-1}}+(p^{m-1}-1)\prod\limits_{\rho\in \mathbb{F}_{p}}w_{\rho}^{\frac{p-1}{2}p^{m-2}}\\ &&+\frac{p-1}{8}\left( p^{m-1}+ p^{\frac{m-1}{2}}\right)\sum\limits_{i=0}^{3} w_{0}^{\frac{p-1}{2}\left( p^{m-2}-p^{\frac{m-3}{2}}\right)} \prod\limits_{\rho\in C_{i}}w_{\rho}^{A_{1}} \prod\limits_{z\in \mathbb{F}_{p}^{*}\setminus C_{i}}w_{z}^{B_{1}}\\ &&+\frac{p-1}{8}\left( p^{m-1}- p^{\frac{m-1}{2}}\right)\sum\limits_{i=0}^{3} w_{0}^{\frac{p-1}{2}\left( p^{m-2}+p^{\frac{m-3}{2}}\right)} \prod\limits_{\rho\in C_{i}}w_{\rho}^{A_{-1}} \prod\limits_{z\in \mathbb{F}_{p}^{*}\setminus C_{i}}w_{z}^{B_{-1}} ,\end{array} $$

where, for ε∈{1,−1},

$$\begin{array}{@{}rcl@{}} A_{\varepsilon}&=& \frac{p-1}{2}p^{m-2}+\frac{\varepsilon} {2}\left( 3 p^{\frac{m-1}{2}}+p^{\frac{m-3}{2}}\right),\\ B_{\varepsilon} &=& \frac{p-1}{2}p^{m-2}- \frac{\varepsilon} {2}\left( p^{\frac{m-1}{2}}-p^{\frac{m-3}{2}}\right). \end{array} $$

Example 2

Let (p, m)=(5,3). Then by Theorem 2, the code C D is a three-weight linear code with parameters [50,3,38] and complete weight enumerator

$$\begin{array}{@{}rcl@{}} w_{0}^{50}&+&10(w_{0}w_{1}w_{2}w_{3})^{12}{w_{4}^{2}}+10(w_{0}w_{1}w_{2}w_{4})^{12}{w_{3}^{2}}+10(w_{0}w_{1}w_{3}w_{4})^{12}{w_{2}^{2}}\\ &+&10(w_{0}w_{2}w_{3}w_{4})^{12}{w_{1}^{2}}+24(w_{0}w_{1}w_{2}w_{3}w_{4})^{10}+15(w_{0}w_{1}w_{2}w_{3})^{8}w_{4}^{18}\\ &+&15(w_{0}w_{1}w_{2}w_{4})^{8}w_{3}^{18}+15(w_{0}w_{1}w_{3}w_{4})^{8}w_{2}^{18}+15(w_{0}w_{2}w_{3}w_{4})^{8}w_{1}^{18}. \end{array} $$

These results coincide with numerical computation by Magma.

Theorem 3

Let p≡1 mod 4 and m be even. Let s and t be defined by p=s 2 +t 2 , s≡1 mod 4. Then the code C D of ( 1 ) is a \(\left [\frac {p-1}{2}p^{m-1},m\right ]\) three-weight linear code with complete weight enumerator

$$\begin{array}{@{}rcl@{}} &&w_{0}^{\frac{p-1}{2}p^{m-1}}+(p^{m-1}-1)\prod\limits_{\rho\in \mathbb{F}_{p}}w_{\rho}^{\frac{p-1}{2}p^{m-2}}\\ &&+\frac{p-1}{8}\left( p^{m-1}+ p^{\frac{m-2}{2}}\right)\sum\limits_{i=0}^{3} w_{0}^{K_{1}} \prod\limits_{\rho_{0}\in C_{i}}w_{\rho_{0}}^{L_{1}} \prod\limits_{\rho_{1}\in C_{i+1}}w_{\rho_{1}}^{R_{1}} \prod\limits_{\rho_{2}\in C_{i+2}}w_{\rho_{2}}^{S_{1}} \prod\limits_{\rho_{3}\in C_{i+3}}w_{\rho_{3}}^{T_{1}}\\ &&+\frac{p\,-\,1}{8}\left( p^{m-1}\,-\, p^{\frac{m-2}{2}}\right)\sum\limits_{i=0}^{3} \! w_{0}^{K_{\!-1\!}} \prod\limits_{\rho_{0}\in C_{i}}\!w_{\rho_{0}}^{L_{\!-1\!}} \prod\limits_{\rho_{1}\in C_{i+1}}\!w_{\rho_{1}}^{R_{\!-1\!}} \prod\limits_{\rho_{2}\in C_{i+2}}\!w_{\rho_{2}}^{S_{\!-1\!}} \prod\limits_{\rho_{3}\in C_{i+3}}\!w_{\rho_{3}}^{T_{\!-1\!}}, \end{array} $$

where, for ε∈{1,−1},

$$\begin{array}{@{}rcl@{}} K_{\varepsilon} &=&\frac{p-1}{2}(p^{m-2}-\varepsilon p^{\frac{m-2}{2}}),\\ L_{\varepsilon} &=&\frac{p-1}{2}p^{m-2}+\varepsilon p^{\frac{m-2}{2}}(1+s),\\ R_{\varepsilon} &=& \frac{p-1}{2}p^{m-2}- \varepsilon p^{\frac{m-2}{2}}t,\\ S_{\varepsilon} &=& \frac{p-1}{2}p^{m-2}+ \varepsilon p^{\frac{m-2}{2}}(1-s),\\ T_{\varepsilon} &=& \frac{p-1}{2}p^{m-2}+ \varepsilon p^{\frac{m-2}{2}}t. \end{array} $$

Example 3

Let (p, m)=(5,4). Then by Theorem 3, the code C D has parameters [250,4,190] and complete weight enumerator

$$\begin{array}{@{}rcl@{}} w_{0}^{250}&+&60w_{0}^{60}w_{1}^{60}w_{2}^{40}w_{3}^{50}w_{4}^{40}+60w_{0}^{60}w_{1}^{50}w_{2}^{60}w_{3}^{40}w_{4}^{40}+60w_{0}^{60}w_{1}^{40}w_{2}^{50}w_{3}^{40}w_{4}^{60}\\ &+&60w_{0}^{60}w_{1}^{40}w_{2}^{40}w_{3}^{60}w_{4}^{50}+124(w_{0}w_{1}w_{2}w_{3}w_{4})^{50}+65w_{0}^{40}w_{1}^{60}w_{2}^{60}w_{3}^{40}w_{4}^{50}\\ &+&65w_{0}^{40}w_{1}^{60}w_{2}^{50}w_{3}^{60}w_{4}^{40}+65w_{0}^{40}w_{1}^{50}w_{2}^{40}w_{3}^{60}w_{4}^{60}+65w_{0}^{40}w_{1}^{40}w_{2}^{60}w_{3}^{50}w_{4}^{60}, \end{array} $$

which is verified by Magma. This is a three-weight linear code.

The following corollary gives the weight enumerator of C D , which follows immediately from its complete weight enumerator.

Corollary 1

The code C D of ( 1 ) has the weight distribution given in Table 1 if m is even and Table 2 if m is odd.

Table 1 The weight distribution of C D when m is even
Table 2 The weight distribution of C D when m is odd

From Tables 1 and 2, we observe that the weights of C D have a common divisor (p−1)/2. This implies that it can be punctured into a shorter code as follows.

Let aSq. Note that Tr(ax) = aTr(x) for any \(x\in \mathbb {F}_{r} \). This indicates that Tr(ax) is a square (nonsquare) in \(\mathbb {F}_{p}^{*} \) if and only if Tr(x) is a square (nonsquare) in \(\mathbb {F}_{p}^{*} \). Then we can select a subset \( \tilde {D} \) of the set D such that \( \cup _{a\in Sq} a\tilde {D} \) is just a partition of D. Hence, the corresponding linear code \(C_{\tilde {D}}\) is the punctured version of C D . The following corollary states the parameters and weight distribution of \(C_{\tilde {D}}\), which directly follows from Corollary 1.

Corollary 2

The code \(C_{\tilde {D}}\) is a [p m−1 ,m] three-weight linear code with the weight distribution given in Table 3 if m is even and Table 4 if m is odd.

Table 3 The weight distribution of \(C_{\tilde {D}}\) when m is even
Table 4 The weight distribution of \(C_{\tilde {D}}\) when m is odd

In the following, we give the punctured version \(C_{\tilde {D}}\) of C D from the previous examples.

Example 4

  1. (i)

    Let (p, m)=(5,3). Then the code \(C_{\tilde {D}}\) in Corollary 2 has parameters [25,3,19] and weight enumerator

    $$\begin{array}{@{}rcl@{}} 1+40z^{19}+24z^{20}+60z^{21}. \end{array} $$

    This code is almost optimal in the sense that the best known code over \(\mathbb {F}_{5}\) of length 25 and dimension 3 has minimum distance 20 according to Markus Grassl’s table (see http://www.codetables.de/).

  2. (ii)

    Let (p, m)=(7,2). From Corollary 2, we know that \(C_{\tilde {D}}\) has parameters [7,2,5] and weight enumerator

    $$\begin{array}{@{}rcl@{}} 1+18z^{5}+6 z^{6}+24z^{7}. \end{array} $$

    This code is almost optimal since the best known code over \(\mathbb {F}_{7}\) of length 7 and dimension 2 has minimum distance 6 according to Markus Grassl’s table.

3 The proofs of the main results

3.1 Auxiliary results

In order to prove Theorems 1, 2 and 3 proposed in Section 2, we will use several results which are depicted and proved in the sequel. We start with cyclotomic classes and group characters.

Recall that r = p m. Let α be a fixed primitive element of \(\mathbb {F}_{r}\) and r−1 = sN, where s, N are two integers with s>1 and N>1. Define \(C_{i}^{(N,r)}=\alpha ^{i}\langle \alpha ^{N}\rangle \) for i = 0,1,⋯ , N−1, where 〈α N〉 denotes the subgroup of \(\mathbb {F}_{r}^{*}\) generated by α N. The cosets \(C_{i}^{(N,r)}\) are called the cyclotomic classes of order N in \(\mathbb {F}_{r}\).

For each \(b\in \mathbb {F}_{r}\), let χ b be an additive character of \(\mathbb {F}_{r}\), which is defined by

$$\chi_{b}(x)=\zeta_{p}^{\text{Tr}(bx)} ~ \mathrm{for~ all }~x\in\mathbb{F}_{r}, $$

where \(\zeta _{p}=\exp \left (\frac {2\pi \sqrt {-1}}{p}\right )\) and Tr is the absolute trace function. Especially when b = 1, χ 1 is called the canonical additive character of \(\mathbb {F}_{r}\). The orthogonal property of additive characters χ, which can be easily checked, is given by

$$ \sum\limits_{x\in \mathbb{F}_{r}}\chi(ax) =\left\{\begin{array}{lll} r &&\text{if}~~a=0, \\ 0 &&\text{if}~~a\in\mathbb{F}_{r}^{*}. \end{array} \right. $$
(2)

The Gauss periods of order N are defined by

$$\eta_{i}^{(N,r)}=\sum\limits_{x\in C_{i}^{(N,r)}}\chi_{1}(x), i=0,1,\cdots,N-1. $$

Let λ be a multiplicative and χ an additive character of \(\mathbb {F}_{r}\). Then the Gauss sum G(λ, χ) is defined by

$$\begin{array}{@{}rcl@{}} G(\lambda,\chi)=\sum\limits_{x\in\mathbb{F}_{r}^{*}}\lambda(x)\chi(x). \end{array} $$

Let η denote the quadratic character of \(\mathbb {F}_{r}\). The associated Gauss sum G(η, χ 1) over \(\mathbb {F}_{r}\) is denoted by G(η). And the Gauss sum \(G(\hat {\eta },\hat {\chi }_{1})\) over \(\mathbb {F}_{p}\) is denoted by \(G(\hat {\eta })\), where \(\hat {\eta }\) and \(\hat {\chi }_{1}\) are the quadratic character and canonical additive character of \(\mathbb {F}_{p}\), respectively.

For each \(y \in \mathbb {F}_{p}^{*}\), we have η(y)=1 if \(m\geqslant 2\) is even, and otherwise \(\eta (y) = \hat {\eta }(y)\) . Moreover, it is well known that \(G(\eta )=(-1)^{m-1}\sqrt {p^{*}}^{m}\) and \(G(\hat {\eta })=\sqrt {p^{*}}\), where \(p^{*}=\left (\frac {-1}{p}\right )p=(-1)^{\frac {p-1}{2}}p\). See [15, 25] for more information.

The following lemmas will be required in the sequel.

Lemma 1

(See Theorem 5.30 of [25]) Let χ be a nontrivial additive character of \(\mathbb {F}_{r}\) , \(k\in \mathbb {N}\) , and λ a multiplicative character of \(\mathbb {F}_{r}\) of order \(d={\gcd }(k,r-1)\) . Then

$$\begin{array}{@{}rcl@{}} \sum\limits_{x\in \mathbb{F}_{r}}\chi(ax^{k}+b)=\chi(b)\sum\limits_{j=1}^{d-1}\bar{\lambda}^{j}(a)G({\lambda}^{j},\chi) \end{array} $$

for any \(a,b\in \mathbb {F}_{r}\) with a≠0, where \(\bar {\lambda }\) denotes the conjugate character of λ.

For \(\rho \in \mathbb {F}_{p}^{*}\) and \(a\in \mathbb {F}_{r}\), in order to study the complete weight enumerator, we define

$$\begin{array}{@{}rcl@{}} &N_{0}(\rho)&=\#\{x\in\mathbb{F}_{r}:\text{Tr}(x)=0, \text{Tr}(ax^{2})=\rho\},\\ &N(\rho)&=\#\{x\in\mathbb{F}_{r}:\text{Tr}(x)\in Sq, \text{Tr}(ax^{2})=\rho\},\\ &N_{1}(\rho)&=\#\{x\in\mathbb{F}_{r}:\text{Tr}(x)\in Nsq, \text{Tr}(ax^{2})=\rho\}. \end{array} $$

The values of N(ρ), N 0(ρ) and N 1(ρ), which depend mainly on the choice of a, are given in the following two lemmas.

Lemma 2

([34]) Let \(a\in \mathbb {F}_{r}^{*} \) and \(\rho \in \mathbb {F}_{p}^{*}\) . Then

$$\begin{array}{@{}rcl@{}} N_{0}(\rho)=\left\{\begin{array}{lll} &p^{m-2}+(-1)^{\frac{p-1}{2}\frac{m-1}{2}}\eta(a)\hat{\eta}(\rho)p^{\frac{m-1}{2}} &if~m~odd ,\text{Tr}(a^{-1})=0,\\ &p^{m-2}-(-1)^{\frac{p-1}{2}\frac{m-1}{2}}\eta(a)\hat{\eta}(\text{Tr}(a^{-1}))p^{\frac{m-3}{2}} &if~m~odd ,\text{Tr}(a^{-1})\neq0,\\ &p^{m-2}+(-1)^{\frac{p-1}{2}\frac{m}{2}}\eta(a)p^{\frac{m-2}{2}} &if~m~even ,\text{Tr}(a^{-1})=0,\\ &p^{m-2}-(-1)^{\frac{p-1}{2}\frac{m-2}{2}}\eta(a)\hat{\eta}(\rho\text{Tr}(a^{-1})) p^{\frac{m-2}{2}} & if~m~even ,\text{Tr}(a^{-1})\neq0. \end{array} \right. \end{array} $$

Lemma 3

Let \(a\in \mathbb {F}_{r}^{*} \) and \(\rho \in \mathbb {F}_{p}^{*} \) . Then we have the following assertion.

$$\begin{array}{@{}rcl@{}} &&N(\rho)+N_{1}(\rho)\\ &&=\left\{\begin{array}{lll} p^{m-1}-p^{m-2} & if~m~even,~\text{Tr}(a^{-1})=0,\\ p^{m-1}-p^{m-2} & if~m~odd, ~\text{Tr}(a^{-1})=0,\\ p^{m-1}-p^{m-2}+\eta(a)(-1)^{\frac{p-1}{2}\frac{m}{2}}p^{\frac{m-2}{2}} \left( 1+\hat{\eta}(-\rho~\text{Tr}(a^{-1}))\right)\ & if~m~even,~\text{Tr}(a^{-1})\neq0,\\ p^{m-1}-p^{m-2}+\eta(a)(-1)^{\frac{p-1}{2}\frac{m-1}{2}}p^{\frac{m-3}{2}} \left( \hat{\eta}(\rho)p+\hat{\eta}~(\text{Tr}(a^{-1}))\right) & if~m~odd,~ \text{Tr}(a^{-1})\neq0. \end{array} \right. \end{array} $$

Proof

Note that

$$\begin{array}{@{}rcl@{}} N_{0}(\rho)+N(\rho)+N_{1}(\rho)=\#\{x\in\mathbb{F}_{r}: \text{Tr}(ax^{2})=\rho\}, \end{array} $$

where \(\rho \in \mathbb {F}_{p}^{*} \). This leads to

$$\begin{array}{@{}rcl@{}} N_{0}(\rho)+N(\rho)+N_{1}(\rho) =p^{m-1}+p^{-1}\sum\limits_{z\in\mathbb{F}_{p}^{*}}\zeta_{p}^{-z\rho}\sum\limits_{x\in\mathbb{F}_{r}}\zeta_{p}^{z~\text{Tr}(ax^{2})}. \end{array} $$

Applying Theorem 5.33 of [25], we can deduce that

$$\begin{array}{@{}rcl@{}} \sum\limits_{z\in\mathbb{F}_{p}^{*}}\sum\limits_{x\in\mathbb{F}_{r}}\zeta_{p}^{z~\text{Tr}(ax^{2})-z\rho} =\left\{\begin{array}{lll} \eta(a)(-1)^{\frac{p-1}{2}\frac{m}{2}}p^{\frac{m}{2}} && \text{if}~m~\text{even},\\ \eta(a)\hat{\eta}(\rho)(-1)^{\frac{p-1}{2}\frac{m-1}{2}}p^{\frac{m+1}{2}} && \text{if}~m~\text{odd}. \end{array} \right. \end{array} $$

The desired conclusion then follows from Lemma 2. □

The following two lemmas will help us to determine the frequency of each composition in C D .

Lemma 4

([34]) For any \(a\in \mathbb {F}_{r}^{*} \) , let

$$\begin{array}{@{}rcl@{}} n_{i,j}&=&\#\{a\in \mathbb{F}_{r}^{*}:\eta(a)=i , \hat{\eta}(\text{Tr}(a^{-1}))=j \}, \;\; i,j\in\{1,-1\}. \end{array} $$
(3)
  1. (i)

    If m is even, then we have

    $$\begin{array}{@{}rcl@{}} n_{1,1}= n_{1,-1}=\frac{p-1}{4}\left( p^{m-1}+(-1)^{\frac{p-1}{2}\frac{m}{2}}p^{\frac{m-2}{2}}\right). \end{array} $$
  2. (ii)

    If m is odd, then we have

    $$\begin{array}{@{}rcl@{}} \left\{\begin{array}{lll} n_{1,1}&=&\frac{p-1}{4}\left( p^{m-1}+(-1)^{\frac{p-1}{2}\frac{m-1}{2}}p^{\frac{m-1}{2}}\right),\\ n_{1,-1}&=&\frac{p-1}{4}\left( p^{m-1}-(-1)^{\frac{p-1}{2}\frac{m-1}{2}}p^{\frac{m-1}{2}}\right).\\ \end{array} \right. \end{array} $$

Lemma 5

For any \(a\in \mathbb {F}_{r}^{*} \) , let n i,j be defined by (3).

  1. (i)

    If m is even, then we have

    $$\begin{array}{@{}rcl@{}} n_{-1,1}= n_{-1,-1}=\frac{p-1}{4}\left( p^{m-1}-(-1)^{\frac{p-1}{2}\frac{m}{2}}p^{\frac{m-2}{2}}\right). \end{array} $$
  2. (ii)

    If m is odd, then we have

    $$\begin{array}{@{}rcl@{}} \left\{\begin{array}{lll} n_{-1,1}&=&\frac{p-1}{4}\left( p^{m-1}-(-1)^{\frac{p-1}{2}\frac{m-1}{2}}p^{\frac{m-1}{2}}\right),\\ n_{-1,-1}&=&\frac{p-1}{4}\left( p^{m-1}+(-1)^{\frac{p-1}{2}\frac{m-1}{2}}p^{\frac{m-1}{2}}\right).\\ \end{array} \right. \end{array} $$

Proof

We point out that

$$\begin{array}{@{}rcl@{}} n_{1,j}+n_{-1,j}=\#\{a\in \mathbb{F}_{r}^{*}:\hat{\eta}(\text{Tr}(a^{-1}))=j\}=\frac{p-1}{2}p^{m-1}, \end{array} $$

with j∈{1,−1}.

The desired conclusion then follows from Lemma 4. □

Consider p≡1 mod 4. Recall that \(\eta _{i}^{(4,p)}={\sum }_{x\in C_{i}^{(4,p)}} {\zeta _{p}^{x}}\), where \(C_{i}^{(4,p)}=\beta ^{i}\langle \beta ^{4}\rangle \) for i = 0,1,2,3, and β is a primitive element of \(\mathbb {F}_{p}\). In the sequel, we write \(\eta _{i}^{(4,p)}\) and \(C_{i}^{(4,p)}\) as η i and C i , respectively. The following lemma plays an important role in determining the complete weight enumerator, in which the value of η 0 coincides with the result of Theorem 4.2.4 of [3].

Lemma 6

Let p≡1 mod 4. Let s and t be defined by p=s 2 +t 2 , s≡1 mod 4. The Gauss periods of order 4 over \(\mathbb {F}_{p}\) are given as follows.

  1. (i)

    If p≡5 mod 8, then

    $$\begin{array}{@{}rcl@{}} \{\eta_{0},\eta_{2}\}&=&\left\{\frac{\sqrt{p}-1}{4}\pm\frac{\sqrt{2}}{4}\sqrt{-\sqrt{p}s-p}\right\},\\ \{\eta_{1},\eta_{3}\}&=&\left\{-\frac{\sqrt{p}+1}{4}\pm\frac{\sqrt{2}}{4}\sqrt{\sqrt{p}s-p}\right\}. \end{array} $$
  2. (ii)

    If p≡1 mod 8, then

    $$\begin{array}{@{}rcl@{}} \{\eta_{0},\eta_{2}\}&=&\left\{\frac{\sqrt{p}-1}{4}\pm\frac{\sqrt{2}}{4}\sqrt{p-\sqrt{p}s}\right\},\\ \{\eta_{1},\eta_{3}\}&=&\left\{-\frac{\sqrt{p}+1}{4}\pm\frac{\sqrt{2}}{4}\sqrt{p+\sqrt{p}s}\right\}. \end{array} $$

Proof

Let β be a primitive element of 𝔽 p . According to [28], the Gauss sums G i are given by

$$\begin{array}{@{}rcl@{}} G_{i}=\sum\limits_{x\in \mathbb{F}_{p}} \zeta_{p}^{\beta^{i} x^{4}}, i=0,1,2,3, \end{array} $$

and they are roots of a polynomial F 4(X), i.e.,

$$\begin{array}{@{}rcl@{}} F_{4}(X)=\prod\limits_{i_{0}}^{3} (X-G_{i}), \end{array} $$

which is called reduced (or modified) period polynomial. By Theorem 14 of [28] (see also Theorem 10.10.6 of [3]), we have

$$\begin{array}{@{}rcl@{}} F_{4}(X)=\left\{\begin{array}{ll} (X^{2}+3p)^{2}-4p(X-s)^{2} &\quad \text{if}~~ p\equiv5\mod 8,\\ (X^{2}-p)^{2}-4p(X-s)^{2} &\quad\text{if} ~~ p\equiv1\mod 8, \end{array} \right. \end{array} $$

where p = s 2 + t 2 with s≡1 mod 4.

In the following, we give the proof of the case p≡5 mod 8 since that of the case p≡1 mod 8 is similarly verified.

In the case of p≡5 mod 8, we have

$$\begin{array}{@{}rcl@{}} F_{4}(X)= \left( X^{2}+3p-2\sqrt{p}(X-s)\right)\left( X^{2}+3p+2\sqrt{p}(X-s)\right). \end{array} $$

Note that \(\eta _{0}+\eta _{2} = \eta _{0}^{(2,p)}=\frac {1}{2}(\sqrt {p}-1)\) yields that \(G_{0}+G_{2}=2\sqrt {p}\), since G i = 4η i +1. Hence, we see that G 0, G 2 are roots of

$$\begin{array}{@{}rcl@{}} X^{2}+3p-2\sqrt{p}(X-s)=0. \end{array} $$

Therefore, G 1, G 3 are roots of

$$\begin{array}{@{}rcl@{}} X^{2}+3p+2\sqrt{p}(X-s)=0. \end{array} $$

It is straightforward that

$$\begin{array}{@{}rcl@{}} &&G_{0}+G_{2}= 2\sqrt{p}, \quad~~~ G_{0}G_{2}=3p+2\sqrt{p} s,\\ &&G_{1}+G_{2}=-2\sqrt{p}, \quad G_{1}G_{3}=3p-2\sqrt{p} s. \end{array} $$

Moreover, we obtain that

$$\begin{array}{@{}rcl@{}} &&\eta_{0}\eta_{2}= \frac{1}{16}(3p+1-2\sqrt{p}(1-s)),\\ &&\eta_{1}\eta_{3}= \frac{1}{16}(3p+1+2\sqrt{p}(1-s)),\\ &&{\eta_{0}^{2}}+{\eta_{2}^{2}}= \frac{1}{8}(1-p-2\sqrt{p}(1+s)),\\ &&{\eta_{1}^{2}}+{\eta_{3}^{2}}= \frac{1}{8}(1-p+2\sqrt{p}(1+s)). \end{array} $$

Consequently, we have

$$\begin{array}{@{}rcl@{}} (\eta_{0}+\eta_{2})^{2} &= \frac{1}{4}(\sqrt{p}-1)^{2},~~ (\eta_{0}-\eta_{2})^{2} &= \frac{1}{2}(-\sqrt{p}s-p),\\ (\eta_{1}+\eta_{3})^{2} &= \frac{1}{4}(\sqrt{p}+1)^{2},~~ (\eta_{1}-\eta_{3})^{2} &= \frac{1}{2}(\sqrt{p}s-p). \end{array} $$

The desired conclusions follow from the facts that \(\eta _{0}+\eta _{2} =\frac {1}{2}(\sqrt {p}-1)\) and η 0 + η 1 + η 2 + η 3 = −1. □

3.2 The proof of Theorem 1

Observe that a = 0 gives the zero codeword and the contribution to the complete weight enumerator is \({w_{0}^{n}}\), where \(n=\frac {p-1}{2}p^{m-1}\). This value occurs only once. Hence, we assume that \(a\in \mathbb {F}_{r}^{*}\) for the rest of the proof.

For \(\rho \in \mathbb {F}_{p}^{*}\), we consider

$$\begin{array}{@{}rcl@{}} A=\sum\limits_{x\in\mathbb{F}_{r}}\sum\limits_{y\in\mathbb{F}_{p}}\zeta_{p}^{y^{2}\text{Tr}(x)} \sum\limits_{z\in\mathbb{F}_{p}}\zeta_{p}^{z~\text{Tr}(ax^{2})-z\rho}. \end{array} $$

Then, it is easy to see that

$$\begin{array}{@{}rcl@{}} A = N_{0}(\rho)p^{2}+(N(\rho)-N_{1}(\rho))p\sqrt{p^{*}}, \end{array} $$
(4)

since

$$\begin{array}{@{}rcl@{}} \sum\limits_{y\in\mathbb{F}_{p}}\zeta_{p}^{y^{2}\text{Tr}(x)} =\left\{\begin{array}{lll} p && \text{if}~ ~\text{Tr}(x)=0,\\ \sqrt{p^{*}} && \text{if} ~~\text{Tr}(x)\in Sq,\\ -\sqrt{p^{*}} && \text{if}~ ~\text{Tr}(x)\in Nsq, \end{array} \right. \end{array} $$

and

$$\begin{array}{@{}rcl@{}} \sum\limits_{z\in\mathbb{F}_{p}}\zeta_{p}^{z~\text{Tr}(ax^{2})-z\rho} =\left\{\begin{array}{lll} p && \text{if}~~\text{Tr}(ax^{2})=\rho,\\ 0 && \text{if}~~ \text{Tr}(ax^{2})\neq \rho. \end{array} \right. \end{array} $$

On the other hand, from Theorem 5.33 of [25] and (2), we get

$$\begin{array}{@{}rcl@{}} A &=&r+\sum\limits_{y\in\mathbb{F}_{p}^{*}}\sum\limits_{x\in\mathbb{F}_{r}}\zeta_{p}^{y^{2}~\text{Tr}(x)} +\sum\limits_{z\in\mathbb{F}_{p}^{*}}\zeta_{p}^{-z\rho} \sum\limits_{y\in\mathbb{F}_{p}}\sum\limits_{x\in\mathbb{F}_{r}}\zeta_{p}^{\text{Tr}(azx^{2}+y^{2}x)} \\ &=&r+\sum\limits_{z\in\mathbb{F}_{p}^{*}}\zeta_{p}^{-z\rho} \sum\limits_{y\in\mathbb{F}_{p}}\zeta_{p}^{\text{Tr}(-\frac{y^{4}}{4az})}\eta(az)G(\eta) \\ &=&r+\eta(a)G(\eta)\sum\limits_{z\in\mathbb{F}_{p}^{*}}\zeta_{p}^{-z\rho}\eta(z) \sum\limits_{y\in\mathbb{F}_{p}}\zeta_{p}^{-\frac{\text{Tr}(a^{-1})}{4z}y^{4}}. \end{array} $$
(5)

In the following, we calculate the value A of (5) by distinguishing the cases of Tr(a −1)=0 and Tr(a −1)≠0.

Case 1

Tr(a −1)=0.

In this case, from (5), we know that

$$\begin{array}{@{}rcl@{}} A=\left\{\begin{array}{lll} r-p\eta(a)G(\eta) && \text{if} ~~m ~~\text{even},\\ r+p\eta(a)\hat{\eta}(-\rho)G(\eta)G(\hat{\eta}) && \text{if} ~~m ~~\text{odd}, \end{array} \right. \end{array} $$

which leads to N(ρ) = N 1(ρ) compared with (4) and Lemma 2. It follows from Lemma 3 that \(N(\rho )=\frac {p-1}{2}p^{m-2}\). This value occurs p m−1−1 times.

Case 2

Tr(a −1)≠0.

Recall that p≡3 mod 4. Thus, \({\gcd }(4,p-1)=2\). From (5) and Lemma 1, we have

$$\begin{array}{@{}rcl@{}} A&=&r+\eta(a)G(\eta)\sum\limits_{z\in\mathbb{F}_{p}^{*}}\zeta_{p}^{-z\rho}\eta(z) \hat{\eta}\left( -\frac{\text{Tr}(a^{-1})}{4z}\right)G(\hat{\eta})\\ &=&r+\eta(a)G(\eta)\hat{\eta}(-\text{Tr}(a^{-1}))\sum\limits_{z\in\mathbb{F}_{p}^{*}}\zeta_{p}^{-z\rho}\eta(z) \hat{\eta}(z)G(\hat{\eta})\\ &=&\left\{\begin{array}{lll} r+\eta(a)\hat{\eta}(\rho~\text{Tr}(a^{-1}))G(\eta)G(\hat{\eta})^{2} && \text{if}~~ m ~~\text{even},\\ r-\eta(a)\hat{\eta}(-\text{Tr}(a^{-1}))G(\eta)G(\hat{\eta}) && \text{if} ~~m ~~\text{odd}, \end{array} \right. \end{array} $$

which also leads to N(ρ) = N 1(ρ) from (4) and Lemma 2. It then follows from Lemma 3 that

$$\begin{array}{@{}rcl@{}} &&N(\rho)=\left\{\begin{array}{lll} \frac{p-1}{2}p^{m-2} && \text{if}~~ \hat{\eta}(\rho~\text{Tr}(a^{-1}))=1\\ \frac{p-1}{2}p^{m-2}+\eta(a)(-1)^{\frac{m}{2}}p^{\frac{m-2}{2}} && \text{if}~~ \hat{\eta}(\rho~\text{Tr}(a^{-1}))=-1 \end{array} \right. \end{array} $$

for even m, and otherwise,

$$\begin{array}{@{}rcl@{}} &&N(\rho)= \frac{p-1}{2}p^{m-2}+\frac{1}{2}\eta(a)(-1)^{\frac{m-1}{2}}p^{\frac{m-3}{2}} (p\hat{\eta}(\rho)+\hat{\eta}(\text{Tr}(a^{-1}))). \end{array} $$

Note that \(N(0)=\frac {p-1}{2}p^{m-1}-{\sum }_{\rho \in \mathbb {F}_{p}^{*}} N(\rho )\). The desired conclusion then follows from Lemmas 4 and 5.

This completes the proof of Theorem 1.

3.3 The proof of Theorem 2

By the proof of Theorem 1, we only need to consider the case Tr(a −1)≠0 with \(a\in \mathbb {F}_{r}^{*}\), since the cases of a = 0 and Tr(a −1)=0 have already been determined. For this purpose, we write (5) as

$$\begin{array}{@{}rcl@{}} A =r+\eta(a)G(\eta)B, \end{array} $$
(6)

where

$$\begin{array}{@{}rcl@{}} B=\sum\limits_{z\in\mathbb{F}_{p}^{*}}\zeta_{p}^{-z\rho}\eta(z) \sum\limits_{y\in\mathbb{F}_{p}}\zeta_{p}^{-\frac{\text{Tr}(a^{-1})}{4z}y^{4}}. \end{array} $$
(7)

Let notations be as aforementioned and p≡1 mod 4. When Tr(a −1)≠0, the value B of (7) can be determined by

$$\begin{array}{@{}rcl@{}} B &=& \sum\limits_{z\in\mathbb{F}_{p}^{*}}\zeta_{p}^{-z\rho}\hat{\eta}(z) \left( 4\eta_{-\frac{\text{Tr}(a^{-1})}{4z}}+1\right) \\ &=& \left( \sum\limits_{z\in C_{0}}+\sum\limits_{z\in C_{2}}-\sum\limits_{z\in C_{1}}-\sum\limits_{z\in C_{3}} \right) 4\zeta_{p}^{-z\rho}\eta_{-\frac{\text{Tr}(a^{-1})}{4z}} + \hat{\eta}(-\rho)G(\hat{\eta}) \\ &=& \left( \sum\limits_{z\in C_{0}}+\sum\limits_{z\in C_{2}}-\sum\limits_{z\in C_{1}}-\sum\limits_{z\in C_{3}} \right) 4\zeta_{p}^{-z\rho}\eta_{-\frac{\text{Tr}(a^{-1})}{4z}} + \hat{\eta}(\rho)\sqrt{p}, \end{array} $$
(8)

since m is odd. By (4), (6), and Lemma 3, we have

$$\begin{array}{@{}rcl@{}} \left\{\begin{array}{lll} N(\rho)+N_{1}(\rho)&=& p^{m-1}-p^{m-2}+\eta(a)p^{\frac{m-3}{2}}\left( \hat{\eta}(\rho) p+\hat{\eta}(\text{Tr}(a^{-1}))\right),\\ N(\rho)-N_{1}(\rho)&=&\eta(a)\left( \hat{\eta}(\text{Tr}(a^{-1}))p^{\frac{m-2}{2}}+p^{\frac{m-3}{2}}B\right). \end{array} \right. \end{array} $$
(9)

Now, we assume that p≡5 mod 8.

Clearly, −1 and 4 are both in C 2. In the following, the value B of (8) will be computed according to the choices of Tr(a −1) and ρ.

Case 1

Tr(a −1)∈C 0, ρC 0.

In this case, by Lemma 6 and (8), we obtain

$$\begin{array}{@{}rcl@{}} B = 4\left( 2\eta_{0}\eta_{2}-{\eta_{1}^{2}}-{\eta_{3}^{2}}\right)+\sqrt{p}= 2p-\sqrt{p}. \end{array} $$

It follows from (9) that

$$\begin{array}{@{}rcl@{}} &N(\rho)&= \frac{p-1}{2}p^{m-2}+\frac{1}{2}\eta(a) \left( 3 p^{\frac{m-1}{2}}+p^{\frac{m-3}{2}}\right),\\ &N_{1}(\rho)&= \frac{p-1}{2}p^{m-2}-\frac{1}{2}\eta(a) \left( p^{\frac{m-1}{2}}-p^{\frac{m-3}{2}}\right). \end{array} $$

Case 2

Tr(a −1)∈C 0, ρC 1.

In this case, we deduce that

$$\begin{array}{@{}rcl@{}} B =4(\eta_{3}\eta_{0}+\eta_{1}\eta_{2}-\eta_{0}\eta_{3}-\eta_{2}\eta_{1})-\sqrt{p}=-\sqrt{p}, \end{array} $$

which indicates that

$$\begin{array}{@{}rcl@{}} N(\rho)=N_{1}(\rho)= \frac{p-1}{2}p^{m-2}-\frac{1}{2}\eta(a) \left( p^{\frac{m-1}{2}}-p^{\frac{m-3}{2}}\right). \end{array} $$

Case 3

Tr(a −1)∈C 0, ρC 2.

In this case, we have

$$\begin{array}{@{}rcl@{}} B =4\left( {\eta_{0}^{2}}+{\eta_{2}^{2}}-2\eta_{1}\eta_{3}\right)+\sqrt{p}=-2p-\sqrt{p}, \end{array} $$

which gives that

$$\begin{array}{@{}rcl@{}} &N(\rho)&= \frac{p-1}{2}p^{m-2}-\frac{1}{2}\eta(a) \left( p^{\frac{m-1}{2}}-p^{\frac{m-3}{2}}\right),\\ &N_{1}(\rho)&= \frac{p-1}{2}p^{m-2}+\frac{1}{2}\eta(a) \left( 3 p^{\frac{m-1}{2}}+p^{\frac{m-3}{2}}\right). \end{array} $$

Case 4

Tr(a −1)∈C 0, ρC 3.

In this case, we obtain

$$\begin{array}{@{}rcl@{}} B =4(\eta_{1}\eta_{0}+\eta_{3}\eta_{2}-\eta_{2}\eta_{3}-\eta_{0}\eta_{1})-\sqrt{p}=-\sqrt{p}. \end{array} $$

As a consequence, we get

$$\begin{array}{@{}rcl@{}} N(\rho)=N_{1}(\rho)= \frac{p-1}{2}p^{m-2}-\frac{1}{2}\eta(a) \left( p^{\frac{m-1}{2}}-p^{\frac{m-3}{2}}\right). \end{array} $$

Moreover, for Tr(a −1)∈C 0, the number of a satisfying η(a)=1 is

$$\begin{array}{@{}rcl@{}} \#\{a\in \mathbb{F}_{r}^{*}:\eta(a)=1, \text{Tr}(a^{-1})\in C_{0} \} =\frac{1}{2}n_{1,1} =\frac{p-1}{8}\left( p^{m-1}+ p^{\frac{m-1}{2}}\right), \end{array} $$

by Lemma 4. In a similar way, the number of a satisfying η(a)=−1 is

$$\begin{array}{@{}rcl@{}} &&\#\{a\in \mathbb{F}_{r}^{*}:\eta(a)=-1, \text{Tr}(a^{-1})\in C_{0} \} =\frac{1}{2}n_{-1,1} =\frac{p-1}{8}\left( p^{m-1}- p^{\frac{m-1}{2}}\right), \end{array} $$

by Lemma 5.

There are sixteen cases all together to be considered. Other cases can be similarly calculated, which are omitted here.

Note that the case of p≡1 mod 8 can be analyzed in an analogous fashion. The proof of Theorem 2 is finished.

3.4 The proof of Theorem 3

This proof is similar to that of Theorem 2 by observing that

$$\begin{array}{@{}rcl@{}} B &=& \left( \sum\limits_{z\in C_{0}}+\sum\limits_{z\in C_{1}}+\sum\limits_{z\in C_{2}}+\sum\limits_{z\in C_{3}} \right) 4\zeta_{p}^{-z\rho}\eta_{-\frac{\text{Tr}(a^{-1})}{4z}} -1, \end{array} $$

from (7), since m is even. Thus, we omit the details here.

4 Concluding remarks

Inspired by the original ideas of [15,30], we constructed a class of three-weight linear codes. By employing some mathematical tools, we presented explicitly their complete weight enumerators and weight enumerators. Their punctured codes contain some almost optimal codes. By Theorem 1, it is easy to check that

$$\begin{array}{@{}rcl@{}} \frac{w_{min}}{w_{max}}>\frac{p-1}{p}, \end{array} $$

for \(m\geqslant 4\). Here w min and w max denote the minimum and maximum nonzero weights in C D , respectively. Therefore, the code C D can be used for secret sharing schemes with interesting access structures. We also mention that the complete weight enumerators, presented in Theorems 1, 2 and 3, can be applied to compute the deception probabilities of certain authentication codes constructed from linear codes. Furthermore, if r is large enough, these authentication codes are asymptotically optimal. See [11,15,23].

Note that \({\gcd }(4,p-1)=4\) if p≡1 mod 4. This implies that we can prove Theorems 2 and 3 with a similar method used in Section 3.2. One can see that it works well though it is indeed very complicated. However, we gave a simpler proof by employing Gauss periods to determine the complete weight enumerator of C D for the case of p≡1 mod 4.

To conclude this paper, we remark that the codes proposed in this paper can be extended to a more general case, that is, for an integer \(t\geqslant 2\), define

$$\begin{array}{@{}rcl@{}} C_{D^{\prime}}=\left\{\left( \text{Tr}(a_{1}{x_{1}^{2}}+\cdots+a_{t}{x_{t}^{2}})\right)_{(x_{1},\cdots,x_{t})\in D}: a_{1},\cdots,a_{t}\in \mathbb{F}_{r}\right\}, \end{array} $$

where

$$\begin{array}{@{}rcl@{}} D^{\prime} =\left\{(x_{1},\cdots,x_{t})\in \mathbb{F}_{r}^{t}:\text{Tr}(x_{1}+\cdots+x_{t})\in Sq\right\}. \end{array} $$

For this kind of linear codes, it will be interesting to settle their complete weight enumerators.