ProofCarryingChunk

Struct ProofCarryingChunk 

Source
pub struct ProofCarryingChunk { /* private fields */ }
Expand description

Represents a Chunk augmented with a Merkle proof of its inclusion in the original blob. This structure is used for verifiable data retrieval and reconstruction.

Implementations§

Source§

impl ProofCarryingChunk

Source

pub fn validate_inclusion_in_blob(&self, blob_commitment: Hash) -> bool

Validates the inclusion of this chunk in the overall blob using the provided blob root commitment.

This method verifies the Merkle proof against the blob’s root commitment, assuming the proof contains the necessary sibling nodes to ascend to the blob root.

Meaning Self::append_proof_to_blob_root() needs to be called after Self::new() to extend the Merkle inclusion proof to the blob root level - only then one can validate inclusion of this chunk in the blob.

§Arguments
  • blob_commitment - The blake3::Hash of the root of the Merkle tree for the entire blob.
§Returns

Returns true if the chunk’s inclusion proof in the blob is valid, false otherwise.

Source

pub fn validate_inclusion_in_chunkset(&self, chunkset_commitment: Hash) -> bool

Validates the inclusion of this chunk within its specific chunkset using the provided chunkset root commitment.

This method checks the Merkle proof against the chunkset’s root commitment.

§Arguments
  • chunkset_commitment - The blake3::Hash of the root of the Merkle tree for the chunkset this chunk belongs to.
§Returns

Returns true if the chunk’s inclusion proof in its chunkset is valid, false otherwise.

Source

pub fn get_chunkset_id(&self) -> usize

Returns the ID of the chunkset this chunk belongs to.

Source

pub fn get_global_chunk_id(&self) -> usize

Returns the global ID of the chunk.

Source

pub fn get_local_chunk_id(&self) -> usize

Returns the local ID of the chunk.

Source

pub fn get_erasure_coded_data(&self) -> &[u8]

Returns a reference to the erasure-coded data contained within the chunk.

Source

pub fn append_proof_to_blob_root(&mut self, blob_proof: &[Hash])

Appends additional Merkle proof hashes to the existing proof, proving blob-level inclusion.

This is used to extend a chunkset-level proof to a blob-level proof. You are supposed to call this function after Self::new is used to contruct a new proof-carrying chunk, which originally holds a proof of inclusion in the corresponding chunkset.

§Arguments
  • blob_proof - A slice of blake3::Hash representing the proof to append.
Source

pub fn to_bytes(&self) -> Result<Vec<u8>, DecdsError>

Serializes the ProofCarryingChunk into a vector of bytes using bincode.

§Returns

Returns a Result which is:

  • Ok(Vec<u8>) containing the serialized bytes if successful.
  • Err(DecdsError::ProofCarryingChunkSerializationFailed) if serialization fails.
Source

pub fn from_bytes(bytes: &[u8]) -> Result<(Self, usize), DecdsError>

Deserializes a ProofCarryingChunk from a byte slice using bincode.

§Arguments
  • bytes - The byte slice from which to deserialize the chunk.
§Returns

Returns a Result which is:

  • Ok((Self, usize)) containing the deserialized ProofCarryingChunk and the number of bytes read if successful.
  • Err(DecdsError::ProofCarryingChunkDeserializationFailed) if deserialization fails.

Trait Implementations§

Source§

impl Clone for ProofCarryingChunk

Source§

fn clone(&self) -> ProofCarryingChunk

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProofCarryingChunk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ProofCarryingChunk

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ProofCarryingChunk

Source§

fn eq(&self, other: &ProofCarryingChunk) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ProofCarryingChunk

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ProofCarryingChunk

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,