1 Introduction

Let \(\mathbb {F}_q\) be the finite field with q elements and \(\mathbb {F}_q^*=\mathbb {F}_q\backslash {\{0\}}\), where \(q=p^m\), p is a prime and m is a positive integer. A linear code C with parameters \(\left[ n,k,d \right]\) over \(\mathbb {F}_p\) is a k-dimensional subspace of \(\mathbb {F}_p^n\) with length n and minimum Hamming distance d. Let \(A_i\) denote the number of codewords with Hamming weight i in a code C of length n. The weight enumerator of C is defined by \(1+A_1z+A_2z^2+...+A_nz^n\). The sequence \((1,A_1,A_2,...,A_n )\) is called the weight distribution of C. A code is said to be a t-weight code if the number of nonzero \(A_i\) in the sequence \((A_1,A_2,... ,A_n )\) is equal to t. The weight distribution of a code contains crucial information about the error correcting capability and the probability of error detection and correction with respect to some algorithms. Hence, the weight distribution attracts much attention in coding theory [1,2,3,4,5,6].

Linear codes with few weights have important applications in secret sharing schemes [7, 8], authentication codes [9], association schemes [10] and strongly regular graphs [11]. There are two generic constructions of linear codes from functions. Let \(Tr=\sum \nolimits _{k=0}^{m-1}x^{p^k}\) be the trace function from \(\mathbb {F}_q\) to \(\mathbb {F}_p\). Then the first one [12] is obtained by considering a code C(f) over \(\mathbb {F}_p\) involving a polynomial f from \(\mathbb {F}_q\) to \(\mathbb {F}_q\) defined by

$$\begin{aligned} C(f)=\{c=(Tr(af(x)+bx))_{x\in \mathbb {F}_q^*}:a\in \mathbb {F}_q ,b\in \mathbb {F}_q\}, \end{aligned}$$

where \(f(0)=0\). The code C(f) from f is a linear code of length \(q-1\) and its dimension is upper bounded by 2m. This generic construction has a long history and its importance is supported by Delsarte’s Theorem [13]. The second generic construction of linear codes from functions [14] is obtained by fixing a set \(D=\{d_1,d_2,...,d_n\}\) in \(\mathbb {F}_q\) and by defining a linear code involving D as follows:

$$\begin{aligned} C_D=\{(Tr(\beta d_1),Tr(\beta d_2),...,Tr(\beta d_n)): \beta \in \mathbb {F}_q\}. \end{aligned}$$

The set D is called the defining set of \(C_D\). This construction is generic in the sense that any code could be produced by selecting the defining set \(D\subseteq \mathbb {F}_q\). The code quality in terms of parameters is closely related to the choice of the set D. The defining set D can be given by functions, i.e., \(D=\{x\in \mathbb {F}_q^*:f(x)=0\}\), where \(f(x)=Tr(F(x))\) is a function from \(\mathbb {F}_q\) to \(\mathbb {F}_p\) and \(F(x)\in \mathbb {F}_q\left[ x\right]\). From the choice of F(x) or f(x), many linear codes can be constructed. Ding [15] presented a survey on recent results on constructing binary linear codes with this method from Boolean functions and proposed some open problems on this construction of binary linear codes. Xiang et al. [16] presented the weight distribution of \(C_D\) for the case \(F(x)=x^{p+1}-x\). Ling et al. [17] constructed a class of three-weight and five-weight linear codes for the case \(F(x)=x^2+x\). Many papers used different functions of special forms in constructing linear codes with few weights [18,19,20,21,22,23,24,25].

Motivated by the above construction, Li et al. [26] defined a p-ary linear code by

$$\begin{aligned} C_D=\{c_{a,b}=(Tr(ax+by))_{(x,y)\in D}:a,b\in \mathbb {F}_{q}\}, \end{aligned}$$
(1)

where \(D\subseteq \mathbb {F}_{q}^2\) is also called a defining set. And several classes of two-weight and three-weight linear codes and their explicit weight enumerators were presented when \(D=\{(x,y)\in \mathbb {F}_{q}^2\backslash \{(0,0)\}:Tr(R(x,y)=0)\}\), where \(R(x,y)=x^{N_1}+y^{N_2}\), \(N_1,\ N_2\in \{1,2, p^{\frac{m}{2}+1}\}\). Jian et al. [27] studied several classes of two-weight and three-weight linear codes of the form (1) for the two cases \(R(x,y)=x+y^{p^u+1}\) and \(R(x,y)=x^2+y^{p^u+1}\). Hu et al. [28] studied \(C_D\) of the form (1) with the defining set given by

$$\begin{aligned} D=\{(x,y)\in {\mathbb {F}_{2^m}^2\backslash \{(0,0)\}}:Tr(x^2+xy)=u\},\ u\in \mathbb {F}_2. \end{aligned}$$

In this paper, we extend their results by choosing the defining set given by

$$\begin{aligned} D=\{(x,y)\in {\mathbb {F}_q^2\backslash \{(0,0)\}}:Tr(x^p+xy)=u\},\ u\in \mathbb {F}_p, \end{aligned}$$
(2)

