mirror of
https://github.com/arnaucube/go-iden3-crypto.git
synced 2026-02-07 11:36:41 +01:00
poseidon consistent use of T
This commit is contained in:
@@ -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
|
// 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 {
|
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)
|
state[i] = constants.fqR.Add(state[i], c)
|
||||||
}
|
}
|
||||||
return state
|
return state
|
||||||
@@ -167,16 +167,16 @@ func Hash(arr []*big.Int) (*big.Int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := constants.fqR.Zero()
|
r := constants.fqR.Zero()
|
||||||
for i := 0; i < len(arr); i = i + 5 {
|
for i := 0; i < len(arr); i = i + T - 1 {
|
||||||
var toHash [6]*big.Int
|
var toHash [T]*big.Int
|
||||||
for j := 0; j < 5; j++ {
|
for j := 0; j < T-1; j++ {
|
||||||
if i+j < len(arr) {
|
if i+j < len(arr) {
|
||||||
toHash[j] = arr[i+j]
|
toHash[j] = arr[i+j]
|
||||||
} else {
|
} else {
|
||||||
toHash[j] = _constants.Zero
|
toHash[j] = _constants.Zero
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toHash[5] = r
|
toHash[T-1] = r
|
||||||
ph, err := PoseidonHash(toHash[:])
|
ph, err := PoseidonHash(toHash[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user