1 Introduction

MacDonald codes are a class of linear codes with two nonzero weights. Two weights linear codes have many wide applications in authentication codes, association schemes and secret sharing schemes. Two weights codes are also closely related to objects in different areas of mathematics such as strongly regular graphs, partial geometries, and projective point sets. Therefore, the construction of two weights linear codes has become a hot topic of coding theory, such as Shi et al. constructed some two weights projective \({\mathbb {Z}}_4\)-codes in  Shi et al. (2017b) gave two new families of two weights codes by codes over finite non-chain rings in  Shi et al. (2017a).

MacDonald codes have such good properties, so they have attracted the attention of coding scholars. The binary MacDonald codes were introduced in MacDonald (1960). And MacDonald codes over finite field \({\mathbb {F}}_q\) were studied in Patel (1975). In 2003, Colbourn and Gupta obtained two families of MacDonald codes over the ring \({\mathbb {Z}}_4\) from \({\mathbb {Z}}_4\)-simplex codes of types \(\alpha \) and \(\beta \) (see Colbourn and Gupta 2003). Dertli and Cengellenmis (2011) studied the MacDonald codes over the finite non-chain ring \({\mathbb {F}}_2+v{\mathbb {F}}_2\) with \(v^2=v\). In 2016, Wang et al. studied MacDonald codes over \({\mathbb {F}}_p+v{\mathbb {F}}_p\) with \(v^2=v\). They also determined the access structure of secret sharing schemes based on these codes (see Wang et al. 2016).

In Delsarte (1973), the association schemes approach was firstly used to deal with a collection of topics involving the weight distribution of a code. Association schemes are closely related to coding theory, graph theory and finite fields theory. Especially, they provide a framework to study codes and designs. Luo et al. (2018) constructed a class of linear codes with two weights over \({\mathbb {F}}_q\) by linear codes over the finite chain ring \({\mathbb {F}}_q+u{\mathbb {F}}_q\) with \(u^2=0\). They also employed these linear codes to construct association schemes.

The finite non-chain ring \({\mathbb {F}}_p+v{\mathbb {F}}_p+v^2{\mathbb {F}}_p\) is the generalization of the ring \({\mathbb {F}}_p+v{\mathbb {F}}_p\). Shi et al. (2013) firstly studied the cyclic codes and the weight enumerator of linear codes over \({\mathbb {F}}_2+v{\mathbb {F}}_2+v^2{\mathbb {F}}_2\) with \(v^3=v\). As an open problem in Shi et al. (2013), Gao studied the structural properties of linear codes and cyclic codes over \({\mathbb {F}}_p+v{\mathbb {F}}_p+v^2{\mathbb {F}}_p\) with \(v^3=v\) and p an odd prime. Some optimal linear codes over finite fields were also constructed (see Gao 2015). To the best of our knowledge, MacDonald codes over the finite non-chain ring \({\mathbb {F}}_p+v{\mathbb {F}}_p+v^2{\mathbb {F}}_p\) with \(v^3=v\) and p an odd prime have not been considered by any other coding scholars. In this paper, we will study this issue. The rest of this paper is organized as follows. In Sect. 2, we give the structural properties of MacDonald codes over \({\mathbb {F}}_p+v{\mathbb {F}}_p+v^2{\mathbb {F}}_p\), where p is an odd prime and \(v^3=v\). The torsion codes and their weight enumerators are also studied in this section. In Sect. 3, as an application of torsion codes, secret sharing schemes are constructed. In Sect. 4, as another application of torsion codes, we employ them to construct some association schemes.

2 MacDonald codes over \({\mathbb {F}}_{p}+v{\mathbb {F}}_{p}+v^2{\mathbb {F}}_{p}\)

Let \(R={\mathbb {F}}_{p}+v{\mathbb {F}}_{p}+v^2{\mathbb {F}}_{p}\), where p is an odd prime and \(v^3=v\). It is clear that R is a finite commutative ring with characteristic p. The ring R is also a semi-local ring with three maximal ideals \(\langle v\rangle \), \(\langle v-1 \rangle \) and \(\langle v+1\rangle \). Any element of R can be uniquely expressed as \(r=a+bv+cv^2\), where \(a,b,c\in {\mathbb {F}}_p\). Clearly, \(v^3-v=v(v-1)(v+1)\) over \({\mathbb {F}}_{p}\). Let \(f_0=v\), \({\widehat{f_0}}=v^2-1\), \(f_1=v-1\), \({\widehat{f_1}}=v^2+v\) and \(f_2=v+1\), \({\widehat{f_2}}=v^2-v\). Then \(f_i\) and \({\widehat{f_i}}\) are coprime, where \(i=0,1,2\). In other words, there exist \(a_i, b_i\in R\) such that \(a_if_i+b_i{\widehat{f_i}}=1\) for \(i=0,1,2\). Let \(e_i=b_i{\widehat{f_i}}+\langle v^3-v\rangle \). Then, \(e_0=1-v^2\), \(e_1=\frac{v^2+v}{2}\), \(e_2=\frac{v^2-v}{2}\), and \(e_i^2=e_i\), \(\sum _{i=0}^{2}e_i=1\). Further, we obtain \(e_ie_j=0\) for any \(i\ne j\), which implies that \(e_0\), \(e_1\) and \(e_2\) are primitive idempotent elements of R. Therefore, \(R=e_0R\oplus e_1R\oplus e_2R=e_0{\mathbb {F}}_p\oplus e_1{\mathbb {F}}_p\oplus e_2{\mathbb {F}}_p\). It means that any \(r\in R\) can also be uniquely expressed as \(r=e_0r_0+e_1r_1+e_2r_2\), where \(r_i\in {\mathbb {F}}_p,~~i=0,1,2\). By the Chinese remainder theorem, we also have that \(R\cong R/\langle v\rangle \times R/\langle v-1\rangle \times R/\langle v+1\rangle \cong {\mathbb {F}}_p\times {\mathbb {F}}_p \times {\mathbb {F}}_p\).

A code C of length n over R is a nonempty subset of \(R^n\). If the subset is also an R-submodule of \(R^n\), then C is called a linear code. For any \(x=(x_0,x_1,\ldots ,x_{n-1}), y=(y_0,y_1,\ldots ,y_{n-1})\in R^n\), we define the Euclidean inner product as \(x\cdot y=\sum _{i=0}^{n-1}x_iy_i\). The dual code of C is defined as \(C^\perp =\{x\in R^n~|~x\cdot y=0, \forall ~y\in C\}\). If \(C\subseteq C^\perp \), then C is called self-orthogonal. If \(C=C^\perp \), then C is called self-dual.

Let C be a linear code of length n over R. Define

$$\begin{aligned} \begin{aligned} H_1&=\left\{ a\in {\mathbb {F}}_{p}^n~|~\exists ~b,c\in {\mathbb {F}}_{p}^n, (1-v^2)a+\frac{v^2+v}{2}b+\frac{v^2-v}{2}c \in C\right\} , \\ H_2&=\left\{ b\in {\mathbb {F}}_{p}^n~|~\exists ~a,c\in {\mathbb {F}}_{p}^n, (1-v^2)a+\frac{v^2+v}{2}b+\frac{v^2-v}{2}c \in C\right\} \end{aligned} \end{aligned}$$

and

$$\begin{aligned} \begin{aligned} H_3&=\left\{ c\in {\mathbb {F}}_{p}^n~|~\exists ~a,b\in {\mathbb {F}}_{p}^n, (1-v^2)a+\frac{v^2+v}{2}b+\frac{v^2-v}{2}c \in C\right\} . \end{aligned} \end{aligned}$$

Then, we have \(C=(1-v^2)H_1\oplus \frac{v^2+v}{2}H_2\oplus \frac{v^2-v}{2}H_3\), and \(H_1\), \(H_2\), \(H_3\) are all linear codes of length n over \({\mathbb {F}}_{p}\). The linear codes \(H_1\), \(H_2\) and \(H_3\) are defined to be the torsion codes of C.

