1 Introduction

In a recent paper [19] it is mentioned that linear codes with few weights have applications in secrete sharing, authentication codes, association schemes and strongly regular graphs. These codes were the topic of several recent papers [5, 11, 18, 19].

On the other hand, bent functions and near-bent functions are boolean functions interesting for coding theory, cryptology and well-correlated binary sequences and were the topic of a lot of works (for instance see [1, 4, 6, 10, 12, 14,15,16]).

In this paper we introduce in the binary case a construction of 3-weight codes from every 2-weight code, with one exception (in [19] such a construction is restricted to codes from quadratic bent functions).

Furthermore we deduce a construction of near-bent functions always from 2-weight binary codes.

The paper is organized as follows:

In Sect. 2 we recall classical definitions on boolean functions and binary linear codes and we specify the vocabulary used in the paper. Further more, a new definition is introduced in Sect. 2.3. Section 3 is devoted to 1-weight and 2-weight binary codes. Useful results and examples are given with references and sometimes proofs are given for sake of convenience. Section 4 contains the main result with its proof and examples. In Sect. 5 we deduce near-bent functions from special 2-weight codes.

2 Preliminaries

\(\mathbb {F}_{2}\) is the finite field of order 2 and an m-boolean function is a map from \(\mathbb {F}_{2}^{m}\) to \(\mathbb {F}_{2}\). As usual, in order to benefit from the properties of a finite field we identify the \(\mathbb {F}_{2}\)-vector space \(\mathbb {F}_{2}^{m}\) with the finite field \(\mathbb {F}_{2^{m}}\). We denote \(\mathbb {F}_{2^{k}}{\smallsetminus }\lbrace 0 \rbrace \) by \(\mathbb {F}_{2^{k}}^{*}\).

The weight of a m-boolean function f is the number of x in \(\mathbb {F}_{2^{m}}\) such that \(f(x)=1\).

The Fourier transform (or Walsh transform) \(\hat{f}\) of an m-boolean function f is the map from \(\mathbb {F}_{2^{m}}\) into \(\mathbb {Z}\) defined by:

  • \(\hat{f}(v)=\sum _{x\in \mathbb {F}_{2^{m}}}(-1)^{f(x)+ tr(vx)}\)

where tr is the trace of \(\mathbb {F}_{2^{m}}\) over \(\mathbb {F}_{2}\). \(\hat{f}(v)\) is called the Fourier coefficient of f at the point of v.

Notation: If \(e\in \mathbb {F}_{2^{m}}\) then \(t_{e}(x)=tr(ex)\) where tr is the trace of \(\mathbb {F}_{2^{m}}\).

It is well-known and easy to prove that:

$$\begin{aligned} \quad \hat{f}(0)=-2(2^{k-1}-n) \quad \text {and}\quad \mathrm{if}\; v\not =0,\,\hat{f}(v)=-2(n-2w_{v}) \end{aligned}$$

where n is the weight of f and \(w_{v}\) is the weight of \(f*t_{v}\) where \(*\) is the product of boolean functions.

2.1 Bent and near-bent functions

A m-boolean function F is bent if all its Fourier coefficients are in \(\lbrace -2^{m/2},2^{m/2}\rbrace \).

F is near-bent if all its Fourier coefficients are in \(\lbrace -2^{(m+1)/2},0,2^{(m+1)/2}\rbrace \).

Since the Fourier coefficients are in \(\mathbb {Z}\), bent functions exist only when m is even and near-bent functions exist only when m is odd.

If \(m=2t-1\) then F is a near-bent function if all its Fourier coefficients are in \(\lbrace -2^{t},\,0,\,2^{t}\rbrace \).

The distribution of the Fourier coefficients of a \((2t-1)\)-near bent function f is well known (see [1, Proposition 4]).

  • \(\hat{f}(v)=2^{t}\quad \,\,\,\,\) number of v: \(2^{2t-3}+(-1)^{f(0)}2^{t-2}\)

  • \(\hat{f}(v)=0\quad \quad \,\,\) number of v: \(2^{2t-2}\)

  • \(\hat{f}(v)=-2^{t}\quad \) number of v: \(2^{2t-3}-(-1)^{f(0)}2^{t-2}\).

2.2 Binary linear codes

We assume that the reader is familiar with the classical definitions and results of the theory of algebraic coding (see [7, 9]).

Recall first classical definitions.

Definition 1

Let C be a binary linear code of dimension k and length n. Let \(B_{1}\) and \(B_{2}\) respectively the number of words with weight 1 and the number of words with weight 2 in the orthogonal of C.

  1. (1)

    C is said to be a projective code if \(B_{1}=0\) and \(B_{2}=0\).

  2. (2)

    If \(B_{2}=0\):

  • A sub-set \(E=\lbrace e_{1}, e_{2},\ldots , e_{n}\rbrace \) of \(\mathbb {F}_{2^{k}}^{*}\) is said to be a support of C if

    $$\begin{aligned} C=\lbrace m_{a}=(tr(ae_{1}),tr(ae_{2}),\ldots tr(ae_{n}))\mid a\in \mathbb {F}_{2^{k}}\rbrace \end{aligned}$$

    where tr is the trace of \(\mathbb {F}_{2^{k}}\).

  • If \(m_{a}=(tr(ae_{1}),tr(ae_{2}),\ldots tr(ae_{n}))\) is a word of C then the support of \(m_{a}\) is supp(\(m_{a}\))=\(\lbrace e_{i}\mid tr(ae_{i})=1\rbrace \).

  • A defining function of C is a k-boolean function indicator of a support of C.

If G is a generator matrix of C then \(B_{2}=0\) means that the columns of G are two by two distinct and \(B_{1}=0\) means that there is no zero vector in the set of columns of G.

Example: Let G be a generator matrix of a binary linear code C with \(B_{2}=0\): If \(\bar{c}_{i}\) is a column of G then let \(e_{i}\) be the element of \(\mathbb {F}_{2^{2t}}\) such that \(\bar{c}_{i}\) is the system of components of \(e_{i}\) with respect to a given basis of \(\mathbb {F}_{2^{2t}}\). Then the set \(\lbrace e_{i}\rbrace _{i=1\ldots N}\) is a support of C.

