arnaucube
arnaucube/go-iden3-cryptoPublic Self-hosted repository
poseidon consistent use of T
arnaucube root@arnaucube.com
Tue, 17 Dec 2019 18:15:22 +0100
commit

c754d01ce07f218334d86a732f38b16212a41944

parent

fcb586591ab6b1d50a9eff5b7a3e93655e62fef8

1 files changed, 5 insertions(+), 5 deletions(-)

jump to
M poseidon/poseidon.go → poseidon/poseidon.go

@@ -101,7 +101,7 @@ }

// ark computes Add-Round Key, from the paper https://eprint.iacr.org/2019/458.pdf func ark(state []*big.Int, c *big.Int) []*big.Int { - for i := 0; i < len(state); i++ { + for i := 0; i < T; i++ { state[i] = constants.fqR.Add(state[i], c) } return state

@@ -167,16 +167,16 @@ return nil, errors.New("inputs values not inside Finite Field")

} r := constants.fqR.Zero() - for i := 0; i < len(arr); i = i + 5 { - var toHash [6]*big.Int - for j := 0; j < 5; j++ { + for i := 0; i < len(arr); i = i + T - 1 { + var toHash [T]*big.Int + for j := 0; j < T-1; j++ { if i+j < len(arr) { toHash[j] = arr[i+j] } else { toHash[j] = _constants.Zero } } - toHash[5] = r + toHash[T-1] = r ph, err := PoseidonHash(toHash[:]) if err != nil { return nil, err