2.1 MacDonald codes of type \(\alpha \)

A type \(\alpha \) simplex code \(S_k^\alpha \) is a linear code over R. Its generator matrix \(G_k^\alpha \) is constructed inductively as follows.

Let \(G_1^\alpha \) be a \(1\times p^3\) matrix consisting of all the elements of R. In other words, \(G_1^\alpha =[0~1~2~\cdots ~p-1~v~2v~\cdots ~1+(p-1)v~\cdots \) \((p-1)v^2~1+(p-1)v^2~2+(p-1)v^2~\cdots \) \((p-1)+(p-1)v^2~v+(p-1)v^2~2v+(p-1)v^2\) \(\cdots ~1+(p-1)v+(p-1)v^2].\) Note that the elements of \(G_1^\alpha \) can be sorted arbitrarily.

Let \(G_k^\alpha \) be a \(k\times p^{3k}\) matrix over R, where

$$\begin{aligned} G_k^\alpha = \begin{bmatrix} 0\cdots 0&1\cdots 1&\cdots&1+(p-1)v+(p-1)v^2\cdots 1+(p-1)v+(p-1)v^2\\ G_{k-1}^\alpha&G_{k-1}^\alpha&\cdots&G_{k-1}^\alpha \end{bmatrix}. \end{aligned}$$

Let \(G(S_k)\), columns consisting of all nonzero p-ary k-tuples, be a generator matrix for an \([n,k]_p\) simplex code \(S_k\) over \({\mathbb {F}}_p\). Then, the extended simplex code \({\widehat{S}}_k\) is generated by \(G({\widehat{S}}_k)=[0|G(S_k)]\), where

$$\begin{aligned} G({\widehat{S}}_k)= \left[ \begin{array}{cccc} 0~\cdots ~0 ~&{}~ 1~\cdots ~1 ~&{} ~\cdots ~ &{}~(p-1)~\ldots ~(p-1)\\ G({\widehat{S}}_{k-1}) ~&{}~ G({\widehat{S}}_{k-1}) ~&{}~\cdots ~&{}~ G({\widehat{S}}_{k-1}) \end{array} \right] \end{aligned}$$

and \(G({\widehat{S}}_1)=\big [0~~1~~2~~\cdots ~~p-1 \big ]\).

Lemma 1

The torsion codes \(H_i\) \((i=1,2,3)\) of \(S_k^\alpha \) are permutation equivalent to \(p^{2k}\) copies of \({\widehat{S}}_k\).

Proof

We prove the \(H_1\) case by induction on k. The generator matrix of \(H_1\) is obtained by replacing \((1-v^2)\) by 1 in the matrix rows \((1-v^2)G_k^\alpha \). For \(k=1\), we can easily verify it. Suppose that the matrix \((1-v^2)G_{k-1}^\alpha \) is permutation equivalent to \(p^{2(k-1)}\) copies of \((1-v^2)G({\widehat{S}}_{k-1})\), then the matrix \((1-v^2)G_{k}^\alpha \) is \((1-v^2)G_{k}^\alpha =\big [\underbrace{G~~G~~\cdots ~~G}_{p^2}\big ]\), where \(G=\big [G_0~~G_1~~\cdots ~~G_{p-1}\big ]_{k\times p^{3k-2}}\) and

$$\begin{aligned} G_j= \left[ \begin{array}{ccc} (1-v^2)j~~&{}\cdots ~~&{}(1-v^2)j\\ (1-v^2)G({\widehat{S}}_{k-1}) &{}~~\cdots ~~&{}~~(1-v^2)G({\widehat{S}}_{k-1}) \end{array} \right] ,\quad j=0,1,\ldots ,p-1. \end{aligned}$$

The size of \(G_j\) is \(k\times p^{3k-3}\). Regrouping the columns, we have the desired result. The proof of \(H_2\) and \(H_3\) is similar to the above. \(\square \)

In the following, we define the MacDonald codes of type \(\alpha \) over R. It can be constructed from the generator matrix \(G_k^\alpha \) of the simplex code \(S_k^\alpha \). For \(1\le u \le k-1\), let \(G_{k,u}^\alpha \) be the matrix obtained from \(G_k^\alpha \) by deleting columns corresponding to the columns of \(G_u^\alpha \), i.e.

$$\begin{aligned} G_{k,u}^\alpha = \left[ G_k^\alpha \backslash \begin{array}{cc} \mathbf{0 }\\ {G_u^\alpha } \end{array} \right] , \end{aligned}$$

where \([A\backslash B]\) denotes the matrix obtained from the matrix A by deleting the matrix B, and the size of the matrix \(\mathbf{0 }\) is \((k-u)\times p^{3u}\).

Definition 1

The code \(C_{k,u}^\alpha \) generated by \(G_{k,u}^\alpha \) is called a type \(\alpha \) MacDonald code.

Clearly, the code \(C_{k,u}^\alpha \) is a linear code over R of length \(p^{3k}-p^{3u}\). Let \(M_{k,u}^\alpha \) be the torsion code of \(C_{k,u}^\alpha \). That is the generator matrix of \(M_{k,u}^\alpha \) obtained by replacing \((1-v^2)\) by 1 in the matrix \((1-v^2)G_{k,u}^\alpha \). Meanwhile, we can get other torsion codes of \(C_{k,u}^\alpha \) by replacing \(\frac{v^2+v}{2}\) by 1 in \(\frac{v^2+v}{2}G_{k,u}^\alpha \) and by replacing \(\frac{v^2-v}{2}\) by 1 in \(\frac{v^2-v}{2}G_{k,u}^\alpha \), respectively. From Lemma 1, we can see that these three torsion codes are equivalent to each other. Therefore, we only need to study the first case, i.e. we only consider the torsion code \(M_{k,u}^\alpha \). In the following, we give the Hamming weight enumerator of \(M_{k,u}^\alpha \) first.

Theorem 1

The torsion code \(M_{k,u}^\alpha \) is a p-ary two weights linear code with parameter \([p^{3k}-p^{3u}, k, (p-1)(p^{3k-1}-p^{3u-1})]\). The number of codewords with Hamming weight \((p-1)p^{3k-1}\) is \(p^{k-u}-1\), and the number of codewords with Hamming weight \((p-1)(p^{3k-1}-p^{3u-1})\) is \(p^k-p^{k-u}\).

Proof

Clearly, the result holds for the case \(k=2\) and \(u=1\). Suppose that the result holds for the case \(k-1\) and \(1\le u \le k-2\). Then for the case k and \(1\le u \le k-1\), the matrix \((1-v^2)G_{k,u}^\alpha \) takes the form

$$\begin{aligned} (1-v^2)G_{k,u}^\alpha = \left[ (1-v^2)G_k^\alpha \backslash \begin{array}{cc} \mathbf{0 }\\ {(1-v^2)G_u^\alpha } \end{array} \right] , \end{aligned}$$

where

$$\begin{aligned} G_k^\alpha = \begin{bmatrix} 0\cdots 0&1\cdots 1&\cdots&1+(p-1)v+(p-1)v^2 \cdots 1+(p-1)v+(p-1)v^2\\ G_{k-1}^\alpha&G_{k-1}^\alpha&\cdots&G_{k-1}^\alpha \end{bmatrix}. \end{aligned}$$

Therefore, we have that each nonzero codeword of \((1-v^2)G_{k,u}^\alpha \) has Hamming weight \((p-1)p^{3k-1}\) or \((p-1)(p^{3k-1}-p^{3u-1})\) and the dimension of \(M_{k,u}^\alpha \) is k. By the computation, there are \(p^{k-u}-1\) codewords of Hamming weight \((p-1)p^{3k-1}\) and \(p^k-p^{k-u}\) codewords of Hamming weight \((p-1)(p^{3k-1}-p^{3u-1})\). \(\square \)

2.2 MacDonald codes of type \(\beta \)

