1 Introduction

Let \(\mathbb {F}_{p}\) be the finite field with p elements, where p is an odd prime. An [nkd] linear code \(\mathcal {C}\) over \(\mathbb {F}_{p}\) is a k-dimensional subspace of \(\mathbb {F}^{n}_{p}\) with minimum distance d. Let \(A_{i}\) denote the number of codewords with Hamming weight i the code \(\mathcal {C}\) of length n. The weight enumerator of \(\mathcal {C}\) is defined by \(1+A_{1}z+A_{2}z^{2}+\cdots +A_{n}z^{n}\). The sequence \((1,A_{1},A_{2},\ldots ,A_{n})\) is called the weight distribution of the code \(\mathcal {C}\). The weight distribution of the linear code is an important subject in coding theory. However, it is difficult to compute the weight distribution of a linear code in general.

Recently, the weight enumerators of linear codes were studied in [1, 2, 4,5,6, 9,10,11,12, 15,16,18] with the help of exponential sums in some cases. Ahn, Ka and Li [1] defined a class of linear codes as follows. Let \(D' = \{(x_{1},x_{2},\ldots ,x_{t}) \in \mathbb {F}_{q}^{t}{\setminus } \{(0,0,\ldots ,0)\} : \mathrm {Tr}_{m}(x_{1}+x_{2}+\cdots +x_{t})=0\}.\) A p-ary linear code \(\mathcal {C}_{D'}\) is defined by

