Skip to content

Commit

Permalink
chore: separate the row proof checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Sep 12, 2024
1 parent fead057 commit 6a2148c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions types/row_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ func (rp RowProof) Validate(root []byte) error {
if len(rp.Proofs) != len(rp.RowRoots) {
return fmt.Errorf("the number of proofs %d must equal the number of row roots %d", len(rp.Proofs), len(rp.RowRoots))
}
if len(rp.Proofs) != 0 &&
(int64(rp.StartRow) != rp.Proofs[0].Index ||
int64(rp.EndRow) != rp.Proofs[len(rp.Proofs)-1].Index) {
return fmt.Errorf("invalid start/end row")
if len(rp.Proofs) == 0 {
return fmt.Errorf("empty proofs")
}
if int64(rp.StartRow) != rp.Proofs[0].Index {
return fmt.Errorf("invalid start row")
}
if int64(rp.EndRow) != rp.Proofs[len(rp.Proofs)-1].Index {
return fmt.Errorf("invalid end row")
}
if !rp.VerifyProof(root) {
return errors.New("row proof failed to verify")
Expand Down

0 comments on commit 6a2148c

Please sign in to comment.