Skip to content

Commit

Permalink
field arithmetic cleanup
Browse files Browse the repository at this point in the history
Co-authored-by: Armando Faz <[email protected]>
  • Loading branch information
pufferffish and armfazh authored Dec 9, 2022
1 parent a4bc835 commit c9afbce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions math/gf4096/gf4096.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion math/gf4096/gf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit c9afbce

Please sign in to comment.