-
Notifications
You must be signed in to change notification settings - Fork 989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
peerDAS: Public methods must accept raw bytes #3579
Conversation
789e24e
to
a4331e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Here's my initial review.
def verify_cell_proof(commitment_bytes: Bytes48, | ||
cell_id: uint64, | ||
cell_bytes: Vector[Bytes32, FIELD_ELEMENTS_PER_CELL], | ||
proof: Bytes48) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be proof_bytes
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 6679860
bytes_to_kzg_commitment(commitment_bytes), | ||
coset, | ||
bytes_to_cell(cell_bytes), | ||
bytes_to_kzg_proof(proof)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also be proof_bytes
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 6679860
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you ensure that all the docstrings have proper punctuation? Lots of the *_polynomialcoeff
methods and other funcs, like verify_kzg_proof_multi_impl
, are missing punctuation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think the documentation of the entire file is a bit lacking to the point that I would suggest we do it in another PR since it requires quite a bit of work.
(PS: That also made me look at the 4844 documentation, and it also seems severely incomplete or outdated)
cell: Cell, | ||
proof: KZGProof) -> bool: | ||
def verify_cell_proof(commitment_bytes: Bytes48, | ||
cell_id: uint64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the new CellID
type here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved in 6679860
proofs: Sequence[KZGProof]) -> bool: | ||
def verify_cell_proof_batch(row_commitments_bytes: Sequence[Bytes48], | ||
row_ids: Sequence[uint64], | ||
column_ids: Sequence[uint64], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be CellID
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not IMO. The ID of a row or column is semantically different from a cell ID, even if the underlying type is the same.
Specifically, we expect to have just a few rows. We also expect the amount of columns to be equal to the amount of cells per blob.
However, due to the semantic difference, I would be hesitant in reusing CellID
here. IMO another approach would be to define a RowID
and ColumnID
type for these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree now, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related commit that will cause conflicts: 665e6fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went address it in #3574 -> RowIndex
and ColumnIndex
. IMO "index" implies they are consecutive numbers but ID is not.
We can fix conflict later whichever merge late.
row_ids=[0], | ||
column_ids=[0, 1], | ||
cells=cells[0:1], | ||
proofs=proofs, | ||
cells_bytes=cells_bytes[0:1], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How many cells are we trying to verify here? Since column_ids
has two values, it appears to be two. But [0:1]
will result in a single value. Think there's a bit of an accident here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that unittest was a bit working by accident. I made it more robust in 2000a4f.
In the future we will want certainly want test_verify_cell_proof_batch()
to do a multi-blob cell verification, but to do that we need to figure out a solution to compute_cells_and_proofs()
taking multiple minutes (perhaps load them directly from a file?).
cells=cells[0:1], | ||
proofs=proofs, | ||
cells_bytes=cells_bytes[0:1], | ||
proofs_bytes=proofs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're sending all the proofs when only the first one is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 2000a4f
@@ -330,7 +344,7 @@ def verify_kzg_proof_multi_impl(commitment: KZGCommitment, | |||
#### `coset_for_cell` | |||
|
|||
```python | |||
def coset_for_cell(cell_id: int) -> Cell: | |||
def coset_for_cell(cell_id: CellID) -> Cell: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think cell_id
should be column_index
(or column_id
) here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practice, column_id
and cell_id
can be used interchangeably in this function, since each cell corresponds to a column in a one-to-one fashion.
I think it's better for us to choose which notion is more intuitive in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Merged. Thanks all! |
The cryptography public methods should take as input raw bytes. This is a lesson from the 4844 cryptography specs. It makes it clear that cryptographic validation of inputs is a responsibility of the cryptography spec and not the rest of the client code.
(Also switched
int
touint64
after discussion in the specs call.)Furthermore, merging this PR will likely break the currently active peerDAS PR #3574.