where p is an odd prime. We mainly use certain exponential sums to determine the parameters and weight distributions of linear codes with the form (1). In particular, most of the linear codes obtained are minimal, which can be used to construct secret sharing schemes [18].

The rest of this paper is organized as follows. Section 2 introduces some results on additive characters, multiplicative characters and Gauss sums. Section 3 introduces some auxiliary results for determining the parameters and weight distributions of linear codes. Section 4 presents a class of three-weight linear codes from defining sets. Section 5 makes a conclusion.

2 Preliminaries

In this section, we introduce some basic results on additive characters, multiplicative characters and Gauss sums.

Definition 1

For \(a\in \mathbb {F}_q\), the trace function Tr(a) of a over \(\mathbb {F}_p\) is defined by

$$\begin{aligned} \begin{aligned} Tr=&Tr_{\mathbb {F}_{q}/\mathbb {F}_p}:\mathbb {F}_{q}\rightarrow \mathbb {F}_p,\\ Tr(a)=&a+a^p+a^{p^2}+...+a^{p^{m-1}}, \end{aligned} \end{aligned}$$

where \(q=p^m\). Note that \(a^q=a\) for each \(a\in \mathbb {F}_q\).

Lemma 1

[29] For \(a,b\in \mathbb {F}_q , c\in \mathbb {F}_p\), the trace function Tr satisfies the following properties:

$$\begin{aligned} \begin{aligned}&(1)\quad Tr(a+b)=Tr(a)+Tr(b),\\&(2)\quad Tr(ca)=cTr(a),\\&(3)\quad Tr(a)^p=Tr(a). \end{aligned} \end{aligned}$$

Definition 2

An additive character of \(\mathbb {F}_q\) is a homomorphism from the additive group \(\mathbb {F}_q\) into the multiplicative group composed by the p-th roots of unity in the complex numbers.

For each \(a\in \mathbb {F}_q\), the function defined by

$$\begin{aligned} \chi _a(x)=\zeta _p^{Tr(ax)}\ for\ all\ x\in \mathbb {F}_q \end{aligned}$$

is an additive character of \(\mathbb {F}_q\), where \(\zeta _p=e^{2\pi \sqrt{-1}/p}\). When \(a=1\), \(\chi _1\) is called the canonical additive character of \(\mathbb {F}_q\). Note that \(\chi _a(x)=\chi _1(ax)\).

Lemma 2

[29] Let \(\chi _1\) be a canonical additive character of \(\mathbb {F}_q\), then the orthogonal property of additive characters is given by

