The Hamming and Golay Number-Theoretic Transforms A. J. A. Paschoal , R. M. Campello de Souza and H. M. de Oliveira

Abstract— New number-theoretic transforms are derived from II.NEW FINITE FIELD TRANSFORMS DERIVED FROM known linear block codes over finite fields. In particular, two BLOCKCODES new such transforms are built from perfect codes, namely the Hamming number-theoretic transform and the Golay number- In [4] Campello de Souza and coworkers used the fact that theoretic transform. A few properties of these new transforms for every linear transform T , its eigenvectors v satisfy are presented. [T − λ ] v = 0, (1) Keywords— Number-theoretic transforms (NTT), Finite fields, I Linear block codes, Perfect codes, Perfect transforms. where λ denotes the eigenvalue associated with v, to show that it is possible to get an associated parity-check matrix for a simply by row reducing the matrix [T − λI]. In this paper we go on a somewhat opposite direction, i.e., starting I.PRELIMINARIES from a linear block code, it is possible to derive a new linear transformation (associated with the generating block code) by Digital transforms are an interesting way to construct completing the parity-check matrix, adding k rows, so as to linear block codes for error correction [4], [5]. Fourier and form a square matrix He and adding it to the matrix λI, i.e., Hartley codes were defined associated with the Fourier number-theoretic transform and the Hartley number-theoretic T = He + λI. (2) transform, respectively. Recently, a new family of multilevel codes – the Pascal codes [14] - has been proposed, which Indeed, λ must be chosen so as to guarantee that det T 6= 0. are constructed from the Pascal number-theoretic transform Such transform receives the name of the linear block code [13]. Also recently, Paschoal [14] proposed a reverse way whose parity matrix was used to derive it. to conceive new digital transforms from known linear block The number of vectors on the whole space of all the N- N codes. Here we present the technique used to engender tuples over GF (p) is p (with no redundancy). The set of two new transforms over finite fields, namely the Hamming all eigenvectors of a transform of length N defined over a Number-Theoretic Transform (HamNT) and the Golay finite field always engender a subspace denoted by V, with Number-Theoretic Transform (GolNT). From now on these dimension k < N with GF (p)-valued components. transforms, based on Perfect Codes, are referred to as “Perfect Definition 1: (perfect transform). A transform T of length Transforms”. Tietav¨ ainen¨ demonstrated in 1971 that the only N over GF (p) is said to be perfect if and only if there is existing perfect block codes over GF (p) are [18] : an integer t such that the eigenvectors subspace V of T has dimension meeting the sphere-packing bound

 pm−1 pm−1  " t # • Hamming codes N = , k = − m, d = 3 . X N p−1 p−1 dim = k = N − log (p − 1)i . (3) V p i • (N = 23, k = 12, d = 7). i=0

arXiv:1806.09727v2 [cs.IT] 25 Sep 2018 The eigenvector subspace of T is a perfect block code [18] • Ternary Golay code (N = 11, k = 6, d = 5). when T is a perfect transform. The perfect codes are also deeply linked to the lattices in III.THE HAMMING NUMBER-THEORETIC TRANSFORM Euclidean spaces [6]. Only the E8 Gosset lattice (associated with the extended Hamming code) and the Λ24 In this section, we illustrate the aforementioned technique (associated with the extended binary Golay code) are perfect splitting it in two ways: sphere packings. a) Fulfilling the Hamming parity-check matrix by adding null rows or using linear combinations of its own rows. b) Cyclic rotating the parity polynomial, h(x). A. J. A. Paschoal, Pernambuco Federal Institute of Education, Sci- ence and Technology (IFPE), Caruaru-PE, Brazil. E-mail: arquime- [email protected]. R. M. Campello de Souza, Federal University of Pernambuco (UFPE), A. The Standard Hamming Number-Theoretic Transform Recife - PE, Brazil. E-mail: [email protected]. H. M. de Oliveira, Statistics department (UFPE), Recife-PE, Brazil. E-mail: Consider the binary Hamming code H(7, 4, 3), with parity- [email protected]. check matrix (reduced row echelon form) T (v0, v1, ··· , vN−1) , vi ∈ GF (p), is the sequence V =  1 1 0 1 1 0 0  T H = 1 1 1 0 0 1 0 . (V0,V1, ··· ,VN−1) ,Vk ∈ GF (p), given by 1 0 1 1 0 0 1 V = T (λ) · v, (4) In this case, in order to construct the Hamming Number- HAM (λ) (λ) Theoretic Transform (HamNT) matrix, THamNT , we need where THAM is the Hamming transformation matrix over to add four rows to this parity matrix to get the matrix GF (p), parametrized by eigenvalue λ. He. Such additional rows are merely null rows. This new The only natural property is that this transformation is linear, matrix, named He, is added to λIN , where λ = 1 is the since the distributive property of multiplication relative to eigenvalue over GF (2) and IN = I7 is the identity matrix addition holds by matrices. Furthermore, all the codewords of dimension 7. Note that, in fact, the eigenvalues are of the classic Hamming code are invariant under the HamNT. unknown and we should test all the possible candidates Example 1: (nonbinary Hamming transform). Consider the eliminating all those that result in a singular transformation ternary Hamming code H(13, 10, 3) whose parity-check ma- matrix. The different eigenvalues may produce different trix is   transformation matrices. From the binary Hamming code, 0000111111111 we get the 7×7 binary HamNT whose transformation matrix is H =  0111000111222  . 1012012012012  0 1 0 1 1 0 0  1 0 1 0 0 1 0 The transform matrix of the ternary Hamming transform, with  1 0 0 1 0 0 1  (1)   eigenvalue λ = 1, is given by T =  0 0 0 1 0 0 0  . HamNT  0 0 0 0 1 0 0   1000111111111   0 0 0 0 0 1 0   0211000111222  0 0 0 0 0 0 1  1022012012012    The eigenvector matrix is given by  0001000000000   0000100000000   1 1 0 0 0 0 1     0000010000000  (1) 1 1 1 0 0 1 0 (1)   eig THAM =   = G,  0000001000000  1 0 1 0 1 0 0 THAM =   . 0 1 1 1 0 0 0  0000000100000     0000000010000  which is the of the Hamming code H(7, 4, 3).    0000000001000  Note that 7 − log2(1 + 7) = 4 = dim V. Figure 1 shows the    0000000000100  implementation of the binary Hamming Transform 7 × 7.  0000000000010  0000000000001 This kind of construction makes it harder to find the properties of such a transform. In what follows we adopt a polynomial approach.

B. The Cyclic Hamming Transform Another way to represent the Hamming transform over GF (p) introduced in the previous subsection is considering the parity-check matrix H as expressed in the form

 h(x)   xh(x)   2   x h(x)  H =   ,  .   .  xn−k−1h(x) where h(x) is the parity polynomial of the cyclic Hamming code over GF (p) [12]. The k rows necessary to construct the matrix He are generated by cyclic shifting the parity polynomial, h(x). Example 2: Consider the binary Hamming H(7, 4, 3) with parity polynomial given by h(x) = x4 + x2 + Fig. 1 x + 1. The parity-check matrix H is given by BLOCKDIAGRAMFORTHEBINARY HAMMING TRANSFORMOFLENGTH 7.  1 0 1 1 1 0 0  H =  0 1 0 1 1 1 0  . Definition 2: The Hamming Number-Theoretic Transform, 0 0 1 0 1 1 1 with length N = (pm − 1)/(p − 1), of the sequence v = The transformation matrix, in this case, is   Note that this definition paves the way for an algebraic 1 0 1 1 1 0 0 treatment of the properties of the CHamNT.  0 1 0 1 1 1 0    (1)  0 0 1 0 1 1 1  Proposition 1: The matrix THAM is a circulant matrix. (λ)   T =  1 0 0 1 0 1 1  + λI7. HAM   The procedure to generate He by means of cyclic shifts of  1 1 0 0 1 0 1  the parity polynomial, h(x), results in a circulant matrix. This  1 1 1 0 0 1 0    aspect is not modified by adding λIN to this matrix. 0 1 1 1 0 0 1 Taking λ = 1 results in the cyclic form of the binary Hamming C. Some of Properties of the Cyclic Hamming Number- transformation matrix (the inverse matrix is also circulant) Theoretic Transform  0 0 1 1 1 0 0  i) Linearity  0 0 0 1 1 1 0  ii) Time shift    0 0 0 0 1 1 1  Consider the sequence vb = (vb0, ··· , vbN−1) where vbi = ˜(1)   v . Then, v ↔ V, where THAM =  1 0 0 0 0 1 1  . i−m b b    1 1 0 0 0 0 1  m   Vb = x V. (5)  1 1 1 0 0 0 0  0 1 1 1 0 0 0 Demonstration: Note that we are considering, without loss of generality, a cyclic shift of m positions to m N (1) (1)  the right. Therefore, we have v = x v (mod x − 1). The transform matrices T and T˜ , ilustrated in Fig.2, b HAM HAM Then, are different representations for the Hamming transform over   m GF (2). Note that, by considering the rows of λ as cyclic [h(x) + λ(x)]  x v0  IN m shifts of the vector [λ00 ··· 0], in polynomial notation, we can  x[h(x) + λ(x)]  x v1  x2[h(x) + λ(x)]   xmv  write Vb =    2   .   .   .   .    m λ(x) xN−1[h(x) + λ(x)] x vN−1  xλ(x)   x2λ(x)    λ N =   . [h(x) + λ(x)]   I   v0  .   x[h(x) + λ(x)]   .  v1 m  x2[h(x) + λ(x)]    xN−1λ = x    .   .   .   .      v xN−1[h(x) + λ(x)] N−1 = xmV.

