Skip to content

Commit c9afbce

Browse files
whyvlarmfazh
andauthored
field arithmetic cleanup
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
1 parent a4bc835 commit c9afbce

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-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

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type (
1717
func assertEq(t *testing.T, a, b Gf) {
1818
t.Helper()
1919
if a != b {
20-
test.ReportError(t, b, a)
20+
test.ReportError(t, a, b)
2121
}
2222
}
2323

0 commit comments

Comments
 (0)