$$\begin{aligned} \sum _{x\in \mathbb {F}_q}\chi _1(ax)=\sum _{x\in \mathbb {F}_q}\zeta _p^{Tr(ax)}=\left\{ \begin{aligned}&q&if\ a=0,\\&0&if\ a\in \mathbb {F}_q^*. \end{aligned} \right. \end{aligned}$$

Some results of multiplicative characters and Gauss sums are given below.

Definition 3

Let \(\alpha\) be a primitive element of \(\mathbb {F}_q\). For each \(j=0,1,...,q-2\), the function given by

$$\begin{aligned} \psi _j(\alpha ^k)=e^{2\pi \sqrt{-1}jk/(q-1)} \ for\ k=0,1,...,q-2 \end{aligned}$$

is a multiplicative character of \(\mathbb {F}_q\). When \(j=(q-1)/2\), \(\psi _{(q-1)/2}\) is called the quadratic multiplicative character of \(\mathbb {F}_q\), which is denoted by \(\eta\). When \(j=(p-1)/2\) and \(q=p\), \(\psi _{(p-1)/2}\) is called the quadratic multiplicative character of \(\mathbb {F}_p\), which is denoted by \(\bar{\eta }\).

Definition 4

Let \(\chi _1\) be a canonical additive character of \(\mathbb {F}_q\) and \(\eta\) be a quadratic multiplicative character of \(\mathbb {F}_q\). The Gauss sum over \(\mathbb {F}_q\) is defined by

$$\begin{aligned} G(\eta ,\chi _1)=\sum _{c\in \mathbb {F}_q^*}\eta (c)\chi _1(c). \end{aligned}$$

Let \(\bar{\chi }_1\) be a canonical additive character of \(\mathbb {F}_p\) and \(\bar{\eta }\) be a quadratic multiplicative character of \(\mathbb {F}_p\). The Gauss sum over \(\mathbb {F}_p\) is defined by

$$\begin{aligned} G(\bar{\eta },\bar{\chi }_1)=\sum _{c\in \mathbb {F}_p^*}\bar{\eta }(c)\bar{\chi }_1(c). \end{aligned}$$

Lemma 3

[29] Let \(\mathbb {F}_q\) be a finite field with \(q=p^m\), where p is an odd prime and \(m\in \mathbb {N}\). Let \(\eta\) be a quadratic multiplicative character of \(\mathbb {F}_q\) and \(\chi _1\) be a canonical additive character of \(\mathbb {F}_q\). Then

$$\begin{aligned} G(\eta ,\chi _1)=\left\{ \begin{aligned}&(-1)^{m-1}q^{\frac{1}{2}}&\quad if\ p\equiv 1(mod\ 4),\\&(-1)^{m-1}(\sqrt{-1})^mq^{\frac{1}{2}}&\quad if\ p\equiv 3(mod\ 4).\\ \end{aligned} \right. \end{aligned}$$

The following lemma on exponential sums is of use.

Lemma 4

[29] Let \(\chi\) be a nontrivial additive character of \(\mathbb {F}_q\) with q odd, and let \(f(x)=a_2x^2+a_1x+a_0\in \mathbb {F}_q\left[ x\right]\) with \(a_2\ne 0\), then

$$\begin{aligned} \sum _{x\in \mathbb {F}_q}\zeta _p^{Tr(f(x))}=\zeta _p^{Tr(a_0-a_1^2(4a_2)^{-1})}\eta (a_2) G(\eta ,\chi ), \end{aligned}$$

where \(\eta\) is a quadratic multiplicative character of \(\mathbb {F}_q\).

3 Auxiliary results

This section gives some lemmas for determining the parameters and weight distributions of linear codes \(C_D\) with the form (1), where the defining set D is defined in (2).

From now on we fix the following notations.

  • \(q=p^m\), where p is an odd prime and m is a positive integer.

  • Tr is the trace function from \(\mathbb {F}_q\) to \(\mathbb {F}_p\).

  • \(\zeta _p=e^{2\pi \sqrt{-1}/p}\).

  • \(u\in \mathbb {F}_p\).

  • \(\bar{\chi }_1\) is a canonical additive character of \(\mathbb {F}_p\), \(\bar{\eta }\) is a quadratic multiplicative character of \(\mathbb {F}_p\).

  • \(S_p=\{x^2:x\in \mathbb {F}_p^*\}\), \(NS_p=\mathbb {F}_p^*\backslash S_p\).

Let \(n_0=\sharp \{(x,y)\in {\mathbb {F}_q^2}:Tr(x^p+xy)=u\}\), then

$$\begin{aligned} \begin{aligned} n_0&=\sharp \{(x,y)\in {\mathbb {F}_q^2}:Tr(x^p+xy)=u\}\\&=\frac{1}{p}\sum \limits _{x,y\in {\mathbb {F}_{p^m}}} \sum \limits _{w_1\in {\mathbb {F}_p}}\zeta _p^{w_1(Tr(x^p+xy)-u)}\\&=\frac{1}{p}\sum \limits _{x,y\in {\mathbb {F}_{p^m}}} (1+\sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{w_1(Tr(x^p+xy)-u)})\\&=p^{2m-1}+\frac{1}{p}\varOmega _1, \end{aligned} \end{aligned}$$
(3)

where

$$\begin{aligned} \varOmega _1=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}} \sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{w_1(Tr(x^p+xy)-u)}. \end{aligned}$$

Let \(N_0=\sharp \{(x,y)\in {\mathbb {F}_q^2}:Tr(x^p+xy)=u,Tr(ax+by)=0\}\), then

$$\begin{aligned} \begin{aligned} N_0&=\sharp \{(x,y)\in {\mathbb {F}_q^2}:Tr(x^p+xy)=u,Tr(ax+by)=0\}\\&=\frac{1}{p^2}\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p}} \zeta _p^{w_1(Tr(x^p+xy)-u)}\sum \limits _{w_2\in {\mathbb {F}_p}}\zeta _p^{w_2Tr(ax+by)}\\&=\frac{1}{p^2}\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}(1+\sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{w_1(Tr(x^p+xy)-u)})(1+\sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{w_2Tr(ax+by)})\\&=p^{2m-2}+\frac{1}{p^2}(\varOmega _1+\varOmega _2+\varOmega _3),&\end{aligned} \end{aligned}$$

where

$$\begin{aligned} \begin{aligned}&\varOmega _2=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \zeta _p^{w_2Tr(ax+by)},\\&\varOmega _3=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{w_1(Tr(x^p+xy)-u)}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \zeta _p^{w_2Tr(ax+by)}. \end{aligned} \end{aligned}$$

The Hamming weight of a codeword \(c_{a,b}\) in \(C_D\) with the form (1) is

$$\begin{aligned} w(c_{a,b})=n_0-N_0=(p-1) p^{2m-2}+\frac{1}{p}\varOmega _1-\frac{1}{p^2}(\varOmega _1+\varOmega _2+\varOmega _3). \end{aligned}$$
(4)

The following lemmas give the values of \(\varOmega _1\), \(\varOmega _2\) and \(\varOmega _3\).

Lemma 5

Let \(\bar{\chi }_1\) be a canonical additive character of \(\mathbb {F}_p\), \(\bar{\eta }\) be a quadratic multiplicative character of \(\mathbb {F}_p\). Then

$$\begin{aligned} \bar{\eta }(-1)G^2(\bar{\eta },\bar{\chi }_1)=p. \end{aligned}$$