iii) Frequency shift Consider the sequence Vb = (Vb0, ··· , VbN−1) where Vbk = l Vk−l. Then, vb = x v. The demonstration is similar to the previous one. iv) Constant sequence transform The transform of a sequence v = (r, r, ··· , r) is the Fig. 2 sequence Vk = r · weight(h(x)), ∀k. (1) ˜(1) This property means that the Hamming transform of a ILLUSTRATION OF HAMMING TRANSFORMS: THAM , THAM . constant vector is also a constant vector. This contrasts sharply with the discrete Fourier transform, where there Definition 3: The Cyclic Hamming Number-Theoretic is a trade-off between the two domains and compressing Transform (CHamNT), with length N = (pm − 1)/(p − 1), of into one domain implies expanding into the other. T the sequence v = (v0, v1, ··· , vN−1) , vi ∈ GF (p), is the v) Impulse sequence transform T sequence V = (V0, V1, ··· , VN−1) , Vk ∈ GF (p), such The transform of the sequence δ = (1, 0, ··· , 0), cor- ˜ (λ) (λ) that V = THAM · v, where responds to the first column of the matrix TH , i.e., the coefficients of x[h(x) + λ(x)].  [h(x) + λ(x)]  IV. THE GOLAY NUMBER-THEORETIC TRANSFORM  x[h(x) + λ(x)]   2  T (λ) (x) =  x [h(x) + λ(x)]  . There exist two Golay codes, the binary G(23, 12, 7) HAM   12 11 10 9 8 5 2  .  (h(x) = x + x + x + x + x + x + x + 1) and the  .  6 5 4 3 2 N−1 ternary G(11, 6, 5) (h(x) = x + 2x + 2x + 2x + x + 1). x [h(x) + λ(x)] Like in the previous section, to define the Golay number  theoretic transform, we adopt a polynomial approach.  21122010000  A. The Binary Golay Transform 12210201000  12201200100  The construction of the transformation matrix of the Cy-  12022100010   10222100001  clic Golay Transform follows the same steps used in the (1)  00000100000  TGolNT =   . construction of the Cyclic Hamming Transform. Note that  00000010000  12 23  00000001000  2 [1 + 23 + 253 + 1771] = 2 and that 23 − log2(1 + 23 +    00000000100  253 + 1771) = 12 = dim V. 00000000010 The Golay binary G(23, 12, 7) code has parity polynomial 00000000001 12 11 10 9 8 5 2 h(x) = x + x + x + x + x + x + x + 1, so that This transform has the characteristic polynomial p(x) = 1 + 2x3 +2x4 +x5 +2x6 +2x7 +x8 +x9 +2x10 +x11, eigenvalue 01111001001010000000000 00111100100101000000000 λ = 1 and determinant equals to 2. In this transform, the   00011110010010100000000 eigenvector subspace associated with λ = 1 has dimension 00001111001001010000000 (1) 00000111100100101000000 dim V = 11−log3(1+22+220) = 6. Note that TCGolNT and   (1) 00000011110010010100000 T are different representations for the Golay transform   GolNT 00000001111001001010000 of length 11 over GF (3), the first one being in the form of a 00000000111100100101000   circulating matrix. 00000000011110010010100 00000000001111001001010 00000000000111100100101 (λ)   T (x) = 10000000000011110010010 , C. A few properties of the cyclic Golay Number-Theoretic CGolNT   01000000000001111001001 Transform 10100000000000111100100   01010000000000011110010 i) Linearity 00101000000000001111001   ii) Time shift 10010100000000000111100 01001010000000000011110 Consider the sequence vb = (vb0, ··· , vbN−1) where vbi = 00100101000000000001111   vi−m. Then, v ↔ Vb , where 10010010100000000000111 b 11001001010000000000011 m 11100100101000000000001 Vb = x V. 11110010010100000000000 iii) Frequency shift the determinant of which is equals to one. Consider the sequence Vb = (Vb0, ··· , VbN−1) where Vbk = l Vk−l. Then, vb = x v. B. The Ternary Golay Transform iv) Constant sequence transform The Golay ternary parity polynomial is h(x) = x6 + 2x5 + The transform of the sequence v = (r, r, ··· , r) is the 2x4 +2x3 +x2 +1. Considering λ = 1 as eigenvalue, we have sequence Vk = r · weight(h(x)), ∀k. the following circulant form for the Golay transform matrix: v) Impulse sequence transform The transform of the sequence δ = (1, 0, ··· , 0), corres-  22221010000  (λ) 02222101000 ponds to the first column of the matrix TCGolNT , i.e., the  00222210100  coefficients of the polynomial x[h(x) + λ(x)].  00022221010   00002222101  (1) These properties hold for both the binary and ternary Golay  10000222210  TCGolNT =   .  01000022221  transform, simply using the corresponding parity polynomial.    10100002222   21010000222  22101000022 V. GOLAY EXTENDED TRANSFORM 22210100002 The ternary eigenvector space of the Golay transform consists The extended versions of the Hamming or Golay codes, of 36 = 729 vectors [16]. According to Sagemath R , this trans- which are selfdual codes [6], can be used to construct new formation matrix has multiplicative order 242, characteristic transforms. For the ternary Golay codes, the extended Golay polynomial (2 + x)6(1 + x + x2 + x3 + 2x4 + x5) and λ = 1 code has parameters G(N = 12, k = 6, d = 6) over GF (3). is an eigenvalue with algebraic multiplicity 6. One possible approach over this field is to take into account In the next example, we consider the construction of the that 2 ≡ −1 and the transform matrix can be viewed only as ternary Golay transform starting from the systematic form of computing additions (multiplication free transform). It should the Golay code parity-check matrix. be interesting to compare it with Hadamard transforms [9]. Example 3: Consider the ternary Golay code G(11, 6, 5) The extended Golay parity-check matrix is given by whose parity-check matrix is  0 −1 −1 −1 −1 −1 1 0 0 0 0 0    −1 0 −1 1 1 −1 0 1 0 0 0 0 11122010000  −1 −1 0 −1 1 1 0 0 1 0 0 0  11210201000   H =  −1 1 −1 0 −1 1 0 0 0 1 0 0  . H =  12101200100  .    12012100010  −1 1 1 −1 0 1 0 0 0 0 1 0 10221100001 −1 −1 1 1 −1 0 0 0 0 0 0 1 We inflate this matrix to a square matrix by adding null rows. Inflating this matrix to a square matrix by adding the following To this matrix we add λI11. Assuming λ = 1, it leads to (arbitrary) linear combinations: l1 + l2, l1 + l3, l1 + l4, l1 + l5, l1 + l6 e l2 + l3, then adding λI12, and assuming λ = 1, REFERENCES results in the 12 × 12 transform matrix [1] A. Amira, A. Bouridane, P. Milligan and M. Roula. ”Novel FPGA implementations of Walsh-Hadamard transforms for signal processing.”  1 −1 −1 −1 −1 −1 1 0 0 0 0 0  IEE Proceedings-Vision, Image and Signal Processing 148.6 377-383, −1 1 −1 1 1 −1 0 1 0 0 0 0   2001 doi: 10.1049/ip-vis:20010674  −1 −1 1 −1 1 1 0 0 1 0 0 0  [2] E. R. J. Berlekamp, H. Van Lint and J. J. Seidel. A survey of combi-  −1 1 −1 1 −1 1 0 0 0 1 0 0    natorial theory. Chapter 3: “A strongly regular graph derived from the  −1 1 1 −1 1 1 0 0 0 0 1 0  perfect ternary Golay code.” 25-30, 1973. doi: 10.1016/B978-0-7204- (1)  −1 −1 1 1 −1 1 0 0 0 0 0 1  T =   , 2262-7.50008-9 EG  −1 −1 1 0 0 1 −1 1 0 0 0 0  [3] S. Boussakta and A. G. J. Holt, “Number theoretic transforms and  −1 1 −1 1 0 0 1 1 1 0 0 0    their applications in image processing,” Advances in imaging and  −1 0 1 −1 1 0 1 0 1 1 0 0  electron physics, Vol. 111. Elsevier, 1-90, 1999. doi: 10.1016/S1076-  −1 0 0 1 −1 0 1 0 0 1 1 0  5670(08)70216-7  −1 1 0 0 1 −1 1 0 0 0 1 1  [4] R. M. Campello de Souza, E. S. V. Freire and H. M. de Oliveira, “Fourier 1 −1 −1 0 −1 0 0 1 1 0 0 1 codes,” In 10th International Symposium on Communication Theory and Applications, Ambleside, UK, 2009. Also available in the repository i.e., the matrix of the ternary extended Golay transform arXiv:1503.03293 [cs.IT] (1) [5] R. M. Campello de Souza, R. M. C. Britto and H. M. de Oliveira, (det TEG = 2). This new transform requires only additi- “Codigos´ de Hartley em corpos finitos,” In Anais do XXIX Simposio´ ons/subtractions in order to be computed. Their symmetries Brasileiro de Telecomunicac¸oes˜ , Curitiba, 2011. properties inherited from the selfdual structure of the space of [6] J. H. Conway and N. J. A. Sloane. Sphere packings, lattices and groups. Vol. 290. Springer Science & Business Media, 2013. eigenvectors can be attractive. The inverse transform matrix Proc. IEEE −1 [7] M. J. E. Golay, “Notes on digital coding,” 37 (1949): 657. TEG is [8] R. W. Hamming, “Error detecting and error correcting codes,” Bell Labs Technical Journal, v.29, 147-160, 1950. doi: 10.1002/j.1538-  1 0 −1 1 1 1 0 −1 1 1 1 1  7305.1950.tb00463.x −1 1 0 1 −1 0 0 −1 1 1 0 0 [9] K. J. Horadam, Hadamard Matrices and their applications, Princeton   university press, 2012.  0 1 −1 0 1 −1 −1 −1 1 −1 0 1   0 1 0 0 0 −1 1 −1 −1 1 −1 −1  [10] M. Kimizuka and R. Sasaki, “M-matrices of the Ternary Golay Code   and the Mathieu Group M ”, Tokyo J. of Math. V. 31, 111-125, 2008  1 1 0 −1 1 1 0 −1 1 0 −1 0  12  −1 −1 −1 0 0 0 1 1 1 −1 1 −1  doi: 10.3836/tjm/1219844826   , [11] P. K. Meher and J. C. Patra. “Fully-pipelined efficient architectures for  −1 0 −1 −1 0 1 1 1 −1 −1 1 1   0 1 0 1 −1 0 −1 −1 −1 0 1 −1  FPGA realization of discrete Hadamard transform.” Application-Specific   Systems, Architectures and Processors. ASAP 2008. International Con-  0 1 −1 0 1 0 1 1 1 −1 0 0   1 1 −1 0 1 −1 0 1 −1 −1 0 1  ference on. IEEE, 2008. doi: 10.1109/ASAP.2008.4580152  −1 −1 1 1 1 0 1 0 −1 0 0 0  [12] T. K. Moon. Error Correction Coding: Mathematical Methods and −1 1 1 1 0 −1 −1 1 −1 0 0 −1 Algorithms. John Wiley and Sons, 2005. [13] A. J. A. Paschoal, H. M. de Oliveira and R. M. Campello de Souza, “A Transformada Numerica´ de Pascal,” XXXIII Simposio´ Brasileiro de Finally, it is worth mentioning that since the eigenvalue is Telecomunicac¸oes˜ , SBrT’15, Juiz de Fora, 2015. unity for the direct transform, all eigenvectors of the inverse [14] A. J. A. Paschoal, Novas Transformadas em Corpos Finitos: Definic¸oes˜ e transform are the same for the direct transform. Cenarios´ de Aplicac¸ao˜ . Tese de Doutorado, Programa de Pos-Graduac¸´ ao˜ em Engenharia Eletrica´ da UFPE, 2018. [15] A. J. A. Paschoal, H. M. de Oliveira, and R. M. Campello de Souza, “No- vas Relac¸oes˜ na Matriz de Transformac¸ao˜ da Transformada Numerica´ de VI.FINAL REMARKS Pascal,” Proceeding Series of the Brazilian Society of Computational and Applied Mathematics, v.6, n. 1, 2018. doi: 10.5540/03.2018.006.01.0404 [16] V. Pless, “On the uniqueness of the Golay codes.” Journal of Combina- The introduction of the Hamming (HamNT) and Golay torial Theory 5.3,215-228, 1968. doi: 10.1016/S0021-9800(68)80067-5 (GolNT) number-theoretic transforms represents an important [17] T. M. Thompson, From error-correcting codes through sphere packings application of the theory introduced in [4], [5] and outlines to simple groups. No. 21. Cambridge University Press, 1983. [18] A. Tietav¨ ainen,¨ “On the nonexistence of perfect codes over finite the existence of some kind of isomorphism between linear fields,” SIAM Journal on Applied Mathematics 24.1, 88-96, 1973. doi: block codes and finite field transforms. All the codewords 10.1137/0124010 of the classic Hamming code are invariant under HamNT (the same happens for the Golay code and the GolNT). A APPENDIX probable link between the Golay transform and Mathieu’s A general formulation of a discrete transform from systematic simple group deserves to be investigated [6], [17]. These block codes: In the general case, starting from a block code transforms can be used in Image Processing [3]. Even if with parity-check matrix it is an introductory work of presenting new ideas, without   investigating potential applications, the strength of geometric T H = −P I(N−k)×(N−k) configurations linked to perfect codes [2], [10] seems to give (N−k)×k an inkle of the potential of these new transforms. This also we arrive at a square transform matrix, N × N, invertible, opens up interesting perspectives in designing fast algorithms given by for the computation of these transformations [1], [11].  T  λI(N−k)×k − P(N−k)×k I(N−k)×(N−k) Tblock code = . Ok×(N−k) λIk×k ACKNOWLEDGEMENTS

The authors would like to thank the support received from their institutions.