TSP CESR Encoding

CESR Code Tables

Codes used by TSP that are already in the CESR draft:

CodeDescriptionCode LengthCount LengthTotal Length
ISHA-256 Digest144
FBlake2b256 Digest144
0A128 bit Nonce224
0BEd25519 signature288

Fixed-length codes introduced by TSP:

CodeDescriptionCode LengthCount LengthTotal Length
XType code14

Variable-length codes introduces by TSP (note: this just introduces the code "B", "C" and "VID", the length of the table below is caused by the regular CESR encoding scheme for variable length codes).

The type for "VID" is temporary, pending a decision on how to choose/encode VID types; but the code for "VID" dictates that only a "large" encoding is available. For non-post-quantum, non-did:peer VID's, a shorter encoding will usually suffice.

CodeDescriptionCode LengthCount LengthTotal Length
4BTSP Plaintext Lead Size 042
5BTSP Plaintext Lead Size 142
6BTSP Plaintext Lead Size 242
7AABTSP Large Plaintext Lead Size 084
8AABTSP Large Plaintext Lead Size 184
9AABTSP Large Plaintext Lead Size 284
4CTSP Ciphertext Lead Size 042
5CTSP Ciphertext Lead Size 142
6CTSP Ciphertext Lead Size 242
7AACTSP Large Ciphertext Lead Size 084
8AACTSP Large Ciphertext Lead Size 184
9AACTSP Large Ciphertext Lead Size 284
7VIDTSP Verifiable ID Lead Size 084
8VIDTSP Verifiable ID Lead Size 184
9VIDTSP Verifiable ID Lead Size 284

Framing codes introduces by TSP:

CodeDescriptionCode LengthCount LengthTotal Length
-E##TSP Encrypt&Signed Envelope424
-S##TSP Signed-Only Envelope424
-I##TSP Hop List424
-Z##TSP Payload424

TSP Message format

An encrypted TSP message is encoded as:

<ETS-ENVELOPE> <TSP-CIPHERTEXT> <SIGNATURE> 

a non-encrypted TSP message is encoded as:

<S-ENVELOPE> <TSP-PLAINTEXT> <SIGNATURE>

where,

ETS-ENVELOPE ::= -E01 Xvvv Xttt <SENDER-VID> <RECEIVER-VID> <OPTIONAL:TSP-PLAINTEXT>
S-ENVELOPE   ::= -S01 Xvvv Xttt <SENDER-VID> <OPTIONAL:RECEIVER-VID>

vvv contains the two-byte "major.minor" version of TSP (currently "0.0"). ttt contains a two-byte "encryption scheme.signature scheme" type indicator:

encryption scheme
0 — Unencrypted (for "S" envelopes" only)
1 — HPKE in Auth mode
2 — HPKE in Base mode with ESSR
3 — Libsodium in Auth mode
4 — Libsodium in ESSR mode

Specifying an encryption scheme in an "S" envelope is technically an error (since there will be no ciphertext anyway)

signature scheme
0 — Unsigned (Reserved for future use)
1 — Ed25519

A TSP-CIPHERTEXT must, after successful decryption, have one of the two encodings:

AUTH-PAYLOAD ::= -Z01 Xppp <PAYLOAD>
ESSR-PAYLOAD ::= -Z02 <SENDER-VID> Xppp <PAYLOAD>

where ppp contains a two-byte "type.subtype" indicator of the control fields present in the payload, which currently are:

type.subtypedescriptionPAYLOAD (after decrypting)
0.0generic message<TSP-PLAINTEXT> for direct,
-I## <VID> <VID>... <TSP-PLAINTEXT> for routed, with the plaintext holding the tsp message
0.1nested message<TSP-PLAINTEXT>
the plaintext holds a (signed, or signed-and-encrypted) TSP message
0.1routed message
1.0NEW_REL<NONCE>
1.1NEW_REL_REPLY<DIGEST>
1.2NEW_NEST_REL<TSP-PLAINTEXT> <NONCE>
the plaintext holds a signed-only TSP message where the sender field has the new nested VID, and an empty receiver
1.3NEW_NEST_REL_REPLY<TSP-PLAINTEXT> <DIGEST>
the plaintext holds a signed-only TSP message where the sender field has the new nested VID, and the receiver is the nested VID of the other party
1.4NEW_REFER_REL<DIGEST> <VID>
1.53P_REFER_REL<VID>
1.255REL_CANCEL<DIGEST>