1 Introduction

Throughout this paper, let \(\mathbb F_q\) be a finite field with \(q=p^m\) elements, where p is an odd prime and m is a positive integer, and let Tr be the trace function from \(\mathbb F_q\) to \(\mathbb F_p\). An [nkd] p-ary linear code \(\mathscr {C}\) is a k-dimensional subspace of \(\mathbb F_{p}^{n}\) and has minimum Hamming distance d. Let \(A_{i}\) denote the number of codewords with Hamming weight i in a code \(\mathscr {C}\) of length n. The weight enumerator is defined by

$$\begin{aligned} 1+A_{1}z+\cdots +A_{n}z^{n}. \end{aligned}$$

The sequence \((1,A_{1},\ldots ,A_{n})\) is called the weight distribution of the code \(\mathscr {C}\). A code \(\mathscr {C}\) is said to be a t-weight code if the number of nonzero \(A_{i}\) is equal to t. Weight distribution is an interesting topic and was investigated in [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]. The weight distribution of a code can not only give the error correcting ability of the code, but also allow the computation of the error probability of error detection and correction.

For a set \(D=\{d_{1},d_{2},\ldots ,d_{n}\}\subseteq \mathbb F_{q}\), define a linear code of length n over \(\mathbb F_{p}\) by

$$\begin{aligned} \mathscr {C}_{D}=\{(Tr(xd_{1}),Tr(xd_{2}),\ldots ,Tr(xd_{n})):x\in \mathbb F_{q}\}. \end{aligned}$$

We call D the defining set of \(\mathscr {C}_{D}\). Many known linear codes could be produced by selecting the defining set. For details of these known codes, the reader is referred to [3, 13, 14].

In this paper, we always assume that \(n, m, k_1, \ldots , k_n\) are positive integers with each \(m/\gcd (m, k_i)\) odd. Then each \(f_i(x)=x^{p^{k_i}+1}\) is a planar function over \(\mathbb F_q\) (see [16]). Fixing \(c\in \mathbb F_p\), we define

$$\begin{aligned}&\displaystyle D=\{(x_{1},\ldots ,x_{n})\in \mathbb F_q^n\backslash \{(0,0,\ldots )\}:Tr\left( x_{1}^{p^{k_{1}}+1}+\cdots +x_{n}^{p^{k_{n}}+1}\right) =c\},\\&\displaystyle \mathscr {C}_{D}=\{c(a_{1},\ldots ,a_{n}):(a_{1},a_{2},\ldots ,a_{n})\in \mathbb F_q^{n}\} , \end{aligned}$$

where

$$\begin{aligned} c(a_{1},\ldots ,a_{n})=(Tr(a_{1}x_{1}+\cdots +a_{n}x_{n}))_{(x_{1},\ldots ,x_{n})\in D}. \end{aligned}$$

In fact, we have some well-known results as follows. If \(n=1\) and either \(k_1=0\) or \(m/\gcd (m,k_1)\) is odd, then it is just the result in [17, 18].

In the paper, we will determine the weight distribution of the linear codes \(\mathscr {C}_D\) in three cases: (1) \(c=0\), (2) \(c\in {\mathbb F_p^*}^2\), (3) \(c\in \mathbb F_p^* \setminus {\mathbb F_p^*}^2\). In the cases (2) and (3), we use the cyclotomic numbers of order 2 to get their distributions.

2 Preliminaries

Let \(\mathbb F_{q}\) be a finite fields with q elements, where q is a power of a prime p. We define the additive character of \(\mathbb F_{q}\) as follows:

$$\begin{aligned} \chi : \mathbb F_{q} \longrightarrow \mathbb {C}^{*}, x \longmapsto \zeta _{p}^{Tr(x)}, \end{aligned}$$

where \(\zeta _{p}\) is a complex p-th primitive root of unity and Tr denotes the trace function from \(\mathbb F_{q}\) to \(\mathbb F_{p}\). The orthogonal property of additive characters [19] is given by

