Skip to content

Commit 6a2148c

Browse files
committed
chore: separate the row proof checks
1 parent fead057 commit 6a2148c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

types/row_proof.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ func (rp RowProof) Validate(root []byte) error {
3434
if len(rp.Proofs) != len(rp.RowRoots) {
3535
return fmt.Errorf("the number of proofs %d must equal the number of row roots %d", len(rp.Proofs), len(rp.RowRoots))
3636
}
37-
if len(rp.Proofs) != 0 &&
38-
(int64(rp.StartRow) != rp.Proofs[0].Index ||
39-
int64(rp.EndRow) != rp.Proofs[len(rp.Proofs)-1].Index) {
40-
return fmt.Errorf("invalid start/end row")
37+
if len(rp.Proofs) == 0 {
38+
return fmt.Errorf("empty proofs")
39+
}
40+
if int64(rp.StartRow) != rp.Proofs[0].Index {
41+
return fmt.Errorf("invalid start row")
42+
}
43+
if int64(rp.EndRow) != rp.Proofs[len(rp.Proofs)-1].Index {
44+
return fmt.Errorf("invalid end row")
4145
}
4246
if !rp.VerifyProof(root) {
4347
return errors.New("row proof failed to verify")

0 commit comments

Comments
 (0)