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/doc/proto_v0.txt

658 lines
16 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:
H(x) is 512 bit blake2b digest of x
7 years ago
HS(x) is 256 bit blake2b digest of x
7 years ago
MD(x, k) is 512 bit blake2b hmac of x with secret value k
7 years ago
MDS(x, k) is 256 bit blake2b hmac of x with secret value k
7 years ago
NE(k, x) is sntrup4591761 encrypt data x to public key k
ND(k, x) is sntrup4591761 decrypt data x with private key k
SE(k, n, x) is chacha20 encrypt data x using symettric key k and nounce n
SD(k, n, x) is chacha20 dectypt data x using symettric key k and nounce n
S(k, x) is sign x with ed25519 using seed k
7 years ago
ECKG() is generate ec keypair (p, s) public key p, seed s, both 32 bytes
7 years ago
V(k, x, sig) is verify x data using signature sig using public key k
7 years ago
DH(x, y) is a ecdh key exchange using ed25519 scalarmult between public keys x
and y
7 years ago
KE(x, y) is a ecdh key exchange using H(x + y + DH(x, y))
PKE(x, y, n) is a path key exchange using MDS(n, KE(x, y))
TKE(x, y, n) is a transport key exchange using MD(n, KE(x, y))
RAND(n) is n random bytes
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
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
{
a: "<16 bytes big endian ipv6 address>",
b: "<16 bytes big endian ipv6 netmask>",
7 years ago
k: "<32 bytes public encryption/signing key>",
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>",
e: lifetime_in_seconds_uint64,
v: 0
}
router contact (RC)
{
a: [ one, or, many, AI, here ... ],
7 years ago
k: "<32 bytes public signing/encryption identity key>",
6 years ago
u: last_updated_seconds_since_epoch_uint64,
7 years ago
v: 0,
7 years ago
x: [ Exit, Infos ],
7 years ago
z: "<64 bytes signature using identity key>"
}
service info (SI)
{
n: "<optional claimed name>",
s: "<32 bytes public signing key>",
7 years ago
v: 0,
x: "<optional nounce for vanity>"
}
service address (SA)
H(BE(SI))
7 years ago
introducer (I)
{
7 years ago
i: "<32 bytes public key of router>",
p: path_id_uint64,
7 years ago
v: 0,
x: time_expires_seconds_since_epoch_uint64
}
7 years ago
introducer set (IS)
{
7 years ago
a: "<64 bytes SA>",
e: "<1218 bytes ntru public encryption key>",
7 years ago
i: [ I, I, I, ... ],
7 years ago
v: 0,
z: "<64 bytes signature using service info signing key>"
}
7 years ago
---
Encrypted frames:
{
v: 0,
w: <32+32+32+N bytes payload>
}
7 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)
1) encode and encrypt
x = BE(msg)
new_x = SE(S, n[0:24], x)
2) generate hmac
6 years ago
h = MDS(n + A.k + new_x, S)
7 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",
r: RC,
v: 0
}
link relay commit message (LRCM)
6 years ago
request a commit to relay traffic to another node.
{
a: "c",
7 years ago
b: [ list, of, encrypted, frames ],
v: 0,
7 years ago
}
7 years ago
7 years ago
link relay commit record (LRCR)
7 years ago
7 years ago
record requesting path with id p relay messages for x seconds to router
6 years ago
-+on network who's i is equal to RC.k and decrypt data any messages using
7 years ago
PKE(n, rc.K, c) as symettric key for encryption and decryption.
7 years ago
{
c: "<32 byte public signing/encryption key used for further communication>",
7 years ago
i: "<32 byte RC.k of next hop>",
n: "<32 bytes nounce for key exchange>",
p: path_id_uint64,
7 years ago
v: 0,
7 years ago
x: seconds_lifetime_uint64
}
7 years ago
if i is equal to RC.k then any LRDM.z values are decrypted and interpreted as
routing layer messages.
if i is not equal to RC.k then forward the LRCM with first element removed
and the last element holding our hop's reply. this ensures that the first entry
in the forwarded LRCM is for the next hop in the requested path.
7 years ago
if i is equal to RC.k unconditionally send a LRDM with encrypted payload
holding a LRSM with our record at the end and the previous ones in the front.
link relay reject record (LRRR)
sent in reply to a LRCM indicating we have rejected the request to relay data
for path with id p, the recipiant of this message MUST backoff sending LRCM for
b milliseconds or recipiant MAY get banned by recipiant router for an undefined
amount of time. r contains a bytestring of 7 bit clean ascii metadata indicating
why the commit was rejected. if included r MUST be logged or collected for later
review by node operator. inclusion of r is OPTIONAL. review of collected events
is RECOMMENDED.
{
b: miliseconds_backoff_uint64,
7 years ago
c: "r",
p: path_id_uint64,
7 years ago
r: "<optional reason metadata here>",
7 years ago
v: 0,
7 years ago
x: "<N bytes arbirary padding>"
}
7 years ago
link relay accept record (LRAR)
sent in reply to a LRCM indicating we have accepted the request to relay data
for path with id p.
{
7 years ago
c: "a",
p: path_id_uint64,
7 years ago
v: 0,
7 years ago
x: "<N bytes arbitrary padding>"
}
7 years ago
link relay status message (LRSM)
sent inside a LRDM after build has reached the end of the path to finish the
path build and send the result of the build.
{
a: "s",
7 years ago
p: [list, of, encrypted, replies],
v: 0,
7 years ago
}
link relay upstream message (LRUM)
sent to relay data via upstream direction of a previously created path.
7 years ago
decrypt z using previously derived key and nounce y. Relay with new_y and new_z
in upstream direction as a LRUM.
new_z = SD(k, y, z)
7 years ago
new_y = y ^ new_z[0:24]
{
a: "u",
p: path_id_uint64,
7 years ago
v: 0,
7 years ago
y: "<insert 24 bytes nounce here>",
7 years ago
z: "<insert N bytes payload here>"
}
link relay downstream message (LRDM)
sent to relay data via downstream direction of a previously created path.
7 years ago
encrypt z using previously derived key and nonce new_y and relay in downstream
direction as a LRDM.
7 years ago
new_y = y ^ z[0:24]
new_z = SE(k, new_y, z)
{
a: "d",
p: path_id_uint64,
7 years ago
v: 0,
7 years ago
y: "<insert 24 bytes nounce here>",
7 years ago
z: "<insert N bytes payload here>"
}
link relay exit message (LRXM)
sent to exit a previously commited path before it expires.
verify signature using cancel key c in relay commit message.
7 years ago
{
a: "x",
7 years ago
b: [ list, of, exit, records, as, encrpyted, frames ],
7 years ago
v: 0,
7 years ago
}
7 years ago
link relay exit record (LRXR)
{
7 years ago
c: "x",
p: path_id_uint64,
7 years ago
v: 0,
7 years ago
x: "<N bytes padding>",
z: "<64 bytes signature>"
}
link immediate dht message (LIDM):
transfer one or more dht messages directly without a previously made path.
{
a: "d",
d: [many, dht, messages],
v: 0,
}
7 years ago
link stateless relay message (LSRM)
7 years ago
statelessly relay a link message.
{
a: "r",
c: r5n_counter_uint8,
d: "<32 bytes rc.K of destination>",
s: "<32 bytes rc.K of source>",
v: 0,
x: "<N bytes encrypted link message>",
y: "<24 bytes nounce>",
z: "<64 bytes signature>"
}
ONLY exchanged over ethernet, if recieved from an IP link it MUST be discarded.
relay an encrypted link message from source s to destination d.
check signature z using public key s and discard if invalid signature.
if d is equal to ourRC.k then decrypt x via SD(KE(d, s), y, x) and process it as
a link message. if the inner decrypted link message is a LRCM forward all
following LRUM, LRDM and LRSM to s via a LSRM. LIDM and LSRM are discarded.
if d is not equal to ourRC.k then forward it to an ethernet peer that is cloeser
to d than you are. if you are closer to d than all of your other ethernet peers
then increment c and send to the ethernet peer with the lowest detected latency
that isn't the peer that this message was recieved from but ONLY if c is less
than 128. if c is equal to or greater than 128 then the message is discarded.
7 years ago
---
routing layer:
7 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.
6 years ago
ipv4 addresses are allowed via ipv4 mapped ipv6 addresses, i.e. ::ffff.10.0.0.1
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",
I: "<32 bytes signing public key for future communication>",
7 years ago
V: 0,
7 years ago
X: lifetime_of_address_mapping_in_seconds_uint64,
}
grant exit address messsage (GXAM)
7 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>",
7 years ago
T: transaction_id_uint64,
7 years ago
V: 0,
7 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
7 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
7 years ago
valid signatures and addresses.
reject exit address message (RXAM)
7 years ago
sent in response to an OXAM to indicate that exit traffic is not allowed or
was denied.
{
A: "R",
B: backoff_milliseconds_uint64,
I: "<32 bytes signing public key of requester>",
R: "<optional reject metadata>",
7 years ago
T: transaction_id_uint64,
7 years ago
V: 0,
7 years ago
Z: "<64 bytes signature signed by exit info's signing key>"
}
7 years ago
B is set to a backoff value.
R contains additional metadata text describing why the exit was rejected.
7 years ago
transfer data fragment message (TDFM)
variant 1 (with path id):
7 years ago
transfer data between paths.
7 years ago
{
A: "T",
P: path_id_uint64,
7 years ago
V: 0,
7 years ago
X: "<N bytes payload>",
7 years ago
Y: "<24 bytes nounce>",
Z: "<64 bytes signature of entire message where Z is set to NUL>",
7 years ago
}
7 years ago
transfer data to another path with id P on the local router place Y and X values
into y and z values into a LRDM message (respectively) and send it in the
downstream direction.
7 years ago
variant 2 (no path id):
transfer ip traffic for exit
{
A: "T",
7 years ago
V: 0,
7 years ago
X: "<N bytes ipv6 packet>",
7 years ago
Y: "<16 bytes nounce>",
Z: "<64 bytes signature using previously provided signing key>"
7 years ago
}
7 years ago
X is parsed as an IPv6 packet and the source addresss is extracted.
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 TDFM, signed with the exit info's signing key and send it downstream the
corrisponding path in an LRDM.
7 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",
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",
T: transaction_id_uint64,
V: 0,
Y: "<16 bytes nounce>",
Z: "<64 bytes signagure using previously provided signing key>"
}
---
DHT messages
7 years ago
find introduction message (FIM)
7 years ago
recursively find an IS
{
A: "F",
7 years ago
R: r5n_counter,
7 years ago
S: "<64 bytes dht key>",
7 years ago
T: transaction_id_uint64,
V: 0
}
7 years ago
if R is non-zero and less or equal to than 5, decrement the value and forward
request to random peer unconditionally. The transaction will persist until
replied to by a GIM or 60 seconds, whichever is reached first.
if R is greater than 5, immediately reply with a GIM with an X value as an empty
list, terminating the transaction.
if R is zero, if we have 1 or more IS at position S in dht keyspace reply with a
GIM holding the IS who contains the introducer with the highest expiration
timestamp.
7 years ago
got introduction message (GIM)
{
7 years ago
A: "G",
T: transaction_id_uint64,
7 years ago
V: 0,
7 years ago
X: [ IS, IS, IS, ... ]
}
7 years ago
publish introduction message (PIM)
publish one or many IM into the dht at once.
7 years ago
each IS will be placed in the dht
version 0 uses the SA of each IS as the keyspace location.
in the future the location will be determined by the dht kdf
which uses a shared random source to obfuscate keyspace location.
7 years ago
R is currently set to 3 +/- 2 by the sender.
{
A: "P",
7 years ago
R: r5n_counter,
7 years ago
T: transaction_id_uint64,
7 years ago
V: 0,
X: [ IS, IS, IS, ... ],
7 years ago
}
acknoleged introduction message (AIM)
7 years ago
acknolege the publishing of a previous PIM, X contains the backoff values in ms
for the previously provided IS, if backoff is 0 the operation was successfull
7 years ago
{
A: "A",
T: transaction_id_uint64,
7 years ago
V: 0,
X: [ 0, 0, backoff, ...],
}
find router contact message (FRCM)
6 years ago
find a router by long term RC.k public key
7 years ago
{
A: "F",
7 years ago
K: "<32 byte public key of router>",
T: transaction_id_uint64
7 years ago
V: 0
}
7 years ago
got router contact message (GRCM)
7 years ago
R is a list containing a single RC if found or is an empty list if not found
sent in reply to FRCM only
{
7 years ago
A: "G",
7 years ago
R: [RC],
T: transaction_id_uint64,
V: 0
7 years ago
}