$$\begin{aligned} \mathcal {C}_{D'}=\left\{ \mathbf {c}(a_{1},a_{2},\ldots ,a_{t}) : (a_{1},a_{2},\ldots ,a_{t})\in \mathbb {F}^{t}_{q}\right\} , \end{aligned}$$

where

$$\begin{aligned} \mathbf {c}(a_{1},a_{2},\ldots ,a_{t})=\left( \mathrm {Tr}_{m}\left( a_{1}x^{2}_{1}+a_{2}x^{2}_{2}+\cdots +a_{t}x^{2}_{t}\right) \right) _{(x_{1},x_{2},\cdots ,x_{t}) \in D'}. \end{aligned}$$

They determined the complete weight enumerators of \(\mathcal {C}_{D'}\). Yang and Yao [17] generalized the results of Ahn, Ka and Li [1]. They defined \(D_{b} = \{(x_{1},x_{2},\ldots ,x_{t}) \in \mathbb {F}_{q}^{t} : \mathrm {Tr}_{m}(x_{1}+x_{2}+\cdots +x_{t})=b\}\) for any \(b \in \mathbb {F}_{p}^{*}\) and determined the complete weight enumerator of a class of p-ary linear codes given by

$$\begin{aligned} \mathcal {C}_{D_{b}}=\left\{ \mathbf {c}(a_{1},a_{2},\ldots ,a_{t}) : (a_{1},a_{2},\ldots ,a_{t})\in \mathbb {F}^{t}_{q}\right\} , \end{aligned}$$

where

$$\begin{aligned} \mathbf {c}(a_{1},a_{2},\ldots ,a_{t})=\left( \mathrm {Tr}_{m}\left( a_{1}x^{2}_{1}+a_{2}x^{2}_{2}+\cdots +a_{t}x^{2}_{t}\right) \right) _{(x_{1},x_{2},\cdots ,x_{t}) \in D_{b}}. \end{aligned}$$

In this paper, we define

$$\begin{aligned} D=\left\{ (x_{1},x_{2}) \in \left( \mathbb {F}_{q}^{*}\right) ^{2} : \mathrm {Tr}_{m}(x_{1}+x_{2})=0\right\} \end{aligned}$$
(1)

and a p-ary linear code \(\mathcal {C}_{D}\) by

$$\begin{aligned} \mathcal {C}_{D}=\left\{ \mathbf {c}(a_{1},a_{2}) : (a_{1},a_{2})\in \mathbb {F}^{2}_{q}\right\} , \end{aligned}$$
(2)

where

$$\begin{aligned} \mathbf {c}(a_{1},a_{2})=\left( \mathrm {Tr}_{m}\left( a_{1}x^{2}_{1}+a_{2}x^{2}_{2}\right) \right) _{(x_{1},x_{2})\in D}. \end{aligned}$$

The purpose of this paper is to compute the weight enumerators of the punctured codes \(\mathcal {C}_{D}\).

Minimal linear codes can be used to construct secret sharing schemes with interesting access structures [7, 8]. The codes presented in this paper are minimal in the sense of Ding and Yuan [7, 8]. We shall explain it at the end of this paper in detail.

2 Preliminaries

Let p be an odd prime and \(q=p^{m}\) for a positive integer m. For any \(a\in \mathbb {F}_{q}\), we can define an additive character of the finite field \(\mathbb {F}_{q}\) as follows:

$$\begin{aligned} \displaystyle \psi _{a}:\mathbb {F}_{q} \longrightarrow \mathbb {C}^{*}, \psi _{a}(x)=\zeta _{p}^{\mathrm {Tr}_{m}(ax)}, \end{aligned}$$

where \(\zeta _p=e^{\frac{2\pi \sqrt{-1}}{p}}\) is a p-th primitive root of unity and \(\mathrm {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 is given by

$$\begin{aligned} \displaystyle \sum _{x\in \mathbb {F}_{q}}\psi _{a}(x) =&\left\{ \begin{array}{ll} q, &{} {\text { if}}\, a=0,\\ 0, &{} {\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}$$

Let \(q-1=sN\) for two positive integers \(s>1\), \(N>1\) and \(\alpha \) be a fixed primitive element of \(\mathbb {F}_{q}\). Let \(\langle \alpha ^{N} \rangle \) denote the subgroup of \(\mathbb {F}_{q}^{*}\) generated by \(\alpha ^{N}\). The cyclotomic classes of order N in \(\mathbb {F}_{q}\) are the cosets \(C_{i}^{(N,q)}=\alpha ^{i}\langle \alpha ^{N}\rangle \) for \(i=0,1,\ldots , N-1.\) We know that \(|C_{i}^{(N,q)}|=\frac{q-1}{N}\). The Gaussian periods of order N are defined by

$$\begin{aligned} \displaystyle \eta _{i}^{(N,q)}=\sum _{x\in C_{i}^{(N,q)}}\psi (x). \end{aligned}$$

Suppose that \(\eta \) is the quadratic character of \(\mathbb {F}^{*}_{q}\) and \(\eta _{p}\) is the quadratic character of \(\mathbb {F}^{*}_{p}.\) For \(z\in \mathbb {F}^{*}_{p}\), it is easily checked that

$$\begin{aligned} \eta (z)=\left\{ \begin{array}{ll} 1,\;&{}\quad {\mathrm{if}}\;m\;{\mathrm{is\;even}}, \\ \eta _{p}(z),\;&{}\quad {\mathrm{if}}\;m\;{\mathrm{is\;odd}}.\end{array}\right. \end{aligned}$$
(3)

Lemma 1

[3, 13] Suppose that \(q=p^m\) where p is an odd prime and \(m \ge 1\). Then

$$\begin{aligned} \displaystyle 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^*=\big (\frac{-1}{p}\big )p=(-1)^{\frac{p-1}{2}}p\).

Lemma 2

[13] If q is odd and \(f(x)=a_{2}x^{2}+a_{1}x+a_{0}\in \mathbb {F}_{q}[x]\) with \(a_{2}\ne 0,\) then

$$\begin{aligned} \displaystyle \sum _{x\in \mathbb {F}_{q}}\zeta _{p}^{\mathrm {Tr}_{m}(f(x))}=\zeta _p^{\mathrm {Tr}_{m}(a_{0}-a_{1}^2(4a_{2})^{-1})}\eta (a_{2})G(\eta ). \end{aligned}$$

Lemma 3

[14] When \(N=2\), the Gaussian periods are given by

$$\begin{aligned} \displaystyle \eta ^{(2,q)}_{0}=&\left\{ \begin{array}{ll} \frac{-1+(-1)^{m-1}\sqrt{q}}{2}, &{}\quad \mathrm{{ if}}\, p\equiv 1\pmod {4},\\ \frac{-1+(-1)^{m-1}(\sqrt{-1})^{m}\sqrt{q}}{2}, &{}\quad \mathrm{{ if}}\, p\equiv 3\pmod {4}, \end{array} \right. \end{aligned}$$

and \(\eta ^{(2,q)}_{1}=-1-\eta ^{(2,q)}_{0}\).

3 Weight enumerators of the linear codes of \(\mathcal {C}_{D}\)

In this section, we present the weight distribution of the linear code \(\mathcal {C}_{D}\) defined by (1) and (2), where

$$\begin{aligned} D=\left\{ (x_{1},x_{2}) \in \left( \mathbb {F}_{q}^{*}\right) ^{2} : \mathrm {Tr}_{m}(x_{1}+x_{2})=0\right\} . \end{aligned}$$

To get the length of \(\mathcal {C}_{D}\), we need the following lemma.

Lemma 4

Denote \(n_{c}=|\{x_{1}, x_{2}, \in \mathbb {F}_{q}^{*} :\mathrm {Tr}_{m}(x_{1}+x_{2})=c\}|\) for each \(c \in \mathbb {F}_{p}\). Then

$$\begin{aligned} n_{c}=\left\{ \begin{array}{ll} \frac{(p^{m}-1)^{2}+p-1}{p},\;&{}\quad {\mathrm{if}}\;c=0, \\ \frac{(p^{m}-1)^{2}-1}{p},\;&{}\quad {\mathrm{if}}\;c\ne 0.\end{array}\right. \end{aligned}$$

Proof

By the orthogonal property of additive characters, we have

$$\begin{aligned} n_{c}&=\sum _{x_{1}, x_{2}, \in \mathbb {F}_{q}^{*}}\frac{1}{p} \sum _{y \in \mathbb {F}_{p}}\zeta _p^{y \big (\mathrm {Tr}_{m}(x_{1}+x_{2})-c\big )}\\&=\frac{(q-1)^{2}}{p}+\frac{1}{p}\sum _{y \in \mathbb {F}_{p}^{*}}\zeta _p^{-yc}\sum _{x_{1} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(yx_{1})}\sum _{x_{2} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(yx_{2})}. \end{aligned}$$

Thus, we get the desired results. \(\square \)

By Lemma 4 it is easy to see that the length of \(\mathcal {C}_{D}\) is \(n_{0}=\frac{(p^{m}-1)^{2}+p-1}{p}\).

For a codeword \(\mathbf {c}(a_{1},a_{2})\) of \(\mathcal {C}_{D}\) and \(\rho \in \mathbb {F}_{p}^{*},\) let \(N_{0}:=N(a_{1},a_{2})\) be the number of components \(\mathrm {Tr}_{m}(a_{1}x^{2}_{1}+a_{2}x^{2}_{2})\) of \(\mathbf {c}(a_{1},a_{2})\) which are equal to 0. Then

$$\begin{aligned} N_{0}&=\sum _{x_{1}, x_{2}\in \mathbb {F}_{q}^{*}}\left( \frac{1}{p}\sum _{y \in \mathbb {F}_{p}}\zeta _p^{y\mathrm {Tr}_{m}(x_{1}+x_{2})}\right) \left( \frac{1}{p}\sum _{z \in \mathbb {F}_{p}}\zeta _p^{z\mathrm {Tr_{m}}(a_{1}x^{2}_{1} +a_{2}x^{2}_{2})}\right) \nonumber \\&=\frac{1}{p^{2}}\sum _{x_{1}, x_{2} \in \mathbb {F}_{q}^{*}}\left( 1+\sum _{y \in \mathbb {F}^{*}_{p}}\zeta _p^{y\mathrm {Tr}_{m}(x_{1}+x_{2})}\right) \left( 1+\sum _{z \in \mathbb {F}^{*}_{p}}\zeta _p^{z\mathrm {Tr}_{m}(a_{1}x^{2}_{1} +a_{2}x^{2}_{2})}\right) \nonumber \\&=\frac{(p^{m}-1)^{2}}{p^{2}}+\frac{1}{p^{2}} (\varOmega _{1}+\varOmega _{2}+\varOmega _{3}), \end{aligned}$$
(4)

where

$$\begin{aligned}&\varOmega _{1}=\sum _{y \in \mathbb {F}_{p}^{*}}\sum _{x_{1} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(yx_{1})}\sum _{x_{2} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(yx_{2})}=p-1,\\&\varOmega _{2}=\sum _{z \in \mathbb {F}^{*}_{p}}\sum _{x_{1} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{1}x^{2}_{1})}\sum _{x_{2} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{2}x^{2}_{2})},\\&\mathrm{and}\\&\varOmega _{3}=\sum _{y,z \in \mathbb {F}^{*}_{p}}\sum _{x_{1} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{1}x^{2}_{1}+yx_{1})}\sum _{x_{2} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{2}x^{2}_{2}+yx_{2})}. \end{aligned}$$

We are going to determine the values of \(\varOmega _{2}\) and \(\varOmega _{3}\) in Lemmas 5 and 6. To simplify formulas, denote \(G_{i}=G(\eta )\eta (a_{i})\) for \(i\in \{1,2\}\).

Lemma 5

If \(a_{1}=0\) and \(a_{2}=0\), then

$$\begin{aligned} \varOmega _{2}=(p^{m}-1)^{2}(p-1). \end{aligned}$$

(1) If m is even, then

$$\begin{aligned} \varOmega _{2}=&\left\{ \begin{array}{ll} (p^{m}-1)(p-1)(G_{1}-1), &{}\quad {\mathrm{if}}\;a_{1}\ne 0,a_{2}=0,\\ (p^{m}-1)(p-1)(G_{2}-1), &{}\quad {\mathrm{if}}\;a_{1}=0,a_{2}\ne 0,\\ (p-1)(G_{1}G_{2}-G_{1}-G_{2}+1), &{}\quad {\mathrm{if}}\;a_{1}\ne 0,a_{2}\ne 0. \end{array} \right. \end{aligned}$$

(2) If m is odd, then

$$\begin{aligned} \varOmega _{2}=&\left\{ \begin{array}{ll} -(p^{m}-1)(p-1), &{}{\mathrm{if}}\;a_{1}\ne 0,a_{2}=0\;{\mathrm{or}}\;{\mathrm{if}}\;a_{1}=0,a_{2}\ne 0,\\ (p-1)(G_{1}G_{2}+1), &{}{\mathrm{if}}\;a_{1}\ne 0,a_{2}\ne 0. \end{array} \right. \end{aligned}$$

Proof

When \(a_{1}=0\) and \(a_{2}=0\), it is obvious that \(\varOmega _{2}\) is equal to \((p^{m}-1)^{2}(p-1)\).

If \(a_{1}\ne 0\) and \(a_{2}=0\), then by the orthogonal property of additive characters, we have

$$\begin{aligned} \varOmega _{2}&=\sum _{z \in \mathbb {F}^{*}_{p}}\sum _{x_{1} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{1}x^{2}_{1})} \sum _{x_{2} \in \mathbb {F}_{q}^{*}}1\\&=(q-1)\sum _{z \in \mathbb {F}^{*}_{p}}\left( \sum _{x_{1} \in \mathbb {F}_{q}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{1}x^{2}_{1})}-1\right) . \end{aligned}$$

By Lemma 2, we obtain

$$\begin{aligned} \varOmega _{2}&=(q-1)\sum _{z \in \mathbb {F}^{*}_{p}}(G(\eta )\eta (za_{1})-1)\\&=(p^{m}-1)G_{1}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z)-(p^{m}-1)(p-1). \end{aligned}$$

By (3), we get the results. Similarly, we compute the value of \(\varOmega _{2}\) when \(a_{1}=0\) and \(a_{2}\ne 0\).

If \(a_{1}\ne 0\) and \(a_{2}\ne 0\), then by Lemma 2, we get

$$\begin{aligned} \varOmega _{2}&=\sum _{z \in \mathbb {F}^{*}_{p}} \left( \sum _{x_{1} \in \mathbb {F}_{q}}\zeta _{p}^{\mathrm {Tr}_{m} (za_{1}x^{2}_{1})}-1\right) \left( \sum _{x_{2} \in \mathbb {F}_{q}}\zeta _{p}^{\mathrm {Tr}_{m} (za_{2}x^{2}_{1})}-1\right) \\&=\sum _{z \in \mathbb {F}^{*}_{p}}(G(\eta )\eta (za_{1})-1)(G(\eta )\eta (za_{2})-1)\\&=G_{1}G_{2}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z^{2})-G_{1}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z)-G_{2}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z)+(p-1). \end{aligned}$$

By (3), we get the results. \(\square \)

To simplify results, we denote \(G(\eta )G(\eta _{p})\) by G and \(A_{i}=\eta (a_{i})\eta _{p}(-\mathrm {Tr}_{m}(a_{i}^{-1}))\) for \(i \in \{1,2\}\).

Lemma 6

If \(a_{1}=0\) and \(a_{2}=0\), then

$$\begin{aligned} \varOmega _{3}=(p-1)^{2}. \end{aligned}$$

Suppose that m is even.

(1) If \(a_{1}\ne 0\) and \(a_{2}=0\), then

$$\begin{aligned} \varOmega _{3}=&\left\{ \begin{array}{ll} -(p-1)^{2}G_{1}+(p-1)^{2}, &{}\quad {\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})=0,\\ (p-1)G_{1}+(p-1)^{2}, &{}\quad {\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0. \end{array} \right. \end{aligned}$$

(2) If \(a_{1}=0\) and \(a_{2}\ne 0\), then

$$\begin{aligned} \varOmega _{3}=&\left\{ \begin{array}{ll} -(p-1)^{2}G_{2}+(p-1)^{2}, &{}\quad {\mathrm{if}}\;\mathrm {Tr}_{m}(a_{2}^{-1})=0,\\ (p-1)G_{2}+(p-1)^{2}, &{}\quad {\mathrm{if}}\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0. \end{array} \right. \end{aligned}$$

(3) If \(a_{1}\ne 0\) and \(a_{2}\ne 0\), then

$$\begin{aligned} \varOmega _{3}=&\left\{ \begin{array}{ll} (p-1)^{2}(G_{1}G_{2}-G_{1}-G_{2}+1),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})=0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{2}^{-1})=0,\\ (p-1)(-G_{1}G_{2}+G_{1}-(p-1)G_{2}+(p-1)),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{2}^{-1})=0,\\ (p-1)(-G_{1}G_{2}+G_{2}-(p-1)G_{1}+(p-1)),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})=0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0,\\ (p-1)((p-1)G_{1}G_{2}+G_{1}+G_{2}+(p-1)),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0,\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})=0,\\ (p-1)(-G_{1}G_{2}+G_{1}+G_{2}+(p-1)),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0,\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})\ne 0. \end{array} \right. \end{aligned}$$