The code length of simplex codes of type \(\alpha \) is large and increases fast. We can omit some columns from \(S_k^\alpha \). A type \(\beta \) simplex code \(S_k^\beta \) is a linear code over R constructed by omitting some columns from \(G_k^\alpha \). Specifically, after deleting some columns of \(G_k^\alpha \), no two columns are multiplied in the generating matrix \(G_k^\beta \) of \(S_k^\beta \).

Let \(\delta _k\) be a matrix of size \(k\times \frac{p^{3k}-p^{2k}}{p-1}\) over R. Let

\(\delta _1=[1~2~\cdots ~p-1~1+v~2+2v~\cdots ~(p-1)+(p-1)v~2+v~4+2v\) \(\cdots ~2(p-1)+(p-1)v ~3+v~6+2v~\cdots ~3(p-1)+(p-1)v\) \(\cdots ~(p-1)+v~2(p-1)+2v\) \(\cdots ~1+(p-1)v~1+(p-2)v+(p-1)v^2~2+2(p-2)v+2(p-1)v^2\) \(\cdots ~(p-1)+2v+v^2~(p-1)+v^2]\) and

$$\begin{aligned} \begin{aligned} \delta _2=\left[ \begin{array}{cccccccc} 0&{}A&{}B&{}C&{}D&{}E&{}\cdots &{}F \\ \delta _1&{}G_1^\alpha &{}\delta _1&{}\delta _1&{}\delta _1&{}\delta _1&{}\cdots &{}\delta _1 \end{array}\right] , \end{aligned} \end{aligned}$$

\(\delta _k\) is constructed inductively as follows:

$$\begin{aligned} \begin{aligned} \delta _k=\left[ \begin{array}{cccccccc} 0&{}A&{}B&{}C&{}D&{}E&{}\cdots &{}F \\ \delta _{k-1}&{}G_{k-1}^\alpha &{}\delta _{k-1}&{}\delta _{k-1}&{}\delta _{k-1}&{}\delta _{k-1}&{}\cdots &{}\delta _{k-1} \end{array}\right] , \end{aligned} \end{aligned}$$

where

$$\begin{aligned} A= & {} [1~2~\cdots ~p-1~1+v~2+2v\cdots ~(p-1)+2v+v^2~(p-1)+v^2],\\ B= & {} [v~2v~3v~\cdots ~(p-1)v],~C=[v^2~2v^2~3v^2~\cdots ~(p-1)v^2],\\ D= & {} [v+v^2~2v+2v^2~3v+3v^2~\cdots ~(p-1)v+(p-1)v^2],\\ E= & {} [2v+v^2~4v+2v^2~6v+3v^2~\cdots ~2(p-1)v+(p-1)v^2],\\ F= & {} [(p-1)v+v^2~2(p-1)v+2v^2~3(p-1)v+3v^2~\cdots ~v+(p-1)v^2]. \end{aligned}$$

Notice that the points between E and F indicate that the first element is from \((2+v)v\) to \(((p-1)+v)v\).

Let \(\lambda _k\) be a matrix of size \(k\times \frac{p^{3k}-p^{2k}}{p-1}\) over R. Let

\(\lambda _1=[1~2~\cdots ~p-1~v~2v~\cdots ~(p-1)v~2+v~4+2v\) \(\cdots ~2(p-1)+(p-1)v~3+v~6+2v\) \(\cdots ~3(p-1)+(p-1)v~\cdots (p-1)+v~2(p-1)+2v\) \(\cdots ~1+(p-1)v~(p-1)+(p-2)v+v^2~2(p-1)+2(p-2)v+2v^2\) \(\cdots ~1+2v+(p-1)v^2~(p-1)v+v^2]\) and

$$\begin{aligned} \begin{aligned} \lambda _2=\left[ \begin{array}{cccccccc} 0&{}A&{}B&{}C&{}D&{}E&{}\cdots &{}F \\ \lambda _1&{}G_1^\alpha &{}\lambda _1&{}\lambda _1&{}\lambda _1&{}\lambda _1&{}\cdots &{}\lambda _1 \end{array}\right] , \end{aligned} \end{aligned}$$

\(\lambda _k\) is constructed inductively as follows:

$$\begin{aligned} \begin{aligned} \lambda _k=\left[ \begin{array}{cccccccc} 0&{}A&{}B&{}C&{}D&{}E&{}\cdots &{}F \\ \lambda _{k-1}&{}G_{k-1}^\alpha &{}\lambda _{k-1}&{}\lambda _{k-1}&{}\lambda _{k-1}&{}\lambda _{k-1}&{}\cdots &{}\lambda _{k-1} \end{array}\right] , \end{aligned} \end{aligned}$$

where

$$\begin{aligned} A= & {} [1~2~\cdots ~p-1~v~2v~\cdots ~1+2v+(p-1)v^2~(p-1)v+v^2],\\ B= & {} [1+v~2+2v~3+3v~\cdots ~(p-1)+(p-1)v],\\ C= & {} [v+v^2~2v+2v^2~3v+3v^2~\cdots ~(p-1)v+(p-1)v^2],\\ D= & {} [1+2v+v^2~2+4v+2v^2~3+6v+3v^2~\cdots ~(p-1)+2(p-1)v+(p-1)v^2],\\ E= & {} [2+3v+v^2~4+6v+2v^2~6+9v+3v^2~\cdots ~2(p-1)+3(p-1)v+(p-1)v^2],\\ F= & {} [(p-1)+v^2~2(p-1)+2v^2~3(p-1)+3v^2~\cdots ~1+(p-1)v^2]. \end{aligned}$$

Notice that the points between E and F indicate that the first element is from \((2+v)(1+v)\) to \(((p-1)+v)(1+v)\).

Let \(\sigma _k\) be a matrix of size \(k\times \frac{p^{3k}-p^{2k}}{p-1}\) over R. Let

\(\sigma _1=[1~2~\cdots ~p-1~v~2v~\cdots ~(p-1)v~1+v~2+2v\) \(\cdots ~(p-1)+(p-1)v~2+v~4+2v~\cdots ~2(p-1)+(p-1)v~ 3+v~6+2v\) \(\cdots ~3(p-1)+(p-1)v~\cdots ~(p-2)+v~2(p-2)+2v\) \(\cdots ~2+(p-1)v~1+v^2~2+2v^2\) \(\cdots ~(p-1)+(p-1)v^2~v+v^2]\) and

$$\begin{aligned} \begin{aligned} \sigma _2=\left[ \begin{array}{cccccccc} 0&{}A&{}B&{}C&{}D&{}E&{}\cdots &{}F \\ \sigma _1&{}G_1^\alpha &{}\sigma _1&{}\sigma _1&{}\sigma _1&{}\sigma _1&{}\cdots &{}\sigma _1 \end{array}\right] , \end{aligned} \end{aligned}$$

\(\sigma _k\) is constructed inductively as follows:

$$\begin{aligned} \begin{aligned} \sigma _k=\left[ \begin{array}{ccccccc} 0&{}A&{}B&{}C&{}D&{}\cdots &{}E \\ \sigma _{k-1}&{}G_{k-1}^\alpha &{}\sigma _{k-1}&{}\sigma _{k-1}&{}\sigma _{k-1}&{}\cdots &{}\sigma _{k-1} \end{array}\right] , \end{aligned} \end{aligned}$$

where

$$\begin{aligned} A= & {} [1~2~\cdots ~p-1~v~2v~\cdots ~(p-1)+(p-1)v^2~v+v^2],\\ B= & {} [(p-1)+v~2(p-1)+2v~3(p-1)+3v~\cdots ~1+(p-1)v],\\ C= & {} [(p-1)v+v^2~2(p-1)v+2v^2~3(p-1)v+3v^2~\cdots ~v+(p-1)v^2],\\ D= & {} [(p-1)+v^2~2(p-1)+2v^2~3(p-1)+3v^2~\cdots ~1+(p-1)v^2],\\ E= & {} [2(p-1)+v+v^2~4(p-1)+2v+2v^2~\cdots ~2+(p-1)v+(p-1)v^2],\\ F= & {} [1+2(p-1)v+v^2~2+4(p-1)v+2v^2~\cdots ~(p-1)+2v+(p-1)v^2]. \end{aligned}$$

