Browse Source

update the input params of hash

fix/bbjj-err
Cool Developer 2 years ago
parent
commit
47b41d8ffc
3 changed files with 14 additions and 9 deletions
  1. +4
    -7
      goldenposeidon/constants.go
  2. +6
    -1
      goldenposeidon/poseidon.go
  3. +4
    -1
      goldenposeidon/poseidon_test.go

+ 4
- 7
goldenposeidon/constants.go

@ -3,13 +3,10 @@ package poseidon
import "github.com/iden3/go-iden3-crypto/ffg" import "github.com/iden3/go-iden3-crypto/ffg"
const ( const (
// NROUNDSF
NROUNDSF = 8
// NROUNDSP
NROUNDSP = 22
// CAPLEN
CAPLEN = 4
mLen = 12
NROUNDSF = 8 //nolint:golint
NROUNDSP = 22 //nolint:golint
CAPLEN = 4 //nolint:golint
mLen = 12
) )
var ( var (

+ 6
- 1
goldenposeidon/poseidon.go

@ -68,5 +68,10 @@ func Hash(inpBI [NROUNDSF]uint64, capBI [CAPLEN]uint64) ([CAPLEN]uint64, error)
state = mix(state) state = mix(state)
} }
return [CAPLEN]uint64{state[0].ToUint64Regular(), state[1].ToUint64Regular(), state[2].ToUint64Regular(), state[3].ToUint64Regular()}, nil
return [CAPLEN]uint64{
state[0].ToUint64Regular(),
state[1].ToUint64Regular(),
state[2].ToUint64Regular(),
state[3].ToUint64Regular(),
}, nil
} }

+ 4
- 1
goldenposeidon/poseidon_test.go

@ -47,7 +47,10 @@ func TestPoseidonHash(t *testing.T) {
}, h, }, h,
) )
h, err = Hash([NROUNDSF]uint64{bm1, bm1, bm1, bm1, bm1, bm1, bm1, bm1}, [CAPLEN]uint64{bm1, bm1, bm1, bm1})
h, err = Hash(
[NROUNDSF]uint64{bm1, bm1, bm1, bm1, bm1, bm1, bm1, bm1},
[CAPLEN]uint64{bm1, bm1, bm1, bm1},
)
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, assert.Equal(t,
[CAPLEN]uint64{ [CAPLEN]uint64{

Loading…
Cancel
Save