Suppose that m is odd.

(1) If \(a_{1}\ne 0\) and \(a_{2}=0\), then

$$\begin{aligned} \varOmega _{3}=&\left\{ \begin{array}{ll} (p-1)^{2}, &{}\quad {\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})=0,\\ -(p-1)GA_{1}+(p-1)^{2}, &{}\quad {\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0. \end{array} \right. \end{aligned}$$

(2) If \(a_{1}=0\) and \(a_{2}\ne 0\), then

$$\begin{aligned} \varOmega _{3}=&\left\{ \begin{array}{ll} (p-1)^{2}, &{}\quad {\mathrm{if}}\;\mathrm {Tr}_{m}(a_{2}^{-1})=0,\\ -(p-1)GA_{2}+(p-1)^{2}, &{}\quad {\mathrm{if}}\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0. \end{array} \right. \end{aligned}$$

(3) If \(a_{1}\ne 0\) and \(a_{2}\ne 0\), then

$$\begin{aligned} \varOmega _{3}=&\left\{ \begin{array}{ll} (p-1)((p-1)G_{1}G_{2}+(p-1)),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})=0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{2}^{-1})=0,\\ (p-1)(-G_{1}G_{2}-GA_{1}+(p-1)),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{2}^{-1})=0,\\ (p-1)(-G_{1}G_{2}-GA_{2}+(p-1)),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})=0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0,\\ (p-1)((p-1)G_{1}G_{2}-GA_{1}-GA_{2}+(p-1)),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0,\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})=0,\\ (p-1)(-G_{1}G_{2}-GA_{1}-GA_{2}+(p-1)),&{}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm{if}}\;\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0,\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})\ne 0. \end{array} \right. \end{aligned}$$

