Skip to content

Commit eed510d

Browse files
authored
Check that disperser uses correct blob length (#1290)
Signed-off-by: litt3 <[email protected]>
1 parent be1be6b commit eed510d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

api/clients/v2/disperser_client.go

+12
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ func (c *disperserClient) DisperseBlob(
175175
return nil, [32]byte{}, fmt.Errorf("error deserializing blob commitments: %w", err)
176176
}
177177
blobCommitments = *deserialized
178+
179+
// We need to check that the disperser used the correct length. Even once checking the commitment from the
180+
// disperser has been implemented, there is still an edge case where the disperser could truncate trailing 0s,
181+
// yielding the wrong blob length, but not causing commitment verification to fail. It is important that the
182+
// commitment doesn't report a blob length smaller than expected, since this could cause payload parsing to
183+
// fail, if the length claimed in the encoded payload header is larger than the blob length in the commitment.
184+
lengthFromCommitment := commitments.GetBlobCommitment().GetLength()
185+
if lengthFromCommitment != uint32(symbolLength) {
186+
return nil, [32]byte{}, fmt.Errorf(
187+
"blob commitment length (%d) from disperser doesn't match expected length (%d): %w",
188+
lengthFromCommitment, symbolLength, err)
189+
}
178190
} else {
179191
// if prover is configured, get commitments from prover
180192

0 commit comments

Comments
 (0)