Upgrade linters

This commit is contained in:
arnaucube
2020-12-16 15:04:43 +01:00
parent 821a601d20
commit 6d75396b4b
14 changed files with 203 additions and 113 deletions

View File

@@ -9,9 +9,9 @@ import (
"github.com/iden3/go-iden3-crypto/utils"
)
const NROUNDSF = 8
const NROUNDSF = 8 //nolint:golint
var NROUNDSP = []int{56, 57, 56, 60, 60, 63, 64, 63}
var NROUNDSP = []int{56, 57, 56, 60, 60, 63, 64, 63} //nolint:golint
func zero() *ff.Element {
return ff.NewElement()

View File

@@ -12,7 +12,9 @@ import (
func TestBlake2bVersion(t *testing.T) {
h := blake2b.Sum256([]byte("poseidon_constants"))
assert.Equal(t, "e57ba154fb2c47811dc1a2369b27e25a44915b4e4ece4eb8ec74850cb78e01b1", hex.EncodeToString(h[:]))
assert.Equal(t,
"e57ba154fb2c47811dc1a2369b27e25a44915b4e4ece4eb8ec74850cb78e01b1",
hex.EncodeToString(h[:]))
}
func TestPoseidonHash(t *testing.T) {
@@ -22,33 +24,47 @@ func TestPoseidonHash(t *testing.T) {
h, err := Hash([]*big.Int{b1})
assert.Nil(t, err)
assert.Equal(t, "11043376183861534927536506085090418075369306574649619885724436265926427398571", h.String())
assert.Equal(t,
"11043376183861534927536506085090418075369306574649619885724436265926427398571",
h.String())
h, err = Hash([]*big.Int{b1, b2})
assert.Nil(t, err)
assert.Equal(t, "17117985411748610629288516079940078114952304104811071254131751175361957805920", h.String())
assert.Equal(t,
"17117985411748610629288516079940078114952304104811071254131751175361957805920",
h.String())
h, err = Hash([]*big.Int{b1, b2, b0, b0, b0})
assert.Nil(t, err)
assert.Equal(t, "3975478831357328722254985704342968745327876719981393787143845259590563829094", h.String())
assert.Equal(t,
"3975478831357328722254985704342968745327876719981393787143845259590563829094",
h.String())
h, err = Hash([]*big.Int{b1, b2, b0, b0, b0, b0})
assert.Nil(t, err)
assert.Equal(t, "19772360636270345724087386688434825760738403416279047262510528378903625000110", h.String())
assert.Equal(t,
"19772360636270345724087386688434825760738403416279047262510528378903625000110",
h.String())
b3 := big.NewInt(3)
b4 := big.NewInt(4)
h, err = Hash([]*big.Int{b3, b4, b0, b0, b0})
assert.Nil(t, err)
assert.Equal(t, "3181200837746671699652342497997860344148947482942465819251904554707352676086", h.String())
assert.Equal(t,
"3181200837746671699652342497997860344148947482942465819251904554707352676086",
h.String())
h, err = Hash([]*big.Int{b3, b4, b0, b0, b0, b0})
assert.Nil(t, err)
assert.Equal(t, "8386348873272147968934270337233829407378789978142456170950021426339096575008", h.String())
assert.Equal(t,
"8386348873272147968934270337233829407378789978142456170950021426339096575008",
h.String())
b5 := big.NewInt(5)
b6 := big.NewInt(6)
h, err = Hash([]*big.Int{b1, b2, b3, b4, b5, b6})
assert.Nil(t, err)
assert.Equal(t, "5202465217520500374834597824465244016759843635092906214933648999760272616044", h.String())
assert.Equal(t,
"5202465217520500374834597824465244016759843635092906214933648999760272616044",
h.String())
}
func TestErrorInputs(t *testing.T) {
@@ -70,12 +86,12 @@ func TestErrorInputs(t *testing.T) {
func BenchmarkPoseidonHash(b *testing.B) {
b0 := big.NewInt(0)
b1 := utils.NewIntFromString("12242166908188651009877250812424843524687801523336557272219921456462821518061")
b2 := utils.NewIntFromString("12242166908188651009877250812424843524687801523336557272219921456462821518061")
b1 := utils.NewIntFromString("12242166908188651009877250812424843524687801523336557272219921456462821518061") //nolint:lll
b2 := utils.NewIntFromString("12242166908188651009877250812424843524687801523336557272219921456462821518061") //nolint:lll
bigArray4 := []*big.Int{b1, b2, b0, b0, b0, b0}
for i := 0; i < b.N; i++ {
Hash(bigArray4) //nolint:errcheck
Hash(bigArray4) //nolint:errcheck,gosec
}
}