Example:

$$\begin{aligned} G= \begin{matrix} 1,&{}\quad \alpha ^{24},&{}\quad \alpha ^{28},&{}\quad \alpha ^{22},&{}\quad \alpha ^{5},&{}\quad \alpha ^{16},&{}\quad \alpha ^{26}\\ 0,&{}\quad 1,&{}\quad 1,&{}\quad 1,&{}\quad 0,&{}\quad 1,&{}\quad 1\\ 0,&{}\quad 1,&{}\quad 0,&{}\quad 0,&{}\quad 0,&{}\quad 1,&{}\quad 0\\ 0,&{}\quad 1,&{}\quad 1,&{}\quad 1,&{}\quad 1,&{}\quad 0,&{}\quad 1\\ 0,&{}\quad 1,&{}\quad 1,&{}\quad 0,&{}\quad 0,&{}\quad 1,&{}\quad 1\\ 1,&{}\quad 0,&{}\quad 0,&{}\quad 1,&{}\quad 1,&{}\quad 1,&{}\quad 1\\ \end{matrix} \end{aligned}$$

With \(\mathbb {F}_{2^{5}}=\mathbb {F}_{2}(\alpha )\) and \(\alpha ^{5}+\alpha ^{2}+1=0\), the support of C obtained by the columns of G is:

$$\begin{aligned} \lbrace 1,\alpha ^{5},\alpha ^{16},\alpha ^{22},\alpha ^{24},\alpha ^{26},\alpha ^{28}\rbrace . \end{aligned}$$

A defining function of C is:

$$\begin{aligned} tr(a^{6}x+a^{10}x^3+a^{13}x^{5}+a^{8}x^{7}+a^{27}x^{11}+a^{11}x^{15}+x^{31}) \end{aligned}$$

where tr is the trace of \(\mathbb {F}_{2^{5}}\).

Remark 2

  • Of course, a binary linear code with \(B_{2}=0\) has several supports and several defining functions depending of the choice of the generator matrix and the choice of the basis of \(\mathbb {F}_{2^{2t}}\). However all the supports are equivalent under the action of the linear group of \(\mathbb {F}_{2^{k}}\).

  • A binary projective linear code is completely determined by one of its defining functions and every boolean function f such that \(f(0)=0\) defines a binary projective linear code.

Definition 3

If E is a support of a binary projective code C of dimension k then the complement code of C is the code whose support is \(\mathbb {F}_{2^{k}}^{*}{\smallsetminus } E\).

The proof of the next proposition is obvious.

Proposition 4

The complement code of C is a projective code.

The weights of a complement of C are the \(2^{k-1}-w_{i}\) where the \(w_{i}\) are the weights of C.

2.3 Doubly restricted code

Now we introduce a new definition.

We restrict any binary projective code of dimension k to one of its \(k-1\) subspace defined by a word m and we restrict the new code to the support of m.

Definition 5

Let C be a binary linear code of dimension k. Let m be a word of C.

  • The restricted code of C with respect to m is the complementary space of \(\lbrace 0,m\rbrace \) in C denoted by \(C_{m}\).

  • The doubly restricted code of C with respect to m is the restricted code of \(C_{m}\) to the support of m. It is denoted by \(\tilde{C}_{m}\).

2.3.1 Generator matrices

G, \(G_{m}\), \(\tilde{G}_{m}\) are respectively generator matrix of C, \(C_{m}\), \(\tilde{C}_{m}\). The rows of G form a basis of C with m as first row.

$$\begin{aligned} G= \begin{pmatrix} m^{(1)},&{}\quad m^{(2)},&{}\quad m^{(3)},&{}\quad \ldots \ldots &{}\quad m^{(i)},\ldots &{}\quad ,m^{(n)}\\ \bar{v}_{1},&{}\quad \bar{v}_{2},&{}\quad \bar{v}_{3},&{}\quad \ldots \ldots &{}\quad \bar{v}_{i}\,,\,\ldots &{}\quad \bar{v}_{n}\\ \end{pmatrix} \end{aligned}$$

where \( m=(m^{(1)}, m^{(2)}, m^{(3)},\ldots \ldots m^{(i)},\ldots ,m^{(n)})\) and \(\bar{v}_{i}\) stands for a binary column vector of length \(k-1\).

Deleting the first row of G we get a generator matrix of \(C_{m}\).

$$\begin{aligned} G_{m}= (\bar{v}_{1},\bar{v}_{2}, \bar{v}_{3},\ldots \ldots \ldots \bar{v}_{i},\ldots ,\bar{v}_{n}) \end{aligned}$$

In order to obtain a generator matrix of \(\tilde{C}_{m}\) we restrict the columns of \(G_{m}\) to the support of m.

$$\begin{aligned} \tilde{G}_{m}= (\bar{v}_{i_{1}},\bar{v}_{i_{2}}\ldots \bar{v}_{i_{w}}) \end{aligned}$$

where \(m^{(i_{1})}, m^{(i_{2})},\ldots m^{(i_{w})}\) are the non-zero components of m.

Example:

