mirror of
https://github.com/arnaucube/go-iden3-crypto.git
synced 2026-02-07 19:46:41 +01:00
Add test that breaks poseidon due to a security issue
This commit is contained in:
@@ -168,15 +168,15 @@ func Hash(arr []*big.Int) (*big.Int, error) {
|
||||
|
||||
r := constants.fqR.Zero()
|
||||
for i := 0; i < len(arr); i = i + 5 {
|
||||
var fiveElems []*big.Int
|
||||
var fiveElems [5]*big.Int
|
||||
for j := 0; j < 5; j++ {
|
||||
if i+j < len(arr) {
|
||||
fiveElems = append(fiveElems, arr[i+j])
|
||||
fiveElems[j] = arr[i+j]
|
||||
} else {
|
||||
fiveElems = append(fiveElems, big.NewInt(int64(0)))
|
||||
fiveElems[j] = _constants.Zero
|
||||
}
|
||||
}
|
||||
ph, err := PoseidonHash(fiveElems)
|
||||
ph, err := PoseidonHash(fiveElems[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user