Skip to content

Commit

Permalink
Fix: index of bounds panics (Layr-Labs#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Mar 31, 2024
1 parent adea768 commit 4c28f58
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/aggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ func NewStdSignatureAggregator(logger logging.Logger, transactor Transactor) (*S
var _ SignatureAggregator = (*StdSignatureAggregator)(nil)

func (a *StdSignatureAggregator) AggregateSignatures(ctx context.Context, state *IndexedOperatorState, quorumIDs []QuorumID, message [32]byte, messageChan chan SignerMessage) (*SignatureAggregation, error) {

// TODO: Add logging

if len(quorumIDs) == 0 {
return nil, errors.New("the number of quorums must be greater than zero")
}

// Ensure all quorums are found in state
for _, id := range quorumIDs {
_, found := state.Operators[id]
Expand Down
3 changes: 3 additions & 0 deletions encoding/kzg/verifier/batch_commit_equivalence.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func GetRandomFr() (fr.Element, error) {
}

func CreateRandomnessVector(n int) ([]fr.Element, error) {
if n <= 0 {
return nil, errors.New("the length of vector must be positive")
}
r, err := GetRandomFr()
if err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions encoding/kzg/verifier/multiframe.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ func (v *Verifier) UniversalVerify(params encoding.EncodingParams, samples []Sam

n := len(samples)
fmt.Printf("Batch verify %v frames of %v symbols out of %v blobs \n", n, params.ChunkLength, m)
if n == 0 {
return errors.New("the number of samples (i.e. chunks) must not be empty")
}

// generate random field elements to aggregate equality check
randomsFr, err := CreateRandomnessVector(n)
Expand Down
7 changes: 7 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ func (n *Node) ProcessBatch(ctx context.Context, header *core.BatchHeader, blobs

log.Debug("Processing batch", "num of blobs", len(blobs))

if len(blobs) == 0 {
return nil, errors.New("the number of blobs must be greater than zero")
}
if len(blobs) != len(rawBlobs) {
return nil, errors.New("the number of parsed blobs must be the same as number of blobs from protobuf request")
}

// Measure num batches received and its size in bytes
batchSize := int64(0)
for _, blob := range blobs {
Expand Down

0 comments on commit 4c28f58

Please sign in to comment.