From c9afbce2dc59ff471d6d78a4a0e03b9cdbe762fb Mon Sep 17 00:00:00 2001 From: Wind Wong Date: Fri, 9 Dec 2022 09:28:02 +0000 Subject: [PATCH] field arithmetic cleanup Co-authored-by: Armando Faz --- math/gf4096/gf4096.go | 8 ++++---- math/gf4096/gf_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/math/gf4096/gf4096.go b/math/gf4096/gf4096.go index bc4b9db3..baba3541 100644 --- a/math/gf4096/gf4096.go +++ b/math/gf4096/gf4096.go @@ -2,11 +2,11 @@ package gf4096 // Gf is a field element of characteristic 2 modulo z^12 + z^3 + 1 -type Gf = uint16 +type Elt = uint16 const ( - GfBits = 12 - GfMask = (1 << GfBits) - 1 + Bits = 12 + Mask = (1 << Bits) - 1 ) // Add two Gf elements together. Since an addition in Gf(2) is the same as XOR, @@ -37,7 +37,7 @@ func Mul(a, b Gf) Gf { tmp ^= t >> 9 tmp ^= t >> 12 - return uint16(tmp & GfMask) + return Elt(tmp & Mask) } // sqr calculates the square of Gf element a diff --git a/math/gf4096/gf_test.go b/math/gf4096/gf_test.go index 61c7b26c..43add0ce 100644 --- a/math/gf4096/gf_test.go +++ b/math/gf4096/gf_test.go @@ -17,7 +17,7 @@ type ( func assertEq(t *testing.T, a, b Gf) { t.Helper() if a != b { - test.ReportError(t, b, a) + test.ReportError(t, a, b) } }