$$\begin{aligned} G= & {} \begin{pmatrix} 0\quad 1\quad 0\quad 0\quad 1\quad 0\quad 1\quad 1\quad 1\quad 1\quad 1\quad 1\quad 1\quad 0\quad 1\quad 1\quad 0\quad 1\quad 0\quad 0\quad 0\\ 1\quad 1\quad 1\quad 1\quad 1\quad 1\quad 1\quad 1\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\\ 0\quad 1\quad 0\quad 0\quad 0\quad 0\quad 1\quad 0\quad 0\quad 0\quad 1\quad 0\quad 1\quad 1\quad 1\quad 0\quad 1\quad 1\quad 0\quad 0\quad 0\\ 0\quad 0\quad 1\quad 1\quad 0\quad 1\quad 0\quad 1\quad 0\quad 1\quad 0\quad 0\quad 0\quad 0\quad 1\quad 0\quad 0\quad 1\quad 1\quad 0\quad 0\\ 0\quad 0\quad 0\quad 0\quad 1\quad 1\quad 0\quad 0\quad 0\quad 0\quad 1\quad 1\quad 0\quad 0\quad 0\quad 1\quad 1\quad 0\quad 1\quad 1\quad 0\\ 0\quad 0\quad 1\quad 0\quad 0\quad 0\quad 1\quad 0\quad 0\quad 0\quad 0\quad 0\quad 1\quad 1\quad 0\quad 1\quad 0\quad 1\quad 0\quad 1\quad 1\\ \end{pmatrix}\\ G_{m}= & {} \begin{pmatrix} 1\quad 1\quad 1\quad 1\quad 1\quad 1\quad 1\quad 1\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\\ 0\quad 1\quad 0\quad 0\quad 0\quad 0\quad 1\quad 0\quad 0\quad 0\quad 1\quad 0\quad 1\quad 1\quad 1\quad 0\quad 1\quad 1\quad 0\quad 0\quad 0\\ 0\quad 0\quad 1\quad 1\quad 0\quad 1\quad 0\quad 1\quad 0\quad 1\quad 0\quad 0\quad 0\quad 0\quad 1\quad 0\quad 0\quad 1\quad 1\quad 0\quad 0\\ 0\quad 0\quad 0\quad 0\quad 1\quad 1\quad 0\quad 0\quad 0\quad 0\quad 1\quad 1\quad 0\quad 0\quad 0\quad 1\quad 1\quad 0\quad 1\quad 1\quad 0\\ 0\quad 0\quad 1\quad 0\quad 0\quad 0\quad 1\quad 0\quad 0\quad 0\quad 0\quad 0\quad 1\quad 1\quad 0\quad 1\quad 0\quad 1\quad 0\quad 1\quad 1\\ \end{pmatrix}\\ \tilde{G}_{m}= & {} \begin{pmatrix} 1\quad 1\quad 1\quad 1\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\quad 0\\ 1\quad 0\quad 1\quad 0\quad 0\quad 0\quad 1\quad 0\quad 1\quad 1\quad 0\quad 1\\ 0\quad 0\quad 0\quad 1\quad 0\quad 1\quad 0\quad 0\quad 0\quad 1\quad 0\quad 1\\ 0\quad 1\quad 0\quad 0\quad 0\quad 0\quad 1\quad 1\quad 0\quad 0\quad 1\quad 0\\ 0\quad 0\quad 1\quad 0\quad 0\quad 0\quad 0\quad 0\quad 1\quad 0\quad 1\quad 1\\ \end{pmatrix} \end{aligned}$$

3 1-Weight and 2-weight codes

If \(\mathcal {N}\in \mathbb {N}{\smallsetminus }\lbrace 0 \rbrace \) then a code C is an \(\mathcal {N}\)-weight code if \(\mathcal {N}\) is the cardinality of the set of non-zero weights of C.

First recall the first three Pless identities which are the main tool to prove results in this section.

3.1 Pless identities

The Pless identities are well-known. We recall the first three identities in the binary case (see [8, Section II, page 50]).

Proposition 6

Let C be a binary linear code of length n, dimension k and with N weights \(w_{i}\), \(i=1,2,\ldots ,N\).

\(A_{w_{i}}\) is the number of words of C with weight \(w_{i}\) and \(B_{i}\) is the number of words of C with weight i in the orthogonal of C respectively.

Then:

  1. (1)

    \(\quad \sum _{i=1}^{N}A_{w_{i}}=2^{k}-1.\)

  2. (2)

    \(\quad \sum _{i=1}^{N}w_{i}A_{w_{i}}=(n-B_{1})2^{k-1}.\)

  3. (3)

    \(\quad \sum _{i=1}^{N}w_{i}^{2}A_{w_{i}}=\lbrace n(n+1)-2nB_{1}+2 B_{2}\rbrace 2^{k-2}\).

The following Proposition 7 and Corollary 8 are well known. Proposition 10 was already published in [13]. The proofs are given here for reader’s convenience.

3.2 Binary 1-weight codes

Proposition 7

If C is a binary linear 1-weight code of length n dimension k with w as unique non-zero weight then there exists \(\lambda \in \mathbb {N}\) such that:

$$\begin{aligned} n-B_{1}=\lambda (2^{k}-1)\quad \hbox {and}\quad w=\lambda 2^{k-1}. \end{aligned}$$

Proof

In this case the second Pless identity is:

$$\begin{aligned} (2^{k}-1)w=(n-B_{1})2^{k-1}. \end{aligned}$$

Since \(2^{k-1}\) and \(2^{k}-1\) are coprime then \(2^{k-1}\) divides w.

We obtain \(w=\lambda 2^{k-1}\) and consequently \(n-B_{1}=\lambda (2^{k}-1)\). \(\square \)

Corollary 8

If C is a binary projective 1-weight code of length n dimension k with w as unique non-zero weight then:

$$\begin{aligned} n=2^{k}-1\quad \hbox {and}\quad w=2^{k-1}. \end{aligned}$$

Proof

The proof is obvious. \(\square \)

The following definition is classical.

Definition 9

(Simplex code) The previous result shows that a defining set of such a code is \(\mathbb {F}_{2^{k}}{\smallsetminus }\lbrace 0 \rbrace \). It is called a binary Simplex code of length \(2^{k}-1\)

3.3 Binary 2-weight codes

For further use we need the following propositions.

Proposition 10

Let C be a binary 2-weight code of length n, dimension k and weight \(w_{1}\) and \(w_{2}\).

  1. (a)

    Define \(F(n,w_{1},w_{2},k)=n^{2}-[2(w_{1}+w_{2})-1]n+\).

  2. (4)

    If C is a projective code then \(F(n,w_{1},w_{2},k)=0\).

  3. (b)

    Let \(A_{w_{1}}\) and \(A_{w_{2}}\) be respectively the numbers of words of weights \(w_{1}\) and \(w_{2}\). Then:

  4. (5)

    \(\quad A_{w_{1}}=\) \(\frac{(2^{k}-1)w_{2}-(n-B_{1})2^{k-1}}{w_{2}-w_{1}}\)

  5. (6)

    \(\quad A_{w_{2}}=\) \(\frac{(n-B_{1})2^{k-1}-(2^{k}-1)w_{1}}{w_{2}-w_{1}}\)

    where \(B_{1}\) is the number of words of weight 1 in the orthogonal of C.

