From c754d01ce07f218334d86a732f38b16212a41944 Mon Sep 17 00:00:00 2001 From: arnaucube Date: Tue, 17 Dec 2019 18:15:22 +0100 Subject: [PATCH] poseidon consistent use of T --- poseidon/poseidon.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/poseidon/poseidon.go b/poseidon/poseidon.go index 2df83b0..929e77d 100644 --- a/poseidon/poseidon.go +++ b/poseidon/poseidon.go @@ -101,7 +101,7 @@ func checkAllDifferent(v []*big.Int) bool { // 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 @@ func Hash(arr []*big.Int) (*big.Int, error) { } 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