$$\begin{aligned}\sum _{x\in \mathbb F_{q}}\chi (ax)=\left\{ \begin{array}{ll} 0, &{} \quad \text{ if } a\in \mathbb F_{q}^{*};\\ q, &{} \quad \text{ if } a=0.\\ \end{array} \right. \end{aligned}$$

Let \(\lambda : \mathbb F_{q}^{*}\longrightarrow \mathbb {C}^{*}\) be a multiplicative character of \(\mathbb F_{q}^{*}\). The trivial character \(\lambda _{0}\) defined by \(\lambda _{0}(x)=1\) for all \(x\in \mathbb F_{q}^{*}\). The orthogonal property of multiplicative characters is given by

$$\begin{aligned}\sum _{x\in \mathbb F_{q}^{*}}\lambda (x)=\left\{ \begin{aligned}&q-1,&\quad \text{ if } \lambda =\lambda _{0};\\&0,&\quad \text{ otherwise }.\\ \end{aligned} \right. \end{aligned}$$

Let \(\bar{\lambda }\) be the conjugate character of \(\lambda \) defined by \(\bar{\lambda }(x)=\overline{\lambda (x)}\). It is easy to obtain that \(\lambda ^{-1}=\bar{\lambda }\). The multiplicative group \(\widehat{\mathbb F}_{q}^{*}\) is isomorphic to \(\mathbb F_{q}^{*}\). For \(\mathbb F_{q}^{*}=\langle \alpha \rangle \), define a multiplicative character by \(\psi (\alpha )=\zeta _{q-1}\), where \(\zeta _{q-1}\) denotes the primitive \(q-1\)-th root of complex unity. Then we have \(\widehat{\mathbb F}_{q}^{*}=\langle \psi \rangle \). Set \(\eta =\psi ^{\frac{q-1}{2}}\) be the quadratic character of \(\mathbb F_q\).

Define the Gauss sum over \(\mathbb F_{q}\) by

$$\begin{aligned} G(\lambda )=\sum _{x\in \mathbb F_{q}^{*}}\lambda (x)\chi (x). \end{aligned}$$

Let \((\frac{\cdot }{p})\) denote the Legendre symbol. The quadratic Gauss sums are known and given in the following.

Lemma 1

[19] Suppose that \(q=p^{m}\) and \(\eta \) is the quadratic multiplicative character of \(\mathbb F_{q}\), where p is odd prime. Then

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

where \(p^{*}=(-1)^{\frac{p-1}{2}}p\) is the discriminant of a prime p.

Let \(\chi '\) be the canonical additive character of \(\mathbb F_p\) such that \(\chi (x)=\chi '({\text {Tr}}(x))\) for \(x\in \mathbb F_q\). Let \(\eta '\) be a quadratic character of \(\mathbb F_p\), then \(\eta (x)=\eta '(N_{q/p}(x))\) for \(x\in \mathbb F_q^*\).

Lemma 2

[20] Let \(x\in \mathbb F_p^*\) and \(q=p^m\), where p is odd prime.

If m is even, then \(\eta (x)=1\).

If m is odd, then \(\eta (x)=\eta '(x)\).

Moreover, \(G(\eta )=(-1)^{m-1}G(\eta ')^m\), where \(G(\eta )\) and \(G(\eta ')\) are the Gauss sums over \(\mathbb F_q\) and \(\mathbb F_p\), respectively.

We now give a brief introduction to the theory of quadratic forms over finite fields. Quadratic forms have been well studied and have applications in sequence design [11, 21] and coding theory [7, 22].

Lemma 3

Let \(d=gcd(k,m)\). Then

$$\begin{aligned} (p^k+1,p^{m}-1)=\left\{ \begin{array}{ll} 2,&{} \quad \text{ if } m/d \; \text{ is } \text{ odd, }\\ p^{d}+1 ,&{} \quad \text{ if } m/d \; \text{ is } \text{ even. } \end{array} \right. \end{aligned}$$

In this paper, we assume that k an integer and \(m/\gcd (k,m)\) odd. Then it is well-known that \(f(x)=x^{p^k+1}\) is a planar function from \(\mathbb F_q\) to \(\mathbb F_q\). In [23, 24], Coulter gave the valuations of the following Weil sums:

$$\begin{aligned} S_k(a,b)=\sum _{x\in \mathbb F_q}\chi (ax^{p^k+1}+bx), \quad a,b\in \mathbb F_q. \end{aligned}$$

Lemma 4

[23, Theorem 1] Let m / d be odd. Then

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

Lemma 5

[24, Theorem 1] Let q be odd and suppose \(f(X)=a^{p^{k}}X^{p^{2k}}+aX\) is a permutation polynomial over \(F_{q}\). Let \(x_{0}\) be the unique solution of the equation \( f(X)=-b^{p^{k}}\). The evaluation of \(S_{k}(a,b)\) partitions into the following two cases:

  1. (1)

    If m / d is odd, then

    $$\begin{aligned} S_{k}(a,b)= & {} \eta (a)G(\eta )\bar{\chi }\left( ax_{0}^{p^{k}+1}\right) \\= & {} \left\{ \begin{array}{ll} (-1)^{m-1}\sqrt{q}\eta (a)\bar{\chi }\left( ax_{0}^{p^{k}+1}\right) ,&{} \quad \text{ if } p\equiv 1 \pmod 4,\\ (-1)^{m-1}i^{m}\sqrt{q}\eta (a)\bar{\chi }\left( ax_{0}^{p^{k}+1}\right) ,&{} \quad \text{ if } p\equiv 3 \pmod 4. \end{array} \right. \end{aligned}$$
  2. (2)

    If m / d is even, then  \(m=2e\)\(a^{\frac{q-1}{p^{d}+1}}\ne (-1)^{m/d}\) and

    $$\begin{aligned} S_{k}(a,b)=(-1)^{m/d}p^{e}\bar{\chi }\left( ax_{0}^{p^{k}+1}\right) . \end{aligned}$$

In fact, Lemma  4 is made of some revision in [24, Theorem 1].

3 Linear codes

Let \(\mathbb F_{q}\) be the finite field with \(q=p^m\) elements, where p is an odd prime and m is an positive integer. Let Tr denote the trace function from \(\mathbb F_{q}\) to \(\mathbb F_{p}\). In this section, we always assume that \(n, k_1, \ldots , k_n\) are positive integers with each \(m/\gcd (m, k_i)\) odd. Let \(f_i(x)=x^{p^{k_i}+1},x\in \mathbb F_{q}\), \(i=1,\dots , n\). It is known from [16] that \(f_i\), \(1\le i\le n\), are planar functions from \(\mathbb F_{q}\) to \(\mathbb F_{q}\).

3.1 The first case

Define

$$\begin{aligned}&\displaystyle D_0=\{(x_{1},\ldots ,x_{n})\in \mathbb F_q^n\backslash \{(0,\ldots , 0)\}: Tr\left( x_{1}^{p^{k_{1}}+1}+\cdots +x_{n}^{p^{k_{n}}+1}\right) =0\},\nonumber \\&\displaystyle \mathscr {C}_{D_0}=\{c(a_{1},\ldots ,a_{n}):(a_{1},\ldots ,a_{n})\in \mathbb F_q^{n}\}, \end{aligned}$$
(3.1)

where

$$\begin{aligned} c(a_{1},\ldots ,a_{n})=(Tr(a_{1}x_{1}+\cdots +a_{n}x_{n}))_{(x_{1},\ldots ,x_{n})\in D_0}. \end{aligned}$$

Lemma 6

Let \(n_0=|D_0|\). Suppose that mn is even, then

$$\begin{aligned} n_0= & {} \frac{q^n-p}{p}+\frac{p-1}{p}G(\eta )^n\\= & {} \left\{ \begin{array}{ll}p^{mn-1}-1+(-1)^{(m-1)n}(p-1)p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 1\pmod 4,\\ p^{mn-1}-1+(-1)^{(m-1)n+\frac{mn}{2}}(p-1)p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 3\pmod 4. \end{array}\right. \end{aligned}$$

Suppose that mn is odd, then

$$\begin{aligned} n_0=p^{mn-1}-1. \end{aligned}$$

Proof

By Lemma  3, we have that

$$\begin{aligned} n_0+1= & {} \frac{1}{p}\sum _{y\in \mathbb F_p}\sum _{(x_1,\ldots , x_n)\in \mathbb F_q^n}\chi \left( y\left( x_1^{p^{k_1}+1}+\cdots +x_n^{p^{k_n}+1}\right) \right) \\= & {} \frac{q^n}{p}+\frac{1}{p}\sum _{y\in \mathbb F_p^*}\sum _{x_1\in \mathbb F_q}\chi \left( yx_1^{p^{k_1}+1}\right) \ldots \sum _{x_n\in \mathbb F_q}\chi \left( yx_n^{p^{k_n}+1}\right) \\= & {} \frac{q^n}{p}+\frac{1}{p}\sum _{y\in \mathbb F_p^*}G(\eta )^n\eta (y)^n. \end{aligned}$$

If m is even or m is odd and n is even, then \(\eta (y)^n=1\) for each \(y\in \mathbb F_p^*\). Hence \(n_0=\frac{q^n-p}{p}+\frac{p-1}{p}G(\eta )^n\).

If mn is odd, then m is odd. Let \(\eta '\) be a quadratic character of \(\mathbb F_p^*\), then \(\eta (y)=\eta '(y)\) for each \(y\in \mathbb F_p^*\). Hence \(\sum _{y\in \mathbb F_p^*}\eta (y)^n=\sum _{y\in \mathbb F_p^*}\eta '(y)=0\), so \(n_0=\frac{q^n-p}{p}\).

By Lemma  1, we can get the exact value of \(n_0\).

Theorem 1

Let \(\mathscr {C}_{D_{0}}\) be the linear code defined as (3.1).

If mn is even, then \(\mathscr {C}_{D_{0}}\) is a two-weight code with the Hamming weight distribution in Table 1.

If mn is odd, then \(\mathscr {C}_{D_0}\) is a three-weight code with the Hamming weight distribution in Table 2.

Table 1 mn is even
Table 2 mn is odd

Proof

Firstly, we determine the weight distribution of the code \(\mathscr {C}_{D_{0}}\). Define the following parameter

$$\begin{aligned}&N_{a}=\Bigg |\Bigg \{(x_1,\ldots , x_n)\in \mathbb F_{q}^n: {\text {Tr}}\left( x_1^{p^{k_1}+1}+\cdots +x_n^{p_n^{k_n}+1}\right) =0,\\&\qquad \quad {\text {Tr}}(a_1x_1+\cdots +a_nx_n)=0\Bigg \}\Bigg |-1, \end{aligned}$$

where \(a=(a_1,\ldots ,a_n)\in \mathbb F_{q}^{n}\). By definition and the basic facts of additive characters, for each \(a=(a_1,\ldots ,a_n)\in \mathbb F_{q}^{n}\setminus \{(0,\ldots ,0)\}\), we have

$$\begin{aligned} N_{a}= & {} \frac{1}{p^2}\sum _{(x_1,\ldots , x_n)\in \mathbb F_{q}^n}\sum _{y\in \mathbb F_{p}}\chi \left( y\left( x_1^{p^{k_1}+1}+\cdots +x_n^{p^{k_n}+1}\right) \right) \sum _{z\in \mathbb F_{p}}\chi \left( z\left( a_1x_1+\cdots +a_nx_n\right) \right) -1\\= & {} \frac{q^n-p^2}{p^2}+\frac{1}{p^2}\sum _{(x_1,\ldots , x_n)\in \mathbb F_{q}^n}\sum _{y\in \mathbb F_{p}^{*}}\chi \left( y\left( x_1^{p^{k_1}+1}+\cdots +x_n^{p^{k_n}+1}\right) \right) \\&+\,\frac{1}{p^2}\sum _{(x_1,\ldots ,x_n)\in \mathbb F_{q}^n}\sum _{z\in \mathbb F_{p}^{*}}\chi (z(a_1x_1+\cdots +a_nx_n))\\&+\, \frac{1}{p^2}\sum _{(x_1,\ldots , x_n)\in \mathbb F_{q}^n}\sum _{y,z\in \mathbb F_{p}^{*}}\chi \left( y\left( x_1^{p^{k_1}+1}+\cdots +x_n^{p^{k_n}+1}\right) +z(a_1x_1+\cdots +a_nx_n)\right) \\= & {} \frac{q^n-p^2}{p^2}+\varOmega _1+\varOmega _2+\varOmega _3. \end{aligned}$$

By Lemmas 2 and  4, we have that

$$\begin{aligned} \varOmega _1= & {} \frac{1}{p^2}\sum _{y\in \mathbb F_{p}^*} \sum _{x_1\in \mathbb F_{q}}\chi \left( yx_1^{p^{k_1}+1}\right) \ldots \sum _{x_n\in \mathbb F_{q}}\chi \left( yx_n^{p^{k_n}+1}\right) \\= & {} \frac{1}{p^2}\sum _{y\in \mathbb F_p^*}\eta (y)^nG(\eta )^n\\= & {} \left\{ \begin{array}{ll}\frac{p-1}{p^2}G(\eta )^n, &{} \quad \text{ if } \; mn \; \text{ is } \text{ even, }\\ 0, &{} \quad \text{ if } \; mn \; \text{ is } \text{ odd. }\end{array}\right. \end{aligned}$$

By \(a=(a_1,\ldots , a_n)\in \mathbb F_q^n\setminus \{(0,\ldots ,0)\}\), we have that

$$\begin{aligned} \varOmega _2= & {} \frac{1}{p^2}\sum _{z\in \mathbb F_{p}^*}\sum _{x_1\in \mathbb F_q}\chi (za_1x_1)\ldots \sum _{x_n\in \mathbb F_q}\chi (za_nx_n)=0. \end{aligned}$$

To compute \(N_{a}\), it is sufficient to determine the value of the exponential sum

$$\begin{aligned} \varOmega _3= & {} \frac{1}{p^2}\sum _{y,z\in \mathbb F_p^{*}}\sum _{x_1\in \mathbb F_q}\chi \left( yx_1^{p^{k_1}+1}+za_1x_1\right) \ldots \sum _{x_n\in \mathbb F_q}\chi \left( yx_n^{p^{k_n}+1}+za_nx_n\right) . \end{aligned}$$

For each \(k_i\) and \(d_i=\gcd (k_i,m)\), \(m/d_i\) is odd. Hence for \(y\in \mathbb F_p^*\), the polynomial \(f_i(x)=y^{p^{k_i}}x^{p^{2k_i}}+yx=y(x^{p^{2k_i}}+x)\) must be a permutation polynomial over \(\mathbb F_q\). In fact, suppose that there is \(0\ne b\in \mathbb F_q\) such that \(f_i(b)=0\). Then \(b^{p^{2k_i}-1}=-1\). Let \(\alpha \) be a primitive element of \(\mathbb F_q^*\) and \(b=\alpha ^t\), then

$$\begin{aligned} t(p^{2k_i}-1)\equiv \frac{p^m-1}{2}\pmod {p^m-1}. \end{aligned}$$
(3.2)

Let \(d_i=\gcd (m,k_i)\), then \(\gcd (2k_i, m)=d_i\) by \(m/d_i\) odd. Hence \(\gcd (p^{2k_i}-1, p^m-1)=(p^{d_i}-1)\) and \((p^{d_i}-1)\not \mid \frac{p^m-1}{2}\), so (3.2) is contradictory.

Since \(f_i(x)=y(x^{p^{2k_i}}+x)\) is a permutation polynomial over \(\mathbb F_q\), for each \(a_i\in \mathbb F_q\) there is the unique solution \(b_i\in \mathbb F_q\) of the equation \(x_i^{p^{2k_i}}+x_i+a_i^{p^{k_i}}=0\). In fact, there is a one-to-one correspondence between \(a_i\in \mathbb F_q\) and \(b_i\in \mathbb F_q\), and \(a_i=0\) is correspond to \(b_i=0\). Hence there is the unique solution \(wb_i\in \mathbb F_q\) of the equation \(y(x_i^{p^{2k_i}}+x_i+wa_i^{p^{k_i}})=0\), where \(w=\frac{z}{y}\in \mathbb F_p^*\).

By Lemma  5, we have that

$$\begin{aligned} \varOmega _3= & {} \frac{1}{p^2}\sum _{y,w\in \mathbb F_p^{*}}\sum _{x_1\in \mathbb F_q}\chi \left( yx_1^{p^{k_1}+1}+ywa_1x_1\right) \ldots \sum _{x_n\in \mathbb F_q}\chi \left( yx_n^{p^{k_n}+1}+ywa_nx_n\right) \\= & {} \frac{1}{p^2}\sum _{y\in \mathbb F_p^*}\eta (y)^nG(\eta )^n\sum _{w\in \mathbb F_p^*}\chi \left( y\sum _{i=1}^n(wb_i)^{p^{k_i}+1}\right) \\= & {} \frac{1}{p^2}\sum _{y\in \mathbb F_p^*}\eta (y)^nG(\eta )^n\sum _{w\in \mathbb F_p^*}\chi ' \left( yw^2{\text {Tr}}\left( \sum _{i=1}^n(b_i)^{p^{k_i}+1}\right) \right) . \end{aligned}$$

Set

$$\begin{aligned} \varGamma _0= & {} \left\{ (b_1,\ldots , b_n)\in \mathbb F_q^n\setminus \{(0,\ldots ,0)\}|{\text {Tr}}\left( \sum _{i=1}^nb_i^{p^{k_i}+1}\right) =0\right\} ,\\ \varGamma _1= & {} \left\{ (b_1,\ldots , b_n)\in \mathbb F_q^n|{\text {Tr}}\left( \sum _{i=1}^nb_i^{p^{k_i}+1}\right) \in \mathbb F_p^*\setminus {\mathbb F_p^*}^2\right\} ,\\ \varGamma _2= & {} \left\{ (b_1,\ldots , b_n)\in \mathbb F_q^n|{\text {Tr}}\left( \sum _{i=1}^nb_i^{p^{k_i}+1}\right) \in {\mathbb F_p^*}^2\right\} . \end{aligned}$$

To compute the value of \(\varOmega _3\), we divide into two cases.

The first case: mn is even, i.e. either m is even or n is even. Then we have that \(\eta (y)^n=1\) for \(y\in \mathbb F_p^*\).

If \((b_1,\ldots , b_n)\in \varGamma _0\), then \(\varOmega _3=\frac{(p-1)^2}{p^2}G(\eta )^n,\)

$$\begin{aligned} N_a=\frac{q^n-p^2}{p^2}+\frac{p-1}{p^2}G(\eta )^n+\frac{(p-1)^2}{p^2}G(\eta )^n=\frac{q^n-p^2}{p^2}+\frac{p-1}{p}G(\eta )^n. \end{aligned}$$

Hence by Lemma  6, the weight of \(\mathscr {C}_{D_{0}}\) is

$$\begin{aligned} n_0-N_a= & {} p^{mn-1}-p^{mn-2}. \end{aligned}$$

If \((b_1,\ldots , b_n)\in \varGamma _1\cup \varGamma _2\), then

$$\begin{aligned} \varOmega _3=\frac{1}{p^2}G(\eta )^n\sum _{y,w\in \mathbb F_p^*}\chi '\left( yw^2{\text {Tr}}\left( \sum _{i=1}^nb_i^{p^{k_i}+1}\right) \right) =-\frac{(p-1)}{p^2}G(\eta )^n, N_a=\frac{q^n-p^2}{p^2}. \end{aligned}$$

Hence by Lemma  6, the weight of \(\mathscr {C}_{D_{0}}\) is

$$\begin{aligned} n_0-N_a= & {} (p-1)\left( \frac{q^n}{p^2}+\frac{1}{p} G(\eta )^n\right) \\= & {} \left\{ \begin{array}{ll}(p-1)\left( p^{mn-2}+(-1)^{(m-1)n}p^{\frac{mn}{2}-1}\right) , &{} \quad \text{ if } p\equiv 1\pmod 4,\\ (p-1)\left( p^{mn-2}+(-1)^{(m-1)n+\frac{mn}{2}}p^{\frac{mn}{2}-1}\right) , &{} \quad \text{ if } p\equiv 3\pmod 4. \end{array}\right. \end{aligned}$$

The second case: mn is odd. Then we have that that \(\eta (y)^n=\eta '(y)\) for \(y\in \mathbb F_p^*\).

If \((b_1,\ldots , b_n)\in \varGamma _0\), then

$$\begin{aligned} \varOmega _3=\frac{p-1}{p^2}G(\eta )^n\sum _{y\in \mathbb F_p^*}\eta '(y)=0, N_a=\frac{q^n-p^2}{p^2}, n_0-N_a=(p-1)p^{mn-2}. \end{aligned}$$

If \((b_1,\ldots , b_n)\in \varGamma _2\), so \({\text {Tr}}(\sum _{i=1}^nb_i^{p^{k_i}+1})=c\in {\mathbb F_p^*}^2\), then

$$\begin{aligned}&\displaystyle \varOmega _3=\frac{p-1}{p^2}G(\eta )^n\sum _{y\in \mathbb F_p^*}\eta '(y)\chi '(y)=\frac{p-1}{p^2}G(\eta )^nG(\eta '),\\&\displaystyle N_a=\frac{q^n-p^2}{p^2}+\frac{p-1}{p^2}G(\eta )^nG(\eta '),\\&\displaystyle n_0-N_a=\left\{ \begin{array}{ll}(p-1)\left( p^{mn-2}-(-1)^{(m-1)n}p^{\frac{mn-3}{2}}\right) , &{} \quad \text{ if } p\equiv 1\pmod 4,\\ (p-1)\left( p^{mn-2}-(-1)^{(m-1)n+\frac{mn+1}{2}}p^{\frac{mn-3}{2}}\right) , &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

If \((b_1,\ldots , b_n)\in \varGamma _1\), so \({\text {Tr}}(\sum _{i=1}^nb_i^{p^{k_i}+1})=c\in \mathbb F_p^*\setminus {\mathbb F_p^*}^2\), then

$$\begin{aligned}&\displaystyle \varOmega _3=\frac{p-1}{p^2}G(\eta )^n\sum _{y\in \mathbb F_p^*}\eta '(cy)\chi '(y)=-\frac{p-1}{p^2}G(\eta )^nG(\eta '),\\&\displaystyle N_a=\frac{q^n-p^2}{p^2}-\frac{p-1}{p^2}G(\eta )^nG(\eta ').\\&\displaystyle n_0-N_a=\left\{ \begin{array}{ll}(p-1)\left( p^{mn-2}+(-1)^{(m-1)n}p^{\frac{mn-3}{2}}\right) , &{} \quad \text{ if } p\equiv 1\pmod 4,\\ (p-1)\left( p^{mn-2}+(-1)^{(m-1)n+\frac{mn+1}{2}}p^{\frac{mn-3}{2}}\right) , &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

Secondly, we determine the frequency of each nonzero weight of \(\mathscr {C}_{D_0}\). It is sufficient to consider the values of \(|\varGamma _i|,i=0,1,2\).

By Lemma  6, it is clear that

$$\begin{aligned} |\varGamma _0|=n_0=\left\{ \begin{array}{ll}\frac{q^n-p}{p}+\frac{p-1}{p}G(\eta )^n, &{} \quad \text{ if } \ mn \; \text{ is } \text{ even, }\\ \frac{q^n-p}{p}, &{} \quad \text{ if } \ mn \; \text{ is } \text{ odd. }\end{array}\right. \end{aligned}$$

If mn is even, then by Lemma  1,

$$\begin{aligned} |\varGamma _0|=\left\{ \begin{array}{ll}\frac{q^n-p}{p}+(-1)^{(m-1)n}(p-1)p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 1\pmod 4,\\ \frac{q^n-p}{p}+(-1)^{(m-1)n+\frac{mn}{2}}(p-1)p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

Since \(|\varGamma _0|<q^n\). Without loss of generality, suppose that \(\varGamma _2\ne \emptyset \). For some \(c\in {\mathbb F_p^*}^2\), there are \((x_1,\ldots , x_n)\in \mathbb F_q^n\) such that \({\text {Tr}}(x_1^{p^{k_1}+1}+\cdots +x_n^{p^{k_n}+1})=c\in {\mathbb F_p^*}^2\). By the property of the trace function, the values are presented averagely from \({\mathbb F_p^*}^2\). Hence

$$\begin{aligned} |\varGamma _2|= & {} \frac{p-1}{2p}\sum _{y\in \mathbb F_p}\sum _{(x_1,\ldots , x_n)\in \mathbb F_q^n}\chi '\left( y{\text {Tr}}\left( x_1^{p^{k_1}+1}+\cdots +x_n^{p^{k_n}+1}\right) -cy\right) \\= & {} \frac{q^n(p-1)}{2p}+\frac{p-1}{2p}\sum _{y\in \mathbb F_p^*}\sum _{x_1\in \mathbb F_q}\chi \left( yx_1^{p_1^{k_1}+1}\right) \ldots \sum _{x_n\in \mathbb F_q}\chi \left( yx_n^{p^{k_n}+1}\right) \chi '(-cy)\\= & {} \frac{(p-1)q^n}{2p}+\frac{p-1}{2p}\sum _{y\in \mathbb F_p^*}G(\eta )^n\eta (y)^n\chi '(-cy)\\= & {} \left\{ \begin{array}{l@{\quad }l}\frac{(p-1)q^n}{2p}-\frac{p-1}{2p} G(\eta )^n, &{}\text{ if } \ mn \; \text{ is } \text{ even, }\\ \frac{(p-1)q^n}{2p}+\frac{p-1}{2p} \eta '(-1)G(\eta )^nG(\eta '), &{}\text{ if } \ mn \; \text{ is } \text{ odd. }\end{array}\right. \end{aligned}$$

If mn is even, then by Lemma  1,

$$\begin{aligned} |\varGamma _2|=\left\{ \begin{array}{ll} \frac{p-1}{2p}\left( p^{mn}-(-1)^{(m-1)n}p^{\frac{mn}{2}}\right) , &{} \quad \text{ if } p\equiv 1\pmod 4,\\ \frac{p-1}{2p}\left( p^{mn}-(-1)^{(m-1)n+\frac{mn}{2}}p^{\frac{mn}{2}}\right) , &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

If mn is odd, then by Lemma  1,

$$\begin{aligned} |\varGamma _2|=\left\{ \begin{array}{ll} \frac{p-1}{2p}\left( p^{mn}+(-1)^{(m-1)n+\frac{mn+1}{2}}p^{\frac{mn+1}{2}}\right) , &{} \quad \text{ if } p\equiv 1\pmod 4,\\ \frac{p-1}{2p}\left( p^{mn}-(-1)^{(m-1)n+\frac{mn+1}{2}}p^{\frac{mn+1}{2}}\right) , &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

Since \(|\varGamma _0|+|\varGamma _2|<q^n\), \(\varGamma _1\ne \emptyset \). Similarly, the values of the trace function are presented averagely from \(\mathbb F_p^*\setminus {\mathbb F_p^*}^2\) and

$$\begin{aligned} |\varGamma _1|= \left\{ \begin{array}{ll}\frac{(p-1)q^n}{2p}-\frac{p-1}{2p} G(\eta )^n, &{} \quad \text{ if } \ mn \; \text{ is } \text{ even, }\\ \frac{(p-1)q^n}{2p}-\frac{p-1}{2p} \eta '(-1)G(\eta )^nG(\eta '), &{} \quad \text{ if } \ mn \; \text{ is } \text{ odd. }\end{array}\right. \end{aligned}$$

If mn is even, then

$$\begin{aligned} |\varGamma _1|=\left\{ \begin{array}{ll} \frac{p-1}{2p}\left( p^{mn}-(-1)^{(m-1)n}p^{\frac{mn}{2}}\right) , &{} \quad \text{ if } p\equiv 1\pmod 4,\\ \frac{p-1}{2p}\left( p^{mn}-(-1)^{(m-1)n+\frac{mn}{2}}p^{\frac{mn}{2}}\right) , &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

If mn is odd, then by Lemma  1,

$$\begin{aligned} |\varGamma _1|=\left\{ \begin{array}{ll} \frac{p-1}{2p}\left( p^{mn}-(-1)^{(m-1)n+\frac{mn+1}{2}}p^{\frac{mn+1}{2}}\right) , &{} \quad \text{ if } p\equiv 1\pmod 4,\\ \frac{p-1}{2p}\left( p^{mn}+(-1)^{(m-1)n+\frac{mn+1}{2}}p^{\frac{mn+1}{2}}\right) , &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

Hence, we get the Tables  1 and  2. \(\square \)

Example 1

Let \(m=3\), \(n=1\), \(p=3\), the code \(\mathscr {C}_{D_0}\) has parameters [8,3,4] and weight enumerator \(1+6z^{4}+8z^{6}+12z^{8}\). This code is almost optimal linear code,as the optimal one has parameters [8,3,5] by the Griesmer bound.

Example 2

Let \(m=2\), \(n=2\), \(p=3\), the code \(\mathscr {C}_{D_0}\) has parameters [44,4,18] and weight enumerator \(1+32z^{18}+36z^{24}\).

3.2 The second case

Fix \(c\in {\mathbb F_p^*}^2\) and define

$$\begin{aligned}&\displaystyle D_2=\Bigg \{(x_{1},\ldots ,x_{n})\in \mathbb F_q^n: {\text {Tr}}\left( x_{1}^{p^{k_{1}}+1}+\cdots +x_{n}^{p^{k_{n}}+1}\right) =c\Bigg \},\nonumber \\&\displaystyle \mathscr {C}_{D_2}=\Bigg \{c(a_{1},\ldots ,a_{n}):(a_{1},\ldots ,a_{n})\in \mathbb F_q^{n}\Bigg \} , \end{aligned}$$
(3.3)

where

$$\begin{aligned} c(a_{1},\ldots ,a_{n})=({\text {Tr}}(a_{1}x_{1}+\cdots +a_{n}x_{n}))_{(x_{1},\ldots ,x_{n})\in D_2}. \end{aligned}$$

Since \(\mathscr {C}_{D_2}\) is a linear code over \(\mathbb F_p\), it is independent of the choice of c. For convenience, we take \(c=1\).

By Lemma  1 and the computation of \(\varGamma _2\) as above, we can get the result.

Lemma 7

Let \(n_2=|D_2|\). Suppose that mn is even, then

$$\begin{aligned} n_2=\frac{q^{n}}{p}-\frac{1}{p} G(\eta )^n=\left\{ \begin{array}{ll}p^{mn-1}-(-1)^{(m-1)n}p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 1\pmod 4,\\ p^{mn-1}-(-1)^{(m-1)n+\frac{mn}{2}}p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

Suppose that mn is odd, then

$$\begin{aligned} n_2= & {} \frac{q^n}{p}+\frac{1}{p} \eta '(-1)G(\eta )^nG(\eta ')\\= & {} \left\{ \begin{array}{ll}p^{mn-1}+(-1)^{(m-1)n}p^{\frac{mn-1}{2}}, &{} \quad \text{ if } p\equiv 1\pmod 4,\\ p^{mn-1}-(-1)^{(m-1)n+\frac{mn+1}{2}}p^{\frac{mn-1}{2}}, &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$
Table 3 mn is even
Table 4 mn is odd

Theorem 2

Let \(\mathscr {C}_{D_{2}}\) be the linear code defined as (3.3).

If mn is even, then \(\mathscr {C}_{D_{2}}\) is a two-weight code with the Hamming weight distribution in Table  3.

If mn is odd, then \(\mathscr {C}_{D_1}\) is a two-weight code with the Hamming weight distribution in Table  4.

Proof

Firstly, we determine the weight distribution of the code \(\mathscr {C}_{D_{2}}\). Fix \(c=1\in {\mathbb F_p^*}^2\). Define the following parameter

$$\begin{aligned} N_{a}'=\Bigg |\Bigg \{(x_1,\ldots , x_n)\in \mathbb F_{q}^n: {\text {Tr}}\left( x_1^{p^{k_1}+1}+\cdots +x_n^{p_n^{k_n}+1}\right) =1, {\text {Tr}}(a_1x_1+\cdots +a_nx_n)=0\Bigg \}\Bigg |, \end{aligned}$$

where \(a=(a_1,\ldots ,a_n)\in \mathbb F_{q}^{n}\setminus \{(0,\ldots ,0)\}\). We have

$$\begin{aligned} N_{a}'= & {} \frac{1}{p^2}\sum _{(x_1,\ldots , x_n)\in \mathbb F_{q}^n, y,z\in \mathbb F_{p}}\chi '\left( y({\text {Tr}}\left( x_1^{p^{k_1}+1}+\cdots +x_n^{p^{k_n}+1})-1\right) \right) \chi (z(a_1x_1+\ldots +a_nx_n))\\= & {} \frac{q^n}{p^2}+\frac{1}{p^2}\sum _{(x_1,\ldots , x_n)\in \mathbb F_{q}^n}\sum _{y\in \mathbb F_{p}^{*}}\chi '\left( y\left( {\text {Tr}}(x_1^{p^{k_1}+1}+\cdots +x_n^{p^{k_n}+1}\right) -1\right) \\&+ \,\frac{1}{p^2}\sum _{(x_1,\ldots ,x_n)\in \mathbb F_{q}^n}\sum _{z\in \mathbb F_{p}^{*}}\chi (z(a_1x_1+\cdots +a_nx_n))\\&+ \, \frac{1}{p^2}\sum _{(x_1,\ldots , x_n)\in \mathbb F_{q}^n}\sum _{y,z\in \mathbb F_{p}^{*}}\chi '\left( y\left( {\text {Tr}}(x_1^{p^{k_1}+1}+\cdots +x_n^{p^{k_n}+1}\right) -1\right) \chi (z(a_1x_1+\cdots +a_nx_n))\\=: & {} \frac{q^n}{p^2}+\varOmega _1'+\varOmega _2'+\varOmega _3'. \end{aligned}$$

We have that

$$\begin{aligned} \varOmega _1'= & {} \frac{1}{p^2}\sum _{y\in \mathbb F_{p}^*}\sum _{x_1\in \mathbb F_{q}}\chi \left( yx_1^{p^{k_1}+1}\right) \cdots \sum _{x_n\in \mathbb F_{q}}\chi \left( yx_n^{p^{k_n}+1}\right) \sum \chi '(-y)\\= & {} \frac{1}{p^2}\sum _{y\in \mathbb F_p^*}G(\eta )^n\eta (y)^n\chi '(-y)\\= & {} \left\{ \begin{array}{ll}-\frac{1}{p^2}G(\eta )^n, &{} \quad \text{ if } mn \; \text{ is } \text{ even, }\\ \frac{1}{p^2}\eta (-1)G(\eta )^nG(\eta '), &{} \quad \text{ if } mn \; \text{ is } \text{ odd. }\end{array}\right. \end{aligned}$$

By \((a_1,\ldots , a_n)\in \mathbb F_p^n\setminus \{(0,\ldots ,0)\}\), we have that

$$\begin{aligned} \varOmega _2'=0. \end{aligned}$$

Similarly, we have

$$\begin{aligned} \varOmega _3' =\frac{1}{p^2}\sum _{y\in \mathbb F_p^*}\eta (y)^nG(\eta )^n\sum _{w\in \mathbb F_p^*}\chi ' \left( y\left( w^2{\text {Tr}}\left( \sum _{i=1}^n(b_i)^{p^{k_i}+1}\right) -1\right) \right) , \end{aligned}$$

where \((b_1,\ldots , b_n)\) is one-to-one correspondent to \((a_1,\ldots , a_n)\), and \((0,\ldots ,0)\) is correspondence to \((0,\ldots ,0)\).

To compute the value of \(\varOmega _3'\), we divide into two cases.

The first case: mn is even. Then \(\eta (y)^n=1\) for \(y\in \mathbb F_p^*\).

If \((b_1,\ldots , b_n)\in \varGamma _0\), then

$$\begin{aligned}&\displaystyle \varOmega _3'=\frac{p-1}{p^2}G(\eta )^n\sum _{y\in \mathbb F_p^*}\chi '(-y)=-\frac{p-1}{p^2}G(\eta )^n,\\&\displaystyle N_a'=\frac{q^n}{p^2}-\frac{1}{p^2}G(\eta )^n-\frac{p-1}{p^2}G(\eta )^n=\frac{q^n}{p^2}-\frac{1}{p}G(\eta )^n, n_2-N_a'=(p-1)p^{mn-2}. \end{aligned}$$

If \((b_1,\ldots , b_n)\in \varGamma _1\), then \(w^2{\text {Tr}}((\sum _{i=1}^n(b_i)^{p^{k_i}+1})\ne 1\) for any \(w\in \mathbb F_p^*\). Hence

$$\begin{aligned} \varOmega _3'=-\frac{p-1}{p^2}G(\eta )^n, N_a'=\frac{q^n}{p^2}-\frac{1}{p}G(\eta )^n, n_2-N_a'=(p-1)p^{mn-2}. \end{aligned}$$

If \((b_1,\ldots , b_n)\in \varGamma _2\), then there are only two \(\pm w_0\in \mathbb F_p^*\) such that \(w_0^2{\text {Tr}}((\sum _{i=1}^n(b_i)^{p^{k_i}+1})=1\), so

$$\begin{aligned} \varOmega _3'= & {} \frac{1}{p^2}G(\eta )^n\left( \sum _{y,w\in \mathbb F_q^*, w\ne \pm w_0}\chi '\left( y\left( w^2{\text {Tr}}\left( \sum _{i=1}^n(b_i)^{p^{k_i}+1}\right) -1\right) \right) +2(p-1)\right) \\= & {} \frac{1}{p^2} G(\eta )^n(-(p-3)+2(p-1))=\frac{p+1}{p^2}G(\eta )^n,\\ N_a'= & {} \frac{q^n}{p^2}-\frac{1}{p^2}G(\eta )^n+\frac{p+1}{p^2}G(\eta )^n=\frac{q^n}{p^2}+\frac{1}{p}G(\eta )^n,\\ n_2-N_a'= & {} \frac{(p-1)q^n}{p^2}-\frac{2}{p}G(\eta )^n\\= & {} \left\{ \begin{array}{ll}(p-1)p^{mn-2}-2(-1)^{(m-1)n}p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 1\pmod 4,\\ (p-1)p^{mn-2}-2(-1)^{(m-1)n+\frac{mn}{2}}p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

The second case: mn is odd. Then \(\eta (y)^n=\eta '(y)\) for any \(y\in \mathbb F_p^*\).

If \((b_1,\ldots , b_n)\in \varGamma _0\), then

$$\begin{aligned}&\displaystyle \varOmega _3'=\frac{p-1}{p^2}\eta '(-1)G(\eta )^nG(\eta '), N_a'=\frac{q^2}{p^2}+\frac{1}{p}\eta '(-1)G(\eta )^nG(\eta ').\\&\displaystyle n_2-N_a'=(p-1)p^{mn-2}. \end{aligned}$$

If \((b_1,\ldots , b_n)\in \varGamma _1\), then \(w^2{\text {Tr}}(\sum _{i=1}^n(b_i)^{p^{k_i}+1})\ne 1\) for any \(w\in \mathbb F_p^*\). let \(\beta \) be a primitive root of \(\mathbb F_p^*\), then \(C_0=<\beta ^2>\) be a subgroup of \(\mathbb F_p^*\) and \(C_1=\beta C_0\), so \(\mathbb F_p^*=C_0\cup C_1\). Define

$$\begin{aligned} (i,j)_2=|(C_i+1)\cap C_j|, \quad i,j=0,1, \end{aligned}$$

all cyclotomic numbers of order 2. We have the following results [25]: If \(p\equiv 1\pmod 4\), then \((1,0)_2=(0,1)_2=(1,1)_2=\frac{p-1}{4}\), \((0,0)_2=\frac{p-5}{4}\). If \(p\equiv 3\pmod 4\), then \((1,0)_2=(0,0)_2=(1,1)_2=\frac{p-3}{4}\), \((0,1)_2=\frac{p+1}{4}\).

Hence

$$\begin{aligned} \varOmega _3'= & {} \frac{2}{p^2}\sum _{y\in \mathbb F_p^*} G(\eta )^n\eta '(y)\left( \sum _{s\in C_1, s-1\in C_0}\chi '((s-1)y)+\sum _{s\in C_1, s-1\in C_1}\chi '(s-1)y\right) \\= & {} \frac{2}{p^2}G(\eta )^nG(\eta ')((0,1)_2-(1,1)_2),\\ N_a'= & {} \frac{q^2}{p^2}+\frac{1}{p^2}\eta (-1)G(\eta )^nG(\eta ')+\frac{2}{p^2}G(\eta )^nG(\eta ')((0,1)_2-(1,1)_2),\\ n_2-N_a'= & {} \left\{ \begin{array}{ll} (p-1)p^{mn-2}, &{} \quad \text{ if } p\equiv 1\pmod 4,\\ (p-1)p^{mn-2}-2(-1)^{(m-1)n+\frac{mn+1}{2}}p^{\frac{mn-3}{2}}, &{} \quad \text{ if } p\equiv 3\pmod 4. \end{array}\right. \end{aligned}$$

If \((b_1,\ldots , b_n)\in \varGamma _2\), then there are only two \(\pm w_0\in \mathbb F_p^*\) such that \(w_0^2{\text {Tr}}((\sum _{i=1}^n(b_i)^{p^{k_i}+1})=1\). Hence

$$\begin{aligned} \varOmega _3'= & {} \frac{2}{p^2}\sum _{y\in \mathbb F_p^*}\eta (y)G(\eta )^n \left( \sum _{s\in C_0, s-1\in C_0}\chi '((s-1)y\right) +\sum _{s\in C_0,s-1\in C_1}\chi '((s-1)y)+1)\\= & {} \frac{2}{p^2}G(\eta )^nG(\eta ')((0,0)_2-(1,0)_2),\\ N_a'= & {} \frac{q^2}{p^2}+\frac{1}{p^2}\eta (-1)G(\eta )^nG(\eta ')+\frac{2}{p^2}G(\eta )^nG(\eta ')((0,0)_2-(1,0)_2),\\ n_2-N_a'= & {} \left\{ \begin{array}{ll}(p-1)p^{mn-2}+2(-1)^{(m-1)n}p^{\frac{mn-3}{2}}, &{} \quad \text{ if } p\equiv 1\pmod 4,\\ (p-1)p^{mn-2}, &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

By the computations of \(\varGamma _0,\varGamma _1,\varGamma _2\), we get the Tables 3 and 4. \(\square \)

Example 3

Let \(m=1\), \(n=2\), \(p=5\), the code \(\mathscr {C}_{D_2}\) is a [4,2,2] almost optimal linear code, as the optimal one has parameters [4,2,3] by the Griesmer bound.

Example 4

Let \(m=2\), \(n=2\), \(p=3\), the code \(\mathscr {C}_{D_2}\) has parameters [24,4,12] and weight enumerator \(1+24z^{12}+50z^{18}\).

Example 5

Let \(m=3\), \(n=3\), \(p=3\), the code \(\mathscr {C}_{D_2}\) has parameters [6642,9,4374] and weight enumerator \(1+13202z^{4374}+6480z^{4401}\).

3.3 The third case

Fix \(c\in \mathbb F_p^* \setminus {\mathbb F_p^*}^2\) and define

$$\begin{aligned}&\displaystyle D_1=\{(x_{1},\ldots ,x_{n})\in \mathbb F_q^n: {\text {Tr}}\left( x_{1}^{p^{k_{1}}+1}+\cdots +x_{n}^{p^{k_{n}}+1}\right) =c\},\nonumber \\&\displaystyle \mathscr {C}_{D_1}=\{c(a_{1},\ldots ,a_{n}):(a_{1},\ldots ,a_{n})\in \mathbb F_q^{n}\} , \end{aligned}$$
(3.4)

where

$$\begin{aligned} c(a_{1},\ldots ,a_{n})=({\text {Tr}}(a_{1}x_{1}+\cdots +a_{n}x_{n}))_{(x_{1},\ldots ,x_{n})\in D_1}. \end{aligned}$$

Since \(\mathscr {C}_{D_1}\) is a linear code over \(\mathbb F_p\), it is independent of the choice of c.

By Lemma  1 and the computation of \(\varGamma _{1}\) as above, we can get the result similarly with Lemma  7.

Lemma 8

Let \(n_1=|D_1|\). Suppose that mn is even, then

$$\begin{aligned} n_1=\frac{q^{n}}{p}-\frac{1}{p} G(\eta )^n=\left\{ \begin{array}{ll}p^{mn-1}-(-1)^{(m-1)n}p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 1\pmod 4,\\ p^{mn-1}-(-1)^{(m-1)n+\frac{mn}{2}}p^{\frac{mn}{2}-1}, &{} \quad \text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$

Suppose that mn is odd, then

$$\begin{aligned} n_1= & {} \frac{q^n}{p}-\frac{1}{p} \eta '(-1)G(\eta )^nG(\eta ')\\= & {} \left\{ \begin{array}{ll}p^{mn-1}-(-1)^{(m-1)n}p^{\frac{mn-1}{2}}, &{}\text{ if } p\equiv 1\pmod 4,\\ p^{mn-1}+(-1)^{(m-1)n+\frac{mn+1}{2}}p^{\frac{mn-1}{2}}, &{}\text{ if } p\equiv 3\pmod 4.\end{array}\right. \end{aligned}$$
Table 5 mn is even
Table 6 mn is odd

Theorem 3

Let \(\mathscr {C}_{D_{1}}\) be the linear code defined as (3.4).

If mn is even, then \(\mathscr {C}_{D_{1}}\) is a two-weight code with the Hamming weight distribution in Table  5.

If mn is odd, then \(\mathscr {C}_{D_1}\) is a two-weight code with the Hamming weight distribution in Table  6.

Proof

By the process of proving Theorem  2, we can get the result. \(\square \)

4 Concluding remarks

There is a recent survey on three-weight codes [3, 9, 17, 18, 22, 26, 27]. We did not find the the parameters of the binary three-weight codes of this paper in these literatures.

Linear codes can be used to construct secret sharing schemes [28]. Let \(w_{\min }\) and \(w_{\max }\) denote the minimum and maximum nonzero Hamming weights of a linear code \(\mathscr {C}\). To obtain secret sharing schemes with interesting access structures, we would like to construct linear codes which have the property that

$$\begin{aligned} w_{\min }/w_{\max }>\frac{p-1}{p}. \end{aligned}$$

We remark that the linear codes in this paper can be employed in secret sharing schemes using the framework in [28].

For the code of \(\mathscr {C}_{D}\) the Theorem 3.2, we have

$$\begin{aligned} w_{\min }/w_{\max }=\frac{(p-1)p^{mn-2}}{(p-1) \left( p^{nm-2}+p^{\frac{nm-3}{2}}\right) }>\frac{p-1}{p}, \quad where \,n \ge 1, m>4 \end{aligned}$$

For the code of \(\mathscr {C}_{D}\) the Theorem 3.4, we have

$$\begin{aligned} w_{\min }/w_{\max }=\frac{(p-1)p^{mn-2}}{(p-1)p^{nm-2} +2p^{\frac{nm-3}{2}}}>\frac{p-1}{p}, \quad where \,n \ge 1, m>4 \end{aligned}$$