Proof

  • Proof of (a):

Since C is projective then \(B_{1}=B_{2}=0\) and the first Pless identities are:

  1. (1’)

    \(A_{w_{1}}+A_{w_{2}}=2^{k}-1.\)

  2. (2’)

    \(\quad w_{1}A_{w_{1}}+w_{2}A_{w_{2}}=n2^{k-1}.\)

  3. (3’)

       \(w_{1}^{2}A_{w_{1}}+w_{2}^{2}A_{w_{2}}= n(n+1)2^{k-2}.\)

Let consider the following polynomial over \(\mathbb {Z}\):

  • \((x-w_{1})(x-w_{2})=a_{0}+a_{1}x+x^2\).

We know that \(a_{0}=w_{1}w_{2}\) and \(a_{1}=-(w_{1}+w_{2})\).

The combination \(a_{0}(1')+a_{1}(2')+(3)\) gives:

$$\begin{aligned} A_{w_{1}}(a_{0}+a_{1}w_{1}+w_{1}^2)+A_{w_{2}}(a_{0}+a_{1}w_{2}+w_{2}^2)= & {} a_{0}(2^{k}-1)+a_{1}n2^{k-1}\\&+\, n(n+1)2^{k-2}. \end{aligned}$$

From the definition of \(a_{0}\) and \(a_{1}\): \(a_{0}+a_{1}w_{1}+w_{1}^2=a_{0}+a_{1}w_{2}+w_{2}^2=0\).

And this leads to the expected result.

  • Proof of (b):

The result is obtained by solving the linear system of identities (\(1'\)) and (\(2'\)). \(\square \)

The following lemma was proved by Delsarte.

Lemma 11

(Delsarte) If \(w_{1}\) and \(w_{2}\) are the weights of a binary projective 2-weight code then there exist \(a\in \mathbb {N}^{*}\) and \(r\in \mathbb {N}\) such that

  • \(w_{1}=a2^{r}\) and \(w_{2}=(a+1)2^{r}\).

Proof

See [3, Section 3, Corollary 2, page 53]. \(\square \)

3.4 Semi-primitive code

Definition 12

Let C be an irreductible cyclic code of length n over \(\mathbb {F}_{q}\) with \((n,q)=1\). Let \(\mathbb {F}_{q^k}\) be the splitting field of \(x^{n}-1\) over \(\mathbb {F}_{q}\) and let d such that \(nd=q^{k}-1\) and \(d\ge 2\).

C is called a semi-primitive code if \(k=2t\) and if there exists a divisor r of t such that \(q^{r}\equiv -1\, mod \, d \).

Proposition 13

Let C be a semi-primitive code and let krtd be defined as above.

The weight distribution of C is:

  • \(\quad n(d-1)\) words of weight \(w_{1}=(q-1)q^{t-1} \left[ \frac{q^{t}-\epsilon }{d}\right] \).

  • \(\quad n\) words of weight \(w_{2}=(q-1)q^{t-1}\left[ \frac{q^{t}+\epsilon (d-1)}{d}\right] \).

where \(\epsilon =(-1)^{\frac{t}{r}}\).

Proof

See [2, 9]. \(\square \)

3.5 A special case

The first proposition below was proved in [17] and the second one seems to be new.

Proposition 14

If the support E of a binary projective code C of dimension k is the complement of a subspace S and if the dimension of S is s then:

  1. (a)

    The length of C is \(n=2^{k}-2^{s}\)

  2. (b)

    The weight distribution C is:

  • \(2^{k-s}-1\) words of weight \(2^{k-1}\)

  • \(2^{k}-2^{k-s}\) words of weight \(2^{k-1}-2^{s-1}\).

Proof

