This commit is contained in:
Hsiao-Wei Wang 2023-10-29 03:28:57 +08:00
parent de3b6a24dc
commit b7e0b88cb1
No known key found for this signature in database
GPG Key ID: AE3D6B174F971DE4
2 changed files with 5 additions and 3 deletions

View File

@ -101,10 +101,12 @@ class BlobIdentifier(Container):
```python
def verify_blob_sidecar_inclusion_proof(blob_sidecar: BlobSidecar) -> bool:
return is_valid_merkle_path(
gindex = get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments', blob_sidecar.index)
return is_valid_merkle_branch(
leaf=blob_sidecar.kzg_commitment.hash_tree_root(),
branch=blob_sidecar.commitment_inclusion_proof,
gindex=get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments', blob_sidecar.index),
depth=floorlog2(gindex),
index=get_subtree_index(gindex),
root=blob_sidecar.signed_block_header.message.body_root,
)
```

View File

@ -55,5 +55,5 @@ def test_blob_sidecar_inclusion_proof_incorrect(spec, state):
for blob_sidecar in blob_sidecars:
block = blob_sidecar.signed_block_header.message
block = block.body_root = hash_tree_root(block.body_root) # mutate body root to break proof
block.body_root = spec.hash(block.body_root) # mutate body root to break proof
assert not spec.verify_blob_sidecar_inclusion_proof(blob_sidecar)