Carriage
Purpose
The transport's one promise, seen from its two ends: a payload in at the sender's edge, the same
payload out at the recipient's, and nothing on the wire that says who it is for. Delivering turns
an opaque payload into routed cells — the payload arrives already sealed by the layer above,
meaningless here; it is split into fixed-size chunks so every cell is the same size, each chunk
sealed under the recipient's SealKey into a Cell the recipient will recognise and can open,
and each cell launched into the tumbler pool through a randomly chosen entry peer, bound for the
recipient's edge. From there the payload is a handful of indistinguishable cells drifting through
the mix.
Collecting is the same promise kept at the other end: cells arrive at the recipient's edge mixed
in with everyone else's who shares that edge, and each one's DetectionTag is tested against the
SealKeys the recipient holds — a cheap check, no unsealing — keeping only the cells that are
theirs and discarding the rest untried. Each kept cell is unsealed into its CellContent, the
chunks are grouped by reassembly id, and a group whose every chunk has arrived is reassembled, in
index order, back into the Payload the layer above will read. A payload still missing a chunk
waits for a later collection. A recipient's collecting touches only their own edge and reveals
nothing about who sent to them.
Role Players
- wire: Wire — the floor seam the cells travel through: handed each launched cell, asked for the cells arrived at an edge
- entropy: Entropy — the randomness that draws each payload's reassembly id and picks each entry peer
Props
(none — each end of the promise brings its own particulars to its act)
Role Methods
wire
- handed: given the peer
Peerand the cellCell, hands the cell to the network toward that peer — fire and forget, the launch of one cell. Result: None - arrived: given the edge
Peer, provides theCellsthat have arrived at it awaiting handling, in no promised order. Result: theCellsthat have arrived at the edge
entropy
- drawn: provides a freshly drawn opaque id, the reassembly id one payload's chunks share.
Result: the drawn id as
Text - entryPeer: given the candidates
Peers, picks the one a cell enters the pool through. Result: the pickedPeer
Functionalities
deliver
Given the payload Payload, the seal key SealKey, the candidates Peers, and the hops Count, splits the payload into fixed-size chunks; for each chunk in turn, builds a CellContent
carrying a reassembly id shared across the payload's chunks — drawn once from the entropy — the
chunk's index and the chunk count, and the chunk itself; seals it under the seal key; wraps it in
a Cell with a DetectionTag the recipient recognises under the seal key and the hop count as
its hops remaining; and hands each cell to the wire toward an entry peer the entropy picks. It
yields the Cells it dispatched — one per chunk, each already on its way.
Result: the dispatched Cells, one per chunk
collect
Given the edge Peer and the keys SealKeys, collects from the wire the cells that have arrived
at that edge; keeps each cell whose detection tag matches one of the keys, discarding the rest
untried; unseals each kept cell with the key that matched into its CellContent; groups the
chunks by reassembly id; and for each group whose chunks are all present — every index from the
first to the chunk count — reassembles them in index order into the Payload. It yields the
Payloads it could reassemble; a payload still missing a chunk waits, reassembled on a later
collection once the chunk arrives.
Result: the reassembled Payloads
Scenarios
A payload becomes same-size cells, each on its way
Given: a Carriage with a wire and an entropy
When: deliver is performed with a Payload whose bytes span three chunks, the SealKey "sk-0163", entry peer candidates "peer-1" and "peer-2", and hop count 3
Then: three cells are dispatched, each the same size, each carrying a DetectionTag that verifies under "sk-0163", each with hops remaining 3, and each handed to the wire toward one of the entry peers
The dispatched cells share one reassembly id
Given: a Carriage with a wire and an entropy
When: deliver is performed with a Payload spanning two chunks, the SealKey "sk-0163", entry peer candidates "peer-1", and hop count 2
Then: the two dispatched cells, once unsealed under "sk-0163", carry the same reassembly id and the chunk indices 0 and 1 of chunk count 2 — one payload, two cells
A recipient reassembles their own payload and ignores the rest
Given: a Carriage with a wire holding three cells for reassembly id "ra-01" — chunks 0, 1, and 2 of 3, each sealed under "sk-0163" and tagged for it — and one cell tagged for a key she does not hold, and an entropy
When: collect is performed with the edge Peer "edge-sofie" and keys holding the SealKey "sk-0163"
Then: one Payload is produced — the three "ra-01" chunks reassembled in order — and the foreign cell is discarded untried
A payload still missing a chunk waits
Given: a Carriage with a wire holding two of the three cells for reassembly id "ra-01" — chunks 0 and 2 of 3, sealed under "sk-0163" — and an entropy
When: collect is performed with the edge Peer "edge-sofie" and keys holding "sk-0163"
Then: no payload is produced yet — chunk 1 has not arrived, so the group is held incomplete until a later collection