Proof

We only compute the value of \(\varOmega _{3}\) for the case \(a_{1}\ne 0\) and \(a_{2}\ne 0\). One can compute the other cases similarly. By the orthogonal property of additive characters, we have

$$\begin{aligned} \varOmega _{3}&=\sum _{y,z \in \mathbb {F}^{*}_{p}}\sum _{x_{1} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{1}x^{2}_{1}+yx_{1})}\sum _{x_{2} \in \mathbb {F}_{q}^{*}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{2}x^{2}_{2}+yx_{2})}\\&=\sum _{y,z \in \mathbb {F}^{*}_{p}}\left( \sum _{x_{1} \in \mathbb {F}_{q}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{1}x^{2}_{1}+yx_{1})}-1\right) \left( \sum _{x_{1} \in \mathbb {F}_{q}}\zeta _{p}^{\mathrm {Tr}_{m}(za_{1}x^{2}_{1}+yx_{1})}-1\right) . \end{aligned}$$

By Lemma 2, we obtain

$$\begin{aligned} \varOmega _{3}&=\sum _{y,z \in \mathbb {F}^{*}_{p}}\left( \zeta _{p}^{\mathrm {Tr}_{m}(-y^{2}((4a_{1})^{-1}+(4a_{2})^{-1}))}G(\eta )^{2}\eta (a_{1}a_{2})-\zeta _{p}^{\mathrm {Tr}_{m}(-y^{2}(4a_{1})^{-1})}G(\eta )\eta (za_{1})\right. \nonumber \\&\left. \;\;\;\;-\zeta _{p}^{\mathrm {Tr}_{m}(-y^{2}(4a_{2})^{-1})}G(\eta )\eta (za_{2})+1\right) \nonumber \\&=G_{1}G_{2}\sum _{z \in \mathbb {F}^{*}_{p}}\sum _{y \in \mathbb {F}^{*}_{p}}\zeta _{p}^{-y^{2}(4z)^{-1}\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})}-G_{1}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z)\sum _{y \in \mathbb {F}^{*}_{p}}\zeta _{p}^{-y^{2}(4z)^{-1}\mathrm {Tr}_{m}(a_{1}^{-1})}\nonumber \\&\;\;\;\;-G_{2}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z)\sum _{y \in \mathbb {F}^{*}_{p}}\zeta _{p}^{-y^{2}(4z)^{-1}\mathrm {Tr}_{m}(a_{2}^{-1})}+(p-1)^{2}. \end{aligned}$$
(5)

If one of \(\mathrm {Tr}_{m}(a_{1}^{-1})\), \(\mathrm {Tr}_{m}(a_{2}^{-1})\) and \(\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})\) is zero, then it is easy to compute the term corresponding to it. We only consider the case of \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\), \(\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\) and \(\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})\ne 0\). Other cases can be computed similarly. From (5) we have

$$\begin{aligned} \varOmega _{3}&=G_{1}G_{2}\sum _{z \in \mathbb {F}^{*}_{p}} \left( \sum _{y \in \mathbb {F}_{p}}\zeta _{p}^{-y^{2}(4z)^{-1}\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})}-1\right) \\&\;\;\;\;-G_{1}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z) \left( \sum _{y \in \mathbb {F}_{p}}\zeta _{p}^{-y^{2}(4z)^{-1}\mathrm {Tr}_{m}(a_{1}^{-1})}-1\right) \\&\;\;\;\;-G_{2}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z) \left( \sum _{y \in \mathbb {F}_{p}}\zeta _{p}^{-y^{2}(4z)^{-1}\mathrm {Tr}_{m}(a_{2}^{-1})}-1\right) +(p-1)^{2}. \end{aligned}$$

By Lemma 2, we obtain

