Skip to main content

ChunkPreimage

Struct ChunkPreimage 

Source
pub struct ChunkPreimage {
    pub preimage: [u8; 32],
    pub index: u8,
}
Expand description

Payer → node released hash-chain preimage, advancing the lane’s claim by one chunk with no signature (ADR 003 §Hash-chain metering (PayWord), ADR 005 §Payment quantum and credit window).

Released after the payer has received and verified the chunk it pays for, so the payer’s exposure stays at zero. Preimage resistance makes the value self-proving: nobody derives keccak^(N−k−1)(s) from keccak^(N−k)(s) without the seed, so a deeper preimage is the receipt for every chunk below it.

§Wire encoding

preimage ‖ index, 33 bytes flat — postcard writes a [u8; 32] raw and a u8 as one byte, so there is no length prefix and no varint. The byte IS the index, with no offset on send and no increment on receipt.

§Index domain

Releasable indices are 1..=MAX_CHAIN_LENGTH. index == 0 is a protocol error — index 0 names chain_root and is the settlement case at redemption, so it proves nothing the voucher does not already say. It is rejected in band by the delivery handler as VoucherRejectReason::ChainIndexZero rather than at decode, so the payer learns why instead of seeing an opaque stream close. An index above MAX_CHAIN_LENGTH cannot be encoded at all: the walk is bounded at 255 hashes by the type, which is stronger than a runtime comparison.

Fields§

§preimage: [u8; 32]

The released value, keccak^(MAX_CHAIN_LENGTH − index) of the payer’s per-lane seed.

§index: u8

Depth of preimage in the chain. Verified as keccak^(index − verified)(preimage) == tip against the receiving stream’s anchor.

Implementations§

Source§

impl ChunkPreimage

Source

pub const fn validate(&self) -> Result<(), MessageValidationError>

Always Ok. Both fields are fixed-width, so a decoded ChunkPreimage has no shape to check — and the one value invariant (index != 0) is deliberately not enforced here: it must surface as an in-band VoucherRejectReason::ChainIndexZero from the delivery handler, which holds the stream it has to answer on. Validating it here would collapse that reason into a decode failure and close the stream mute.

Present so ClientMessage::validate stays total over the enum, for the same reason ChunkData::validate is.

§Errors

Never.

Trait Implementations§

Source§

impl Clone for ChunkPreimage

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ChunkPreimage

Source§

impl Debug for ChunkPreimage

Source§

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

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

impl<'de> Deserialize<'de> for ChunkPreimage

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 Eq for ChunkPreimage

Source§

impl PartialEq for ChunkPreimage

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for ChunkPreimage

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 ChunkPreimage

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.