Proof

From Lemma 3, if \(p\equiv 1(mod\ 4)\), \(\bar{\eta }(-1)=1\), \(G(\bar{\eta },\bar{\chi }_1)=p^{\frac{1}{2}}\), then \(\bar{\eta }(-1)G^2(\bar{\eta },\bar{\chi }_1)=p\). If \(p\equiv 3(mod\ 4)\), \(\bar{\eta }(-1)=-1\), \(G(\bar{\eta },\bar{\chi }_1)=\sqrt{-1}p^{\frac{1}{2}}\), then \(\bar{\eta }(-1)G^2(\bar{\eta }, \bar{\chi }_1)=(-1)(\sqrt{-1})^2p=p\). Hence, this lemma follows. \(\square\)

Lemma 6

Let \(\varOmega _1=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{w_1(Tr(x^p+xy)-u)}\), then

$$\begin{aligned} \begin{aligned} \varOmega _1=\left\{ \begin{aligned}&(p-1) p^m&if\ u=0,\\&-p^m&if\ u\ne 0. \end{aligned} \right. \end{aligned} \end{aligned}$$

Proof

From Lemma 2,

$$\begin{aligned} \begin{aligned} \varOmega _1&=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{w_1(Tr(x^p+xy)-u)}\\&=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}} \sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}}\zeta _p^{w_1Tr(x^p+xy)}\\&=\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}}\sum \limits _ {x\in {\mathbb {F}_{p^m}}}\zeta _p^{w_1Tr(x)}\sum \limits _{y\in {\mathbb {F}_{p^m}}} \zeta _p^{w_1Tr(yx)}\\&=\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}}(p^m+\sum\limits_{{\begin{subarray} {*{20}c} {x \in \mathbb{F}_{{p^{m} }} } \\ {x \ne 0} \\ \end{subarray} }}{\zeta _{p}^{{w_{1} Tr(x)}} }\sum \limits _{y\in {\mathbb {F}_{p^m}}}\zeta _ p^{w_1Tr(yx)})\\&=p^m\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}}\\&=\left\{ \begin{aligned}&(p-1) p^m&if\ u=0,\\&-p^m&if\ u\ne 0. \end{aligned} \right. \end{aligned} \end{aligned}$$

Hence, this lemma follows. \(\square\)

Lemma 7

Let \(\varOmega _2=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \zeta _p^{w_2Tr(ax+by)}\), where \(a, b\in \mathbb {F}_q\), then

$$\begin{aligned} \begin{aligned} \varOmega _2=\left\{ \begin{aligned}&(p-1) p^{2m}&if\ (a,b)=(0,0),\\&0&if\ (a,b)\ne (0,0). \end{aligned} \right. \end{aligned} \end{aligned}$$

Proof

From Lemma 2, we have

$$\begin{aligned} \begin{aligned} \varOmega _2&=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \zeta _p^{w_2Tr(ax+by)}\\&=\sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\sum \limits _{x,y \in {\mathbb {F}_{p^m}}}\zeta _p^{w_2Tr(ax+by)}\\&=\sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\sum \limits _{x\in {\mathbb {F}_{p^m}}} \zeta _p^{w_2Tr(ax)}\sum \limits _{y\in {\mathbb {F}_{p^m}}}\zeta _p^{w_2Tr(by)}\\&=\left\{ \begin{aligned}&(p-1) p^{2m}&if\ (a,b)=(0,0),\\&0&if\ (a,b)\ne (0,0). \end{aligned} \right. \end{aligned} \end{aligned}$$

Hence, this lemma follows. \(\square\)

Lemma 8

Let \(\varOmega _3=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{w_1(Tr(x^p+xy)-u)}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \zeta _p^{w_2Tr(ax+by)}\), where \(a, b\in \mathbb {F}_q\).

(1) When \(u=0\),

$$\begin{aligned} \varOmega _3=\left\{ \begin{aligned}&(p-1)^2p^m&if\ Tr(ab)=0\ and\ Tr(b)=0,\\&-(p-1)p^m&if\ Tr(ab)=0\ and\ Tr(b)\ne 0,\\{} \hfill&or,Tr(ab)\ne 0\ and\ Tr(b)=0,&\\&p^m&if\ Tr(ab)\ne 0\ and\ Tr(b)\ne 0. \end{aligned} \right. \end{aligned}$$

(2) When \(u\ne 0\),

$$\begin{aligned} \varOmega _3=\left\{ \begin{aligned}&-(p-1)p^m&if\ Tr(ab)=0\ and\ Tr(b)=0, \\&or,Tr(ab)\ne 0\ and\ B\in NS_p,\\&p^m&if\ Tr(ab)=0\ and\ Tr(b)\ne 0,\\&or,Tr(ab)\ne 0\ and\ B=0,\\&(p+1)p^m&if\ Tr(ab)\ne 0\ and\ B\in S_p. \end{aligned} \right. \end{aligned}$$

where \(B=Tr^2(b)-4uTr(ab)\).

Proof

We evaluate the values of \(\varOmega _3\) by the results of exponential sums.

$$\begin{aligned} \begin{aligned} \varOmega _3&=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^ {w_1(Tr(x^p+xy)-u)}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{w_2Tr(ax+by)}\\&=\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}} \sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\zeta _p^{Tr(w_1(x^p+xy))+Tr(w_2(ax+by))}\\&=\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}} \sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \sum \limits _{x\in {\mathbb {F}_{p^m}}}\zeta _p^{Tr(w_1x+w_2ax)} \sum \limits _{y\in {\mathbb {F}_{p^m}}} \zeta _p^{Tr(y(w_1x+w_2b))}\\&=p^m\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}} \sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\sum\limits_{{\mathop {x \in {\mathbb{F}}_{{p^{m} }} }\limits_{{w_{1} x + w_{2} b = 0}} }} {\zeta _{p}^{{Tr(w_{1} x + w_{2} ax)}} \quad } \quad \;(Lemma~2) \\&=p^m\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}} \sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \sum\limits_{{\mathop {x \in {\mathbb{F}}_{{p^{m} }} }\limits_{{w_{1} x + w_{2} b = 0}} }} {\zeta _{p}^{{Tr(w_{2} ax - w_{2} b)}} } \\&=p^m\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}}\zeta _p^{Tr((-w_2a) (\frac{w_2}{w_1}b)-w_2b)}\\&=p^m\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{-u{w_1}} \zeta _p^{Tr(ab)\frac{-w_2^2}{w_1}-Tr(b)w_2}.&\end{aligned} \end{aligned}$$

