You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/docs/proto_v0.txt

805 lines
18 KiB
Plaintext

7 years ago
LLARP v0
7 years ago
LLARP (Low Latency Anon Routing Protocol) is a protocol for anonymizing senders and
recipiants of encrypted messages sent over the internet without a centralied
trusted party.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119 [RFC2119].
basic structures:
all structures are key, value dictionaries encoded with bittorrent encoding
7 years ago
notation:
7 years ago
a + b is a concatanated with b
a ^ b is a bitwise XOR b
x[a:b] is a memory slice of x from index a to b
BE(x) is bittorrent encode x
BD(x) is bittorrent decode x
{ a: b, y: z } is a dictionary with two keys a and y
who's values are b and z respectively
[ a, b, c ... ] is a list containing a b c and more items in that order
"<description>" is a bytestring who's contents and length is described by the
quoted value <description>
"<value>" * N is a bytestring containing the <value> concatenated N times.
7 years ago
cryptography:
6 years ago
see crypto_v0.txt
7 years ago
---
6 years ago
wire protocol
see iwp-v0.txt
---
datastructures:
all datastructures are assumed version 0 if they lack a v value
otherwise version is provided by the v value
6 years ago
all ip addresses can be ipv4 via hybrid dual stack ipv4 mapped ipv6 addresses,
i.e ::ffff.8.8.8.8. The underlying implementation MAY implement ipv4 as native
ipv4 instead of using a hybrid dual stack.
net address:
net addresses are a variable length byte string, if between 7 and 15 bytes it's
treated as a dot notation ipv4 address (xxx.xxx.xxx.xxx)
if it's exactly 16 bytes it's treated as a big endian encoding ipv6 address.
address info (AI)
An address info (AI) defines a publically reachable endpoint
7 years ago
{
c: transport_rank_uint16,
d: "<transport dialect name>",
e: "<32 bytes public encryption key>",
i: "<net address>",
p: port_uint16,
v: 0
}
6 years ago
example iwp address info:
{
c: 1,
6 years ago
d: "iwp",
e: "<32 bytes of 0x61>",
i: "123.123.123.123",
p: 1234,
v: 0
}
bencoded form:
6 years ago
d1:ci1e1:d3:iwp1:e32:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1:d3:iwp1:i15:123.123.123.1231:pi1234e1:vi0ee
Traffic Policy (TP)
Traffic policy (TP) defines port, protocol and QoS/drop policy.
{
a: protocol_integer,
b: port_integeger,
d: drop_optional_integer,
v: 0
}
drop d is set to 1 to indicate that packets of protocol a with source port b will be dropped.
if d is 0 or not provided this traffic policy does nothing.
7 years ago
Exit Info (XI)
6 years ago
An exit info (XI) defines a exit address that can relay exit traffic to the
internet.
7 years ago
{
6 years ago
a: "<net address exit address>",
b: "<net address exit netmask>",
6 years ago
k: "<32 bytes public encryption/signing key>",
p: [ list, of, traffic, policies],
v: 0
7 years ago
}
6 years ago
Exit Route (XR)
An exit route (XR) define an allocated exit address and any additional
information required to access the internet via that exit address.
{
a: "<16 bytes big endian ipv6 gateway address>",
b: "<16 bytes big endian ipv6 netmask>",
c: "<16 bytes big endian ipv6 source address>",
6 years ago
l: lifetime_in_milliseconds_uint64,
6 years ago
v: 0
}
router contact (RC)
6 years ago
router's full identity
{
a: [ one, or, many, AI, here ... ],
k: "<32 bytes public long term identity signing key>",
n: "<optional max 32 bytes router nickname>",
p: "<32 bytes public path encryption key>",
6 years ago
u: next_update_needed_milliseconds_since_epoch_uint64,
6 years ago
v: 0,
6 years ago
x: [ Exit, Infos ],
6 years ago
z: "<64 bytes signature using identity key>"
}
service info (SI)
6 years ago
public information blob for a hidden service
e is the long term public encryption key
6 years ago
s is the long term public signing key
v is the protocol version
x is a nounce value for generating vanity addresses that can be omitted
6 years ago
if x is included it MUST be equal to 16 bytes
6 years ago
{
e: "<32 bytes public encryption key>",
s: "<32 bytes public signing key>",
6 years ago
v: 0,
6 years ago
x: "<optional 16 bytes nonce for vanity>"
}
service address (SA)
6 years ago
the "network address" of a hidden service, which is computed as the blake2b
256 bit hash of the public infomration blob.
HS(BE(SI))
when in string form it's encoded with z-base32 and uses the .loki tld
introduction (I)
6 years ago
a descriptor annoucing a path to a hidden service
k is the rc.k value of the router to contact
6 years ago
p is the path id on the router that is owned by the service
v is the protocol version
6 years ago
x is the timestamp milliseconds since epoch that this introduction expires at
6 years ago
{
k: "<32 bytes public identity key of router>",
l: advertised_path_latency_ms_uint64, (optional)
p: "<16 bytes path id>",
6 years ago
v: 0,
6 years ago
x: time_expires_milliseconds_since_epoch_uint64
}
introduction set (IS)
a signed set of introductions for a hidden service
a is the service info of the publisher
i is the list of introductions that this service is advertising with
k is the public key to use when doing encryption to this hidden service
n is a 16 byte null padded utf-8 encoded string tagging the hidden service in
a topic searchable via a lookup (optional)
6 years ago
v is the protocol version
w is an optinal proof of work for DoS protection (slot for future)
6 years ago
z is the signature of the entire IS where z is set to zero signed by the hidden
service's signing key.
{
6 years ago
a: SI,
6 years ago
i: [ I, I, I, ... ],
k: "<1218 bytes sntrup4591761 public key block>",
n: "<16 bytes service topic (optional)>",
t: timestamp_uint64_milliseconds_since_epoch_published_at,
6 years ago
v: 0,
w: optional proof of work,
z: "<64 bytes signature using service info signing key>"
}
6 years ago
---
Encrypted frames:
6 years ago
Encrypted frames are encrypted containers for link message records like LRCR.
32 bytes hmac, h
32 bytes nounce, n
32 bytes ephmeral sender's public encryption key, k
remaining bytes ciphertext, x
decryption:
0) verify hmac
S = PKE(n, k, our_RC.K)
verify h == MDS(n + k + x, S)
If the hmac verification fails the entire parent message is discarded
1) decrypt and decode
new_x = SD(S, n[0:24], x)
msg = BD(new_x)
If the decoding fails the entire parent message is discarded
encryption:
to encrypt a frame to a router with public key B.k
0) prepare nounce n, ephemeral keypair (A.k, s) and derive shared secret S
A.k, s = ECKG()
n = RAND(32)
S = PKE(p, A.k, B.k, n)
6 years ago
1) encode and encrypt
x = BE(msg)
new_x = SE(S, n[0:24], x)
2) generate message authentication
6 years ago
6 years ago
h = MDS(n + A.k + new_x, S)
6 years ago
resulting frame is h + n + A.k + new_x
---
link layer messages:
the link layer is responsible for anonymising the source and destination of
routing layer messages.
any link layer message without a key v is assumed to be version 0 otherwise
indicates the protocol version in use.
6 years ago
link introduce message (LIM)
This message MUST be the first link message sent before any others. This message
identifies the sender as having the RC contained in r. The recipiant MUST
validate the RC's signature and ensure that the public key in use is listed in
the RC.a matching the ipv6 address it originated from.
{
a: "i",
n: "<32 bytes nonce for key exhcange>",
p: uint64_milliseconds_session_period,
6 years ago
r: RC,
v: 0,
z: "<64 bytes signature of entire message by r.k>"
6 years ago
}
the link session will be kept open for p milliseconds after which
the session MUST be renegotiated.
link relay commit message (LRCM)
6 years ago
request a commit to relay traffic to another node.
{
a: "c",
c: [ list, of, encrypted, frames ],
6 years ago
v: 0
7 years ago
}
c and r MUST contain dummy records if the hop length is less than the maximum
hop length.
6 years ago
link relay commit record (LRCR)
7 years ago
record requesting relaying messages for 600 seconds to router
6 years ago
on network who's i is equal to RC.k and decrypt data any messages using
6 years ago
PKE(n, rc.K, c) as symettric key for encryption and decryption.
7 years ago
if l is provided and is less than 600 and greater than 10 then that lifespan
is used (in seconds) instead of 600 seconds.
6 years ago
if w is provided and fits the required proof of work then the lifetime of
the path is extended by w.y seconds
7 years ago
{
c: "<32 byte public encryption key used for upstream>",
6 years ago
i: "<32 byte RC.k of next hop>",
l: uint_optional_lifespan,
6 years ago
n: "<32 bytes nounce for key exchange>",
r: "<16 bytes rx path id>",
t: "<16 bytes tx path id>",
v: 0,
6 years ago
w: proof of work
}
6 years ago
w if provided is a dict with the following struct
{
t: time_created_seconds_since_epoch,
6 years ago
v: 0,
y: uint32_seconds_extended_lifetime,
z: "<32 bytes nonce>"
}
6 years ago
the validity of the proof of work is that given
7 years ago
6 years ago
h = HS(BE(w))
6 years ago
h has log_e(y) prefixed bytes being 0x00
6 years ago
this proof of work requirement is subject to change
6 years ago
if i is equal to RC.k then any LRDM.x values are decrypted and interpreted as
routing layer messages. This indicates that we are the farthest hop in the path.
7 years ago
link relay upstream message (LRUM)
sent to relay data via upstream direction of a previously created path.
{
a: "u",
6 years ago
p: "<16 bytes path id>",
6 years ago
v: 0,
6 years ago
x: "<N bytes encrypted x1 value>",
6 years ago
y: "<32 bytes nonce>"
}
6 years ago
x1 = SD(k, y, x)
6 years ago
6 years ago
if we are the farthest hop, process x1 as a routing message
otherwise transmit a LRUM to the next hop
{
6 years ago
a: "u",
6 years ago
p: p,
v: 0,
x: x1,
y: y ^ HS(k)
}
6 years ago
link relay downstream message (LRDM)
sent to relay data via downstream direction of a previously created path.
6 years ago
{
a: "d",
p: "<16 bytes path id>",
v: 0,
x: "<N bytes encrypted x1 value>",
y: "<32 bytes nonce>"
}
6 years ago
6 years ago
if we are the creator of the path decrypt x for each hop key k
6 years ago
x = SD(k, y, x)
6 years ago
otherwise transmit LRDM to next hop
6 years ago
x1 = SE(k, y, x)
{
6 years ago
a: "d",
p: p,
6 years ago
v: 0,
6 years ago
x: x1,
y: y ^ HS(k)
}
link immediate dht message (LIDM):
transfer one or more dht messages directly without a previously made path.
{
6 years ago
a: "m",
m: [many, dht, messages],
6 years ago
v: 0
}
6 years ago
6 years ago
link immediate SML message (LISM)
6 years ago
6 years ago
transfer an SML message between nodes
6 years ago
6 years ago
{
a: "s",
s: SMLMessage,
v: 0
}
----
6 years ago
Stateles Mesh Layer (SML)
As a censor circumvention method layer 4 (udp) or layer 2 (ethernet)
network bridges are used to stateless route messages to the main onion
routing network in a stateless manner such that these network bridges
can be cacsaded many layers deep. The incentive to run these would be
the ability to hide your traffic shape in the shape of others without
the need to excess node churn.
6 years ago
stateless mesh discovery protocol (SMDP)
6 years ago
protocol for detecting and discovering mesh local
topology and where the mainline network is.
6 years ago
TODO: implement me
stateless mesh layer (SML)
similar to link layer messeages but sent over the connectivity mesh layer that
uses ethernet.
SML messages MUST be contained inside a LISM when not over ethernet.
6 years ago
SML message MUST be routed to the recipiant if we are not the recipiant based
on the currently unspecified stateless routing protocol.
TODO: implement routing protocol :^)
{
6 years ago
a: protocol_id_uint16
r: "<32 bytes public identity key of recipiant>",
s: "<32 bytes public identity key of sender>",
6 years ago
t: "<1280 bytes payload>",
v: 0,
6 years ago
z: "<64 bytes signature generated by sender>"
}
6 years ago
protocol values:
6 years ago
0 - mesh discovery
6 years ago
t is a SMDP frame (todo: specify me)
6 years ago
1 - direct chat
t is a NUL padded plaintext chat message for node opers to communicate between
nodes.
6 years ago
2 - relayed data packet
6 years ago
t is a udp packet relayed from a client behind a client.
6 years ago
6 years ago
3 - snode to snode direct ip traffic
t is an ip packet for "0 hop" direct ip traffic between service nodes
6 years ago
---
routing layer:
6 years ago
the routing layer provides inter network communication between the LLARP link
layer and ip (internet protocol) for exit traffic or ap (anonymous protocol) for
hidden services. replies to messages are sent back via the path they
originated from inside a LRDM. all routing messages have an S value which
provides the sequence number of the message so the messages can be ordered.
6 years ago
ipv4 addresses are allowed via ipv4 mapped ipv6 addresses, i.e. ::ffff.10.0.0.1
6 years ago
path confirm message (PCM)
6 years ago
6 years ago
sent as the first message down a path after it's built to confirm it was built
6 years ago
always the first message sent
6 years ago
{
6 years ago
A: "P",
L: uint64_milliseconds_path_lifetime,
S: 0,
T: uint64_milliseconds_sent_timestamp,
6 years ago
V: 0
}
path latency message (PLM)
a latency measurement message, reply with a PLM response if we are the far end
of a path.
6 years ago
variant 1, request, generated by the path creator:
{
A: "L",
S: uint64_sequence_number,
6 years ago
V: 0
}
variant 2, response, generated by the endpoint that recieved the request.
{
A: "L",
S: uint64_sequence_number,
T: uint64_timestamp_recieved,
6 years ago
V: 0
}
obtain exit address message (OXAM)
sent to an exit router to obtain a NAT ip address for ip exit traffic.
replies are sent down the path that messages originate from.
{
7 years ago
A: "X",
6 years ago
B: [list, of, permitted, blacklisted, traffic, policies],
I: "<32 bytes signing public key for future communication>",
S: uint64_sequence_number,
6 years ago
T: uint64_transaction_id,
6 years ago
V: 0,
6 years ago
W: [list, of, required, whitelisted, traffic, policies],
7 years ago
X: lifetime_of_address_mapping_in_seconds_uint64,
6 years ago
Z: "<64 bytes signature using I>"
}
grant exit address messsage (GXAM)
6 years ago
sent in response to an OXAM to grant an ip for exit traffic from an external
ip address used for exit traffic.
{
A: "G",
6 years ago
E: XR,
I: "<32 bytes signing public key of requester>",
S: uint64_sequence_number,
6 years ago
T: transaction_id_uint64,
6 years ago
V: 0,
6 years ago
Z: "<64 bytes signature using exit info's signing key>"
}
6 years ago
E contains an exit route that was granted to the requester that can be used with
6 years ago
IP exit traffic.
6 years ago
The requester will now have any ip traffic going to address S forwarded to them
via the path that originally sent the OXAM and any TDFM will is recieved on the
same path will be forwarded out to the internet, given that they have
6 years ago
valid signatures and addresses.
reject exit address message (RXAM)
6 years ago
sent in response to an OXAM to indicate that exit traffic is not allowed or
was denied.
{
A: "J",
B: backoff_milliseconds_uint64,
I: "<32 bytes signing public key of requester>",
6 years ago
R: [list, of, rejected, traffic, policies],
S: uint64_sequence_number,
6 years ago
T: transaction_id_uint64,
6 years ago
V: 0,
6 years ago
Z: "<64 bytes signature signed by exit info's signing key>"
}
7 years ago
discarded data fragment message (DDFM)
sent in reply to TDFM when we don't have a path locally or are doing network
congestion control. indcates a TDFM was discarded.
{
A: "D",
P: "<16 bytes path id>",
S: uint64_sequence_number_of_fragment_dropped,
V: 0
}
transfer data fragment message (TDFM)
transfer data between paths.
{
A: "T",
P: "<16 bytes path id>",
S: uint64_sequence_number,
T: hidden_service_frame,
V: 0
}
transfer data to another path with id P on the local router place a random 32
byte and T values into y and z values into a LRDM message (respectively) and
send it in the downstream direction. if this path does not exist on the router
it is replied to with a DDFM.
hidden service data (HSD)
data sent anonymously over the network to a recipiant from a sender.
sent inside a HSFM encrypted with a shared secret.
{
a: protocol_number_uint,
d: "<N bytes payload>",
i: Introduction for reply,
n: uint_message_sequence_number,
o: N seconds until this converstation plans terminate,
s: SI of sender,
t: "<16 bytes converstation tag present only when n is 0>",
v: 0
}
6 years ago
hidden service frame (HSF)
6 years ago
TODO: document this better
6 years ago
intro message (variant 1)
start a new session
{
6 years ago
A: "H",
C: "<1048 bytes ciphertext block>",
6 years ago
D: "<N bytes encrypted HSD>",
N: "<32 bytes nonce for key exchange>",
V: 0,
Z: "<64 bytes signature of entire message using sender's signing key>"
}
alice (A) wants to talk to bob (B) over the network, both have hidden services
set up and are online on the network.
A and B are both SI.
A_sk is alice's private signing key.
for alice (A) to send the string "beep" to bob (B), alice picks an introduction
to use on one of her paths (I_A) such that I_A is aligning with one of bobs's
paths (I_B)
6 years ago
alice generates:
T = RAND(16)
m = {
a: 0,
d: "beep",
i: I_A,
n: 0,
s: A,
t: T,
v: 0
6 years ago
}
X = BE(m)
6 years ago
C, K = PQKE_A(I_B.k)
N = RAND(32)
D = SE(X, K, N)
6 years ago
M = {
A: "T",
P: I_B.P,
S: uint64_sequence_number,
T: {
A: "H",
C: C,
D: D,
N: N,
V: 0,
Z: "\x00" * 64
},
V: 0
}
Z = S(A_sk, BE(M))
7 years ago
alice transmits a TDFM to router with public key I_B.K via her path that ends
with router with public key I_B.k
7 years ago
{
A: "T",
P: I_B.P,
S: uint64_sequence_number,
T: {
A: "H",
C: C,
D: D,
N: N,
V: 0,
Z: Z
},
6 years ago
V: 0
7 years ago
}
the shared secret (S) for further message encryption is:
S = HS(K + PKE(A, B, sk, N))
given sk is the local secret encryption key used by the current hidden service
please note:
signature verification can only be done after decryption
TODO: explain bob's side too (it's invsere of alice's process)
data from a previously made session (variant 2)
transfer data on a session previously made
{
A: "H",
D: "<N bytes encrypted HSD>",
N: "<32 bytes nonce for symettric cipher>",
T: "<16 bytes converstation tag>",
V: 0,
Z: "<64 bytes signature using sender's signing key>"
}
6 years ago
transfer ip traffic message (TITM)
7 years ago
transfer ip traffic for exit
{
A: "E",
S: uint64_sequence_number,
6 years ago
V: 0,
X: "<N bytes ip packet>",
6 years ago
Y: "<16 bytes nounce>",
Z: "<64 bytes signature using previously provided signing key>"
7 years ago
}
X is parsed as an IP packet and the source addresss is extracted.
6 years ago
Next we find the corrisponding signing key for a previously granted exit address
and use it to validate the siganture of the entire message. If the signing key
cannot be found or the signature is invalid this message is dropped, otherwise
the X value is sent on the appropriate exit network interface.
When we recieve an ip packet from the internet to an exit address, we put it
into a TITM, signed with the exit info's signing key and send it downstream the
corrisponding path in an LRDM.
6 years ago
update exit path message (UXPM)
sent from a new path by client to indicate that a previously established exit
should use the new path that this message came from.
{
A: "U",
S: uint64_sequence_number,
6 years ago
T: transaction_id_uint64,
V: 0,
Y: "<16 bytes nounce>",
Z: "<64 bytes signature using previously provided signing key>"
}
T is the transaction ID from the GXAM
close exit path message (CXPM)
client sends a CXPM when the exit is no longer needed.
The address used in exit MAY be reused later.
{
A: "C",
S: uint64_sequence_number,
6 years ago
T: transaction_id_uint64,
V: 0,
Y: "<16 bytes nounce>",
Z: "<64 bytes signagure using previously provided signing key>"
}
DHT message holder message:
wrapper message for sending many dht messages down a path.
{
A: "M",
M: [many, dht, messages, here],
S: uint64_sequence_number,
V: 0
}