diff --git a/gen.go b/gen.go index 70febb3..789ad94 100644 --- a/gen.go +++ b/gen.go @@ -24,13 +24,13 @@ func main() { // Rotation constants x, y := 1, 0 for i := 1; i < 25; i++ { - rotc[x][y] = (i*(i+1)/2) % 64 + rotc[x][y] = (i * (i + 1) / 2) % 64 x, y = y, (2*x+3*y)%5 } var ctx = struct { Rotc [5][5]int - } { + }{ rotc, } err := tmpl.Execute(os.Stdout, &ctx) @@ -41,14 +41,14 @@ func main() { func count(n int) []int { var out = make([]int, n) - for i := 0; i < n; i ++ { + for i := 0; i < n; i++ { out[i] = i } return out } func add(a, b, m int) int { - return (a+b) % m + return (a + b) % m } func sub(a, b int) int { @@ -56,14 +56,14 @@ func sub(a, b int) int { } func mul(a, b int) int { - return a*b + return a * b } var funcs = template.FuncMap{ "count": count, - "add": add, - "sub": sub, - "mul": mul, + "add": add, + "sub": sub, + "mul": mul, } var tmpl = template.Must(template.New("keccak").Funcs(funcs).Parse(` diff --git a/sponge.go b/sponge.go index d43914e..0b12c86 100644 --- a/sponge.go +++ b/sponge.go @@ -10,18 +10,18 @@ var round = roundGo // digest implements hash.Hash type digest struct { - a [5][5]uint64 // a[y][x][z] - buf [200]byte + a [5][5]uint64 // a[y][x][z] + buf [200]byte dsbyte byte - len int - size int + len int + size int } -func New256() hash.Hash { return &digest{size: 256/8, dsbyte: 0x06} } -func New512() hash.Hash { return &digest{size: 512/8, dsbyte: 0x06} } +func New256() hash.Hash { return &digest{size: 256 / 8, dsbyte: 0x06} } +func New512() hash.Hash { return &digest{size: 512 / 8, dsbyte: 0x06} } -func newKeccak256() hash.Hash { return &digest{size: 256/8, dsbyte: 0x01} } -func newKeccak512() hash.Hash { return &digest{size: 512/8, dsbyte: 0x01} } +func newKeccak256() hash.Hash { return &digest{size: 256 / 8, dsbyte: 0x01} } +func newKeccak512() hash.Hash { return &digest{size: 512 / 8, dsbyte: 0x01} } func (d *digest) Size() int { return d.size } func (d *digest) BlockSize() int { return 200 - d.size*2 } @@ -40,7 +40,7 @@ func (d *digest) Write(b []byte) (int, error) { n := copy(d.buf[d.len:bs], b) d.len += n b = b[n:] - if d.len == bs { + if d.len == bs { d.flush() } }