Let n be the length of C and let \(m_{a}\) be a word of C.

  • \(m_{a}=(tr(ae_{1}),tr(ae_{2}),\ldots tr(ae_{n}))\quad \) with \(a\in \mathbb {F}_{2^{k}}\).

  • \(\bar{m}_{a}=(tr(a\bar{e}_{1}),tr(a\bar{e}_{2})\ldots tr(a\bar{e}_{2^{s}-1})\quad \) where \(\lbrace \bar{e}_{1},\bar{e}_{2},\ldots \bar{e}_{2^{s}-1}\rbrace =S\).

The concatenation of \(m_{a}\) and \(\bar{m}_{a}\) is a word of the Simplex code of length \(2^{k}-1\) whence its weight is \(2^{k-1}\).

  1. (1)

    If the hyperplane \(H_{a}\) of \(\mathbb {F}_{2^k}\) with equation \(tr(ax)=0\) contains S then the weight of \(\bar{m}_{a}\) is 0 and then the weight of \(m_{a}\) is \(2^{k}-1\). There exist \(2^{k-s}-1\) such hyperplanes.

  2. (2)

    If S is not in \(H_{a}\) then \(H_{a}\cap S\) contains \(2^{s-1}\) elements of S and the weight of \(m_{a}\) is \(2^{k-1}-2^{s-1}\) and we have \(2^{k}-2^{k-s}\) words of this type.

\(\square \)

Proposition 15

If a projective code C of dimension k is a 2-weight code and if one of the weights is \(2^{k-1}\) then a support of C is a complement of a subspace.

Proof

Let n be the length of C and let \(\bar{C}\) be the complement of C. The length of \(\bar{C}\) is \(\bar{n}=2^{k}-1-n\).

If the weights of C are \(w_{1}=2^{k-1}\) and \(w_{2}\) then \(w_{2}< 2^{k-1}\) and the weights of \(\bar{C}\) are \(2^{k-1}-w_{1}=0\) and \(2^{k-1}-w_{2}\). Hence \(\bar{C}\) is a 1-weight code with weight \(2^{k-1}-w_{2}\). Then \(\bar{C}\) is a 1-weight projective code and according to Corollary 8 there exists r such that \(\bar{n}=2^{r}-1\) and \(\mathbb {F}_{2^{r}}{\smallsetminus } \lbrace 0\rbrace \) is a defining set of \(\bar{C}\). In other words C is the complement set of a subspace. \(\square \)

4 3-Weight codes from binary 2-weight codes

The next theorem is the main result of this work.

Notation:

  • If E is a set then \(\mid E\mid \) denotes the cardinality of E.

  • For \(i=1,2\) \(E_{i}\) is the set of words of weight \(w_{i}\) in C and \(\mathcal {A}_{i}\) is the cardinality of \(E_{i}\).

  • \(E_{i}^{m}\) is the set of words of weight \(w_{i}\) in \(C_{m}\) and \(\mathcal {A}_{i}^{m}\) is the cardinality of \(E_{i}^{m}\).

  • \(B_{1}^{m}\) is the number of words of weight 1 in the orthogonal of \(C_{m}\).

Remark 16

\(B_{1}^{m}\) is also the number of zero-vectors among the columns of a generator matrix of \(C_{m}\). This number is independent of the choice of such a generator matrix.

We now use the generator matrix introduced in Sect. 2.3.1. Note that \(\bar{0}\) is a column of \(G_{m}\) if and only if \({1\atopwithdelims ()\bar{0}}\) or \({0\atopwithdelims ()\bar{0}}\) is a column of G.

Because C is a projective code then \({0\atopwithdelims ()\bar{0}}\) is not a column of G and \({1\atopwithdelims ()\bar{0}}\) can be a column of G at most once. Conclusion:

  • \(\mathcal {R}_{1}\): \(B_{1}^{m}=0\) or \(B_{1}^{m}=1\).

On the other hand, \(\bar{v}_{i_{l}}\) is a column of \(\tilde{G}_{m}\) if and only if \({1\atopwithdelims ()\bar{v}_{i_{l}}}\) is a column of G. Since C is projective then:

  • \(\mathcal {R}_{2}\): The \(\bar{v}_{i_{l}}\) \(l=1,2,\ldots w\) are distinct and \(\bar{v}_{i_{l}}=\bar{0}\) at most once.

Theorem 17

Let C be a binary projective 2-weight code of dimension k with weights \(w_{1}\) and \(w_{2}\). Let m be a word of C with weight w. Let E be a support of C.

If E is not the complement of a subspace then:

The doubly restricted code \(\tilde{C}_{m}\) of C is a projective three-weight code of length w and dimension \(k-1\) and the weights of \(\tilde{C}_{m}\) are:

$$\begin{aligned} \frac{1}{2}\left[ w-(w_{1}-w_{2})\right] ,\quad \frac{1}{2}w,\quad \frac{1}{2}\left[ w+(w_{1}-w_{2})\right] . \end{aligned}$$

Proof

From the definition the weights of \(\tilde{C}_{m}\) are the cardinalities of the intersections of supp(m) with the supports of the words of \(C_{m}\). In other words they are:

  • \(w(m_{1}*m)\) where \(m_{1}\in E_{1}^{m}\) and \(w(m_{2}*m)\quad \) where \(m_{2}\in E_{2}^{m}\).

Since \(w(m_{1}+m)=w(m_{1})+w(m)-2w(m_{1}*m)\) and \(w(m_{2}+m)=w(m_{2})+w(m)-2w(m_{2}*m)\), we have:

  • \(w(m_{1}*m)=\frac{1}{2}[w(m_{1})+w(m)-w(m_{1}+m)]\) and similarly:

  • \(w(m_{2}*m)=\frac{1}{2}[w(m_{2})+w(m)-w(m_{2}+m)]\).

Consequently

  1. (a)

    If there exists \(m_{1}\in E_{1}^{m}\) such that \( m_{1}+m\in E_{1}\) then

    • \(w(m_{1}*m)=\frac{1}{2}w(m)\).

  2. (b)

    If there exists \(m_{1}\in E_{1}^{m}\) such that \( m_{1}+m\in E_{2}\) then

    • \(w(m_{1}*m)=\frac{1}{2}[w(m)+(w_{1}-w_{2})]\).

  3. (c)

    If there exists \(m_{2}\in E_{2}^{m}\) such that \( m_{2}+m\in E_{1}\) then

    • \(w(m_{2}*m)=\frac{1}{2}[w(m)-(w_{1}-w_{2})]\).

  4. (d)

    If there exists \(m_{2}\in E_{2}^{m}\) such that \( m_{2}+m\in E_{2}\) then

    • \(w(m_{2}*m)= \frac{1}{2}w(m)\).

Conclusion: the weights of \(\tilde{C}_{m}\) belong to the set:

$$\begin{aligned} \left\{ \frac{1}{2}[w-(w_{1}-w_{2})],\frac{1}{2}w,\,\frac{1}{2}[w+(w_{1}-w_{2})\right\} . \end{aligned}$$

We are now facing the problem to search if the cases (a), (b), (c), (d) effectively exist.

First remark, from the definition of \(C_{m}\), that:

  • \((*)\quad C=C_{m}+(m+C_{m})\) and,

since m is not in \(C_{m}\):

  • \((**)\quad C_{m}\cap (m+C_{m})=\emptyset \).

For \(i,j\in \lbrace 1,2\rbrace \), define \(E_{(i,j)}\) as the set of words with weight \(w_{j}\) in \((m+E_{i}^{m})\).

Our task is to prove that, with one exception, properties (a), (b), (c), (d) are satisfied or, equivalently that \(E_{(1,1)},\,E_{(2,1)},\,E_{(1,2)},\,E_{(2,2)}\) are not empty.

Our strategy now is to examine what happen when such sets are not empty.

\(\underline{\underline{\mathrm{Step \, 1}}}\)

\(\underline{\mathrm{Case \, 1}: E_{(1,1)}=\emptyset ,\,E_{(2,1)}=\emptyset }\)

In this case there is no word of weight \( w_{1}\) in \(m+C_{m}\). Therefore the words of weight \( w_{1}\) in C are the elements of \(E_{i}^{m}\) and w if \(w=w_{1}\). Thus:

  • \(\mathcal {A}_{1}=\mathcal {A}_{1}^{m}+\epsilon \) with \(\epsilon =1\) if \(w=w_{1}\) and \(\epsilon =0\) if \(w=w_{2}\).

We find from (5) and (6) of Proposition 10:

  • \((\lozenge )\quad (2^{k-1}-\epsilon )w_{2}+\epsilon w_{1}-\left( n-B_{1}^{m}\right) 2^{k-2}=0\).

  • If \(\epsilon =0\) and \(B_{1}^{m}=0\):

    \((\lozenge )\) gives \(2w_{2}=n\) and with (4) of Proposition 10 we obtain \((2^{k}-1) w_{1}=(2w_{1}-1)2^{k-1}\). Since \(2w_{1}-1\not =0\) and because \(2^{k}-1\) and \(2^{k-1}\) are coprime then \(2^{k-1}\) divides \(w_{1}\) and thus \( w_{1}=\mu 2^{k-1}\). The case \(\mu \ge 2\) is not possible since \(w_{1}\le 2^{k-1}\) and therefore \( w_{1}=\ 2^{k-1}\). According to Proposition 15, E is the complement of a subspace.

  • If \(\epsilon =0\) and \(B_{1}^{m}=1\):

    With \((\lozenge )\) we have \(2w_{2}=n+1\). Using (4) we have: \(w_{1}(2^{k}-1-n)=0\). If \(2^{k}-1-n=0\) then C is the simplex code (see Definition 9), which is not a 2 weight code. Hence \(w_{1}=0\) which is not possible.

  • If \(\epsilon =1\) and \(B_{1}^{m}=0\):

    \((\lozenge )\) gives \(2^{k-2}(2w_{2}-n)=w_{2}-w_{1}\).

    Following Delsarte (Lemma 11) we know that the two weights are \(a2^{r}\) and \((a+1)2^{r}\). The previous result gives \( 2^{k-2}\mid 2w_{2}-n)\mid =2^r\) that is \( 2^{k-2-r}\mid 2w_{2}-n)\mid =1\). Then \( 2^{k-2-r}=1\) and \(\mid 2w_{2}-n)\mid =1\). It comes \(r=k-2\). Because \(a\ge 1\) then one of the weights is \((a+1)2^{k-2}\) which is greater or equal than \(2^{k-1}\). Therefore, this weight is \(2^{k-1}\) and then C is the complement of a subspace.

  • If \(\epsilon =1\) and \(B_{1}^{m}=1\):

With the same method we find \(2^{k-2}(2w_{2}-n-1)=w_{2}-w_{1}\) and this leads to the same conclusion: a support of C is the complement of a subspace.

Finally, if E is not the complement of a subspace then \(E_{(1,1)}=\emptyset \) and \(E_{(2,1)}=\emptyset \) is not possible. Conclusion:

\((\mathcal {C}_{1})\) :

If E is not the complement of a subspace then

  • \(E_{(1,1)}\not =\emptyset \) or \(E_{(2,1)}\not =\emptyset \).

\(\underline{\mathrm{Case \, 2:} E_{(1,1)}=\emptyset ,\,E_{(2,1)}\not =\emptyset }\)

In this case:

  • \(\mathcal {A}_{1}=\mathcal {A}_{1}^{m}+\mid E_{(2,1)}\mid + \epsilon \quad \) with \(\epsilon =1\) if \(w=w_{1}\) and \(\epsilon =0\) if \(w=w_{2}\).

Since all the weights of \(m+E_{1}^{m}\) are \(w_{2}\) and \(\mid m+E_{1}^{m}\mid =\mid E_{1}^{m} \mid \), then:

  • \(\mathcal {A}_{2}=\mathcal {A}_{1}^{m}+\mid E_{(2,2)}\mid + \mu \quad \) with \(\mu =1\) if \(w=w_{2}\) and \(\mu =0\) if \(w=w_{1}\).

We deduce: \(\mathcal {A}_{1}+ \mathcal {A}_{2}=2\mathcal {A}_{1}^{m}+\mid E_{(2,1)}\mid + \mid E_{(2,2)}\mid +1\).

On the other hand \(m+E_{2}^{m}=E_{(2,1)}\cup E_{(2,2)}\) and \(E_{(2,1)}\cap E_{(2,2)}=\emptyset \) whence \(\mid E_{(2,1)}\mid + \mid E_{(2,2)}\mid =\mid m+E_{2}^{m}\mid =\mid E_{2}^{m}\mid =\mathcal {A}_{2}^{m}\).

Finally:

  • \(\mathcal {A}_{1}+ \mathcal {A}_{2}=\mathcal {A}_{1}^{m}+\mathcal {A}_{1}^{m}+\mathcal {A}_{2}^{m}+1\).

We know that \(\mathcal {A}_{1}+\mathcal {A}_{2}=2^{k}-1\) and \( \mathcal {A}_{1}^{m}+\mathcal {A}_{2}^{m}=2^{k-1}-1\). This gives: \(\mathcal {A}_{1}^{m}=2^{k-1}-1\) and we conclude that \(C_{m}\) is a 1-weight code of dimension \(k-1\).

According to Proposition 7: \(n-B_{1}^{m}=\lambda (2^{k-1}-1)\) and \(w_{1}=\lambda 2^{k-2}\) with \(\lambda \in \mathbb {N}{\smallsetminus } \lbrace 0 \rbrace \).

The length of \(C_{m}\) is also the length of C and \(w_{1}\) is a weight of C. Then \(\lambda \ge 2\) is impossible since the length of a projective code of dimension k is at most \(2^{k}-1\) and a weight of such a code is at most \(2^{k-1}\).

