-
Notifications
You must be signed in to change notification settings - Fork 34
Serialisation format
Dmitry Chestnykh edited this page Feb 9, 2017
·
9 revisions
Proteus uses CBOR (RFC 7049) as its serialisation format. The following sections describe the serialised structure definitions using CDDL syntax.
Envelope = {
0: uint, ;; Version
1: Mac,
2: bstr ;; Message as embedded CBOR.
}
Message = (1, PlainMessage) / (2, PreKeyMessage)
PlainMessage = {
0: bstr, ;; Session tag
1: uint, ;; Counter (u32)
2: uint, ;; Previous counter (u32)
3: PublicKey, ;; Ratchet key
4: bstr ;; Cipher text
}
PreKeyMessage = {
0: uint, ;; Prekey ID (u16)
1: PublicKey,
2: IdentityKey
PlainMessage
}
PreKeyBundle = {
0: uint, ;; Version
1: uint, ;; Prekey ID (u16)
2: PublicKey,
3: IdentityKey,
4: ?Signature ;; Signature of public key
}
PreKey = {
0: uint, ;; Version
1: uint, ;; Prekey ID (u16)
2: SecretKey,
3: PublicKey ;; Public key
}
IdentityKey = {
0: uint, ;; Version
1: SecretKey,
2: PublicKey
}
Session = {
0: uint, ;; Version
1: bstr, ;; Session tag
2: PublicKey, ;; Local identity
3: PublicKey, ;; Remote identity public key
4: ?{
0: uint, ;; Prekey ID
1: PublicKey ;; Public prekey
},
5: {+ bstr => SessionState } ;; Map of session tags to session states
}
SessionState = {
0: [+ ReceiveChain ],
1: SendChain
2: RootKey
3: uint ;; Counter
}
ReceiveChain = {
0: ChainKey,
1: PublicKey, ;; Ratchet key
2: [* MessageKeys ] ;; Skipped message keys
}
SendChain = {
0: ChainKey,
1: KeyPair
)
ChainKey = {
0: MacKey
1: uint ;; Counter
}
MessageKeys = {
0: CipherKey,
1: MacKey,
2: uint ;; Counter
)
KeyPair = { 0: SecretKey, 1: PublicKey }
PublicKey = { 0: bstr }
SecretKey = { 0: bstr }
Signature = { 0: bstr }
Mac = { 0: bstr }
MacKey = { 0: bstr }
CipherKey = { 0: bstr }