Expand description
StreamsRoot: the sender’s stream commitment.
Each block that sends commits one hash, the root of a keyed binary Patricia trie over
(StreamId, current stream root) for every active stream. The relay records it as the sender’s
Provides, and a receiver proves the streams it consumed against it, without a sender-state
proof.
§Why a keyed trie
The trie is keyed by StreamId::to_bytes, so a proof is a walk driven by the key:
verification recomputes the leaf from the caller’s StreamId and takes each branch direction
from that key’s bits. A proof built for stream A cannot verify as stream B. Requires-lift
synthesis depends on this, since lifts are matched to the consumption record’s streams by
position. A positional Merkle tree does not give it. Patricia compression also keeps proofs
O(log S) in the number of streams rather than O(64) in the key width.
Roles: the sender builds the root (streams_root) and its node serves proofs
(gen_stream_proof), checking its own header digest (read_streams_root); a receiver’s
lift walks a proof up to the committed root (streams_root_from_proof).
A leaf hash binds the full key, an inner hash its split bit.
Structs§
- Stream
Proof - A membership proof that
(stream, stream_root)is committed under aStreamsRoot. Served by the sender, verified by the receiver. Carries no leaf index; the key drives the walk. - Streams
Root - The sender’s per-block stream commitment root. Defined relay-side and re-exported here.
Root of a sender’s stream commitment tree: a compact binary trie keyed by the 8-byte
StreamIdencoding, with the streams’ MMR roots as leaves. - Tree
Step - One step of a trie walk. The branch direction is not stored; verification takes it from the
proven key’s bit at
split_bit.
Functions§
- gen_
stream_ proof - Build the trie over
entriesand return(StreamsRoot, proof)forstream, orNoneif absent. Sender side. - read_
streams_ root - Read the sender’s
StreamsRootfrom its header digest.Noneif absent or not exactly what the sender deposits: oneSPMSitem with a 32-byte payload. Foreign readers must agree on validity, so nothing else is accepted. - streams_
root - The
StreamsRootover(stream, stream_root)entries;Nonewith no active streams. Sender side. Takes aBTreeMapso keys are unique; duplicates would reachfirst_diverging_bitwith identical keys. - streams_
root_ from_ proof - Fold a membership proof for
(stream, stream_root)up to theStreamsRootit implies, orNoneon a malformed step. Callers compare the root themselves (the requires-lift records it, the fetch checks it againstunder). Each branch direction isstream’s bit atsplit_bit, so a proof built for another stream folds the siblings on the wrong sides and yields a different root.