Skip to content

Commit

Permalink
feat(eips): Indexed Blob Hash (#1526)
Browse files Browse the repository at this point in the history
feat: indexed blob hash
  • Loading branch information
refcell authored Oct 24, 2024
1 parent e39fc49 commit 626c696
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions crates/eips/src/eip4844/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ use alloc::vec::Vec;
#[cfg(feature = "kzg")]
pub(crate) const VERSIONED_HASH_VERSION_KZG: u8 = 0x01;

/// A Blob hash
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct IndexedBlobHash {
/// The index of the blob
pub index: u64,
/// The hash of the blob
pub hash: B256,
}

/// This represents a set of blobs, and its corresponding commitments and proofs.
///
/// This type encodes and decodes the fields without an rlp header.
Expand Down Expand Up @@ -115,9 +125,12 @@ impl BlobTransactionSidecarItem {
result.then_some(()).ok_or(BlobTransactionValidationError::InvalidProof)
}

/// Verify the blob sidecar against its [crate::NumHash].
pub fn verify_blob(&self, hash: &crate::NumHash) -> Result<(), BlobTransactionValidationError> {
if self.index != hash.number {
/// Verify the blob sidecar against its [IndexedBlobHash].
pub fn verify_blob(
&self,
hash: &IndexedBlobHash,
) -> Result<(), BlobTransactionValidationError> {
if self.index != hash.index {
let blob_hash_part = B256::from_slice(&self.blob[0..32]);
return Err(BlobTransactionValidationError::WrongVersionedHash {
have: blob_hash_part,
Expand Down

0 comments on commit 626c696

Please sign in to comment.