Notice that the points between E and F indicate that the first element is from \((2+v)((p-1)+v)\) to \(((p-1)+v)((p-1)+v)\).

Let \(\mu _k\) be a matrix of size \(k\times \frac{p^k(p^k-1)^2}{(p-1)^2}\) over R. Let

$$\begin{aligned} \mu _1=\big [1~~2~~\cdots ~~p-1~~v\big ] \end{aligned}$$

and

$$\begin{aligned} \begin{aligned} \mu _2=\left[ \begin{array}{ccccc} 0&{}A&{}B&{}C&{}D \\ \mu _1&{}G_1^\alpha &{}\lambda _1&{}\sigma _1&{}\mu _1 \end{array}\right] , \end{aligned} \end{aligned}$$

\(\mu _k\) is constructed inductively as follows:

$$\begin{aligned} \begin{aligned} \mu _k=\left[ \begin{array}{ccccc} 0&{}A&{}B&{}C&{}D \\ \mu _{k-1}&{}G_{k-1}^\alpha &{}\lambda _{k-1}&{}\sigma _{k-1}&{}\mu _{k-1} \end{array}\right] , \end{aligned} \end{aligned}$$

where

$$\begin{aligned} A= & {} [1~2~\cdots ~p-1~v],\\ B= & {} [1+v~2+2v~3+3v~\cdots ~(p-1)+(p-1)v~v+v^2],\\ C= & {} [(p-1)+v~2(p-1)+2v~\cdots ~1+(p-1)v~(p-1)v+v^2],\\ D= & {} [(p-1)+v^2~2(p-1)+2v^2~3(p-1)+3v^2~\cdots ~1+(p-1)v^2]. \end{aligned}$$

Let \(\nu _k\) be a matrix of size \(k\times \frac{p^k(p^k-1)^2}{(p-1)^2}\) over R. Let

$$\begin{aligned} \nu _1=\big [1~~2~~\cdots ~~p-1~~(p-1)+v\big ] \end{aligned}$$

and

$$\begin{aligned} \begin{aligned} \nu _2=\left[ \begin{array}{ccccc} 0&{}A&{}B&{}C&{}D \\ \nu _1&{}G_1^\alpha &{}\delta _1&{}\lambda _1&{}\nu _1 \end{array}\right] , \end{aligned} \end{aligned}$$

\(\nu _k\) is constructed inductively as follows:

$$\begin{aligned} \begin{aligned} \nu _k=\left[ \begin{array}{ccccc} 0&{}A&{}B&{}C&{}D \\ \nu _{k-1}&{}G_{k-1}^\alpha &{}\delta _{k-1}&{}\lambda _{k-1}&{}\nu _{k-1} \end{array}\right] , \end{aligned} \end{aligned}$$

where

$$\begin{aligned} A= & {} [1~2~\cdots ~p-1~(p-1)+v],\\ B= & {} [v~2v~3v~\cdots ~(p-1)v~(p-1)v+v^2],\\ C= & {} [1+v~2+2v~3+3v~\cdots ~(p-1)+(p-1)v~(p-1)+v^2],\\ D= & {} [v+v^2~2v+2v^2~3v+3v^2~\cdots ~(p-1)v+(p-1)v^2]. \end{aligned}$$

Let \(\omega _k\) be a matrix of size \(k\times \frac{p^k(p^k-1)^2}{(p-1)^2}\) over R. Let

$$\begin{aligned} \omega _1=\big [1~~2~~\cdots ~~p-1~~1+v\big ] \end{aligned}$$

and

$$\begin{aligned} \begin{aligned} \omega _2=\left[ \begin{array}{ccccc} 0&{}A&{}B&{}C&{}D \\ \omega _1&{}G_1^\alpha &{}\delta _1&{}\sigma _1&{}\omega _1 \end{array}\right] , \end{aligned} \end{aligned}$$

\(\omega _k\) is constructed inductively as follows:

$$\begin{aligned} \begin{aligned} \omega _k=\left[ \begin{array}{ccccc} 0&{}A&{}B&{}C&{}D \\ \omega _{k-1}&{}G_{k-1}^\alpha &{}\delta _{k-1}&{}\sigma _{k-1}&{}\omega _{k-1} \end{array}\right] , \end{aligned} \end{aligned}$$

where

$$\begin{aligned} A= & {} [1~2~\cdots ~p-1~1+v],~B=[v~2v~3v~\cdots ~(p-1)v~v+v^2],\\ C= & {} [(p-1)+v~2(p-1)+2v~\cdots ~1+(p-1)v~(p-1)+v^2],\\ D= & {} [(p-1)v+v^2~2(p-1)v+2v^2~3(p-1)v+3v^2~\cdots ~v+(p-1)v^2]. \end{aligned}$$

Let \(G_k^\beta \) be the generator matrix of \(S_k^\beta \), where \(k\ge 2\). The size of \(G_k^\beta \) is \(k\times \frac{(p^k-1)^3}{(p-1)^3}\). \(G_2^\beta \) is given as

$$\begin{aligned} G_2^\beta = \left[ \begin{array}{cccccccc} 1&{}0&{}v&{}1+v&{}(p-1)+v&{}(p-1)+v^2&{}v+v^2&{}(p-1)v+v^2\\ G_1^\alpha &{}1&{}\delta _1&{}\lambda _1&{}\sigma _1&{}\mu _1&{}\nu _1&{}\omega _1 \end{array} \right] . \end{aligned}$$

\(G_k^\beta \) is constructed inductively as follows:

$$\begin{aligned} G_k^\beta = \begin{bmatrix} 1&0&v&1+v&(p-1)+v&(p-1)+v^2&v+v^2&(p-1)v+v^2\\ G_{k-1}^\alpha&G_{k-1}^\beta&\delta _{k-1}&\lambda _{k-1}&\sigma _{k-1}&\mu _{k-1}&\nu _{k-1}&\omega _{k-1} \end{bmatrix}. \end{aligned}$$

Then, we have the following result. The proof is similar to that of Lemma 1, so we omit it.

Lemma 2

The torsion codes \(H_i\) ( \(i=1,2,3\)) of \(S_k^\beta \) are permutation equivalent to each other.

We can construct type \(\beta \) MacDonald codes similarly to the construction of type \(\alpha \) MacDonald codes. For \(2\le u \le k-1\), let \(G_{k,u}^\beta \) be the matrix obtained from \(G_k^\beta \) by deleting columns corresponding to the columns of \(G_u^\beta \), i.e.

$$\begin{aligned} G_{k,u}^\beta = \left[ G_k^\beta \backslash \begin{array}{cc} \mathbf{0 }\\ {G_u^\beta } \end{array} \right] , \end{aligned}$$

where \([A\backslash B]\) denotes the matrix obtained from the matrix A by deleting the matrix B, and the size of the matrix \(\mathbf{0 }\) is \((k-u)\times \frac{(p^u-1)^3}{(p-1)^3}\).

Definition 2

The code \(C_{k,u}^\beta \) generated by \(G_{k,u}^\beta \) is called a type \(\beta \) MacDonald code.

Let \(M_{k,u}^\beta \) be the torsion code of \(C_{k,u}^\beta \). That is the generator matrix of \(M_{k,u}^\beta \) obtained by replacing \((1-v^2)\) by 1 in the matrix \((1-v^2)G_{k,u}^\beta \). Meanwhile, we can get other torsion codes of \(C_{k,u}^\beta \) by replacing \(\frac{v^2+v}{2}\) by 1 in \(\frac{v^2+v}{2}G_{k,u}^\beta \) and by replacing \(\frac{v^2-v}{2}\) by 1 in \(\frac{v^2-v}{2}G_{k,u}^\beta \), respectively. From Lemma 1, we can see that these three torsion codes are equivalent to each other. Therefore, we only need to study the first case, i.e. we only consider the torsion code \(M_{k,u}^\beta \). In the following, we give the Hamming weight enumerator of \(M_{k,u}^\beta \) first.

