mirror of
https://github.com/arnaucube/go-iden3-crypto.git
synced 2026-02-07 03:26:39 +01:00
fix the lint issues
This commit is contained in:
@@ -106,7 +106,7 @@ var (
|
|||||||
0x4543d9df5476d3cb, 0xf172d73e004fc90d, 0xdfd1c4febcc81238, 0xbc8dfb627fe558fc,
|
0x4543d9df5476d3cb, 0xf172d73e004fc90d, 0xdfd1c4febcc81238, 0xbc8dfb627fe558fc,
|
||||||
}
|
}
|
||||||
|
|
||||||
c_opt = []uint64{
|
cOpt = []uint64{
|
||||||
0xb585f766f2144405,
|
0xb585f766f2144405,
|
||||||
0x7746a55f43921ad7,
|
0x7746a55f43921ad7,
|
||||||
0xb2fb0d31cee799b4,
|
0xb2fb0d31cee799b4,
|
||||||
@@ -909,8 +909,8 @@ var (
|
|||||||
|
|
||||||
// C is a constant array of element
|
// C is a constant array of element
|
||||||
C []*ffg.Element
|
C []*ffg.Element
|
||||||
// C_OPT is a constant array of element
|
// COpt is a constant array of element
|
||||||
C_OPT []*ffg.Element
|
COpt []*ffg.Element
|
||||||
// M is a matrix
|
// M is a matrix
|
||||||
M [][]*ffg.Element
|
M [][]*ffg.Element
|
||||||
// P is a matrix
|
// P is a matrix
|
||||||
@@ -924,8 +924,8 @@ func init() {
|
|||||||
C = append(C, ffg.NewElementFromUint64(c[i]))
|
C = append(C, ffg.NewElementFromUint64(c[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(c_opt); i++ {
|
for i := 0; i < len(cOpt); i++ {
|
||||||
C_OPT = append(C_OPT, ffg.NewElementFromUint64(c_opt[i]))
|
COpt = append(COpt, ffg.NewElementFromUint64(cOpt[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(s); i++ {
|
for i := 0; i < len(s); i++ {
|
||||||
|
|||||||
@@ -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
|
// arkOpt computes Add-Round Key, from the paper https://eprint.iacr.org/2019/458.pdf
|
||||||
func arkOpt(state []*ffg.Element, it int) {
|
func arkOpt(state []*ffg.Element, it int) {
|
||||||
for i := 0; i < len(state); i++ {
|
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++ {
|
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++ {
|
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++ {
|
for r := 0; r < NROUNDSP; r++ {
|
||||||
exp7(state[0])
|
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()
|
s0 := zero()
|
||||||
mul := zero()
|
mul := zero()
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ func TestPoseidonHashCompare(t *testing.T) {
|
|||||||
bm1 := prime - 1
|
bm1 := prime - 1
|
||||||
bM := prime
|
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.Nil(t, err)
|
||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
[CAPLEN]uint64{
|
[CAPLEN]uint64{
|
||||||
@@ -37,7 +38,8 @@ func TestPoseidonHashCompare(t *testing.T) {
|
|||||||
}, h,
|
}, 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.Nil(t, err)
|
||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
[CAPLEN]uint64{
|
[CAPLEN]uint64{
|
||||||
@@ -48,7 +50,8 @@ func TestPoseidonHashCompare(t *testing.T) {
|
|||||||
}, h,
|
}, 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.Nil(t, err)
|
||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
[CAPLEN]uint64{
|
[CAPLEN]uint64{
|
||||||
@@ -73,7 +76,8 @@ func TestPoseidonHashCompare(t *testing.T) {
|
|||||||
}, h,
|
}, 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.Nil(t, err)
|
||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
[CAPLEN]uint64{
|
[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}
|
inp := [NROUNDSF]uint64{1, 2, 3, 4, 5, 6, 7, 8}
|
||||||
cap := [CAPLEN]uint64{10, 11, 12, 13}
|
cap := [CAPLEN]uint64{10, 11, 12, 13}
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
Hash(inp, cap) //nolint:errcheck,gosec
|
NeptuneHash(inp, cap) //nolint:errcheck,gosec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user