We further evaluate the above exponential sum. Let \(t_1=Tr(ab)\), \(t_2=Tr(b)\).

(1) Case \(u=0\).

When \(t_1=0\),

$$\begin{aligned} \varOmega _3=\left\{ \begin{aligned}&p^m\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}}\zeta _p^0=(p-1)^2p^m&\quad if\ t_2=0,\\&p^m\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{-t_2w_2}=-(p-1)p^m&\quad if\ t_2\ne 0.&\end{aligned} \right. \end{aligned}$$

When \(t_1\ne 0\), then

$$\begin{aligned} \begin{aligned} \varOmega _3&=p^m\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{t_1\frac{-w_2^2}{w_1}-t_2w_2}\\&=p^m\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\left(\sum \limits _{w_2\in {\mathbb {F}_p}} \zeta _p^{\frac{-t_1}{w_1}w_2^2-t_2w_2}-1\right)\\&=p^m\left(\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\sum \limits _{w_2\in {\mathbb {F}_p}}\zeta _p^{\frac{-t_1}{w_1}w_2^2-t_2w_2}-\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}1\right)\quad \quad \quad \quad \quad (Lemma~4)\\&=p^m\left( \sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{\frac{t_2^2}{4t_1}w_1}\bar{\eta }\left( \frac{-t_1}{w_1}\right) G(\bar{\eta },\bar{\chi }_1)-(p-1)\right) . \end{aligned} \end{aligned}$$

We further evaluate the above exponential sum by distinguishing the cases that \(t_2=0\) and \(t_2\ne 0\).

If \(t_2=0\), then

$$\begin{aligned} \begin{aligned} \varOmega _3&=p^m\left( \sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\bar{\eta } \left( \frac{-t_1}{w_1}\right) G(\bar{\eta },\bar{\chi }_1)-(p-1)\right) \\&=p^m(\bar{\eta }(-t_1)G(\bar{\eta },\bar{\chi }_1)\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\bar{\eta }(w_1)-(p-1))\\&=-(p-1)p^m. \end{aligned} \end{aligned}$$

If \(t_2\ne 0\), from Definition 4 and Lemma 5, then

$$\begin{aligned} \begin{aligned} \varOmega _3&=p^m\left( \sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{\frac{t_2^2}{4t_1}w_1} \bar{\eta }\left( \frac{t_2^2}{4t_1}w_1\right) \bar{\eta }\left( \frac{-4t_1^2}{t_2^2}\right) G(\bar{\eta },\bar{\chi }_1)-(p-1)\right) \\&=p^m\left( \bar{\eta }\left( \frac{-4t_1^2}{t_2^2}\right) G^2(\bar{\eta },\bar{\chi }_1) -(p-1)\right) \\&=p^m\left( \bar{\eta }\left( \frac{4t_1^2}{t_2^2}\right) \bar{\eta }(-1)G^2(\bar{\eta }, \bar{\chi }_1)-(p-1)\right) \\&=p^m(\bar{\eta }(-1)G^2(\bar{\eta },\bar{\chi }_1)-(p-1))\\&=p^m.&\end{aligned} \end{aligned}$$

(2) Case \(u\ne 0\).

When \(t_1=0\),

$$\begin{aligned} \varOmega _3=\left\{ \begin{aligned}&p^m\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{-uw_1}=-(p-1)p^m&\quad if\ t_2=0,\\&p^m\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-uw_1}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{-t_2w_2}=p^m&\quad if\ t_2\ne 0.&\end{aligned} \right. \end{aligned}$$