Theorem 2

The torsion code \(M_{k,u}^\beta \) is a p-ary two weights linear code with parameters

$$\begin{aligned} \left[ \frac{(p^k-1)^3-(p^u-1)^3}{(p-1)^3}, k, \frac{p^{k-1}(p^k-1)^2-p^{u-1}(p^u-1)^2}{(p-1)^2}\right] . \end{aligned}$$

The number of codewords with Hamming weight \(\frac{p^{k-1}(p^k-1)^2}{(p-1)^2}\) is \(p^{k-u}-1\), and the number of codewords with Hamming weight \(\frac{p^{k-1}(p^k-1)^2-p^{u-1}(p^u-1)^2}{(p-1)^2}\) is \(p^k-p^{k-u}\).

Proof

Clearly, the result holds for the case \(k=3\) and \(u=2\). Suppose that the result holds for the case \(k-1\) and \(2\le u \le k-2\). Then for the case k and \(2\le u \le k-1\), the matrix \((1-v^2)G_{k,u}^\beta \) takes the form

$$\begin{aligned} (1-v^2)G_{k,u}^\beta = \left[ (1-v^2)G_k^\beta \big \backslash \begin{array}{cc} \mathbf{0 }\\ {(1-v^2)G_u^\beta } \end{array} \right] , \end{aligned}$$

where \(G_k^\beta \) is defined above. Therefore, we have that each nonzero codeword of \((1-v^2)G_{k,u}^\beta \) has Hamming weight \(\frac{p^{k-1}(p^k-1)^2}{(p-1)^2}\) or \(\frac{p^{k-1}(p^k-1)^2-p^{u-1}(p^u-1)^2}{(p-1)^2}\), and the dimension of \(M_{k,u}^\beta \) is k. By the computation, there are \(p^{k-u}-1\) codewords of Hamming weight \(\frac{p^{k-1}(p^k-1)^2}{(p-1)^2}\) and \(p^k-p^{k-u}\) codewords of Hamming weight \(\frac{p^{k-1}(p^k-1)^2-p^{u-1}(p^u-1)^2}{(p-1)^2}\). \(\square \)

At the end of this section, we give an example of the torsion code \(M_{3,2}^\beta \) to illustrate the main work.

Example 1

Consider the type \(\beta \) MacDonald codes over the ring \({\mathbb {F}}_3+v{\mathbb {F}}_3+v^2{\mathbb {F}}_3\) with \(v^3=v\). In this case, we have \(G_1^\alpha =[0~1~2~v~2v~1+v~2+2v~2+v~1+2v~v^2~1\) \(+v^2~2+v^2~v+v^2~2v+v^2~1+v+v^2~2+2v+v^2~2+v+v^2\) \(1+2v+v^2~2v^2~1+2v^2~2+2v^2~v+2v^2~2v+2v^2\) \(1+v+2v^2~2+2v+2v^2\) \(2+v+2v^2~1+2v+2v^2]\),

$$\begin{aligned} G_2^\beta = \left[ \begin{array}{cccccccc} 1&{}0&{}v&{}1+v&{}2+v&{}2+v^2&{}v+v^2&{}2v+v^2\\ G_1^\alpha &{}1&{}\delta _1&{}\lambda _1&{}\sigma _1&{}\mu _1&{}\nu _1&{}\omega _1 \end{array} \right] , \end{aligned}$$

where

$$\begin{aligned} \delta _1= & {} [1~2~1+v~2+2v~2+v~1+2v~1+v+2v^2~2+2v+v^2~2+v^2],\\ \lambda _1= & {} [1~2~v~2v~2+v~1+2v~2+v+v^2~1+2v+2v^2~2v+v^2],\\ \sigma _1= & {} [1~2~v~2v~1+v~2+2v~1+v^2~2+2v^2~v+v^2],\\ \mu _1= & {} [1~2~v],~\nu _1=[1~2~2+v],~\omega _1=[1~2~1+v] \end{aligned}$$

and

$$\begin{aligned} G_3^\beta = \left[ \begin{array}{cccccccc} 1~~&{}0~~&{}v~~&{}1+v~~&{}2+v~~&{}2+v^2~~&{}v+v^2~~&{}2v+v^2\\ G_2^\alpha ~~&{}G_2^\beta ~~&{}\delta _2~~&{}\lambda _2~~&{}\sigma _2~~&{}\mu _2~~&{}\nu _2~~&{}\omega _2 \end{array} \right] , \end{aligned}$$

where

$$\begin{aligned} \delta _2= & {} \left[ \begin{array}{cccccccccc} 0&{}A&{}v&{}2v&{}v^2&{}2v^2&{}v+v^2&{}2v+2v^2&{}2v+v^2&{}v+2v^2\\ \delta _1&{}G_1^\alpha &{}\delta _1&{}\delta _1&{}\delta _1&{}\delta _1&{}\delta _1&{}\delta _1&{}\delta _1&{}\delta _1\\ \end{array}\right] ,\\ A= & {} [1~2~1+v~2+2v~2+v~1+2v~1+v+2v^2~2+2v+v^2~2+v^2].\\ \lambda _2= & {} \left[ \begin{array}{cccccccc} 0&{}B&{}1+v&{}2+2v&{}v+v^2&{}2v+2v^2&{}C\\ \lambda _1&{}G_1^\alpha &{}\lambda _1&{}\lambda _1&{}\lambda _1&{}\lambda _1&{}\lambda _1\\ \end{array}\right] ,\\ B= & {} [1~2~v~2v~2+v~1+2v~2+v+v^2~1+2v+2v^2~2v+v^2],\\ C= & {} [1+2v+v^2~2+v+2v^2~2+v^2~1+2v^2].\\ \sigma _2= & {} \left[ \begin{array}{ccccccc} 0&{}D&{}2+v&{}1+2v&{}2v+v^2&{}v+2v^2&{}E\\ \sigma _1&{}G_1^\alpha &{}\sigma _1&{}\sigma _1&{}\sigma _1&{}\sigma _1&{}\sigma _1\\ \end{array}\right] ,\\ D= & {} [1~2~v~2v~1+v~2+2v~1+v^2~2+2v^2~v+v^2],\\ E= & {} [2+v^2~1+2v^2~1+v+v^2~2+2v+2v^2].\\ \mu _2= & {} \left[ \begin{array}{ccccccccc} 0&{}F&{}1+v&{}2+2v&{}v+v^2&{}2+v&{}1+2v&{}2v+v^2&{}H\\ \mu _1&{}G_1^\alpha &{}\lambda _1&{}\lambda _1&{}\lambda _1&{}\sigma _1&{}\sigma _1&{}\sigma _1&{}\mu _1 \end{array}\right] ,\\ F= & {} [1~2~v], ~H=[2+v^2~1+2v^2].\\ \nu _2= & {} \left[ \begin{array}{cccccccccc} 0&{}I&{}v&{}2v&{}2v+v^2&{}1+v&{}2+2v&{}2+v^2&{}v+v^2&{}2v+2v^2\\ \nu _1&{}G_1^\alpha &{}\delta _1&{}\delta _1&{}\delta _1&{}\lambda _1&{}\lambda _1&{}\lambda _1&{}\nu _1&{}\nu _1 \end{array}\right] ,\\ I= & {} [1~2~2+v]. \end{aligned}$$

and

$$\begin{aligned} \omega _2= & {} \left[ \begin{array}{cccccccccc} 0&{}J&{}v&{}2v&{}v+v^2&{}2+v&{}1+2v&{}2+v^2&{}2v+v^2&{}v+2v^2\\ \omega _1&{}G_1^\alpha &{}\delta _1&{}\delta _1&{}\delta _1&{}\sigma _1&{}\sigma _1&{}\sigma _1&{}\omega _1&{}\omega _1 \end{array}\right] .\\ J= & {} [1~2~1+v]. \end{aligned}$$