$$\begin{aligned} \varOmega _{3}&=G_{1}G_{2}\sum _{z \in \mathbb {F}^{*}_{p}}(\eta _{p}(-(4z)^{-1})\eta _{p}(\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})G(\eta _{p})-1)\\&\;\;\;\;-G_{1}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z)(\eta _{p}(-(4z)^{-1})\eta _{p}(\mathrm {Tr}_{m}(a_{1}^{-1})G(\eta _{p})-1)\\&\;\;\;\;-G_{2}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z)(\eta _{p}(-(4z)^{-1})\eta _{p}(\mathrm {Tr}_{m}(a_{2}^{-1})G(\eta _{p})-1)+(p-1)^{2}\\&=G_{1}G_{2}\sum _{z \in \mathbb {F}^{*}_{p}}(\eta _{p}(z)\eta _{p}(-\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})G(\eta _{p})-1)\\&\;\;\;\;-G_{1}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z)(\eta _{p}(z)\eta _{p}(-\mathrm {Tr}_{m}(a_{1}^{-1})G(\eta _{p})-1)\\&\;\;\;\;-G_{2}\sum _{z \in \mathbb {F}^{*}_{p}}\eta (z)(\eta _{p}(z)\eta _{p}(-\mathrm {Tr}_{m}(a_{2}^{-1})G(\eta _{p})-1)+(p-1)^{2}. \end{aligned}$$

By (3), we get the result. \(\square \)

Then by Lemmas 5 and 6, we obtain the values of \(N_{0}\). To get the frequency of each composition, we need the following lemmas.

Lemma 7

[1, Lemma 3.4] For any \(c \in \mathbb {F}_{p}\), let

$$\begin{aligned} m_{c}=|\{a\in \mathbb {F}^{*}_{q} : \mathrm {Tr}_{m}(a^{-1})=c\}|. \end{aligned}$$

Then we have

$$\begin{aligned} m_{c}=&\left\{ \begin{array}{ll} p^{m-1}-1, &{}\quad {\mathrm{if}}\;c=0,\\ p^{m-1}, &{}\quad {\mathrm{if}}\;c\ne 0. \end{array} \right. \end{aligned}$$

Lemma 8

[1, Lemma 3.5] For any \(c\in \mathbb {F}_{p}\), let

$$\begin{aligned} n_{i,c}=|\{a\in \mathbb {F}^{*}_{q} : \eta (a)=i\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a^{-1})=c\}|,\quad i \in \{-1,1\}. \end{aligned}$$

(1) If m is even, then

$$\begin{aligned} n_{i,c}=&\left\{ \begin{array}{ll} \frac{1}{2p}(q-p+i(p-1)G(\eta )), &{}\quad {\mathrm{if}}\;c=0,\\ \frac{1}{2p}(q-iG(\eta )), &{}\quad {\mathrm{if}}\;c\ne 0. \end{array} \right. \end{aligned}$$

(2) If m is odd, then

$$\begin{aligned} n_{i,c}=&\left\{ \begin{array}{ll} \frac{1}{2p}(q-p), &{}\quad {\mathrm{if}}\;c=0,\\ \frac{1}{2p}(q+i\eta _{p}(-c)G), &{}\quad {\mathrm{if}}\;c\ne 0.\\ \end{array} \right. \end{aligned}$$

Proof

If \(c=0\), then we get the result from [1, Lemma 3.5] with \(t=1\). If \(c\ne 0\), then by the orthogonal property of additive characters, we have

$$\begin{aligned} n_{1,c}&=\sum _{a\in C_{0}^{(2,q)}}\frac{1}{p} \sum _{x\in \mathbb {F}_{p}}\zeta _{p}^{x(\mathrm {Tr}_{m}(a^{-1})-c)}\nonumber \\&=\sum _{a\in C_{0}^{(2,q)}}\frac{1}{p} \left( \sum _{x\in \mathbb {F}^{*}_{p}}\zeta _{p}^{x(\mathrm {Tr}_{m}(a^{-1}) -c)}+1\right) \nonumber \\&=\frac{1}{p}\left( \sum _{x\in \mathbb {F}^{*}_{p}}\zeta _{p}^{-cx}\sum _{a\in C_{0}^{(2,q)}}\zeta _{p}^{\mathrm {Tr}_{m}(a^{-1}x)}+\frac{q-1}{2}\right) . \end{aligned}$$
(6)

Assume that m is even, then 2 divides \(\frac{q-1}{p-1}\) and so \(\mathbb {F}^{*}_{p}\subseteq C_{0}^{(2,q)}.\) By (6) we obtain

$$\begin{aligned} n_{1,c}&=\frac{1}{p}\left( \sum _{x\in \mathbb {F}^{*}_{p}}\zeta _{p}^{-cx}\eta _{0}^{(2,q)}+\frac{q-1}{2}\right) . \end{aligned}$$

Thus, we get the results. Also the case of \(n_{-1,c}\) is proved similarly.

Now suppose that m is odd, then \(\mathbb {F}^{*}_{p}=\{\mathbb {F}^{*}_{p}\cap C_{0}^{(2,q)}\}\cup \{\mathbb {F}^{*}_{p}\cap C_{1}^{(2,q)}\}.\) i.e.,\(|\mathbb {F}^{*}_{p}\cap C_{0}^{(2,q)}|=|\mathbb {F}^{*}_{p}\cap C_{1}^{(2,q)}|=\frac{p-1}{2}.\) By (6) we obtain

$$\begin{aligned} n_{1,c}&=\frac{1}{p}\left( \sum _{x\in \mathbb {F}^{*}_{p}\cap C_{0}^{(2,q)}}\zeta _{p}^{-cx}\sum _{a\in C_{0}^{(2,q)}}\zeta _{p}^{\mathrm {Tr}_{m}(a^{-1}x)}+\sum _{x\in \mathbb {F}^{*}_{p}\cap C_{1}^{(2,q)}}\zeta _{p}^{-cx}\sum _{a\in C_{0}^{(2,q)}}\zeta _{p}^{\mathrm {Tr}_{m}(a^{-1}x)}+\frac{q-1}{2}\right) \\&=\frac{1}{p}\left( \sum _{x\in \mathbb {F}^{*}_{p}\cap C_{0}^{(2,q)}}\zeta _{p}^{-cx}\eta _{0}^{(2,p)}+\sum _{x\in \mathbb {F}^{*}_{p}\cap C_{1}^{(2,q)}}\zeta _{p}^{-cx}\eta _{1}^{(2,p)}+\frac{q-1}{2}\right) . \end{aligned}$$

If \(-c \in C_{0}^{(2,p)}\), then we have

$$\begin{aligned} n_{1,c}=\frac{1}{p}\left( \eta _{0}^{(2,p)}\eta _{0}^{(2,q)} +\eta _{1}^{(2,p)}\eta _{1}^{(2,q)}+\frac{q-1}{2}\right) . \end{aligned}$$

If \(-c \in C_{1}^{(2,p)}\), then we have

$$\begin{aligned} n_{1,c}=\frac{1}{p}\left( \eta _{1}^{(2,p)}\eta _{0}^{(2,q)} +\eta _{0}^{(2,p)}\eta _{1}^{(2,q)}+\frac{q-1}{2}\right) . \end{aligned}$$

It is easily checked that \(\eta _{0}^{(2,p)}\eta _{0}^{(2,q)}+\eta _{1}^{(2,p)}\eta _{1}^{(2,q)}=\frac{G+1}{2}\) and \(\eta _{1}^{(2,p)}\eta _{0}^{(2,q)}+\eta _{0}^{(2,p)}\eta _{1}^{(2,q)}=\frac{-G+1}{2}\). Thus, we get the results. Also \(n_{-1,c}\) is computed similarly. This completes the proof. \(\square \)

Lemma 9

[1, Lemma 3.7] Suppose that m is odd, let

$$\begin{aligned} n^{\prime }_{i,j}=|\{a\in \mathbb {F}^{*}_{q} : \eta (a)=i\;{\mathrm{and}}\;\eta _{p}(-\mathrm {Tr}_{m}(a^{-1}))=j\}|,\;i,j \in \{-1,1\}. \end{aligned}$$

Then we have

$$\begin{aligned} n^{\prime }_{i,j}=\frac{p-1}{4p}\big (q+ijG). \end{aligned}$$

Theorem 1

Let \(\mathcal {C}_{D}\) be a linear code defined by (1) and (2) where \(D=\{(x_{1},x_{2}) \in (\mathbb {F}_{q}^{*})^{2} : \mathrm {Tr}_{m}(x_{1}+x_{2})=0\}.\) Suppose that m is even. If \(m=2\), then the weight distribution of \(\mathcal {C}_{D}\) is given by Table 1 and the code \(\mathcal {C}_{D}\) has parameters \([\frac{(p^{2}-1)^{2}+p-1}{p},\;4,\;(p-1)(p^{2}-p-2)]\). If \(m\ge 4\), then the weight distribution of \(\mathcal {C}_{D}\) is given by Table  2 and the code \(\mathcal {C}_{D}\) has parameters \([\frac{(p^{m}-1)^{2}+p-1}{p},\;2m,\;(p-1)\big (p^{2(m-1)}-p^{m-2}-p^{\frac{3m-4}{2}})]\).

Table 1 The weight distribution of \(\textit{C}_{D}\) for \(m=2\)
Table 2 The weight distribution of \(\textit{C}_{D}\) for even \(m\ge 4\)

Proof

Recall that \(N_{0}=\frac{(q-1)^{2}}{p^{2}}+\frac{1}{p^{2}}(\varOmega _{1}+\varOmega _{2}+\varOmega _{3})\). We employ Lemmas 5 and 6 to compute \(N_{0}\).

Assume that \(a_{1}\ne 0\) and \(a_{2}=0\).

If \(\mathrm {Tr}_{m}(a_{1}^{-1})=0\), then we obtain

$$\begin{aligned} N_{0}&=\frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}((q-p)G(\eta )\eta (a_{1})+p-q+1). \end{aligned}$$

Thus,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}((q-p)(G(\eta )-1)+1),&{}\quad {\mathrm{if}}\;\eta (a_{1})=1,\\ \frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}((q-p)(G(\eta )+1)-1),&{}\quad {\mathrm{if}}\;\eta (a_{1})=-1. \end{array} \right. \end{aligned}$$

Now the frequencies are \(n_{1,0}\) and \(n_{-1,0}\) in Lemma 8, respectively.

If \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\), then we obtain