The unique solution is \(\lambda = 1\) and \(n-B_{1}^{m}=2^{k-1}-1,\,w_{1}=2^{k-2}\).

  1. (I)

    From (4) we have: \(F(n,w_{1},w_{2},k)=0\).

  2. (i)

    If \(B_{1}^{m}=1\) then \(n=2^{k-1}\). With \(w_{1}=2^{k-2}\) condition (I) gives \(w_{2}=2^{k-1}\).

    Once again this proves that E is the complement of a subspace.

  3. (ii)

    If \(B_{1}^{m}=0\) then \(n=2^{k-1}-1,\,w_{1}=2^{k-2}\) and (I) gives \(w_{2}=0\) which is not possible.

Then if E is not the complement of a subspace then \(E_{(1,1)}=\emptyset \) and \(E_{(2,1)}\not =\emptyset \) is not possible. Conclusion:

\((\mathcal {C}_{2})\) :

If E is not the complement of a subspace then

  • \(E_{(1,1)}\not =\emptyset \quad \)or\(\quad E_{(2,1)}=\emptyset \).

\(\underline{\mathrm{Case \, 3:} E_{(1,1)}\not =\emptyset ,\,E_{(2,1)}=\emptyset }\)

Using the same method we find \(\mathcal {A}_{2}^{m}=2^{k-1}-1\) and thus:

\((\mathcal {C}_{3})\) :

If E is not the complement of a subspace then

  •       \(E_{(1,1)}=\emptyset \quad \)or\(\quad E_{(2,1)}\not =\emptyset \).

Partial conclusion: Since \( E_{(1,1)}\not =\emptyset \) or \(E_{(2,1)}\not =\emptyset \) and because neither (\(E_{(1,1)}=\emptyset \) and \(E_{(1,1)}\not =\emptyset \)) nor (\( E_{(1,1)}\not =\emptyset \) and \(E_{(2,1)}=\emptyset \)) are true, then:

\((\mathcal {C}_{4})\) :

If E is not the complement of a subspace then

  • \(E_{(1,1)}\not =\emptyset \quad \)and\(\quad E_{(2,1)}\not =\emptyset \).

\(\underline{\underline{\mathrm{Step \, 2}}}\)

Replacing \(E_{(1,1)}\) and \(E_{(2,1)}\) respectively by \(E_{(1,2)}\) and \(E_{(2,2)}\) and using the method of Step 1 we have a similar result:

\((\mathcal {C}_{5})\) :

If E is not the complement of a subspace then

  • \(E_{(1,1)}\not =\emptyset \quad \)and\(\quad E_{(2,1)}\not =\emptyset \).

\(\underline{\underline{\mathrm{General \, conclusion}}}\)

\((\mathcal {C})\) :

If E is not the complement of a subspace then \(E_{(1,1)},\,E_{(2,1)},\,E_{(1,2)},\,E_{(2,2)}\) are not empty.

This is the proof that (a), (b), (c), (d) are satisfied and thus the theorem is proved. \(\square \)

Remark 18

The previous result is independent of the choice of E because, in one hand all support of C and in other hand all subspaces of a given dimension, are equivalent under the action of the linear group of \(\mathbb {F}_{2^{k}}\).

4.1 Examples

Recall that the weights of \(\tilde{C}_{m}\) are:

$$\begin{aligned} \tilde{w}_{1}=\frac{1}{2}[w-(w_{1}-w_{2})],\quad \tilde{w}_{2} =\frac{1}{2}w,\quad \tilde{w}_{3}=\frac{1}{2}[w+(w_{1}-w_{2})]. \end{aligned}$$

4.1.1 Semi-primitive code

The weights of C are \(w_{1}=2^{t-1}\left( \frac{2^{t}-\epsilon }{d}\right) \) and \(w_{2}=2^{t-1}\left( \frac{2^{t}+\epsilon (d-1)}{d}\right) \).

The weights of \(\tilde{C}_{m}\) are:

$$\begin{aligned} \tilde{w}_{1}=\frac{1}{2}[w-(w_{1}-w_{2})],\quad \tilde{w}_{2} =\frac{1}{2}w,\quad \tilde{w}_{3}=\frac{1}{2}[w+(w_{1}-w_{2})]. \end{aligned}$$

With \(w=w_{1}\) we find:

$$\begin{aligned} \tilde{w}_{1}= & {} 2^{t-2}\left( \frac{2^{t}+\epsilon (d-1)}{d}\right) ,\quad \tilde{w}_{2} =2^{t-2}\left( \frac{2^{t}-\epsilon }{d}\right) ,\quad \\ \tilde{w}_{3}= & {} 2^{t-2}\left( \frac{2^{t}-\epsilon (d+1)}{d}\right) . \end{aligned}$$

With \(w=w_{2}\) we find:

$$\begin{aligned} \tilde{w}_{1}= & {} 2^{t-2}\left( \frac{2^{t}+\epsilon (2d-1)}{d}\right) ,\quad \tilde{w}_{2} =2^{t-2}\left( \frac{2^{t}+\epsilon (d-1)}{d}\right) ,\quad \\\tilde{w}_{3}= & {} 2^{t-2}\left( \frac{2^{t}-\epsilon }{d}\right) . \end{aligned}$$

4.1.2 Bent function code

If the support of a code C is the support of a bent function then it is well known (see [12]) that the dimension of C is 2t and the two weights of C are \(w_{1}=2^{2t-2}\) and \(w_{2}=2^{2t-2}-\epsilon 2^{t-1}\) where \(\epsilon \in \lbrace -1,+1\rbrace \).

If \(w=w_{1}\):

  • \(\tilde{w}_{1}=2^{2t-3}-\epsilon 2^{t-2},\,\tilde{w}_{2}=2^{2t-3},\,\tilde{w}_{3}=2^{2t-3}+\epsilon 2^{t-2}\).

If \(w=w_{2}\):

  • \(\tilde{w}_{1}=2^{2t-3}-\epsilon 2^{t-1},\,\tilde{w}_{2}=2^{2t-3}-\epsilon 2^{t-2},\,\tilde{w}_{3}=2^{2t-3}\).

5 Near-bent functions from 2-weight code

Theorem 19

