1 Introduction

Error correcting codes are widely studied by researchers and employed by engineers. They have long been known to have applications in computer and communication systems, data storage devices (starting from the use of Reed Solomon codes in CDs) and consumer electronics. A lot of progress has been made on the constructions of linear codes with few weights. Such codes have applications in secret sharing [1, 6, 912, 19, 39], authentication codes [22], association schemes [2], and strongly regular graphs [3]. Interesting two-weight and three-weight codes have been obtained in several papers. A non-exhaustive list dealing with codes with few weights is [8, 13, 1721, 23, 27, 31, 3538, 40, 41].

Certain special types of functions and vector spaces over finite fields are closely related to linear or nonlinear codes. Two generic constructions (say, of “type I” and of “type II”) of linear codes involving special functions have been isolated and next investigated in literature. Linear codes obtained from the generic construction of type II are defined via their defining set while those obtained from the generic construction of type I are defined as the trace function of some functions involving polynomials which vanish at zero. Recently, based on the generic construction of type II, several approaches for constructing linear codes with special types of functions were proposed, and a lot of linear codes with excellent parameters were obtained. A very nice survey devoted to the construction of binary linear codes from Boolean functions based on the generic construction of type II is given by Ding in [17].

Bent functions are maximally nonlinear Boolean functions. They were introduced by Rothaus [34] in the 1960’s and initially studied by Dillon as early as 1974 in his Thesis [15]. The notion of bent function has been extended in arbitrary characteristic by Kumar et al. [30]. For their own sake as interesting combinatorial objects, but also for their relations to coding theory (e.g. Reed-Muller codes, Kerdock codes, etc.), combinatorics (e.g. difference sets), design theory, sequence theory, and applications in cryptography (design of stream ciphers and of S-boxes for block ciphers), bent functions have attracted a lot of research for the past four decades as shown in a jubilee survey paper on bent functions [7] and a book [32] devoted especially to bent functions and containing a complete survey (including variations, generalizations and applications). It is well-known that Kerdock codes are constructed from bent functions. Very recently, it has been shown in a few papers [16, 35, 42] that bent functions lead to the construction of interesting linear codes with few weights based on the generic construction of type II.

In this paper, we focus on the construction of linear codes from bent functions in arbitrary characteristic based on the generic construction of type I. The paper is organized as follows. In Section 2, we fix our main notation and recall the necessary background. In Section 3, we present the two generic constructions of binary codes from functions which have been highlighted by Ding in [17] and focus on one of them. In Section 4, we study codes from mappings based on the first generic construction and present results in a very general context. Finally, in Section 5, we derive a new class of linear codes with three weights from weakly regular bent functions and present its weight distribution. Such a class contains some optimal codes meeting certain bound on linear codes. The reader will notice that the general idea of the construction of our codes is a classical one since it has been already employed in [4, 5] in the binary case and in [6, 38] in odd characteristic. Nevertheless, the specific choice of the function employed for designing our codes is new.

2 Notation and preliminaries

We present basic notation that will be employed in subsequent sections.

2.1 Some notation fixed throughout this paper

Throughout this paper we adopt the following notation unless otherwise stated.

  • For any set E, E = E∖{0} and #E will denote the cardinality of E;

  • p is a prime;

  • h is a positive integer divisor of m. Set m = h r and q = p h;

  • \(\mathbb {F}_{n}\) is the Galois field of order n;

  • \(\mathbb {Z}\) is the rational integer ring and \(\mathbb {Q}\) the rational field;

  • \((\frac {a}{p})\) is the Legendre symbol for 1 ≤ ap − 1;

  • \(p^{*}=(\frac {-1}{p})p=(-1)^{(p-1)/2}p\). Note that \(p^{m}=(\frac {-1}p)^{m} \sqrt {p^{*}}^{2m}\);

  • \(\xi _{p}=e^{\frac {2\pi \sqrt {-1}}p}\) is the primitive p-th root of unity.

2.2 Some background related to coding theory

Definition 1

A linear [n, k, d] q code \(\mathcal {C}\) over \(\mathbb {F}_{q}\) is a k-dimensional subspace of \(\mathbb {F}_{q}^{n}\) with minimum Hamming distance d.