When \(t_1\ne 0\), then

$$\begin{aligned} \begin{aligned} \varOmega _3&=p^m\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-uw_1} \sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{t_1\frac{-w_2^2}{w_1}-t_2w_2}\\&=p^m\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-uw_1}(\sum \limits _{w_2\in {\mathbb {F}_p}} \zeta _p^{\frac{-t_1}{w_1}w_2^2-t_2w_2}-1)\\&=p^m(\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{-uw_1}\sum \limits _{w_2\in {\mathbb {F}_p}} \zeta _p^{\frac{-t_1}{w_1}w_2^2-t_2w_2}-\sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{-uw_1})\\&=p^m\left( \sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{(\frac{t_2^2}{4t_1}-u )w_1}\bar{\eta }\left( \frac{-t_1}{w_1}\right) G(\bar{\eta },\bar{\chi }_1)+1\right) \quad \quad \quad \quad (Lemma~4)\\&=p^m\left( \sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{(\frac{t_2^2-4ut_1}{4t_1})w_1} \bar{\eta }\left( \frac{-t_1}{w_1}\right) G(\bar{\eta },\bar{\chi }_1)+1\right) . \end{aligned} \end{aligned}$$

We further evaluate the above exponential sum by distinguishing the cases that \(t_2^2-4ut_1\ne 0\) and \(t_2^2-4ut_1=0\).

If \(t_2^2-4ut_1\ne 0\), from Definition 4 and Lemma 5, then