Let \(G_k^{\alpha '}\) be the matrix replacing \((1-v^2)\) by 1 in \((1-v^2)G_k^\alpha \), \(G_k^{\beta '}\) be the matrix replacing \((1-v^2)\) by 1 in \((1-v^2)G_k^\beta \). In addition, \(\delta '_k, \lambda '_k, \sigma '_k, \mu '_k, \nu '_k\) and \(\omega '_k\) be the matrices replacing \((1-v^2)\) by 1 in \((1-v^2)\delta _k, (1-v^2)\lambda _k, (1-v^2)\sigma _k, (1-v^2)\mu _k, (1-v^2)\nu _k\) and \((1-v^2)\omega _k\), respectively. Then, we have

$$\begin{aligned} G_1^{\alpha '}= & {} [0~1~2~0~0~1~2~2~1~0~1~2~0~0~1~2~2~1~0~1~2~0~0~1~2~2~1],\\ G_2^{\alpha '}= & {} \left[ \begin{array}{cccccccccccccccccccc} 0&{}1&{}2&{}0&{}0&{}1&{}2&{}2&{}1&{}\cdots &{}2&{}2&{}1\\ G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}\cdots &{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '} \end{array}\right] ,\\ G_2^{\beta '}= & {} \left[ \begin{array}{cccccccccccc} 1&{}0&{}0&{}1&{}2&{}2&{}0&{}0\\ G_1^{\alpha '}&{}1&{}\delta '_1&{}\lambda '_1&{}\sigma '_1&{}\mu '_1&{}\nu '_1&{}\omega '_1 \end{array}\right] ,\\ \delta '_2= & {} \left[ \begin{array}{cccccccccc} 0&{}A&{}0&{}0&{}0&{}0&{}0&{}0&{}0&{}0\\ \delta '_1&{}G_1^{\alpha '}&{}\delta '_1&{}\delta '_1&{}\delta '_1&{}\delta '_1&{}\delta '_1&{}\delta '_1&{}\delta '_1&{}\delta '_1 \end{array}\right] ,\\ A= & {} [1~2~1~2~2~1~1~2~2].\\ \lambda '_2= & {} \left[ \begin{array}{ccccccccccc} 0&{}B&{}1&{}2&{}0&{}0&{}1&{}2&{}2&{}1\\ \lambda '_1&{}G_1^{\alpha '}&{}\lambda '_1&{}\lambda '_1&{}\lambda '_1&{}\lambda '_1&{}\lambda '_1&{}\lambda '_1&{}\lambda '_1&{}\lambda '_1 \end{array}\right] ,\\ B= & {} [1~2~0~0~2~1~2~1~0].\\ \sigma '_2= & {} \left[ \begin{array}{ccccccccccc} 0&{}C&{}2&{}1&{}0&{}0&{}2&{}1&{}1&{}2\\ \sigma '_1&{}G_1^{\alpha '}&{}\sigma '_1&{}\sigma '_1&{}\sigma '_1&{}\sigma '_1&{}\sigma '_1&{}\sigma '_1&{}\sigma '_1&{}\sigma '_1 \end{array}\right] ,\\ C= & {} [1~2~0~0~1~2~1~2~0].\\ \mu '_2= & {} \left[ \begin{array}{cccccccccccc} 0&{}1&{}2&{}0&{}1&{}2&{}0&{}2&{}1&{}0&{}2&{}1\\ \mu '_1&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}\lambda '_1&{}\lambda '_1&{}\lambda '_1&{}\sigma '_1&{}\sigma '_1&{}\sigma '_1&{}\mu '_1&{}\mu '_1 \end{array} \right] ,\\ \nu '_2= & {} \left[ \begin{array}{cccccccccccc} 0&{}1&{}2&{}2&{}0&{}0&{}0&{}1&{}2&{}2&{}0&{}0\\ \nu '_1&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}\delta '_1&{}\delta '_1&{}\delta '_1&{}\lambda '_1&{}\lambda '_1&{}\lambda '_1&{}\nu '_1&{}\nu '_1 \end{array} \right] , \end{aligned}$$

and

$$\begin{aligned} \omega '_2= \left[ \begin{array}{cccccccccccc} 0&{}1&{}2&{}1&{}0&{}0&{}0&{}2&{}1&{}2&{}0&{}0\\ \omega '_1&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}\delta '_1&{}\delta '_1&{}\delta '_1&{}\sigma '_1&{}\sigma '_1&{}\sigma '_1&{}\omega '_1&{}\omega '_1 \end{array} \right] . \end{aligned}$$

