mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
crypto/kzg4844: remove duplicates validation
This commit is contained in:
parent
22bcf90bf0
commit
d8b98b7f99
1 changed files with 3 additions and 12 deletions
|
|
@ -20,7 +20,6 @@ package kzg4844
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"hash"
|
"hash"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
@ -214,6 +213,8 @@ func IsValidVersionedHash(h []byte) bool {
|
||||||
// For this function, it is sufficient to only provide some of the cells.
|
// For this function, it is sufficient to only provide some of the cells.
|
||||||
//
|
//
|
||||||
// The `cellIndices` specify which of the 128 cells of each blob are given.
|
// The `cellIndices` specify which of the 128 cells of each blob are given.
|
||||||
|
// Indices must be given in ascending order.
|
||||||
|
//
|
||||||
// Note the list of indices is shared among all blobs, i.e. for a given list of indices
|
// Note the list of indices is shared among all blobs, i.e. for a given list of indices
|
||||||
// [1, 2, 13], the cells slice must contain cells [1, 2, 13] of each blob.
|
// [1, 2, 13], the cells slice must contain cells [1, 2, 13] of each blob.
|
||||||
// Thus, `len(cells)` must be a multiple of `len(cellIndices)`.
|
// Thus, `len(cells)` must be a multiple of `len(cellIndices)`.
|
||||||
|
|
@ -272,16 +273,6 @@ func validateCellIndices(cells []Cell, cellIndices []uint64) error {
|
||||||
case len(cells)%len(cellIndices) != 0:
|
case len(cells)%len(cellIndices) != 0:
|
||||||
return errors.New("len(cells) must be a multiple of len(cellIndices)")
|
return errors.New("len(cells) must be a multiple of len(cellIndices)")
|
||||||
}
|
}
|
||||||
// check no duplicates
|
// The library checks the canonical ordering of indices, so we don't have to do it here.
|
||||||
var bm [CellsPerBlob / 8]uint64
|
|
||||||
for _, i := range cellIndices {
|
|
||||||
if i >= CellsPerBlob {
|
|
||||||
return fmt.Errorf("invalid cell index %d", i)
|
|
||||||
}
|
|
||||||
if bm[i>>8]&(1<<(i%8)) != 0 {
|
|
||||||
return fmt.Errorf("duplicate cell index %d", i)
|
|
||||||
}
|
|
||||||
bm[i>>8] |= 1 << (i % 8)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue