mirror of
https://github.com/vocdoni/arbo.git
synced 2026-01-07 21:14:02 -05:00
fix HashBigInts() append
Since HashBigInts() was initializing the slice and then appending, the content of chunks was not i.e [1,2,3] but [0,0,0,1,2,3]. Use the index on the loop and assign values w/o append.
This commit is contained in:
@@ -269,12 +269,12 @@ func bigIntsToLeaf(hFn HashFunction, keyLen int, key *big.Int, bigints []*big.In
|
||||
// using the hash function of the tree. The resulting hash can be used as the leaf value
|
||||
func HashBigInts(hFn HashFunction, values ...*big.Int) ([]byte, error) {
|
||||
chunks := make([][]byte, len(values))
|
||||
for _, v := range values {
|
||||
for i, v := range values {
|
||||
value := hFn.SafeBigInt(v)
|
||||
if value == nil {
|
||||
return nil, fmt.Errorf("value cannot be nil")
|
||||
}
|
||||
chunks = append(chunks, value)
|
||||
chunks[i] = value
|
||||
}
|
||||
return hFn.Hash(chunks...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user