View Source Lob (Lob v1.0.3)

Length-Object-Binary (LOB) Packet Encoding

Data serialization, primarily in use by the Telehash Project

Summary

Functions

Cloak a packet to frustrate wire monitoring

De-cloak a cloaked packet.

Decode a wire packet for consumption

Encode a head and body into a packet

Types

@type maybe_binary() :: binary() | nil

Functions

@spec cloak(binary()) :: binary()

Cloak a packet to frustrate wire monitoring

A random number (between 1 and 20) of rounds are applied. This also serves to slightly obfuscate the message size.

@spec decloak(binary()) :: Lob.DecodedPacket.t() | no_return()

De-cloak a cloaked packet.

Upon success, the decoded packet will have the number of cloaking rounds unfurled in the cloaked field.

@spec decode(binary()) :: Lob.DecodedPacket.t() | no_return()

Decode a wire packet for consumption

The parts are returned in a struct compliant with the specification. Errors reflecting improperly decoded JSON are stored in the json field.

@spec encode(maybe_binary() | map(), maybe_binary()) :: binary() | no_return()

Encode a head and body into a packet

The packet should be usable across any supported transport. May raise an exception if the payload is too large or there are encoding errors.