$$\begin{aligned} \begin{aligned} \varOmega _3&=p^m\left( \sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{\frac{t_2^2-4ut_1}{4t_1} w_1}\bar{\eta }\left( \frac{t_2^2-4ut_1}{4t_1}w_1\right) \bar{\eta }\left( \frac{-4t_1^2}{t_2^2-4ut_1}\right) G(\bar{\eta },\bar{\chi }_1)+1\right) \\&=p^m\left( \bar{\eta }\left( \frac{-4t_1^2}{t_2^2-4ut_1}\right) G^2(\bar{\eta },\bar{\chi }_1)+1\right) \\&=p^m\left( \bar{\eta }\left( \frac{4t_1^2}{t_2^2-4ut_1}\right) \bar{\eta }(-1)G^2(\bar{\eta },\bar{\chi }_1)+1\right) \\&=p^m\left( \bar{\eta }\left( \frac{4t_1^2}{t_2^2-4ut_1}\right) p+1\right) \\&=\left\{ \begin{aligned} -(p-1)p^m&\quad if\ t_2^2-4ut_1\in NS_p,\\ (p+1)p^m&\quad if\ t_2^2-4ut_1\in S_p. \end{aligned} \right. \end{aligned} \end{aligned}$$

If \(t_2^2-4ut_1=0\), then

$$\begin{aligned} \begin{aligned} \varOmega _3&=p^m\left( \sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\bar{\eta }\left( \frac{-t_1}{w_1}\right) G(\bar{\eta },\bar{\chi }_1)+1\right) \\&=p^m(\bar{\eta }(-t_1)G(\bar{\eta },\bar{\chi }_1) \sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\bar{\eta }(w_1)+1)\\&=p^m. \end{aligned} \end{aligned}$$

Hence, this lemma follows. \(\square\)

4 A class of three-weight linear codes

In this section, we consider the linear codes \(C_D\) with the form (1) from the defining set D defined in (2). Then we obtain a class of three-weight linear codes. The parameters and the weight distributions of the linear codes are given in the following theorem.

Theorem 1

Let p be an odd prime, \(D=\{(x,y)\in {\mathbb {F}_q^2\backslash \{(0,0)\}}:Tr(x^p+xy)=u\}\), where \(u\in \mathbb {F}_p\) and \(q=p^m\).

(1) When \(u=0\), the code \(C_D\) defined by (1) is a three-weight linear code with parameters \(\left[ p^{2m-1}+(p-1)p^{m-1}-1,2m,(p-1)p^{2m-2}\right]\), whose weight distribution is listed in Table 1.

Table 1 The three-weight linear code with \(u=0\)

(2) When \(u\ne 0\), then the code \(C_D\) defined by (1) is a three-weight linear code with parameters \(\left[ p^{2m-1}-p^{m-1},2m,(p-1)p^{2m-2}-2p^{m-1}\right]\), whose weight distribution is listed in Table 2.

Table 2 The three-weight linear code with \(u\ne 0\)

Proof

From (3) and Lemma 6, we have

$$\begin{aligned} n_0=\left\{ \begin{aligned}&p^{2m-1}+(p-1) p^{m-1}&if\ u=0,\\&p^{2m-1}-p^{m-1}&if\ u\ne 0. \end{aligned} \right. \end{aligned}$$

Then the length n of the linear code \(C_D\) is given by

$$\begin{aligned} n=\left\{ \begin{aligned}&n_0-1=p^{2m-1}+(p-1)p^{m-1}-1&if\ u=0,\\&n_0=p^{2m-1}-p^{m-1}&if\ u\ne 0. \end{aligned} \right. \end{aligned}$$

(1) When \(u=0\), it follows from (4), Lemmas 6, 7 and 8 that the Hamming weight \(w(c_{a,b})\) of the nonzero codeword \(c_{a,b}\) is given by

$$w(c_{{a,b}} ) = \left\{ {\begin{array}{*{20}l} {(p - 1)p^{{2m - 2}} } \hfill & {if\;Tr(ab) = 0\;and\;Tr(b) = 0,} \hfill \\ {(p - 1)p^{{2m - 2}} + (p - 1)p^{{m - 1}} } \hfill & {if\;Tr(ab) = 0\;and\;Tr(b) \ne 0,{\text{ }}} \hfill \\ {} \hfill & {or,Tr(ab) \ne 0\;and\;Tr(b) = 0,} \hfill \\ {(p - 1)p^{{2m - 2}} + (p - 2)p^{{m - 1}} } \hfill & {if\;Tr(ab) \ne 0\;and\;Tr(b) \ne 0.} \hfill \\ \end{array} } \right.$$

Through the above analysis, let \(w_1=(p-1) p^{2m-2},\ w_2=(p-1)p^{2m-2}+(p-1)p^{m-1},\ w_3=(p-1)p^{2m-2}+(p-2) p^{m-1}\), and \(A_{w_1}\), \(A_{w_2}\), \(A_{w_3}\) denote the numbers of codewords with weights \(w_1\), \(w_2\), \(w_3\) respectively.

When \(Tr(ab)=0\) and \(Tr(b)=0\), the number of codewords with weight \(w_1\) can be obtained.

$$\begin{aligned} \begin{aligned} A_{w_1}&=\frac{1}{p^2}\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p}} \zeta _p^{w_1Tr(xy)}\sum \limits _{w_2\in {\mathbb {F}_p}}\zeta _p^{w_2Tr(y)}-1\\&=\frac{1}{p^2}\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}(1+\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{w_1Tr(xy)})(1+\sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{w_2Tr(y)})-1\\&=p^{2m-2}+\frac{1}{p^2}(\varLambda _1+\varLambda _2+\varLambda _3)-1,&\end{aligned} \end{aligned}$$

where

$$\begin{aligned} \begin{aligned}&\varLambda _1=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{w_1Tr(xy)},\ \varLambda _2=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \zeta _p^{w_2Tr(y)},\\&\varLambda _3=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{w_1 Tr(xy)}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{w_2Tr(y)}. \end{aligned} \end{aligned}$$

The values of \(\varLambda _1,\ \varLambda _2\) and \(\varLambda _3\) are as follows:

From Lemma 2, then

$$\begin{aligned} \varLambda _1&=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p^{*}}} \zeta _p^{w_1Tr(xy)}\\&=\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\zeta _p^{w_1Tr(xy)}\\&=\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\sum \limits _{x\in {\mathbb {F}_{p^m}}} \sum \limits _{y\in {\mathbb {F}_{p^m}}}\zeta _p^{w_1Tr(yx)}\\&=\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}(p^m+\sum\limits_{{\mathop {x \in {\mathbb{F}}_{{p^{m} }} }\limits_{{x \ne 0}} }} {\sum\limits_{{y \in {\mathbb{F}}_{{p^{m} }} }} {\zeta _{p}^{{w_{1} Tr(yx)}} } } )\\&=(p-1)p^m. \\ \varLambda _2&=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}} \zeta _p^{w_2Tr(y)}=0.\\ \varLambda _3&=\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\sum \limits _{w_1\in {\mathbb {F}_p^{*}}}\zeta _p^{w_1 Tr(xy)}\sum \limits _{w_2\in {\mathbb {F}_p^{*}}}\zeta _p^{w_2Tr(y)}\\&=\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}}\sum \limits _{x,y\in {\mathbb {F}_{p^m}}}\zeta _p^{w_1Tr(xy)+w_2Tr(y)}\\&=\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}}\sum \limits _{y\in {\mathbb {F}_{p^m}}} \zeta _p^{w_2Tr(y)}\sum \limits _{x\in {\mathbb {F}_{p^m}}}\zeta _p^{w_1Tr(xy)}\\&=\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}} (p^m+\sum\limits_{{\mathop {y \in {\mathbb{F}}_{{p^{m} }} }\limits_{{y \ne 0}} }} {\zeta _{p}^{{w_{2} Tr(y)}} }\sum \limits _{x\in {\mathbb {F}_{p^m}}}\zeta _p^{Tr(xy)})\\&=\sum \limits _{w_1,w_2\in {\mathbb {F}_p^{*}}}p^m\\&=(p-1)^2p^m.&\end{aligned}$$

Through the above results, we can obtain:

$$\begin{aligned} \begin{aligned} A_{w_1}=p^{2m-2}+(p-1)p^{m-1}-1. \end{aligned} \end{aligned}$$

Then by Pless Power Moments [30], we have

