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
impl ProofCarryingChunk
Sourcepub fn validate_inclusion_in_blob(&self, blob_commitment: Hash) -> bool
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- Theblake3::Hashof 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.
Sourcepub fn validate_inclusion_in_chunkset(&self, chunkset_commitment: Hash) -> bool
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- Theblake3::Hashof 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.
Sourcepub fn get_chunkset_id(&self) -> usize
pub fn get_chunkset_id(&self) -> usize
Returns the ID of the chunkset this chunk belongs to.
Sourcepub fn get_global_chunk_id(&self) -> usize
pub fn get_global_chunk_id(&self) -> usize
Returns the global ID of the chunk.
Sourcepub fn get_local_chunk_id(&self) -> usize
pub fn get_local_chunk_id(&self) -> usize
Returns the local ID of the chunk.
Sourcepub fn get_erasure_coded_data(&self) -> &[u8] ⓘ
pub fn get_erasure_coded_data(&self) -> &[u8] ⓘ
Returns a reference to the erasure-coded data contained within the chunk.
Sourcepub fn append_proof_to_blob_root(&mut self, blob_proof: &[Hash])
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 ofblake3::Hashrepresenting the proof to append.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, DecdsError>
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.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<(Self, usize), DecdsError>
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 deserializedProofCarryingChunkand the number of bytes read if successful.Err(DecdsError::ProofCarryingChunkDeserializationFailed)if deserialization fails.
Trait Implementations§
Source§impl Clone for ProofCarryingChunk
impl Clone for ProofCarryingChunk
Source§fn clone(&self) -> ProofCarryingChunk
fn clone(&self) -> ProofCarryingChunk
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProofCarryingChunk
impl Debug for ProofCarryingChunk
Source§impl<'de> Deserialize<'de> for ProofCarryingChunk
impl<'de> Deserialize<'de> for ProofCarryingChunk
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ProofCarryingChunk
impl PartialEq for ProofCarryingChunk
Source§impl Serialize for ProofCarryingChunk
impl Serialize for ProofCarryingChunk
impl StructuralPartialEq for ProofCarryingChunk
Auto Trait Implementations§
impl Freeze for ProofCarryingChunk
impl RefUnwindSafe for ProofCarryingChunk
impl Send for ProofCarryingChunk
impl Sync for ProofCarryingChunk
impl Unpin for ProofCarryingChunk
impl UnwindSafe for ProofCarryingChunk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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