Therefore, the generator matrix \(G_{3,2}^{\beta '}\) of \(M_{3,2}^\beta \) is

$$\begin{aligned} G_{3,2}^{\beta '}= \left[ \begin{array}{cccccccc} 1&{}0&{}0&{}1&{}2&{}2&{}0&{}0\\ G_2^{\alpha '}&{}G_2^{\beta '}&{}\delta '_2&{}\lambda '_2&{}\sigma '_2&{}\mu '_2&{}\nu '_2&{}\omega '_2 \end{array} \right] . \end{aligned}$$

By the Magma computational algebra system (see Bosma et al. 1997), the torsion code \(M_{3,2}^\beta \) is a 3-ary [2133, 3, 1473] linear code with Hamming weight distributions \(A_H(0)=1\), \(A_H(1473)=24\) and \(A_H(1521)=2\).

3 Secret sharing schemes from MacDonald codes over R

A secret sharing scheme is a method that a dealer distributes shares of a secret to participants such that only qualified subsets of participants can recover the secret from their shares. Let \({\mathcal {P}}=\{P_1,P_2,\ldots ,P_{n-1}\}\) be a set of participants. We use s to denote a secret. If a set \(A\subseteq {\mathcal {P}}\) can recover the secret s, then A is called a qualified set. Otherwise, it is called a unqualified set. A secret sharing scheme is called perfect if all the unqualified sets cannot get any information about the secret s in the information theoretic sense. Throughout this paper, we consider only perfect secret sharing schemes. If the shares are of the same size as that of the secret s, the secret sharing scheme is called ideal. A minimal qualified set B is that if \(B\subseteq {\mathcal {P}}\) is a qualified set and for all \(C\subset B\) with C is an unqualified set. The access structure of a secret sharing scheme is defined to be the set of all qualified sets.

In Massey (1993), the author gave a method of constructing secret sharing schemes by linear codes over finite field \({\mathbb {F}}_q\). We employ the same method in this section. Let C ba an \([n,k]_q\) linear code over \({\mathbb {F}}_q\), and \(G=[g_0,g_1,\ldots ,g_{n-1}]\) be the generator matrix of C. Let \(C^\perp \) be the dual code of C, and \(H=[h_0,h_1,\ldots ,h_{n-1}]\) be the generator matrix of \(C^\perp \).

In the secret sharing scheme based on C, the secret s is an element of \({\mathbb {F}}_q\), and \(n-1\) parties \(P_1,P_2,\ldots ,P_{n-1}\) and a dealer are involved. To compute shares with respect to a secret s, the dealer chooses randomly a vector \(u=(u_0,u_1,\ldots ,u_{n-k-1})\) such that \(s=uh_0\). The dealer then treats u as an information vector and computes the corresponding codeword

$$\begin{aligned} t=(t_0,t_1,\ldots ,t_{n-1})=uH. \end{aligned}$$

He then gives \(t_i\) to party \(P_i\) as share for each \(i\ge 1\).

Note that \(t_0=uh_0=s\). Clearly, a set of shares \(\{t_{i_1},t_{i_2},\ldots ,t_{i_{m}}\}\), \(1\le i_1< \cdots < i_m \le n-1\) and \(1 \le m \le n-1\), determines the secret if and only if \(h_0\) is a linear combination of \(h_{i_1},h_{i_2}\ldots ,h_{i_m}\). Generally, we have the following result.

Lemma 3

(Massey 1993) Let G be a generator matrix of an \([n,k]_q\) linear code C. In the secret sharing scheme based on C, a set of shares \(\{t_{i_1},t_{i_2},\ldots ,t_{i_{m}}\}\), \(1\le i_1< \cdots < i_m \le n-1\) and \(1 \le m \le n-1\), determines the secret if and only if there is a codeword \((1,0,\ldots ,0,c_{i_1},0,\ldots ,0,c_{i_m},0,\ldots ,0)\) in the dual code \(C^\perp \), where \(c_{i_j}\ne 0\) for at least one j.

To describe the secret sharing scheme of a linear code, we also need to introduce the covering problem of linear codes.

The support of a vector \(c=(c_0,c_1,\ldots ,c_{n-1})\) is defined as the set \(\{0\le i \le n-1~|~c_i \ne 0\}\). We say that a vector \(c_1\) covers a vector \(c_2\) if the support of \(c_1\) contains that of \(c_2\) as a proper subsets. If a nonzero codeword c covers only its scalar multiples, but no other nonzero codewords, then it is called a minimal codeword. The covering problem of a linear code C is to determine its all minimal codewords. This is a very hard problem in general, but can be solved for certain types of linear codes. From Lemma 3, we can see that there is a one-to-one correspondence between the set of minimal qualified sets and the set of minimal codewords with 1 as its first component in the dual code \(C^\perp \).

The access structure of the secret sharing scheme based on a linear code is very complex in general, but can be determined in certain special cases.

Lemma 4

(Ding and Yuan 2003) Let C be an \([n,k]_q\) linear code and \(G=[g_0,g_1,\ldots ,g_{n-1}]\) be its generator matrix. If each nonzero codeword of C is a minimal codeword, then in the secret sharing scheme based on \(C^\perp \), there are altogether \(q^{k-1}\) minimal qualified sets. In addition, we have the following:

  1. 1.

    If \(g_i\) is a multiple of \(g_0\), \(1\le i \le n-1\), then participant \(P_i\) must be in every minimal qualified set.

  2. 2.

    If \(g_i\) is not a multiple of \(g_0\), \(1\le i \le n-1\), then participant \(P_i\) must be in \((q-1)q^{k-2}\) out of \(q^{k-1}\) minimal qualified set.

When the conditions of Lemma 3 are satisfied, the secret sharing scheme based on the dual code \(C^\perp \) is interesting. In the following, we give a lemma to construct a linear code whose nonzero codewords are all minimal.

Lemma 5

(Ashikhmin and Barg 1998) In an \([n,k]_q\) linear code C, let \(w_{\min }\) and \(w_{\max }\) be the minimum and maximum nonzero weights, respectively. If \(\frac{w_{\min }}{w_{\max }}> \frac{q-1}{q}\), then all the codewords of C are minimal.

Let \(G_{k,u}^\alpha \) and \(G_{k,u}^\beta \) be the generator matrices of the torsion codes \(M_{k,u}^\alpha \) and \(M_{k,u}^\beta \), respectively. In the following, we will prove that all the codewords of the torsion codes \(M_{k,u}^\alpha \) and \(M_{k,u}^\beta \) are minimal.

Proposition 1

In the secret sharing scheme based on \({M_{k,u}^\alpha }^\perp \), there are \(p^{3k}-p^{3u}-1\) participants and \(p^{k-1}\) minimal qualified sets. If the ith column of \(G_{k,u}^\alpha \) is a multiple of the 0th column of \(G_{k,u}^\alpha \), then participant \(P_i\) is in every minimal qualified set. Otherwise, each participant \(P_i\) is involved in exactly \((p-1)p^{k-2}\) out of \(p^{k-1}\) minimal qualified sets.

Proof

Let \(w_{\min }\) and \(w_{\max }\) be the minimum and maximum nonzero weights in the torsion code \(M_{k,u}^\alpha \). From Theorem 1, we know that \(w_{\min }=(p-1)(p^{3k-1}-p^{3u-1})\) and \(w_{\max }=(p-1)p^{3k-1}\). Therefore, we have

$$\begin{aligned} \frac{w_{\min }}{w_{\max }}=\frac{(p-1)(p^{3k-1}-p^{3u-1})}{(p-1)p^{3k-1}}=1-\frac{1}{p^{3(k-u)}}> \frac{p-1}{p}, \end{aligned}$$

where \(1\le u \le k-1\). By Lemma 5, we have that all the codewords of \(M_{k,u}^\alpha \) are minimal. Then, the conclusion comes from Lemma 4. \(\square \)

Proposition 2

In the secret sharing scheme based on \({M_{k,u}^\beta }^\perp \), there are \(\frac{(p^k-1)^3-(p^u-1)^3}{(p-1)^3}-1\) participants and \(p^{k-1}\) minimal qualified sets. If the ith column of \(G_{k,u}^\beta \) is a multiple of the 0th column of \(G_{k,u}^\beta \), then participant \(P_i\) is in every minimal qualified set. Otherwise each participant \(P_i\) is involved in exactly \((p-1)p^{k-2}\) out of \(p^{k-1}\) minimal qualified sets.

Proof

Let \(w_{\min }\) and \(w_{\max }\) be the minimum and maximum nonzero weights in the torsion code \(M_{k,u}^\beta \). From Theorem 2, we know that

$$\begin{aligned} \begin{aligned} w_{\min }=\frac{p^{k-1}(p^k-1)^2-p^{u-1}(p^u-1)^2}{(p-1)^2}\quad \mathrm{and}\quad w_{\max }=\frac{p^{k-1}(p^k-1)^2}{(p-1)^2}. \end{aligned} \end{aligned}$$

Therefore, we have

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

where \(2\le u \le k-1\). By Lemma 5, we have that all the codewords of \(M_{k,u}^\beta \) are minimal. Then, the conclusion comes from Lemma 4. \(\square \)

Example 2

By Example 1, we have that the Hamming weight distributions of torsion code \(M_{3,2}^\beta \) are \(A_H(0)=1\), \(A_H(1473)=24\) and \(A_H(1521)=2\). In the following, we construct secret sharing schemes based on \(M_{3,2}^{\beta ^\perp }\). We have 2132 participants and 9 minimal qualified sets. We can consider participants \(P_i\), where \(i\in Q=\){3, 5, 9, 12, 13, 18, 21, 22, 81, 84, 85, 90, 93, 94, 99, 102, 103, 108, 111, 112, 117, 120, 121, 126, 129, 130, 243, 246, 247, 252, 255, 256, 261, 264, 265, 324, 327, 328, 333, 336, 337, 342, 345, 346, 351, 354, 355, 360, 363, 364, 369, 372, 373, 486, 489, 490, 495, 498, 499, 504, 507, 508, 567, 570, 571, 576, 579, 580, 585, 588, 589, 594, 597, 598, 603, 606, 607, 612, 615, 616, 1055, 1056, 1061, 1116, 1119, 1120, 1125, 1128, 1129, 1134, 1137, 1138, 1143, 1146, 1147, 1152, 1155, 1156, 1161, 1164, 1165, 1278, 1281, 1282, 1287, 1290, 1291, 1296, 1299, 1300, 1325, 1326, 1331, 1334, 1335, 1340, 1379, 1380, 1385, 1440, 1443, 1444, 1449, 1452, 1453, 1458, 1461 1462, 1467, 1470, 1471, 1476, 1479, 1480, 1485, 1487, 1489, 1602, 1605, 1606, 1611, 1614, 1615, 1620, 1623, 1624, 1649, 1650, 1655, 1658, 1659, 1664, 1703, 1758, 1761, 1762, 1767, 1770, 1771, 1776, 1779, 1780, 1805, 1806, 1811, 1832, 1833, 1838}.

Since these columns of \(G_{3,2}^\beta \) are multiples of the 0th column of \(G_{3,2}^\beta \), then these participants \(P_i\), \(i\in Q\) must be in every minimal qualified set. Other participants \(P_j\) must be in exactly 6 out of 9 minimal qualified sets, where \(0< j\notin Q\).

4 Association schemes from MacDonald codes over R

In Luo et al. (2018), the authors obtained a class of linear codes with two weights over \({\mathbb {F}}_q\). They also employed these linear codes to construct association schemes. Similarly, we can use MacDonald codes of type \(\alpha \) over R to construct association schemes. Let X be a finite set with the cardinality of X greater than 2. Denote by \(X\times X\) the Cartesian product of X. For a positive integer d, consider a set \(L=\{L_0, L_1, \ldots , L_d\}\), where \(L_i\), \(i=0,1,\ldots ,d\), is a subset of \(X\times X\).

Definition 3

(Luo et al. 2018) Let X be a finite set with the cardinality of X greater than 2, \(L_0=\{(a,a)|~a\in X\}\), \(L_i=\{(a,b)|~a,b\in X\}\), \(i=1,2,\ldots ,d\). Let \(X\times X\) is a disjoint union of \(L_0, L_1, \ldots , L_d\). For each integer \(i,j,k\in \{0,1,\ldots ,d\}\), there exists an integer \(j\in \{0,1,\ldots ,d\}\) such that \(L_j=L_i^t\), where \(L_i^t=\{(a,b)|~(b,a)\in L_i\}\). And each pair \((a,b)\in L_k\), the cardinality of set \(\{c\in X|~(a,c)\in L_i, (c,b)\in L_j\}\) is equal to a constant integer \(p_{ij}^k\). Then, the pair (XL) is called a d-class association scheme.

Let \(X={\mathbb {F}}_p^n\). For any \(\mathbf{x },\mathbf{y }\in X\), denote the Hamming distance of \(\mathbf{x }\) and \(\mathbf{y }\) by \(d(\mathbf{x },\mathbf{y })\), where \(d(\mathbf{x },\mathbf{y })=\#\{i~|~1\le i \le n, x_i\ne y_i\}\). Let \(L_i=\{(\mathbf{x },\mathbf{y })\in {\mathbb {F}}_p^n\times {\mathbb {F}}_p^n |~d(\mathbf{x },\mathbf{y })=i\}\), \(L=\{L_0, L_1, \ldots , L_d\}\). Then, \(({\mathbb {F}}_p^n, L)\) is an n-class association scheme known as the Hamming association scheme.

In Luo et al. (2018), the authors give a necessary and sufficient condition for constructing a 2-class association scheme from a linear code with parameters [n, 2].

Lemma 6

(Luo et al. 2018) Assume that C is an [n, 2] linear code over \({\mathbb {F}}_q\) with nonzero weights \(w_1\) and \(w_2\). Let \(c_1\), \(c_2\) be two codewords of C such that \(c_1\), \(c_2\) are linear independent and \(w(c_1)=w(c_2)=w_1\). For any \(a,b\in {\mathbb {F}}_q^*\), if \(w(ac_1+bc_2)=w_2\), then the restriction to C of the Hamming association scheme is a 2-class association scheme if and only if \(w_2\ne w_1+1\).

In the following, we give an proposition to show that 2-class association schemes can be constructed by MacDonald codes over \({\mathbb {F}}_q+v{\mathbb {F}}_q+v^2{\mathbb {F}}_q\).

Proposition 3

Let \(M_{2,1}^\alpha \) be a torsion code of MacDonald codes of type \(\alpha \) over the ring \({\mathbb {F}}_p+v{\mathbb {F}}_p+v^2{\mathbb {F}}_p\) with \(v^3=v\). Let \(c_1\), \(c_2\) be two codewords of \(M_{2,1}^\alpha \) such that \(c_1\), \(c_2\) are linear independent and \(w(c_1)=w(c_2)=w_1\). For any \(a,b\in {\mathbb {F}}_p^*\), if \(w(ac_1+bc_2)=w_2\), then the restriction to \(M_{2,1}^\alpha \) of the Hamming association scheme is a 2-class association scheme.

Proof

By Theorem 1, we have that \(M_{2,1}^\alpha \) is an \([p^6-p^3,2,(p-1)(p^5-p^2)]\) linear code over \({\mathbb {F}}_q\) with nonzero weights \(w_1=(p-1)(p^5-p^2)\) and \(w_2=(p-1)p^5\). Clearly, \(w_1+1\ne w_2\) for p is an odd prime. Then, the conclusion comes from Lemma 6. \(\square \)

Example 3

Consider the torsion code \(M_{2,1}^\alpha \) of MacDonald codes of type \(\alpha \) over the ring \({\mathbb {F}}_3+v{\mathbb {F}}_3+v^2{\mathbb {F}}_3\) with \(v^3=v\). The generator matrix \(G_{2,1}^{\alpha '}\) of \(M_{2,1}^\alpha \) is given by

$$\begin{aligned} G_{2,1}^{\alpha '}= \left[ \begin{array}{cccccccccccccccc} 1&{}2&{}0&{}0&{}1&{}2&{}2&{}1&{}A&{}A\\ G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '}&{}G_1^{\alpha '} \end{array}\right] , \end{aligned}$$

where \(A=[0~1~2~0~0~1~2~2~1]\). By the Magma computational algebra system (Bosma et al. 1997), the torsion code \(M_{2,1}^\alpha \) is a 3-ary [702, 2, 468] code with Hamming weight distributions \(A_H(0)=1\), \(A_H(468)=6\) and \(A_H(486)=2\).

Let \(c_0=\) (0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1,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 1, 2, 0, 0, 1, 2, 2, 1, 1, 2, 0, 1, 1, 2, 0, 0, 2, 1, 2, 0, 1, 1, 2, 0, 0, 2, 1, 2, 0, 1, 1, 2, 0, 0, 2, 2, 0, 1, 2, 2, 0, 1, 1, 0, 2, 0, 1, 2, 2, 0, 1, 1, 0, 2, 0, 1, 2, 2, 0, 1, 1, 0, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 0, 1, 2, 0, 0, 1, 2, 2, 1, 1, 2, 0, 1, 1, 2, 0, 0, 2, 1, 2, 0, 1, 1, 2, 0, 0, 2, 1, 2, 0, 1, 1, 2, 0, 0, 2, 2, 0, 1, 2, 2, 0, 1, 1, 0, 2, 0, 1, 2, 2, 0, 1, 1, 0, 2, 0, 1, 2, 2, 0, 1, 1, 0, 1, 2, 0, 1, 1, 2, 0, 0, 2, 1, 2, 0, 1, 1, 2, 0, 0, 2, 1, 2, 0, 1, 1, 2, 0, 0, 2, 2, 0, 1, 2, 2, 0, 1, 1, 0, 2, 0, 1, 2, 2, 0, 1, 1, 0, 2, 0, 1, 2, 2, 0, 1, 1, 0). We find that both codewords \(c_0\) and \(c_1\) are linear independent and \(w(c_0)=w(c_1)=468\), \(2w(c_0)+w(c_1)=486\). Consequently, the restriction to \(M_{2,1}^\alpha \) of the Hamming scheme is a 2-class association scheme.

5 Conclusion

In this paper, we studied MacDonald codes over the finite non-chain ring \({\mathbb {F}}_p+v{\mathbb {F}}_p+v^2{\mathbb {F}}_p\), where p is an odd prime and \(v^3=v\). Some applications of MacDonald codes were also investigated in this paper. For \(p=2\), the ring \({\mathbb {F}}_2+v{\mathbb {F}}_2+v^2{\mathbb {F}}_2\) has different structural properties from the ring \({\mathbb {F}}_p+v{\mathbb {F}}_p+v^2{\mathbb {F}}_p\) with p an odd prime (see Shi et al. 2013). It is interesting to consider MacDonald codes and their applications over this ring. Further, the ring \({\mathbb {F}}_p+v{\mathbb {F}}_p+v^2{\mathbb {F}}_p\) is the special case of the ring \({\mathbb {F}}_p[v]/\langle v^m-v\rangle \) with \(m=3\). Based on the complexity of the generator matrix of MacDonald codes, considering MacDonald codes and their applications over the general finite non-chain ring \({\mathbb {F}}_p[v]/\langle v^m-v\rangle \) may be an interesting and challenging work.