$$\begin{aligned} N_{0}&=\frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}} (qG(\eta )\eta (a_{1})+p-q+1). \end{aligned}$$

Thus,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}(q\big (G(\eta )-1)+p+1),&{}\quad {\mathrm{if}}\;\eta (a_{1})=1,\\ \frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}(q\big (G(\eta )+1)-p-1),&{}\quad {\mathrm{if}}\;\eta (a_{1})=-1. \end{array} \right. \end{aligned}$$

Now the frequencies are \(\displaystyle \sum \nolimits _{c \in \mathbb {F}^{*}_{p}}n_{1,c}\) and \(\displaystyle \sum \nolimits _{c \in \mathbb {F}^{*}_{p}}n_{-1,c}\), respectively. If \(a_{1}=0\) and \(a_{2}\ne 0\), then we also have the same weights and the same frequencies with the case of \(a_{1}\ne 0\) and \(a_{2}=0\).

Now, assume that \(a_{1}\ne 0\) and \(a_{2}\ne 0\).

If \(\mathrm {Tr}_{m}(a_{1}^{-1})=\mathrm {Tr}_{m}(a_{2}^{-1})=0\), then we obtain

$$\begin{aligned} N_{0}&=\frac{(q-1)^{{2}}}{p^{2}}+\frac{(p-1)}{p^{2}} (pG(\eta )^{2}\eta (a_{1}a_{2})-pG(\eta )\eta (a_{1})-pG(\eta )\eta (a_{2})+p+1).\\ \end{aligned}$$

Thus,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}(pG(\eta )^{2}\\ -2pG(\eta )+p+1),&{}\quad {\mathrm{if}}\;\eta (a_{1})=1\;{\mathrm{and}}\;\eta (a_{2})=1,\\ \frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}(pG(\eta )^{2}-p-1),&{}\quad {\mathrm{if}}\;\eta (a_{1}a_{2})=-1,\\ \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}(pG(\eta )^{2}\\ +2pG(\eta )+p+1),&{}\quad {\mathrm{if}}\;\eta (a_{1})=-1\;{\mathrm{and}}\;\eta (a_{2})=-1. \end{array} \right. \end{aligned}$$

Now the frequencies are \((n_{1,0})^{2}\), \(2n_{1,0}n_{-1,0}\), \((n_{-1,0})^{2}\), respectively.

If \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{2}^{-1})=0\), then we have

$$\begin{aligned} N_{0}&=\frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}\big (pG(\eta )\eta (a_{2})-p-1). \end{aligned}$$

Thus,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}\big (pG(\eta )-p-1),&{}\quad {\mathrm{if}}\;\eta (a_{2})=1,\\ \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (pG(\eta )+p+1),&{}\quad {\mathrm{if}}\;\eta (a_{2})=-1. \end{array} \right. \end{aligned}$$

Now the frequencies are \(\displaystyle \left( \sum \nolimits _{c \in \mathbb {F}^{*}_{p}}m_{c}\right) n_{1,0}\) and \(\displaystyle \left( \sum \nolimits _{c \in \mathbb {F}^{*}_{p}}m_{c}\right) n_{-1,0}\), in Lemmas 7 and 8, respectively.

If \(\mathrm {Tr}_{m}(a_{1}^{-1})=0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\), then we have the same weights and the same frequencies with the case of \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{2}^{-1})=0\).

If \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0,\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})=0\), then we have

$$\begin{aligned} N&=\frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}(pG(\eta )^{2}\eta (a_{1}a_{2})+p+1). \end{aligned}$$

Thus,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}(pG(\eta )^{2}+p+1),&{}\quad {\mathrm{if}}\;\eta (a_{1}a_{2})=1,\\ \frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}(pG(\eta )^{2}-p-1),&{}\quad {\mathrm{if}}\;\eta (a_{1}a_{2})=-1. \end{array} \right. \end{aligned}$$

Now the frequencies are \(\displaystyle \sum \nolimits _{c \in \mathbb {F}^{*}_{p}}n_{1,c}^{2}+n_{-1,c}^{2}\) and \(\displaystyle 2\sum \nolimits _{c \in \mathbb {F}^{*}_{p}}n_{1,c}n_{-1,c}\), respectively.

If \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0,\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\;{\mathrm{and}}\;\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})\ne 0,\) then we have

$$\begin{aligned} N_{0}&=\frac{(q-1)}{p^{2}}+\frac{(p-1)}{p^{2}}\big (p+1). \end{aligned}$$

And the frequency is

$$\begin{aligned} |\{a_{1},a_{2}\in \mathbb {F}^{*}_{q} : \mathrm {Tr}_{m}(a_{1}^{-1})\ne 0,\;\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0,\;{\mathrm{and}}\; \mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})\ne 0\}|. \end{aligned}$$

It is equal to \(\displaystyle T-\sum \nolimits _{c \in \mathbb {F}^{*}_{p} }\big (m_{c}m_{-c}),\) where \(T=|\{(a_{1},a_{2}) \in (\mathbb {F}^{*}_{q})^{2} : \mathrm {Tr}_{m}(a_{1}^{-1})\ne 0 \quad {\mathrm{and}}\quad \mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\}|.\) By Lemmas 4, 7 we get

$$\begin{aligned} T&=\left( \sum _{c \in \mathbb {F}^{*}_{q} }m_{c}\right) ^{2}=\frac{(p-1)^{2}q^{2}}{p^{2}}\;{\mathrm{and}}\;\displaystyle \sum _{c \in \mathbb {F}^{*}_{p} }\big (m_{c}m_{-c})=\frac{(p-1)q^{2}}{p^{2}}. \end{aligned}$$

Thus we compute the frequency.

Since the Hamming weight of \(\mathbf {c}(a_{1},a_{2})\) is equal to \(W_{H}(\mathbf {c}(a_{1},a_{2}))=n_{0}-N_{0}\), we immediately have the desired results. \(\square \)

Example 1

(1) Let \(p=3\) and \(m=2.\) Then \(q=9\) and \(n=22.\) By Theorem 1, the code \(\textit{C}_{D}\) is a [22, 4, 8] linear code. Its weight enumerator is

$$\begin{aligned} 1+10x^{8}+4x^{10}+18x^{14}+8x^{12}+24x^{16}+8x^{20}+8x^{22}, \end{aligned}$$

which is checked by Magma.

(2) Let \(p=5\) and \(m=2.\) Then \(q=25\) and \(n=116.\) By Theorem 1, the code \(\textit{C}_{D}\) is a [116, 4, 72] linear code. Its weight enumerator is

$$\begin{aligned} 1+52x^{72}+16x^{76}+24x^{80}+300x^{92}+160x^{96}+48x^{112}+24x^{116}, \end{aligned}$$

which is checked by Magma.

(3) Let \(p=3\) and \(m=4.\) Then \(q=81\) and \(n=2134.\) By Theorem 1, the code \(\textit{C}_{D}\) is a [2134, 8, 1278] linear code. Its weight enumerator is

$$\begin{aligned}&1+48x^{1278}+32x^{1284}+100x^{1356}+738x^{1368}\\&\quad +256x^{1380} +1080x^{1416}+1458x^{1422}\\&\quad +1728x^{1428}+1040x^{1476}+20x^{1596}+60x^{1602}, \end{aligned}$$

which is checked by Magma.

Theorem 2

Let \(\mathcal {C}_{D}\) be a linear code defined by (1) and (2) where \(D=\{(x_{1},x_{2}) \in (\mathbb {F}_{q}^{*})^{2} : \mathrm {Tr}_{m}(x_{1}+x_{2})=0\}.\) Suppose that m is odd and \(m \ge 3\). Then the weight distribution of \(\mathcal {C}_{D}\) is given by Table 3 and the code \(\mathcal {C}_{D}\) has parameters \(\left[ \frac{(p^{m}-1)^{2}+p-1}{p},\;2m,\;(p-1)\big (p^{2(m-1)}-2p^{m-2}-p^{m-1}-2p^{\frac{m-3}{2}}) \right] \).

Table 3 The weight distribution of \(\textit{C}_{D}\) for odd \(m\ge 3\)

Proof

Recall that \(N_{0}=\frac{(q-1)^{2}}{p^{2}}+\frac{1}{p^{2}}(\varOmega _{1}+\varOmega _{2}+\varOmega _{3})\). We employ Lemmas 5 and 6 to compute \(N_{0}\).

Suppose that \(a_{1}\ne 0\) and \(a_{2}=0\).

If \(\mathrm {Tr}_{m}(a_{1}^{-1})=0\), then we obtain

$$\begin{aligned} N_{0}&=\frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (p-q+1). \end{aligned}$$

Now the frequency is \(m_{0}\) in Lemma 7.

If \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\), then we obtain

$$\begin{aligned} N_{0}=&\frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (-GA_{1}+p-q+1). \end{aligned}$$

Thus,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}\big (G-p+q-1),&{}\quad {\mathrm{if}}\;A_{1}=1,\\ \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (G+p-q+1),&{}\quad {\mathrm{if}}\;A_{1}=-1. \end{array} \right. \end{aligned}$$

Now the frequencies are \(n^{\prime }_{1,1}+n^{\prime }_{-1,-1}\) and \(n^{\prime }_{1,-1}+n^{\prime }_{-1,1}\) in Lemma 9, respectively. If \(a_{1}=0\) and \(a_{2}\ne 0\), then we have the same values and the same frequencies with the case of \(a_{1}\ne 0\) and \(a_{2}=0\).

Now, assume that \(a_{1}\ne 0\) and \(a_{2}\ne 0\).

If \(\mathrm {Tr}_{m}(a_{1}^{-1})=\mathrm {Tr}_{m}(a_{2}^{-1})=0\), then we obtain

$$\begin{aligned} N_{0}=&\frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (pG(\eta )^{2}\eta (a_{1}a_{2})+p+1). \end{aligned}$$

Thus,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (pG(\eta )^{2}+p+1),&{}\quad {\mathrm{if}}\;\eta (a_{1}a_{2})=1,\\ \frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}\big (pG(\eta )^{2}-p-1),&{}\quad {\mathrm{if}}\;\eta (a_{1}a_{2})=-1. \end{array} \right. \end{aligned}$$

Now the frequencies are \(n_{1,0}^{2}+n_{-1,0}^{2}\) and \(2n_{1,0}n_{-1,0}\) in Lemma 8, respectively.

If \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\) and \(\mathrm {Tr}_{m}(a_{2}^{-1})=0\), then we have

$$\begin{aligned} N_{0}=&\frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (-GA_{1}+p+1). \end{aligned}$$

Thus,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}\big (G-p-1),&{}\quad {\mathrm{if}}\;A_{1}=1,\\ \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (G+p+1),&{}\quad {\mathrm{if}}\;A_{1}=-1. \end{array} \right. \end{aligned}$$

Now the frequencies are \(m_{0}(n^{\prime }_{1,1}+n^{\prime }_{-1,-1})\) and \(m_{0}(n^{\prime }_{1,-1}+n^{\prime }_{-1,1})\), respectively. If \(\mathrm {Tr}_{m}(a_{1}^{-1})=0\) and \(\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\), then we have the same values and the same frequencies with the case of \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\) and \(\mathrm {Tr}_{m}(a_{2}^{-1})=0\).

If \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\), \(\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\) and \(\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})=0\), then we have

$$\begin{aligned} N_{0}=\frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (pG(\eta )^{2}\eta (a_{1}a_{2})-GA_{1}-GA_{2}+p+1). \end{aligned}$$

Since \(\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})=0\), we have \(A_{1}A_{2}=\eta (a_{1}a_{2})\eta _{p}(-1)\).

Assume that \(p \equiv 1 \pmod 4\). Then,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}{+}\frac{(p-1)}{p^{2}}\big (pG(\eta )^{2}-2G{+}p{+}1),&{}\quad {\mathrm{if}}\;\eta (a_{1}a_{2})=A_{1}=A_{2}=1,\\ \frac{(q-1)^{2}}{p^{2}}{+}\frac{(p-1)}{p^{2}}\big (pG(\eta )^{2}{+}2G{+}p{+}1),&{}\quad {\mathrm{if}}\;\eta (a_{1}a_{2})=1\;{\mathrm{and}}\;A_{1}=A_{2}{=}-1,\\ \frac{(q-1)^{2}}{p^{2}}{+}\frac{(p-1)}{p^{2}}\big (-pG(\eta )^{2}{+}p{+}1),&{}\quad {\mathrm{if}}\;\eta (a_{1}a_{2}){=}A_{1}A_{2}{=}-1. \end{array} \right. \end{aligned}$$