$$\begin{aligned} \left\{ \begin{aligned}&A_{w_1}+A_{w_2}+A_{w_3}=p^{2m}-1,\\&w_1A_{w_1}+w_2A_{w_2}+w_3A_{w_3}=(p-1) np^{2m-1}. \end{aligned} \right. \end{aligned}$$

Solving the above system of linear equations, we have \(A_{w_2}=p^{2m-1}+(p-2)p^{2m-2}-(p-1)p^{m-1}\) and \(A_{w_3}=(p-1)p^{2m-1}-(p-1) p^{2m-2}\). Hence, we have the weight distribution in Table 1.

(2) When \(u\ne 0\), then it follows from (4), Lemmas 6, 7 and 8 that the Hamming weight \(w(c_{a,b})\) of the nonzero codeword \(c_{a,b}\) is given by

$$\begin{aligned} w(c_{a,b})=\left\{ \begin{aligned}&(p-1)p^{2m-2}&if\ Tr(ab)=Tr(b)=0,\\&or, Tr(ab)\ne 0\ and\ B\in NS_p,\\&(p-1)p^{2m-2}-p^{m-1}&if\ Tr(ab)=0\ and\ Tr(b)\ne 0,\\&or,Tr(ab)\ne 0\ and\ B=0,\\&(p-1)p^{2m-2}-2p^{m-1}&if\ Tr(ab)\ne 0\ and\ B\in S_p, \end{aligned} \right. \end{aligned}$$

where \(B=Tr^2(b)-4uTr(ab)\). Let \(w_1=(p-1) p^{2m-2},\ w_2=(p-1)p^{2m-2}-p^{m-1},\ w_3=(p-1) p^{2m-2}-2 p^{m-1}\). With the same technique as \(u=0\), we have \(A_{w_1}=\frac{p-1}{2}p^{2m-1}+p^{2m-2}+\frac{p-1}{2} p^{m-1}-1,\ A_{w_2}=2(p-1) p^{2m-2},\ A_{w_3}=\frac{p+1}{2}p^{2m-1}-(2p-1)p^{2m-2}-\frac{p-1}{2} p^{m-1}\). Hence, we have the corresponding weight distribution in Table 2. \(\square\)

The results of Theorem 1 are verified by Magma.

Example 1

Let \(p=3,\ m=2,\ u=0\), then the code \(C_D\) in Theorem 1(1) has parameters \(\left[ 32,4,18\right]\) and weight enumerator \(1+14z^{18}+36z^{21}+30z^{24}\).

Example 2

Let \(p=5,\ m=2,\ u=0\), then the code \(C_D\) in Theorem 1(1) has parameters \(\left[ 144,4,100\right]\) and weight enumerator \(1+44z^{100}+400z^{115}+180z^{120}\).

Example 3

Let \(p=3,\ m=2,\ u=1\), then the code \(C_D\) in Theorem 1(2) has parameters \(\left[ 24,4,12\right]\) and weight enumerator \(1+6z^{12}+36z^{15}+38z^{18}\).

Example 4

Let \(p=5,\ m=2,\ u=1\), then the code \(C_D\) in Theorem 1(2) has parameters \(\left[ 120,4,90\right]\) and weight enumerator \(1+140z^{90}+200z^{95}+284z^{100}\).

Minimal linear codes have interesting applications in secret sharing schemes [8, 31]. A sufficient condition [32] for a linear code to be minimal is given in the following lemma.

Lemma 9

[18] Every nonzero codeword of a linear code C over \(\mathbb {F}_p\) is minimal, provided that

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

where \(w_{max}\) and \(w_{min}\) denote the maximum and minimum nonzero weights in C, respectively.

For the code \(C_D\) of Theorem 1, we have

(1) when \(u=0,\ m\ge 2\),

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

(2) when \(u\ne 0,\ m\ge 3\),

$$\begin{aligned} \frac{w_{min}}{w_{max}}=\frac{(p-1)p^{2m-2}-2p^{m-1}}{(p-1)p^{2m-2}}>\frac{p-1}{p}. \end{aligned}$$

Then it follows from Lemma 9 that all the nonzero codewords of \(C_D\) are minimal if \(m\ge 3\). Hence, these codes can be used to construct secret sharing schemes.

Remark

Some interesting linear codes with three weights were presented in [16,17,18,19, 21,22,23,24, 26,27,28, 33, 34]. We list lengths of known three-weight linear codes in Table 3. Note that some of our codes have been presented in [17] when \(p\mid m\). However, parameters of our codes are more flexible. Our codes in Theorem 1 are not covered in previous papers and most of our codes are new.

Table 3 The comparison of three-weight linear codes

5 Conclusion

In this paper, we generalized the results of [28], and obtained a class of three-weight linear codes over finite fields of odd characteristic. The parameters and weight distributions of linear codes were determined by some results of exponential sums. Further, most of linear codes obtained are minimal, which can be used to construct secret sharing schemes. It would be interesting to construct linear codes with good properties by new methods and present more applications of linear codes.