Sphinx per-hop routing commands #
A routing-info block is a sequence of tag-prefixed commands, read until a null tag or the end of
the block. Every command has a constant wire size.
A routing command. null is the terminal marker (tag 0x00, no body).
- nextNodeHop (id mac : Vector UInt8 32) : RoutingCommand
- recipient (id : Vector UInt8 32) : RoutingCommand
- surbReply (id : Vector UInt8 16) : RoutingCommand
- nodeDelay (delay : UInt32) : RoutingCommand
- null : RoutingCommand
Instances For
@[instance_reducible]
Equations
- One or more equations did not get rendered due to their size.
- Cryptlib.Protocols.Sphinx.Commands.instBEqRoutingCommand.beq Cryptlib.Protocols.Sphinx.Commands.RoutingCommand.null Cryptlib.Protocols.Sphinx.Commands.RoutingCommand.null = true
- Cryptlib.Protocols.Sphinx.Commands.instBEqRoutingCommand.beq x✝¹ x✝ = false
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[instance_reducible]
Equations
- (Cryptlib.Protocols.Sphinx.Commands.RoutingCommand.nextNodeHop a a_1).toBytes = { data := #[1] } ++ Cryptlib.Util.Bytes.ofVector a ++ Cryptlib.Util.Bytes.ofVector a_1
- (Cryptlib.Protocols.Sphinx.Commands.RoutingCommand.recipient a).toBytes = { data := #[2] } ++ Cryptlib.Util.Bytes.ofVector a
- (Cryptlib.Protocols.Sphinx.Commands.RoutingCommand.surbReply a).toBytes = { data := #[3] } ++ Cryptlib.Util.Bytes.ofVector a
- (Cryptlib.Protocols.Sphinx.Commands.RoutingCommand.nodeDelay a).toBytes = { data := #[128] } ++ Cryptlib.Util.Bytes.ofVector (Cryptlib.Protocols.Sphinx.Commands.u32be✝ a)
- Cryptlib.Protocols.Sphinx.Commands.RoutingCommand.null.toBytes = { data := #[0] }
Instances For
@[simp]
theorem
Cryptlib.Protocols.Sphinx.Commands.RoutingCommand.nextNodeHop_toBytes_size
(id mac : Vector UInt8 32)
:
A .nextNodeHop serializes to exactly nextNodeHopLength bytes.
Parse one command, returning it and the unconsumed remainder. none means an empty buffer or
the null terminal.
Equations
- One or more equations did not get rendered due to their size.
Instances For
parseAll with explicit fuel, so its behavior is provable.
Equations
- One or more equations did not get rendered due to their size.
- Cryptlib.Protocols.Sphinx.Commands.parseAllFuel 0 x✝ = pure []
Instances For
Parse every command in a routing-info block, stopping at null or the end of the buffer.
Equations
Instances For
theorem
Cryptlib.Protocols.Sphinx.Commands.parseAllFuel_append_zeros
(cmds : List RoutingCommand)
(hn : ∀ c ∈ cmds, c ≠ RoutingCommand.null)
(zeros : ByteArray)
(hzeros : (zeros.data.all fun (x : UInt8) => x == 0) = true)
(fuel : ℕ)
(hfuel : cmds.length ≤ fuel)
:
parseAllFuel fuel
(List.foldl (fun (acc : ByteArray) (c : RoutingCommand) => acc ++ c.toBytes) ByteArray.empty cmds ++ zeros) = Except.ok cmds
Parsing serialized commands followed by any all-zero padding recovers the commands, given
enough fuel and no .null among them.
theorem
Cryptlib.Protocols.Sphinx.Commands.parseAll_append_zeros
(cmds : List RoutingCommand)
(hn : ∀ c ∈ cmds, c ≠ RoutingCommand.null)
(zeros : ByteArray)
(hzeros : (zeros.data.all fun (x : UInt8) => x == 0) = true)
:
parseAll (List.foldl (fun (acc : ByteArray) (c : RoutingCommand) => acc ++ c.toBytes) ByteArray.empty cmds ++ zeros) = Except.ok cmds
parseAll undoes commandsToBytes followed by any all-zero padding.