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: u8Depth of preimage in the chain. Verified as
keccak^(index − verified)(preimage) == tip against the receiving
stream’s anchor.
Implementations§
Source§impl ChunkPreimage
impl ChunkPreimage
Sourcepub const fn validate(&self) -> Result<(), MessageValidationError>
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.