Let C be a binary projective linear 2-weight code of dimension 2t with weights \(w_{1}\) and \(w_{2}\) such that a support of C is not the complement of a subspace.

  1. (a)

    If there exists a word m in C with weight \(w=2^{2t-2}-\eta 2^{t-1}\) with \(\eta \in \lbrace -1,\,0,\,+1 \rbrace \)

    and

  2. (b)

    If \(\mid w_{2}-w_{1}\mid =2^{t-1}\)

then every defining function of the doubly restricted code \(\tilde{C}_{m}\) is a near-bent function.

Proof

Note that the dimension of is \(2t-1\) and the length of \(\tilde{C}_{m}\) is w which also is the weight of f. Then:

  • If \(w=2^{2t-2}-\eta 2^{t-1}\) then \(\hat{f}(0)=2(2^{2t-2}-(2^{2t-2}-\eta 2^{t-1}))=\eta 2^{t}\).

  • If \(w=2^{2t-2}\) then \(\hat{f}(0)=2(2^{2t-2}-2^{2t-2})=0.\)

  • If \(v\not =0\) then \(\hat{f}(v)=-2(n-2w_{v})\).

If f is a defining function of \(\tilde{C}_{m}\) then \(n=w\) and for every v the \(w_{v}\) are the weights of \(\tilde{C}_{m}\): \(\frac{1}{2}[w-(w_{1}-w_{2})],\frac{1}{2}w,\,\frac{1}{2}[w+(w_{1}-w_{2})]\).

With \(\mid w_{2}-w_{1}\mid =2^{t-1}\):

  • \(\hat{f}(v)=-2[w-[w-(w_{1}-w_{2})]=2^{t}\)

or

  • \(\hat{f}(v)=-2[w-[w]]=0\)

or

  • \(\hat{f}(v)=-2[w-[w-(w_{1}+w_{2})]=+2^{t}\).

\(\square \)

5.1 Weight distribution

The defining function involved in the previous theorem is a three-valued boolean function. The distribution of a three-valued m-boolean function is given in [1, Proposition 4].

Assume that the hypotheses of Theorem 19 are satisfied for a code C. Using the link, which appears in the proof of the theorem, between the weights of \(\tilde{C}_{m}\) and the Fourier coefficients of f, and using [1, Proposition 4], we are able to determine the weight distribution of \(\tilde{C}_{m}\) .

Theorem 20

If C is a binary projective 2-weight code satisfying the hypothesis of Theorem 19 then the weight distribution of \(\tilde{C}_{m}\) is as follows.

(iff stands for if an only if).

Weight

Number of words

\(\frac{1}{2}[w-(w_{1}-w_{2})]\)

\(2^{2t-3}+2^{t-2}-\theta \) with \(\theta =1\) iff \(\eta =1\)

\(\frac{1}{2}w\)

\(2^{2t-2}-\gamma \) with \(\gamma =1\) iff \(\eta =0\)

\(\frac{1}{2}[w+(w_{1}-w_{2})]\)

\(2^{2t-3}-2^{t-2}-\omega \) with \(\omega =1\) iff \(\eta =-1\)

Proof

We just have to connect the weights of \(\tilde{C}_{m}\) with the Fourier coefficients of f as in the proof of Theorem 19, then use the coefficient distribution introduced in 2.1 and remark that \(\hat{f}(0)=-2^{t}\) if \(\eta =1\), \(\hat{f}(0)= 0\) if \(\eta =0\) and \(\hat{f}(0)=2^{t}\) if \(\eta =-1\). \(\square \)

5.2 Examples

5.2.1 Special semi-primitive code

Let us consider the binary cyclic code C of dimension 6 and length 21 with generator \(g(x)=1+x^{2}+x^{5}+x^{8}+x^{9}+x^{12}+x^{14}+x^{15}\).

This is a semi-primitive code with \(t=3,\,d=3,\,r=1,\,\epsilon =-1\) the weights are \(w_{1}=2^{2}(\frac{2^{3}+1}{3})=12\) and \(w_{2}=2^{2}(\frac{2^{3}-2}{3})=8\).

Remark that \(12=2^{2t-2}- 2^{t-1}\) whence part (a) of Theorem 19 holds. Then:

If m is a word of weight 12 in C and if f is a defining function of the doubly restricted code \(\tilde{C}_{m}\) of C then f is a near-bent function. This is the example of Sect. 2.3.1.

With \(\mathbb {F}_{2^{5}}=\mathbb {F}_{2}(\alpha )\) and \(\alpha ^{5}+\alpha ^{2}+1=0\), the support of \(\tilde{C}_{m}\) obtained by the columns of \(\tilde{G}_{m}\) is:

$$\begin{aligned} E=\lbrace 0, 1,\alpha ,\alpha ^{2},\alpha ^{6},\alpha ^{7},\alpha ^{8},\alpha ^{18},\alpha ^{20},\alpha ^{21},\alpha ^{25},\alpha ^{30}\rbrace \end{aligned}$$

A defining function of C, indicator of E is:

$$\begin{aligned} tr(1+a^{4}x+a^{11}x^3+a^{22}x^{5}+a^{24}x^{7}+a^{28}x^{11}+a^{17}x^{15}) \end{aligned}$$

where tr is the trace of \(\mathbb {F}_{2^{5}}\).

It seems that this is the unique semi-primitive code satisfying the conditions of Theorem 19.

5.2.2 Bent function code

Theorem 21

Let C be a binary linear code such that a support of C is the support of a bent function. Let m be a word of C.

If f is a defining function of the doubly restricted code \(\tilde{C}_{m}\) then f is a near-bent function.

Proof

It is well known (see [12]) that the dimension of C is 2t and the two weights of C are \(w_{1}=2^{2t-2}\) and \(w_{2}=2^{2t-2}-\epsilon 2^{t-1}\) where \(\epsilon \in \lbrace -1,+1\rbrace \). And we have \(w_{1}-w_{2}=\epsilon 2^{t-1}\). The conclusion comes directly from Theorem 19. \(\square \)

6 Conclusion

We have constructed binary 3-weight codes and near-bent functions from 3-weight codes. An open question now is to find new examples of near-bent functions obtained with Theorem 19.