Browse Source

poseidon consistent use of T

fix/issue-9
arnaucube 4 years ago
parent
commit
c754d01ce0
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      poseidon/poseidon.go

+ 5
- 5
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

Loading…
Cancel
Save