Skip to content

Commit 9e75216

Browse files
whyvlarmfazh
andcommitted
field arithmetic cleanup
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
1 parent d81cf1e commit 9e75216

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

math/gf4096/gf4096.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
package gf4096
33

44
// Gf is a field element of characteristic 2 modulo z^12 + z^3 + 1
5-
type Gf = uint16
5+
type Elt = uint16
66

77
const (
8-
GfBits = 12
9-
GfMask = (1 << GfBits) - 1
8+
Bits = 12
9+
Mask = (1 << Bits) - 1
1010
)
1111

1212
// 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 {
3737
tmp ^= t >> 9
3838
tmp ^= t >> 12
3939

40-
return uint16(tmp & GfMask)
40+
return Elt(tmp & Mask)
4141
}
4242

4343
// sqr calculates the square of Gf element a

math/gf4096/gf_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ type (
1515
)
1616

1717
func assertEq(t *testing.T, a, b Gf) {
18+
t.Helper()
1819
if a != b {
19-
test.ReportError(t, b, a)
20+
test.ReportError(t, a, b)
2021
}
2122
}
2223

0 commit comments

Comments
 (0)