The support of a vector \(\bar a=(a_{0},\cdots , a_{n-1})\in \mathbb {F}_{q}^{n}\) denoted by \(supp(\bar a)\) is defined by \(supp(\bar a):=\{0 \leq i\leq n-1: a_{i}\not =0 \}.\) The Hamming weight of a vector \(\bar a\in \mathbb {F}_{q}^{n}\) denoted by \(wt(\bar a)\) is the cardinality of its support, that is, \(wt(\bar a):=\#supp(\bar a)\).

2.3 Cyclotomic field \(\mathbb {Q}(\xi _{p})\)

In this subsection we recall some basic results on cyclotomic fields (see e.g. [29]). The ring of integers in \(\mathbb {Q}(\xi _{p})\) is \(\mathcal {O}_{K}=\mathbb {Z}(\xi _{p})\). An integral basis of \(\mathcal {O}_{\mathbb {Q}(\xi _{p})}\) is \(\{{\xi _{p}^{i}} \mid 1\leq i\leq p-1\}\). The field extension \(\mathbb {Q}(\xi _{p})/\mathbb {Q}\) is Galois of degree p − 1 and the Galois group \(Gal (\mathbb {Q}(\xi _{p})/\mathbb {Q})=\{\sigma _{a} \mid a \in (\mathbb {Z}/p\mathbb {Z})^{*}\}\), where the automorphism σ a of \(\mathbb {Q}(\xi _{p})\) is defined by \(\sigma _{a}(\xi _{p})={\xi _{p}^{a}}\). The field \(\mathbb {Q}(\xi _{p})\) has a unique quadratic subfield \(\mathbb {Q}(\sqrt {p^{*}})\) with \(p^{*}=(\frac {-1}{p})p\). For 1 ≤ ap − 1, \(\sigma _{a}(\sqrt {p^{*}})=(\frac {a}{p})\sqrt {p^{*}}\). Hence, the Galois group \(Gal(\mathbb {Q}(\sqrt {p^{*}})/\mathbb {Q}\) is {1,σ γ }, where γ is any quadratic nonresidue in \(\mathbb {F}_{p}\).

2.4 Some background related to p-ary functions

The trace function \(Tr_{q^{r}/q} : \mathbb {F}_{q^{r}} \rightarrow \mathbb {F}_{q}\) is defined as:

$$Tr_{q^{r}/q}(x):=\sum\limits_{i=0}^{r-1} x^{q^{i}}=x+x^{q}+x^{q^{2}}+\cdots+x^{q^{r-1}}. $$

The trace function from \(\mathbb {F}_{q^{r}}\) to its prime subfield is called the absolute trace function.

Recall that the trace function \(Tr_{q^{r}/q}\) is \(\mathbb {F}_{q}\)-linear and satisfies the transitivity property in a chain of extension fields (m = h r): \(Tr_{p^{m}/p}(x)= Tr_{p^{h}/p} (Tr_{p^{m}/p^{h}}(x))\) for all \(x\in \mathbb {F}_{q^{r}}\).

Given two positive integers s and r, the functions from \(\mathbb {F}_{q}^{s}\) to to \(\mathbb {F}_{q}^{r}\) will be called (s, r)-q-ary functions or (if the values s and r are omitted) vectorial q-ary functions. The component functions of F are the q-ary functions lF, where l ranges over the set of all the nonzero linear forms over \(\mathbb {F}_{q}^{r}\). Equivalently, they are the linear combinations of a non-null number of their coordinate functions, that is, the functions of the form vF, where \(v\in \mathbb {F}_{q}^{r}\setminus \{0\}\) and ‘ ⋅” denotes the usual inner product in \(\mathbb {F}_{q}^{r}\) (or any other inner product). The vector spaces \(\mathbb {F}_{q}^{s}\) and \(\mathbb {F}_{q}^{r}\) can be identified with the Galois fields \(\mathbb {F}_{q^{s}}\) and \(\mathbb {F}_{q^{r}}\) of orders q s and q r respectively. Hence, (s, r)-q-ary functions can be viewed as functions from \(\mathbb {F}_{q^{s}}\) to \(\mathbb {F}_{q^{r}}\). In this case, the component functions are the functions \(Tr_{q^{r}/q}(v F(x))\).

Let \(f : \mathbb {F}_{p^{m}} \longrightarrow \mathbb {F}_{p}\) be a p-ary function. The Walsh transform of f is given by:

$$\widehat{\chi_{f}}(\lambda)=\sum\limits_{x\in \mathbb {F}_{p^{m}}} {\xi_{p}}^{{f(x)}-Tr_{p^{m}/p} (\lambda x)}, \lambda\in \mathbb {F}_{p^{m}}$$

where \( \xi _{p}=e^{\frac {2\pi \sqrt {-1}}{p}}\) is a complex primitive p-th root of unity and the elements of \(\mathbb {F}_{p}\) are considered as integers modulo p.

Function f can be recovered from \(\widehat {\chi _{f}}\) by the inverse transform:

$$ \xi_{p}^{f(x)}=\frac{1}{p^{m}} \sum\limits_{b\in\mathbb {F}_{p^{m}}} \widehat{\chi_{f}}(b) \xi_{p}^{-Tr_{p^{m}/p}(bx)}. $$
(1)

2.5 Bent functions and (weakly) regular bent functions

A p-ary function \(f :\mathbb {F}_{p^{m}} \longrightarrow \mathbb {F}_{p}\) is called bent if all its Walsh-Hadamard coefficients satisfy \( \vert \widehat {\chi _{f}}(b) \vert ^{2}=p^{m}.\) A bent function f is called regular bent if for every \(b\in \mathbb {F}_{p^{m}}\), \(p^{-\frac {m}2} \widehat {\chi _{f}}(b)=\xi _{p}^{f^{\star }(b)}\) for some p-ary function \(f^{\star }: \mathbb {F}_{p^{m}}\rightarrow \mathbb {F}_{p}\) ([30], [definition 3]). The bent function f is called weakly regular bent if there exist a complex number u with |u|=1 and a p-ary function f such that \(up^{-\frac {m}2} \widehat {\chi _{f}}(b)=\xi _{p}^{f^{\star }(b)}\) for all \(b\in \mathbb {F}_{p^{m}}\). Such function f (x) is called the dual of f(x). From [24, 25], a weakly regular bent function f(x) satisfies

$$ \widehat{\chi_{f}}(b)=\epsilon \sqrt{p^{*}}^{m} \xi_{p}^{f^{*}(b)}, $$
(2)

where 𝜖 = ±1 is called the sign of the Walsh transform of f(x) and p denotes \((\frac {-1}{p})p\). Note that from (1), for the weakly regular bent function f(x), we have \({\sum }_{b \in \mathbb {F}_{p^{m}}} \xi _{p}^{f^{*}(b)-Tr_{p^{m}/p}(bx)}=\epsilon p^{m} \xi _{p}^{f(x)}/\sqrt {p^{*}}^{m}\). Moreover, Walsh-Hadamard transform coefficients of a p-ary bent function f with odd p satisfy

$$\begin{array}{@{}rcl@{}} p^{-\frac{m}2} \widehat{\chi_{f}}(b)=\left\{\begin{array}{ll}\pm\xi_{p}^{f^{\star}(b)}, & \text{ if } m \text{ is even or } m \text{ is odd and } p \equiv 1\pmod 4,~ \\ \pm i\xi_{p}^{f^{\star}(b)}, & \text{ if } m \text{ is odd and } p\equiv 3\pmod 4,\\ \end{array}\right. \end{array} $$
(3)

where i is a complex primitive 4-th root of unity. Therefore, regular bent functions can only be found for even m and for odd m with p ≡ 1 (mod 4). Moreover, for a weakly regular bent function, the constant u (defined above) can only be equal to ±1 or ±i.

We summarize in Table 1 all known weakly regular bent functions over \(\mathbb {F}_{p^{m}}\) with odd characteristic p.

Table 1 Known weakly regular bent functions over \(\mathbb {F}_{p^{m}}\), p odd

3 Two generic constructions of linear codes from functions

Boolean functions or more generally p-ary functions have important applications in cryptography and coding theory. In coding theory, they have been used to construct linear codes. Historically, the Reed-Muller codes and Kerdock codes have been -for a long time- the two famous classes of binary codes derived from Boolean functions. Next, a lot of progress has been made in this direction and further codes have been derived from more general and complex functions. Nevertheless, as highlighted by Ding in his very recent survey [17], despite the advances in the past two decades, one can isolate essentially only two generic constructions of linear codes from functions. The first one is obtained by considering a code \(\mathcal {C}(f)\) over \(\mathbb {F}_{p}\) involving a polynomial f from \(\mathbb {F}_{q}\) to \(\mathbb {F}_{q}\) (where q = p m) defined by

$$\mathcal{C}(f)=\{\textbf{c}=(Tr_{q/p}(af(x)+bx))_{x\in\mathbb{F}^{*}_{q}}\mid a\in\mathbb{F}_{q}, b\in\mathbb{F}_{q}\}.$$

The resulting code \(\mathcal {C}(f)\) from f is a linear code of length q − 1 and its dimension is upper bounded by 2m which is reached in many cases. As mentioned in the literature (see for instance [17]), this generic construction has a long history and its importance is supported by Delsarte’s Theorem [14]. In the binary case (that is, when p = 2), the first generic construction allows us to provide a kind of coding-theory characterization of special cryptographic functions such as APN functions, almost bent functions and semi-bent functions (see for instance [4, 5, 28]).

The second generic construction of linear codes from functions is obtained by fixing a set D = {d 1,d 2,⋯ ,d n } in \(\mathbb {F}_{q}\) (where q = p m) and by defining a linear code involving D as follows:

$$\mathcal {C}_{D}=\{(Tr_{q/p}(x d_{1}), Tr_{q/p}(x d_{2}), \cdots, Tr_{q/p}(xd_{n}))\mid x\in\mathbb{F}_{q}\}.$$

The set D is usually called the defining set of the code \(\mathcal {C}_{D}\). The resulting code \(\mathcal {C}_{D}\) has length n and dimension at most m. This construction is generic in the sense that many classes of known codes 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.

4 On the first generic construction of linear codes from mappings over finite fields

In this section, we shall use the notation introduced in Section 2.1. For any \(\alpha , \beta \in \mathbb {F}_{q^{r}}\), define

$$\begin{array}{ccccl} f_{\alpha, \beta} &:& \mathbb {F}_{q^{r}}& \longrightarrow & \mathbb {F}_{q}\\ &&x&\longmapsto& f_{\alpha, \beta}(x):=Tr_{q^{r}/q}(\alpha {\Psi} (x)-\beta x) \end{array}$$

where Ψ is a mapping from \(\mathbb {F}_{q^{r}} \) to \(\mathbb {F}_{q^{r}}\) such that Ψ(0)=0.

We now define a linear code \(\mathcal {C}_{\Psi }\) over \(\mathbb {F}_{q}\) as :

$$\mathcal {C}_{\Psi}:=\{\bar {c}_{\alpha, \beta}=(f_{\alpha, \beta}(\zeta_{1}),f_{\alpha, \beta}(\zeta_{2}),\cdots, f_{\alpha, \beta}(\zeta_{q^{r}-1})), \alpha,\beta\in\mathbb {F}_{q^{r}}\}$$

where \(\zeta _{1}, \cdots , \zeta _{q^{r}-1}\) denote the nonzero elements of \(\mathbb {F}_{q^{r}}\).

Proposition 1

The linear code \(\mathcal {C}_{\Psi }\) has length q r −1. If the mapping Ψ has no linear component then \(\mathcal {C}_{\Psi }\) has dimension 2r.

Proof

It is clear that \(\mathcal {C}_{\Psi }\) is of length q r−1. Now, let us compute the cardinality of \(\mathcal {C}_{\Psi }\) . Let \(\bar {c}_{\alpha , \beta }\) be a codeword of \(\mathcal {C}_{\Psi }\). We have

$$\begin{array}{@{}rcl@{}} \bar {c}_{\alpha, \beta} &=&0 \iff Tr_{q^{r}/q}(\alpha {\Psi} (\zeta_{i})-\beta \zeta_{i})=0, \forall i\in\{1,\cdots,q^{r}-1\}\\ &&\iff Tr_{q^{r}/q}(\alpha {\Psi} (x)-\beta x)=0, \forall x\in \mathbb {F}_{q^{r}}^{\star}\\ &&\Rightarrow Tr_{q^{r}/p}(\alpha {\Psi} (x)-\beta x)=0, \forall x\in \mathbb {F}_{q^{r}}^{\star}\\ &&\Rightarrow Tr_{q^{r}/p}(\alpha {\Psi} (x)-\beta x)=0, \forall x\in \mathbb {F}_{q^{r}}\\ &&\Rightarrow Tr_{q^{r}/p}(\alpha {\Psi} (x))=Tr_{q^{r}/p} (\beta x), \forall x\in \mathbb {F}_{q^{r}} \end{array} $$

Hence, \(\bar {c}_{\alpha , \beta }=0\) implies that the component of Ψ associated with α ≠ 0 is linear or null and coincides with \(x\mapsto Tr_{q^{r}/p} (\beta x)\). Therefore, to ensure that the null codeword appears only once (for α = β = 0), it suffices that no component function of Ψ is identically equal to 0 or linear. Furthermore, this implies that all the codewords \(\bar {c}_{\alpha , \beta }\) are pairwise distinct. In this case, the size of the code is q 2r and its dimension thus equals 2r. □

The following statement shows that the weight distribution of the code \(\mathcal {C}_{\Psi }\) of length q r−1 can be expressed by means of the Walsh transform of some absolute trace functions over \(\mathbb {F}_{p^{m}}\) involving the map Ψ.

Proposition 2

We keep the notation above. Let \(a\in \mathbb {F}_{p^{m}}\) . Let us denote by ψ a mapping from \(\mathbb {F}_{p^{m}}\) to \(\mathbb {F}_{p}\) defined as:

$$\psi_{a}(x)=Tr_{p^{m}/p}(a{\Psi}(x)).$$

For \(\bar {c}_{\alpha , \beta }\in \mathcal {C}_{\Psi }\) , we have:

$$wt (\bar {c}_{\alpha, \beta})=p^{m}-\frac {1}q \sum\limits_{\omega \in\mathbb {F}_{q}} \widehat{\chi_{\psi_{\omega\alpha}}}(\omega \beta).$$

Proof

Notethat Ψ(0)=0 implies that f α, β (0)=0. Now, let \(\bar {c}_{\alpha , \beta }\) be a codeword of \(\mathcal {C}_{\Psi }\) then,

$$\begin{array}{@{}rcl@{}} wt (\bar {c}_{\alpha, \beta}) &=&\#\{x\in\mathbb {F}_{q^{r}}^{\star} \mid f_{\alpha, \beta}(x)\not=0\}\\ &=&\#\{x\in\mathbb {F}_{q^{r}} \mid f_{\alpha, \beta}(x)\not=0\}\\ &=&p^{m}-\#\{x\in\mathbb {F}_{q^{r}} \mid f_{\alpha, \beta}(x)=0\}\\ &=&p^{m}-\sum\limits_{x\in\mathbb {F}_{q^{r}}} \frac{1}q\sum\limits_{\omega\in \mathbb {F}_{q}}{\xi_{p}}^{Tr_{q/p}(\omega f_{\alpha, \beta}(x))}. \end{array} $$

The latter equality comes from the fact that the sum of characters equals q if f α, β (x)=0 and 0 otherwise. Moreover (using the transitivity property of the trace function \(Tr_{q^{r}/p}\) and the fact that \(Tr_{q^{r}/q}\) is \(\mathbb {F}_{q}\)-linear)

$$\begin{array}{@{}rcl@{}} wt (\bar {c}_{\alpha, \beta}) &=&p^{m}- \frac{1}q \sum\limits_{\omega\in \mathbb {F}_{q}} \sum\limits_{x\in\mathbb {F}_{q^{r}}}{\xi_{p}}^{Tr_{q/p}(\omega f_{\alpha, \beta}(x))}\\ &=&p^{m}- \frac{1}q \sum\limits_{\omega\in \mathbb {F}_{q}} \sum\limits_{x\in\mathbb {F}_{q^{r}}}{\xi_{p}}^{Tr_{q/p}(\omega Tr_{q^{r}/q}(\alpha {\Psi} (x)- \beta x))}\\ &=&p^{m}- \frac{1}q \sum\limits_{\omega\in \mathbb {F}_{q}} \sum\limits_{x\in\mathbb {F}_{q^{r}}}{\xi_{p}}^{Tr_{q^{r}/p}(\omega \alpha {\Psi} (x)- \omega\beta x)}\\ &=&p^{m}- \frac{1}q \sum\limits_{\omega\in \mathbb {F}_{q}} \sum\limits_{x\in\mathbb {F}_{q^{r}}}{\xi_{p}}^{{\psi_{\omega \alpha}(x)}- {Tr_{q^{r}/p}(\omega\beta x)}}\\ &=&p^{m}-\frac {1}q \sum\limits_{\omega \in\mathbb {F}_{q}} \widehat{\chi_{\psi_{\omega\alpha}}}(\omega \beta).\\ \end{array} $$

5 A new family of linear codes with few weights from weakly regular bent functions based on the first genetic construction

In this section we study a particular subclass of the family of linear codes considered in the previous section. We shall fix h = 1 and assume \(\alpha \in \mathbb {F}_{p}\). Let then g α, β be the p-ary function from \(\mathbb {F}_{p^{m}}\) to \(\mathbb {F}_{p}\) given by \(g_{\alpha ,\beta }(x)=\alpha Tr_{p^{m}/p}({\Psi }(x))-Tr_{p^{m}/p}(\beta x)\). Note that \(g_{\alpha ,\beta }(x)=\alpha \psi _{1}(x)-Tr_{p^{m}/p}(\beta x)\) where ψ a is defined as in Section 4 by \(\psi _{a}(x)=Tr_{p^{m}/p}(a{\Psi }(x))\). Now let us define a subcode \(\mathcal {C}\) of \(\mathcal {C}_{\Psi }\) as follows:

$$ \mathcal {C}:=\{\tilde {c}_{\alpha, \beta}=(g_{\alpha, \beta}(\zeta_{1}),g_{\alpha, \beta}(\zeta_{2}),\cdots, g_{\alpha, \beta}(\zeta_{p^{m}-1})), \alpha\in\mathbb{F}_{p},\beta\in\mathbb {F}_{p^{m}}\}. $$
(4)

where \(\zeta _{1}, \cdots , \zeta _{p^{m}-1}\) denote the nonzero elements of \(\mathbb {F}_{p^{m}}\). According to Proposition 2 (where T r q/p is the identity function since here p = q),

$$\begin{array}{@{}rcl@{}} wt (\tilde {c}_{\alpha, \beta})&=&p^{m}-\frac {1}p \sum\limits_{\omega \in\mathbb {F}_{p}} \widehat{\chi_{\psi_{\omega\alpha}}}(\omega \beta)\\ &=&p^{m}-p^{m-1}-\frac {1}p \sum\limits_{\omega \in\mathbb {F}_{p}^{\star}} \widehat{\chi_{\psi_{\omega\alpha}}}(\omega \beta)\\ &=&p^{m}-p^{m-1}-\frac {1}p \sum\limits_{\omega \in\mathbb {F}_{p}^{\star}} \sum\limits_{x\in\mathbb{F}_{p^{m}}}\xi_{p}^{ Tr_{p^{m}/p}(\omega\alpha {\Psi}(x)-\omega \beta x)}\\ &=&p^{m}-p^{m-1}-\frac {1}p \sum\limits_{\omega \in\mathbb {F}_{p}^{\star}} \sum\limits_{x\in\mathbb{F}_{p^{m}}}\xi_{p}^{\omega Tr_{p^{m}/p}(\alpha {\Psi}(x)-\beta x)}\\ &=&p^{m}-p^{m-1}-\frac {1}p \sum\limits_{\omega \in\mathbb {F}_{p}^{\star}} \sigma_{\omega}(\widehat{\chi_{\psi_{\alpha}}}(\beta)).\\ \end{array} $$

But \(\widehat {\chi _{\psi _{\alpha }}}(\beta )=\sigma _{\alpha }(\widehat {\chi _{\psi _{1}}}(\bar \alpha \beta ))\) where \(\bar \alpha \) satisfies \(\bar \alpha \alpha =1\) in \(\mathbb {F}_{p}\). Indeed,

$$\begin{array}{@{}rcl@{}} \sigma_{\alpha}(\widehat{\chi_{\psi_{1}}}(\bar\alpha\beta))&=&\sigma_{\alpha}\left( \sum\limits_{x\in\mathbb{F}_{p^{m}}} \xi_{p}^{\psi_{1}(x)-Tr_{p^{m}/p}(\bar\alpha \beta x)}\right)\\ &=&\sum\limits_{x\in\mathbb{F}_{p^{m}}} \xi_{p}^{\alpha\psi_{1}(x)-Tr_{p^{m}/p}(\beta x)}\\ &=&\widehat{\chi_{\alpha\psi_{1}}}(\beta)=\widehat{\chi_{\psi_{\alpha}}}(\beta). \end{array} $$

Consequently,

$$wt (\tilde {c}_{\alpha, \beta})=p^{m}-p^{m-1}-\frac {1}p {\sum}_{\omega \in\mathbb{F}_{p}^{\star}} \sigma_{\omega}(\sigma_{\alpha}(\widehat{\chi_{\psi_{1}}}(\bar\alpha\beta))). $$

Note that if α = 0 then \(wt (\tilde {c}_{\alpha , \beta })=p^{m}-p^{m-1}-\frac {1}p {\sum }_{\omega \in \mathbb {F}_{p}^{\star }} \sigma _{\omega } (\widehat {\chi _{\textbf {0}}}(\beta ))\) (where 0 denotes the zero function). Since \(\widehat {\chi _{\textbf {0}}}(\beta )={\sum }_{x\in \mathbb {F}_{p}^{m}}\xi _{p}^{-\beta x}=p^{m} \delta _{0,\beta }\) (where δ r, s denotes the Dirac symbol defined by δ r, s = 1 if s = r and 0 otherwise). Therefore,

$$\begin{array}{llll} wt (\tilde {c}_{\alpha, \beta})&=&p^{m}-p^{m-1}-\frac{1}p {\sum}_{\omega \in\mathbb {F}_{p}^{\star}} \sigma_{\omega} (p^{m} \delta_{0,\beta})\\ &=&p^{m}-p^{m-1}-p^{m-1}(p-1) \delta_{0,\beta}.\\ \end{array} $$

Hence, we obtain \(wt (\tilde {c}_{0, 0})=0\) and for β ≠ 0, \(wt (\tilde {c}_{0, \beta })=p^{m}-p^{m-1}\), which gives the Hamming weight of any codeword \(\tilde {c}_{0, \beta }\) in any characteristic.

Let us consider firstly the binary case (p = 2). Assume \(\psi _{1}:=Tr_{2^{m}/2}({\Phi })\) is bent. Then \(\widehat {\chi _{\psi {1}}}(\beta )=(-1)^{\psi _{1}^{*}(\beta )}2^{\frac {m}2}\). Hence, \(wt (\tilde {c}_{1,\beta })=2^{m}-2^{m-1}-\frac {1}{2}(-1)^{\psi _{1}^{*}(\beta )}2^{\frac {m}{2}}=2^{m-1}-(-1)^{\psi _{1}^{*}(\beta )}2^{\frac {m}2-1}\).

From now on, we assume p odd and \(\psi _{1}:=Tr_{p^{m}/p}({\Phi })\) is weakly regular bent. Then, by definition, we have:

$$\widehat{\chi\psi_{1}}(\bar \alpha\beta)=\epsilon \sqrt{p^{*}}^{m}\xi_{p}^{\psi_{1}^{*}(\bar \alpha\beta)}.$$

Using the fact \(\sigma _{\alpha }(\sqrt {p^{*}}^{m})=\sigma _{\alpha }(\sqrt p^{\star })^{m}=(\frac {\alpha }{p})^{m}\sqrt {p^{*}}^{m}\) and if m is even, \((\frac {\alpha }p)^{m}=1\) and \(\sqrt {p^{*}}^{m}=\sqrt {p}^{m}\), one gets

$$\begin{array}{lllll} \sigma_{\alpha}(\widehat{\chi_{\psi{1}}}(\bar \alpha \beta))&=\epsilon \sigma_{\alpha}(\sqrt {p^{*}}^{m})\xi_{p}^{\alpha \psi_{1}^{*}(\bar \alpha\beta)}\\ &=\epsilon (\frac{\alpha}{p})^{m}\sqrt {p^{*}}^{m} \xi_{p}^{\alpha \psi_{1}^{*}(\bar \alpha\beta)}.\\ \end{array} $$

Therefore,

$$\begin{array}{llll} wt (\tilde {c}_{\alpha, \beta})&=p^{m}-p^{m-1}-\frac{1}p{\sum}_{\omega\in\mathbb{F}^{*}_{p}}\sigma_{\omega}\left( \epsilon ({\frac{\alpha}{p}})^{m}\sqrt {p^{*}}^{m} \xi_{p}^{\alpha \psi_{1}^{*}(\bar \alpha\beta)}\right)\\ &=p^{m}-p^{m-1}-\frac{1}p\epsilon(\frac{\alpha}{p})^{m}{\sum}_{\omega\in\mathbb{F}^{*}_{p}}\sigma_{\omega}(\sqrt {p^{*}}^{m}) \xi_{p}^{\omega\alpha \psi_{1}^{*}(\bar \alpha\beta)}\\ &=p^{m}-p^{m-1}-\frac{1}p\epsilon({\frac{\alpha}{p}})^{m}{\sum}_{\omega\in\mathbb{F}^{*}_{p}}(\frac{\omega}{p})^{m}\sqrt {p^{*}}^{m} \xi_{p}^{\omega\alpha \psi_{1}^{*}(\bar \alpha\beta)}\\ &=\left\{ \begin{array}{ll} p^{m}-p^{m-1}-\frac{1}p\epsilon(\frac{\alpha}{p})\sqrt {p^{*}}^{m}{\sum}_{\omega\in\mathbb{F}^{*}_{p}}(\frac{\omega}{p}) \xi_{p}^{\omega\alpha \psi_{1}^{*}(\bar \alpha\beta)} &\text{ if } m \text{ odd } \\ p^{m}-p^{m-1}-p^{\frac{m}2-1}\epsilon{\sum}_{\omega\in\mathbb{F}^{*}_{p}} \xi_{p}^{\omega\alpha \psi_{1}^{*}(\bar \alpha\beta)} &\text{ if } m \text{ even.} \end{array} \right.\\ \end{array} $$

Let us distinguish both cases.

  1. 1.

    Case m odd.

    • If \(\psi _{1}^{*}(\bar \alpha \beta )=0\) then (using the fact that \({\sum }_{\omega \in \mathbb {F}^{*}_{p}} (\frac {\omega }{p})=0\))

      $$\begin{array}{lllll} wt (\tilde {c}_{\alpha, \beta})&=p^{m}-p^{m-1}-\frac{1}p\epsilon(\frac{\alpha}{p})\sqrt {p^{*}}^{m}{\sum}_{\omega\in\mathbb{F}^{*}_{p}}(\frac{\omega}{p})\\ &=p^{m}-p^{m-1}. \end{array} $$
    • If \(\psi _{1}^{*}(\bar \alpha \beta )\not =0\) then (using in particular the evaluation of the Gauss sum: \({\sum }_{\omega \in \mathbb {F}^{*}_{p}}(\frac {\omega }{p}) \xi _{p}^{\omega }=\sqrt {p^{*}}\))

      $$\begin{array}{lllll} wt (\tilde {c}_{\alpha, \beta})&=p^{m}-p^{m-1}-\frac{1}p\epsilon(\frac{\alpha}{p})\sqrt {p^{*}}^{m}{\sum}_{\omega\in\mathbb{F}^{*}_{p}}(\frac{\omega}{p}) (\xi_{p}^{\omega})^{\alpha \psi_{1}^{*}(\bar \alpha\beta)}\\ &=p^{m}-p^{m-1}-\frac{1}p\epsilon(\frac{\alpha}{p})\sqrt {p^{*}}^{m} \sigma_{\alpha \psi_{1}^{*}(\bar \alpha\beta)}\left( {\sum}_{\omega\in\mathbb{F}^{*}_{p}}(\frac{\omega}{p}) \xi_{p}^{\omega}\right)\\ &=p^{m}-p^{m-1}-\frac{1}p\epsilon(\frac{\alpha}{p})\sqrt {p^{*}}^{m} \sigma_{\alpha \psi_{1}^{*}(\bar \alpha\beta)}(\sqrt {p^{*}})\\ &=p^{m}-p^{m-1}-\frac{1}p\epsilon(\frac{\alpha}{p})\sqrt {p^{*}}^{m} \left( \frac{\alpha \psi_{1}^{*}(\bar \alpha\beta)}{p}\right)\sqrt {p^{*}}\\ &=p^{m}-p^{m-1}-\frac{1}p\epsilon{p^{*}}^{\frac{m+1}2} \left( \frac{ \psi_{1}^{*}(\bar \alpha\beta)}{p}\right)\\ &=p^{m}-p^{m-1}-\frac{1}p\epsilon(({\frac{-1}{p})p})^{\frac{m+1}2} \left( \frac{ \psi_{1}^{*}(\bar \alpha\beta)}{p}\right)\\ &=p^{m}-p^{m-1}-\epsilon(\frac{-1}{p})^{\frac{m+1}2}p^{\frac{m-1}2} \left( \frac{ \psi_{1}^{*}(\bar \alpha\beta)}{p}\right). \end{array} $$
  2. 2.

    Case m even.

    • If \(\psi _{1}^{*}(\bar \alpha \beta )=0\) then we have

      $$\begin{array}{llll} wt (\tilde {c}_{\alpha, \beta})&=p^{m}-p^{m-1}-p^{\frac{m}2-1}\epsilon{\sum}_{\omega\in\mathbb{F}^{*}_{p}} \xi_{p}^{\omega\alpha \psi_{1}^{*}(\bar \alpha\beta)}\\ &=p^{m}-p^{m-1}-p^{\frac{m}2-1}\epsilon(p-1). \end{array} $$
    • If \(\psi _{1}^{*}(\bar \alpha \beta )\not =0\) then (since \(\alpha \omega \in \mathbb {F}_{p}^{*}\)) we have \({\sum }_{\omega \in \mathbb {F}_{p}}\xi _{p}^{\alpha \omega \psi _{1}^{*}(\bar \alpha \beta )}=0\). Thus

      $$\begin{array}{llll} wt (\tilde {c}_{\alpha, \beta})&=p^{m}-p^{m-1}-p^{\frac{m}2-1}\epsilon{\sum}_{\omega\in\mathbb{F}^{*}_{p}} \xi_{p}^{\omega\alpha \psi_{1}^{*}(\bar \alpha\beta)}\\ &=p^{m}-p^{m-1}+p^{\frac{m}2-1}\epsilon. \end{array} $$

Collecting the previous results, we give in Theorem 1 the Hamming weights of the codewords of \(\mathcal {C}\).

Theorem 1

Let \(\mathcal {C}\) be the linear code defined by ( 4 ) whose codewords are denoted by \(\tilde {c}_{\alpha , \beta }\) . Assume that the function \(\psi _{1}:=Tr_{p^{m}/p}({\Psi })\) is bent or weakly regular bent if p=2 or p odd, respectively. We denote by \(\psi _{1}^{\star }\) its dual function. Then the weight distribution of \(\mathcal {C}\) is given as follows. In any characteristic, \(wt (\tilde {c}_{0, 0})=0\) and for β ≠ 0, \(wt (\tilde {c}_{0, \beta })=p^{m}-p^{m-1}\). Moreover,

  1. 1.

    when p = 2 then the Hamming weight of \(\tilde {c}_{1, \beta }\) ( \(\beta \in \mathbb {F}_{2^{m}}^{\star }\) ) is given by \(wt(\tilde {c}_{1, \beta })=2^{m-1}-(-1)^{\psi _{1}^{*}(\beta )}2^{\frac {m}2-1}\).

  2. 2.

    when p is odd then

    • if m is odd, the Hamming weight of \(\tilde {c}_{\alpha , \beta }\) is given by

      $$\left\{ \begin{array}{ll} p^{m}-p^{m-1} \text{ if } \alpha\in\mathbb{F}_{p}^{\star} \text{ and } \psi_{1}^{*}(\bar \alpha\beta)=0; \\ p^{m}-p^{m-1}-\epsilon(\frac{-1}{p})^{\frac{m+1}2}p^{\frac{m-1}2} \left( \frac{ \psi_{1}^{*}(\bar \alpha\beta)}{p}\right) \text{ if } \alpha\in\mathbb{F}_{p}^{\star} \text{ and } \psi_{1}^{*}(\bar \alpha\beta)\in\mathbb{F}_{p^{m}}^{\star}.\\ \end{array} \right.\\ $$
    • if m is even, the Hamming weight of \(\tilde {c}_{\alpha , \beta }\) is given by

      $$\left\{ \begin{array}{ll} p^{m}-p^{m-1}-p^{\frac{m}2-1}\epsilon(p-1) \text{ if } \alpha\in\mathbb{F}_{p}^{\star} \text{ and } \psi_{1}^{*}(\bar \alpha\beta)=0; \\ p^{m}-p^{m-1}+p^{\frac{m}2-1}\epsilon \text{ if } \alpha\in\mathbb{F}_{p}^{\star} \text{ and } \psi_{1}^{*}(\bar \alpha\beta)\in\mathbb{F}_{p^{m}}^{\star}.\\ \end{array} \right.\\ $$

We are now going to compute the weight distribution of \(\mathcal C\) when p is an odd prime. To this end, let us write the Walsh transform of ψ 1 as

$$\widehat{\chi\psi_{1}}(\omega)=\epsilon up^{\frac{m}2} \xi_{p}^{\psi_{1}^{*}(\omega)},$$

where 𝜖 ∈ {−1, 1} denotes the sign of the Walsh transform \(\widehat {\chi _{\psi _{1}}}\) and \(u\in \{1,i\}\in \mathbb C\).

The weight distribution of the code \(\mathcal {C}\) is closely related to the bentness of the involved function. Let g be a weakly regular bent function over \(\mathbb {F}_{p^{m}}\):

$$\widehat{\chi_g}(\omega)=\epsilon up^{\frac{m}2}\xi^{g^{*}(\omega)}_{p}, \omega\in\mathbb{F}_{p^{m}},\,\epsilon=\pm 1,\,u\in\{1,i\}.$$

Then g is a weakly regular bent function and

$$\widehat{\chi_g}(\omega)=\epsilon u^{-1}p^{\frac{m}2}\xi^{g(-\omega)}_{p}, \omega\in\mathbb{F}_{p^{m}}.$$

Set

$$N_{j}:=\#\{x\in\mathbb{F}_{p^{m}} \mid g(x)=j\}.$$

The following result allows to compute the N j . Numbers N j are known (see for instance [26], Theorem 2.2) for the even case. However, for the sake of completeness, we state their values in Proposition 3 translated into our framework, together with a proof.

Proposition 3

Using the above notation and assuming g (0) = 0. Then if m is even,

$$N_{0}=p^{m-1}-\epsilon p^{\frac{m}2-1}+\epsilon p^{\frac{m}2};$$
$$N_{j}=p^{m-1}-\epsilon p^{\frac{m}2-1}, 1\leq j\leq p-1;$$

if m is odd,

$$N_{0}=p^{m-1};$$
$$N_{j}=p^{m-1}+\epsilon p^{\frac{m-1}2}(\frac{j}{p}), 1\leq j\leq p.$$

Proof

One has

$$\widehat{\chi_g}(0)=\sum\limits_{x\in\mathbb{F}_{p^{m}}}\xi^{g(x)}_{p}=\epsilon up^{\frac{m}2}\xi^{g^{*}(0)}_{p}=\sum\limits_{j=0}^{p-1} N_{j}{\xi^{j}_{p}}$$

that is,

$$ \sum\limits_{j=0}^{p-1}N_{j}{\xi^{j}_{p}}-\epsilon up^{\frac{m}2}=0. $$
(5)
  • If m is even, u = 1. Now since \({\sum }_{j=0}^{p-1}x^{j}\) is the minimal polynomial of ξ p over the rational number field, we have

    $$N_{j}=a, 1\leq j\leq p-1 \text{ and } N_{0}-\epsilon p^{\frac{m}2}=N_{1}$$

    for some a, that is, all the N j ’s are equal except for N 0. Now, \({\sum }_{j=0}^{p-1}N_{j}=p^{m}\). Hence \(a+\epsilon p^{\frac {m}2}+(p-1)a=p^{m}\) from which one deduces \(a=p^{m-1}-\epsilon p^{\frac {m}2-1}\).

  • If m is odd, u = i. Recall the well-known identity (see. e.g [33])

    $$ \sum\limits_{j=1}^{p}(\frac{j}p){\xi^{j}_{p}}=\left\{\begin{array}{ll}p^{\frac{1}2}; & \text{ if } p \equiv 1\pmod 4;~ \\ ip^{\frac{1}2},& \text{ if } p\equiv 3\pmod 4,\\ \end{array}\right. $$
    (6)

    that is, \({\sum }_{j=1}^{p}(\frac {j}p){\xi ^{j}_{p}}=up^{\frac {1}2}\). Equation (5) can therefore be rewritten as

    $$\sum\limits_{j=0}^{p-1}N_{j}{\xi^{j}_{p}}-\epsilon p^{\frac{m-1}2}\sum\limits_{j=1}^{p} (\frac {j}p){\xi^{j}_{p}}=0.$$

    By similar arguments as in the even case, we conclude that

    $$N_{0}=N_{j}-\epsilon p^{\frac{m-1}2}(\frac{j}p), 1\leq j\leq p.$$

    Now, \({\sum }_{j=0}^{p-1} N_{j}=p^{m}=pN_{0}+\epsilon p^{\frac {m-1}2}{\sum }_{j=1}^{p} (\frac {j}p)=pN_{0}\). Thus N 0 = p m − 1.

Now, using Proposition 3, we give in the following theorem the weight distribution of the code \(\mathcal {C}\) when m is even in any characteristic.

Theorem 2

If m is even, then the weight distribution of the linear code \(\mathcal {C}\) (which is of dimension m+1) is given by Tables 4 and 3 for p odd or p = 2, respectively.

Proof

One can get from Theorem 1 that there are p m−1 codewords of Hamming weight p mp m − 1. Set \(K:=\#\{(\alpha ,\beta )\in \mathbb {F}^{*}_{p}\times \mathbb {F}_{p^{m}}\mid \psi _{1}^{*}(\bar {\alpha }\beta )=0\}\) and \(N_{0}:=\#\{\gamma \in \mathbb {F}_{p^{m}}\mid \psi _{1}^{*}(\gamma )=0\}\). Clearly, K = (p − 1)N 0 and \((p-1)(p^{m}-N_{0})=\#\{(\alpha ,\beta )\in \mathbb {F}^{*}_{p}\times \mathbb {F}_{p^{m}}\mid \psi _{1}^{*}(\bar {\alpha }\beta )\not =0\}\) . Now, according to Proposition 3, \(N_{0}=p^{m}-\epsilon p^{\frac {m}2-1}+\epsilon p^{\frac {m}2}\). Thus,

$$K=p^{m}-p^{m-1}+\epsilon p^{\frac{m}2-1}(p-1)^{2},\\ $$

and

$$\begin{array}{llll} (p-1)(p^{m}-N_{0})&=&(p-1)(p^{m}-p^{m-1}-\epsilon p^{\frac{m}{2}-1}(p-1))\\ &=&(p^{m}-p^{m-1})(p-1)-\epsilon p^{\frac{m}{2}-1}(p-1)^{2}.\\ \end{array} $$

Now, according to Theorem 1, the number of codewords of Hamming weight \(p^{m}-p^{m-1}-\epsilon p^{\frac {m}2-1}(p-1)\) is equal to \(p^{m}-p^{m-1}+\epsilon p^{\frac {m}2-1}(p-1)^{2}\) and the number of codewords of Hamming weight \(p^{m}-p^{m-1}+\epsilon p^{\frac {m}2-1}\) is equal to \((p^{m}-p^{m-1})(p-1)-\epsilon p^{\frac {m}2-1}(p-1)^{2}\). □

Table 2 The weight distribution of \(\mathcal {C}\) when m is even, p odd
Table 3 The weight distribution of \(\mathcal {C}\) when m is even, p=2

Theorem 3

Let p be an odd prime. If m is odd, then the weight distribution of the linear code \(\mathcal {C}\) (which is of dimension m+1) is given by Table 4.

Proof

Let us take again similar notations as in the proof of Theorem 2. Set \(K:=\#\{(\alpha ,\beta )\in \mathbb {F}^{*}_{p}\times \mathbb {F}_{p^{m}}\mid \psi _{1}^{*}(\bar {\alpha }\beta )=0\}\) and \(N_{j}:=\#\{\gamma \in \mathbb {F}_{p^{m}}\mid \psi _{1}^{*}(\gamma )=j\}\). According to Theorem 1, the number of codewords of weight p mp m − 1 is equal to p m−1 + K = p m−1+(p − 1)N 0 while the number of codewords of Hamming weight \(p^{m}-p^{m-1}-\epsilon (\frac {-1}p)p^{\frac {m-1}2}\) and of Hamming weight \(p^{m}-p^{m-1}+\epsilon (\frac {-1}p)p^{\frac {m-1}2}\) are equal respectively to \({\sum }_{j\in \{1,\cdots , p-1\}, (\frac {j}p)=1}N_{j}\) and \({\sum }_{j\in \{1,\cdots , p-1\}, (\frac {j}p)=-1}N_{j}\). According to Proposition 3,

$$p^{m}-1+(p-1)N_{0}=p^{m}-1+(p-1)(p^{m-1})=2p^{m}-p^{m-1}-1;$$
$$\begin{array}{lll} {\sum}_{j\in\{1,\cdots, p-1\}, (\frac{j}p)=1}N_{j}&=&{\sum}_{j\in\{1,\cdots, p-1\}, (\frac{j}p)=1}(p-1)(p^{m-1}+\epsilon p^{\frac{m-1}2})\\ &=&(p^{m-1}+\epsilon p^{\frac{m-1}2})(\frac {p-1}2)(p-1);\\ \end{array} $$

and

$$\begin{array}{lll} {\sum}_{j\in\{1,\cdots, p-1\}, (\frac{j}p)=-1}N_{j}&={\sum}_{j\in\{1,\cdots, p-1\}, (\frac{j}p)=-1}(p-1) (p^{m-1}-\epsilon p^{\frac{m-1}2})\\ &=(p^{m-1}-\epsilon p^{\frac{m-1}2})(\frac {p-1}2)(p-1).\\ \end{array} $$

Table 4 The weight distribution of \(\mathcal {C}\) when m and p are odd

6 Concluding remarks

The paper is a contribution to the knowledge of codes with few weights from weakly bent functions. The general idea of the construction is a classical one but our specific choice of the function employed is new. Our codes are different from those studied in literature [18, 19, 35] by their lengths and dimensions. Moreover, we notice that our codes have dimension m + 1, the same weight distribution as a subcode of some codes in [4] when p = 2 and the same weight distribution as a subcode of some codes in [6, 38] when p is odd.