Remove verify_cell_kzg_proof (non-batch)
This commit is contained in:
parent
81f3ea8322
commit
c078a97f0c
|
@ -43,7 +43,6 @@
|
|||
- [Cell computation](#cell-computation)
|
||||
- [`compute_cells_and_kzg_proofs`](#compute_cells_and_kzg_proofs)
|
||||
- [Cell verification](#cell-verification)
|
||||
- [`verify_cell_kzg_proof`](#verify_cell_kzg_proof)
|
||||
- [`verify_cell_kzg_proof_batch`](#verify_cell_kzg_proof_batch)
|
||||
- [Reconstruction](#reconstruction)
|
||||
- [`construct_vanishing_polynomial`](#construct_vanishing_polynomial)
|
||||
|
@ -642,32 +641,6 @@ def compute_cells_and_kzg_proofs(blob: Blob) -> Tuple[
|
|||
|
||||
### Cell verification
|
||||
|
||||
#### `verify_cell_kzg_proof`
|
||||
|
||||
```python
|
||||
def verify_cell_kzg_proof(commitment_bytes: Bytes48,
|
||||
cell_index: CellIndex,
|
||||
cell: Cell,
|
||||
proof_bytes: Bytes48) -> bool:
|
||||
"""
|
||||
Check a cell proof
|
||||
|
||||
Public method.
|
||||
"""
|
||||
assert len(commitment_bytes) == BYTES_PER_COMMITMENT
|
||||
assert cell_index < CELLS_PER_EXT_BLOB
|
||||
assert len(cell) == BYTES_PER_CELL
|
||||
assert len(proof_bytes) == BYTES_PER_PROOF
|
||||
|
||||
coset = coset_for_cell(cell_index)
|
||||
|
||||
return verify_kzg_proof_multi_impl(
|
||||
bytes_to_kzg_commitment(commitment_bytes),
|
||||
coset,
|
||||
cell_to_coset_evals(cell),
|
||||
bytes_to_kzg_proof(proof_bytes))
|
||||
```
|
||||
|
||||
#### `verify_cell_kzg_proof_batch`
|
||||
|
||||
```python
|
||||
|
|
|
@ -108,20 +108,6 @@ def test_construct_vanishing_polynomial(spec):
|
|||
assert all(a != 0 for a in zero_poly_eval_brp[start:end])
|
||||
|
||||
|
||||
@with_eip7594_and_later
|
||||
@spec_test
|
||||
@single_phase
|
||||
def test_verify_cell_kzg_proof(spec):
|
||||
blob = get_sample_blob(spec)
|
||||
commitment = spec.blob_to_kzg_commitment(blob)
|
||||
cells, proofs = spec.compute_cells_and_kzg_proofs(blob)
|
||||
|
||||
cell_index = 0
|
||||
assert spec.verify_cell_kzg_proof(commitment, cell_index, cells[cell_index], proofs[cell_index])
|
||||
cell_index = 1
|
||||
assert spec.verify_cell_kzg_proof(commitment, cell_index, cells[cell_index], proofs[cell_index])
|
||||
|
||||
|
||||
@with_eip7594_and_later
|
||||
@spec_test
|
||||
@single_phase
|
||||
|
|
|
@ -8,6 +8,5 @@ The KZG test suite runner has the following handlers:
|
|||
|
||||
- [`compute_cells`](./compute_cells.md)
|
||||
- [`compute_cells_and_kzg_proofs`](./compute_cells_and_kzg_proofs.md)
|
||||
- [`verify_cell_kzg_proof`](./verify_cell_kzg_proof.md)
|
||||
- [`verify_cell_kzg_proof_batch`](./verify_cell_kzg_proof_batch.md)
|
||||
- [`recover_all_cells`](./recover_all_cells.md)
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
# Test format: Verify cell KZG proof
|
||||
|
||||
Use the cell KZG `proof` to verify that the KZG `commitment` for a given `cell` is correct.
|
||||
|
||||
## Test case format
|
||||
|
||||
The test data is declared in a `data.yaml` file:
|
||||
|
||||
```yaml
|
||||
input:
|
||||
commitment: Bytes48 -- the KZG commitment
|
||||
cell_index: CellIndex -- the cell index
|
||||
cell: Cell -- the cell
|
||||
proof: Bytes48 -- the KZG proof for the cell
|
||||
output: bool -- true (correct proof) or false (incorrect proof)
|
||||
```
|
||||
|
||||
- `Bytes48` is a 48-byte hexadecimal string, prefixed with `0x`.
|
||||
- `CellIndex` is an unsigned 64-bit integer.
|
||||
- `Cell` is a 2048-byte hexadecimal string, prefixed with `0x`.
|
||||
|
||||
All byte(s) fields are encoded as strings, hexadecimal encoding, prefixed with `0x`.
|
||||
|
||||
## Condition
|
||||
|
||||
The `verify_cell_kzg_proof` handler should verify that `commitment` is a correct KZG commitment to `cell` by using the cell KZG proof `proof`, and the result should match the expected `output`. If the commitment or proof is invalid (e.g. not on the curve or not in the G1 subgroup of the BLS curve), `cell` is invalid (e.g. incorrect length or one of the 32-byte blocks does not represent a BLS field element), or `cell_index` is invalid (e.g. greater than the number of cells for an extended blob), it should error, i.e. the output should be `null`.
|
|
@ -58,160 +58,6 @@ def case_compute_cells_and_kzg_proofs():
|
|||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Test cases for verify_cell_kzg_proof
|
||||
###############################################################################
|
||||
|
||||
def case_verify_cell_kzg_proof():
|
||||
# Valid cases
|
||||
for i in range(len(VALID_BLOBS)):
|
||||
cells, proofs = VALID_CELLS_AND_PROOFS[i]
|
||||
commitment = VALID_COMMITMENTS[i]
|
||||
cell_index = (2 ** i - 1) % spec.CELLS_PER_EXT_BLOB
|
||||
cell = cells[cell_index]
|
||||
proof = proofs[cell_index]
|
||||
assert spec.verify_cell_kzg_proof(commitment, cell_index, cell, proof)
|
||||
identifier = make_id(commitment, cell_index, cell, proof)
|
||||
yield f'verify_cell_kzg_proof_case_valid_{identifier}', {
|
||||
'input': {
|
||||
'commitment': encode_hex(commitment),
|
||||
'cell_index': cell_index,
|
||||
'cell': encode_hex(cell),
|
||||
'proof': encode_hex(proof),
|
||||
},
|
||||
'output': True
|
||||
}
|
||||
|
||||
# Incorrect commitment
|
||||
for i in range(len(VALID_BLOBS)):
|
||||
cells, proofs = VALID_CELLS_AND_PROOFS[i]
|
||||
commitment = bls_add_one(VALID_COMMITMENTS[i])
|
||||
cell_index = 99 % spec.CELLS_PER_EXT_BLOB
|
||||
cell = cells[cell_index]
|
||||
proof = proofs[cell_index]
|
||||
assert not spec.verify_cell_kzg_proof(commitment, cell_index, cell, proof)
|
||||
identifier = make_id(commitment, cell_index, cell, proof)
|
||||
yield f'verify_cell_kzg_proof_case_incorrect_commitment_{identifier}', {
|
||||
'input': {
|
||||
'commitment': encode_hex(commitment),
|
||||
'cell_index': cell_index,
|
||||
'cell': encode_hex(cell),
|
||||
'proof': encode_hex(proof),
|
||||
},
|
||||
'output': False
|
||||
}
|
||||
|
||||
# Incorrect cell
|
||||
for i in range(len(VALID_INDIVIDUAL_RANDOM_CELL_BYTES)):
|
||||
cell_index = 16 % spec.CELLS_PER_EXT_BLOB
|
||||
commitment = VALID_COMMITMENTS[i]
|
||||
cells, proofs = VALID_CELLS_AND_PROOFS[i]
|
||||
cell = VALID_INDIVIDUAL_RANDOM_CELL_BYTES[i]
|
||||
proof = proofs[cell_index]
|
||||
assert not spec.verify_cell_kzg_proof(commitment, cell_index, cell, proof)
|
||||
identifier = make_id(commitment, cell_index, cell, proof)
|
||||
yield f'verify_cell_kzg_proof_case_incorrect_cell_{identifier}', {
|
||||
'input': {
|
||||
'commitment': encode_hex(commitment),
|
||||
'cell_index': cell_index,
|
||||
'cell': encode_hex(cell),
|
||||
'proof': encode_hex(proof),
|
||||
},
|
||||
'output': False
|
||||
}
|
||||
|
||||
# Incorrect proof
|
||||
for i in range(len(VALID_BLOBS)):
|
||||
cell_index = 91 % spec.CELLS_PER_EXT_BLOB
|
||||
commitment = VALID_COMMITMENTS[i]
|
||||
cells, proofs = VALID_CELLS_AND_PROOFS[i]
|
||||
cell = cells[cell_index]
|
||||
proof = bls_add_one(proofs[cell_index])
|
||||
assert not spec.verify_cell_kzg_proof(commitment, cell_index, cell, proof)
|
||||
identifier = make_id(commitment, cell_index, cell, proof)
|
||||
yield f'verify_cell_kzg_proof_case_incorrect_proof_{identifier}', {
|
||||
'input': {
|
||||
'commitment': encode_hex(commitment),
|
||||
'cell_index': cell_index,
|
||||
'cell': encode_hex(cell),
|
||||
'proof': encode_hex(proof),
|
||||
},
|
||||
'output': False
|
||||
}
|
||||
|
||||
# Edge case: Invalid commitment
|
||||
for commitment in INVALID_G1_POINTS:
|
||||
cells, proofs = VALID_CELLS_AND_PROOFS[0]
|
||||
cell_index = 81 % spec.CELLS_PER_EXT_BLOB
|
||||
cell = cells[cell_index]
|
||||
proof = proofs[cell_index]
|
||||
expect_exception(spec.verify_cell_kzg_proof, commitment, cell_index, cell, proof)
|
||||
identifier = make_id(commitment, cell_index, cell, proof)
|
||||
yield f'verify_cell_kzg_proof_case_invalid_commitment_{identifier}', {
|
||||
'input': {
|
||||
'commitment': encode_hex(commitment),
|
||||
'cell_index': cell_index,
|
||||
'cell': encode_hex(cell),
|
||||
'proof': encode_hex(proof),
|
||||
},
|
||||
'output': None
|
||||
}
|
||||
|
||||
# Edge case: Invalid cell_index
|
||||
for cell_index in [spec.CELLS_PER_EXT_BLOB, spec.CELLS_PER_EXT_BLOB + 1]:
|
||||
cells, proofs = VALID_CELLS_AND_PROOFS[1]
|
||||
commitment = VALID_COMMITMENTS[1]
|
||||
cell = cells[0]
|
||||
proof = proofs[0]
|
||||
expect_exception(spec.verify_cell_kzg_proof, commitment, cell_index, cell, proof)
|
||||
identifier = make_id(commitment, cell_index, cell, proof)
|
||||
yield f'verify_cell_kzg_proof_case_invalid_cell_index_{identifier}', {
|
||||
'input': {
|
||||
'commitment': encode_hex(commitment),
|
||||
'cell_index': cell_index,
|
||||
'cell': encode_hex(cell),
|
||||
'proof': encode_hex(proof),
|
||||
},
|
||||
'output': None
|
||||
}
|
||||
|
||||
# Edge case: Invalid cell
|
||||
for cell in INVALID_INDIVIDUAL_CELL_BYTES:
|
||||
cell_index = 32 % spec.CELLS_PER_EXT_BLOB
|
||||
commitment = VALID_COMMITMENTS[2]
|
||||
cells, proofs = VALID_CELLS_AND_PROOFS[2]
|
||||
proof = proofs[cell_index]
|
||||
expect_exception(spec.verify_cell_kzg_proof, commitment, cell_index, cell, proof)
|
||||
identifier = make_id(commitment, cell_index, cell, proof)
|
||||
yield f'verify_cell_kzg_proof_case_invalid_cell_{identifier}', {
|
||||
'input': {
|
||||
'commitment': encode_hex(commitment),
|
||||
'cell_index': cell_index,
|
||||
'cell': encode_hex(cell),
|
||||
'proof': encode_hex(proof),
|
||||
},
|
||||
'output': None
|
||||
}
|
||||
|
||||
# Edge case: Invalid proof
|
||||
for proof in INVALID_G1_POINTS:
|
||||
cells, _ = VALID_CELLS_AND_PROOFS[3]
|
||||
commitment = VALID_COMMITMENTS[3]
|
||||
cell_index = 36 % spec.CELLS_PER_EXT_BLOB
|
||||
cell = cells[cell_index]
|
||||
expect_exception(spec.verify_cell_kzg_proof, commitment, cell_index, cell, proof)
|
||||
identifier = make_id(commitment, cell_index, cell, proof)
|
||||
yield f'verify_cell_kzg_proof_case_invalid_proof_{identifier}', {
|
||||
'input': {
|
||||
'commitment': encode_hex(commitment),
|
||||
'cell_index': cell_index,
|
||||
'cell': encode_hex(cell),
|
||||
'proof': encode_hex(proof),
|
||||
},
|
||||
'output': None
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Test cases for verify_cell_kzg_proof_batch
|
||||
###############################################################################
|
||||
|
@ -812,7 +658,6 @@ if __name__ == "__main__":
|
|||
gen_runner.run_generator("kzg_7594", [
|
||||
# EIP-7594
|
||||
create_provider(EIP7594, 'compute_cells_and_kzg_proofs', case_compute_cells_and_kzg_proofs),
|
||||
create_provider(EIP7594, 'verify_cell_kzg_proof', case_verify_cell_kzg_proof),
|
||||
create_provider(EIP7594, 'verify_cell_kzg_proof_batch', case_verify_cell_kzg_proof_batch),
|
||||
create_provider(EIP7594, 'recover_cells_and_kzg_proofs', case_recover_cells_and_kzg_proofs),
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue