From 49541f2eadd1155269f1ecc886a5033088dfdd8a Mon Sep 17 00:00:00 2001 From: Cool Developer Date: Mon, 11 Apr 2022 15:07:41 +0100 Subject: [PATCH] fix the lint issues --- goldenposeidon/constants.go | 10 +++++----- goldenposeidon/poseidon.go | 6 +++--- goldenposeidon/poseidon_test.go | 16 ++++++++++------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/goldenposeidon/constants.go b/goldenposeidon/constants.go index a2b3c28..1025074 100644 --- a/goldenposeidon/constants.go +++ b/goldenposeidon/constants.go @@ -106,7 +106,7 @@ var ( 0x4543d9df5476d3cb, 0xf172d73e004fc90d, 0xdfd1c4febcc81238, 0xbc8dfb627fe558fc, } - c_opt = []uint64{ + cOpt = []uint64{ 0xb585f766f2144405, 0x7746a55f43921ad7, 0xb2fb0d31cee799b4, @@ -909,8 +909,8 @@ var ( // C is a constant array of element C []*ffg.Element - // C_OPT is a constant array of element - C_OPT []*ffg.Element + // COpt is a constant array of element + COpt []*ffg.Element // M is a matrix M [][]*ffg.Element // P is a matrix @@ -924,8 +924,8 @@ func init() { C = append(C, ffg.NewElementFromUint64(c[i])) } - for i := 0; i < len(c_opt); i++ { - C_OPT = append(C_OPT, ffg.NewElementFromUint64(c_opt[i])) + for i := 0; i < len(cOpt); i++ { + COpt = append(COpt, ffg.NewElementFromUint64(cOpt[i])) } for i := 0; i < len(s); i++ { diff --git a/goldenposeidon/poseidon.go b/goldenposeidon/poseidon.go index 0340905..920218d 100644 --- a/goldenposeidon/poseidon.go +++ b/goldenposeidon/poseidon.go @@ -32,7 +32,7 @@ func ark(state []*ffg.Element, it int) { // arkOpt computes Add-Round Key, from the paper https://eprint.iacr.org/2019/458.pdf func arkOpt(state []*ffg.Element, it int) { for i := 0; i < len(state); i++ { - state[i].Add(state[i], C_OPT[it+i]) + state[i].Add(state[i], COpt[it+i]) } } @@ -98,7 +98,7 @@ func NeptuneHash(inpBI [NROUNDSF]uint64, capBI [CAPLEN]uint64) ([CAPLEN]uint64, } for i := 0; i < mLen; i++ { - state[i].Add(state[i], C_OPT[i]) + state[i].Add(state[i], COpt[i]) } for r := 0; r < NROUNDSF/2; r++ { @@ -109,7 +109,7 @@ func NeptuneHash(inpBI [NROUNDSF]uint64, capBI [CAPLEN]uint64) ([CAPLEN]uint64, for r := 0; r < NROUNDSP; r++ { exp7(state[0]) - state[0].Add(state[0], C_OPT[(NROUNDSF/2+1)*mLen+r]) + state[0].Add(state[0], COpt[(NROUNDSF/2+1)*mLen+r]) s0 := zero() mul := zero() diff --git a/goldenposeidon/poseidon_test.go b/goldenposeidon/poseidon_test.go index 8cdae83..6e4f73d 100644 --- a/goldenposeidon/poseidon_test.go +++ b/goldenposeidon/poseidon_test.go @@ -26,7 +26,8 @@ func TestPoseidonHashCompare(t *testing.T) { bm1 := prime - 1 bM := prime - h, err := compareHash([NROUNDSF]uint64{b0, b0, b0, b0, b0, b0, b0, b0}, [CAPLEN]uint64{b0, b0, b0, b0}) + h, err := compareHash([NROUNDSF]uint64{b0, b0, b0, b0, b0, b0, b0, b0}, + [CAPLEN]uint64{b0, b0, b0, b0}) assert.Nil(t, err) assert.Equal(t, [CAPLEN]uint64{ @@ -37,7 +38,8 @@ func TestPoseidonHashCompare(t *testing.T) { }, h, ) - h, err = compareHash([NROUNDSF]uint64{b1, b1, b1, b1, b1, b1, b1, b1}, [CAPLEN]uint64{b1, b1, b1, b1}) + h, err = compareHash([NROUNDSF]uint64{b1, b1, b1, b1, b1, b1, b1, b1}, + [CAPLEN]uint64{b1, b1, b1, b1}) assert.Nil(t, err) assert.Equal(t, [CAPLEN]uint64{ @@ -48,7 +50,8 @@ func TestPoseidonHashCompare(t *testing.T) { }, h, ) - h, err = compareHash([NROUNDSF]uint64{b1, b1, b1, b1, b1, b1, b1, b1}, [CAPLEN]uint64{b1, b1, b1, b1}) + h, err = compareHash([NROUNDSF]uint64{b1, b1, b1, b1, b1, b1, b1, b1}, + [CAPLEN]uint64{b1, b1, b1, b1}) assert.Nil(t, err) assert.Equal(t, [CAPLEN]uint64{ @@ -73,7 +76,8 @@ func TestPoseidonHashCompare(t *testing.T) { }, h, ) - h, err = compareHash([NROUNDSF]uint64{bM, bM, bM, bM, bM, bM, bM, bM}, [CAPLEN]uint64{b0, b0, b0, b0}) + h, err = compareHash([NROUNDSF]uint64{bM, bM, bM, bM, bM, bM, bM, bM}, + [CAPLEN]uint64{b0, b0, b0, b0}) assert.Nil(t, err) assert.Equal(t, [CAPLEN]uint64{ @@ -114,11 +118,11 @@ func BenchmarkPoseidonHash(b *testing.B) { } } -func BenchmarkPoseidonNeptuneHash(b *testing.B) { +func BenchmarkNeptuneHash(b *testing.B) { inp := [NROUNDSF]uint64{1, 2, 3, 4, 5, 6, 7, 8} cap := [CAPLEN]uint64{10, 11, 12, 13} for i := 0; i < b.N; i++ { - Hash(inp, cap) //nolint:errcheck,gosec + NeptuneHash(inp, cap) //nolint:errcheck,gosec } }