mirror of
https://github.com/arnaucube/go-iden3-crypto.git
synced 2026-02-07 03:26:39 +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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user