Now the frequencies are \(\displaystyle \sum \nolimits _{c \in C_{0}^{(2,p)}}n_{1,c}n_{1,-c}+\sum \nolimits _{c \in C_{1}^{(2,p)}}n_{-1,c}n_{-1,-c}\), \(\displaystyle \sum \nolimits _{c \in C_{1}^{(2,p)}}n_{1,c}n_{1,-c}+\sum \nolimits _{c \in C_{0}^{(2,p)}}n_{-1,c}n_{-1,-c}\),\(\displaystyle \sum \nolimits _{c \in C_{0}^{(2,p)}}n_{1,c}n_{-1,-c}+\sum \nolimits _{c \in C_{1}^{(2,p)}}n_{1,c}n_{-1,-c}+\sum \nolimits _{c \in C_{0}^{(2,p)}}n_{-1,c}n_{1,-c}+\sum \nolimits _{c \in C_{1}^{(2,p)}}n_{-1,c}n_{1,-c},\) in Lemma8, respectively.

In the case of \(p \equiv 3 \pmod 4\), we compute similarly.

If \(\mathrm {Tr}_{m}(a_{1}^{-1})\ne 0\), \(\mathrm {Tr}_{m}(a_{2}^{-1})\ne 0\) and \(\mathrm {Tr}_{m}(a_{1}^{-1}+a_{2}^{-1})\ne 0\), then we have

$$\begin{aligned} N_{0}=&\frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}} \big (-GA_{1}-GA_{2}+p+1). \end{aligned}$$

Thus,

$$\begin{aligned} N_{0}=&\left\{ \begin{array}{ll} \frac{(q-1)^{2}}{p^{2}}-\frac{(p-1)}{p^{2}}\big (2G-p-1),&{}\quad {\mathrm{if}}\;A_{1}=A_{2}=1,\\ \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)}{p^{2}}\big (2G+p+1),&{}\quad {\mathrm{if}}\;A_{1}=A_{2}=-1,\\ \frac{(q-1)^{2}}{p^{2}}+\frac{(p-1)(p+1)}{p^{2}},&{}\quad {\mathrm{if}}\;A_{1}A_{2}=-1.\\ \end{array} \right. \end{aligned}$$

We compute the frequency for the case of \(A_{1}A_{2}=-1\). We compute similarly for the other cases. From Lemma 8, the frequency is

$$\begin{aligned}&\displaystyle \sum _{c \in C_{0}^{(2,p)}}\frac{1}{2p}\big (\eta _{p}(c)G+q)\sum _{\begin{array}{c} d \in C_{0}^{(2,p)}\\ d\ne -c \end{array}}\frac{1}{2p}\big (\eta _{p}(d)G+q)\\&\quad \;\;\;\;+\sum _{c \in C_{0}^{(2,p)}}\frac{1}{2p}\big (\eta _{p}(c)G+q)\sum _{\begin{array}{c} d \in C_{1}^{(2,p)}\\ d\ne -c \end{array}}\frac{1}{2p}\big (-\eta _{p}(d)G+q)\\&\quad \;\;\;\;+\sum _{c \in C_{1}^{(2,p)}}\frac{1}{2p}\big (-\eta _{p}(c)G+q)\sum _{\begin{array}{c} d \in C_{0}^{(2,p)}\\ d\ne -c \end{array}}\frac{1}{2p}\big (\eta _{p}(d)G+q)\\&\quad \;\;\;\;+\sum _{c \in C_{1}^{(2,p)}}\frac{1}{2p}\big (-\eta _{p}(c)G+q)\sum _{\begin{array}{c} d \in C_{1}^{(2,p)}\\ d\ne -c \end{array}}\frac{1}{2p}\big (-\eta _{p}(d)G+q),\\&\quad =\frac{1}{4p^{2}}(G+q)^{2}\frac{p-1}{4}(p-1+p-1+p-3+p-3),\\&\quad =\frac{(p-1)(p-2)}{4p^{2}}(G+q)^{2}. \end{aligned}$$

\(\square \)

Example 2

(1) Let \(p=3\) and \(m=3.\) Then \(q=27\) and \(n=226.\) By Theorem 2, the code \(\textit{C}_{D}\) is a [226, 6, 128] linear code. Its weight enumerator is

$$\begin{aligned}&1+18x^{128}+32x^{132}+72x^{136}+18x^{146}+96x^{148}+72x^{150}+192x^{152}\\&+84x^{154}+16x^{156}+24x^{158}+104x^{168}, \end{aligned}$$

which is checked by Magma.

(2) Let \(p=5\) and \(m=3.\) Then \(q=125\) and \(n=3076.\) By Theorem 2, the code \(\textit{C}_{D}\) is a [3076, 6, 2352] linear code. Its weight enumerator is

$$\begin{aligned}&1+400x^{2352}+288x^{2360}+900x^{2368}+1200x^{2452}+1920x^{2456} +3600x^{2460}\\&+2880x^{2464}+2700x^{2468}+80x^{2476}+48x^{2480} +120x^{2484}+1488x^{2560}, \end{aligned}$$

which is checked by Magma.

4 Concluding remarks

Let \(w_{min}\) and \(w_{max}\) be the minimum and maximum nonzero weight of linear code \(\textit{C}_{D}\), respectively. We recall that if

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

then all nonzero codewords of code \(\textit{C}_{D}\) are minimal (see [8]).

By Theorem 1, we easily check

$$\begin{aligned} \frac{w_{min}}{w_{max}}=\frac{(p-1)\left( p^{2(m-1)}-p^{m-2}-p^{\frac{3m-4}{2}}\right) }{(p-1)\big (p^{2(m-1)}-p^{m-2}+ p^{\frac{3m-4}{2}})}>\frac{p-1}{p}, \end{aligned}$$

where even \(m\ge 4\). Moreover, by Theorem 2 we easily check

$$\begin{aligned} \frac{w_{min}}{w_{max}}=\frac{(p-1)\left( p^{2(m-1)}-2p^{m-2}-p^{m-1}-2p^{\frac{m-3}{2}}\right) }{(p-1)\left( p^{2(m-1)}-2p^{m-1}+p^{m-1}\right) }>\frac{p-1}{p}, \end{aligned}$$

where odd \(m\ge 3\).

Hence, the linear codes in this paper satisfy \(w_{min}/w_{max}> (p-1)/p\) for \(m\ge 3\), and can be used to get secret sharing schemes with interesting access structures.