Skip to content

Latest commit

 

History

History
180 lines (132 loc) · 9.1 KB

File metadata and controls

180 lines (132 loc) · 9.1 KB

9 Structure of a DATEX Block

9.1 Overview

A DATEX Block consists of 4 main sections:

  • A Routing Header, which mainly contains information about the sender and receivers of the block, and important information about the block (e.g. block size)
  • A Block Header, which contains metadata about the current block (type, timestamp, id, flags)
  • A Encrypted Header that is part of the optionally encrypted section of the block, and contains secret information that is only visible to the receivers of the block
  • A Body, which contains executable DATEX instructions

9.2 The Routing Header

Field Size Type Condition (for optional fields)
Magic Number 2 bytes array -
Version 1 byte uint8 -
Block Size 2 bytes uint16 -
Flags 1 byte bitmask -
Checksum 4 bytes uint32 Has Checksum equals true
Distance 1 byte uint8 -
TTL 1 byte uint8 -
Sender 21 bytes endpoint -
Receivers Pointer ID 26 bytes pointer Receiver Type equals "Pointer"
Number of Receivers 1 byte uint8 Receiver Type in ("Receivers","ReceiversWithKeys")
Receivers 21 bytes x Number of Receivers endpoint Receiver Type equals "Receivers"
Receivers with Keys 533 bytes x Number of Receivers - Receiver Type equals "ReceiversWithKeys"
Signature 108 bytes string Signature Type equals "Unencrypted"
Encrypted Signature 108 bytes string Signature Type equals "Encrypted"

9.2.1 Flags

Field Size Type
Signature Type 2 bits enum
Encryption Type 1 bit enum
Receiver Type 2 bits enum
Is Bounce Back 1 bit boolean
Has Checksum 1 bit boolean

9.2.1.1 Signature Type

Enum Mapping:

Integer Value Mapped Value
0b00 "None"
0b10 "Unencrypted"
0b11 "Encrypted"
0b01 "Invalid"

9.2.1.2 Encryption Type

Enum Mapping:

Integer Value Mapped Value
0 "None"
1 "Encrypted"

9.2.1.3 Receiver Type

Enum Mapping:

Integer Value Mapped Value
0b00 "None"
0b01 "Pointer"
0b10 "Receivers"
0b11 "ReceiversWithKeys"

9.2.2 Receivers with Keys

Field Size Type
Receiver 21 bytes endpoint
Key 512 bytes hex

9.3 The Block Header

Field Size Type Condition (for optional fields)
Context ID 4 bytes uint32 -
Section Index 2 bytes uint16 -
Block Number 2 bytes uint16 -
Flags and Timestamp 8 bytes bitmask -
Lifetime 4 bytes uint32 Has Lifetime equals true
Represented By 21 bytes endpoint Has Represented By equals true
IV 16 bytes - Has IV equals true

9.3.1 Flags and Timestamp

Field Size Type
Block Type 4 bits enum
Has Side Effects 1 bit boolean
Has Only Data 1 bit boolean
Is End of Section 1 bit boolean
Is End of Context 1 bit boolean
Has Lifetime 1 bit boolean
Has Represented By 1 bit boolean
Has IV 1 bit boolean
Is Compressed 1 bit boolean
Is Signature in Last Subblock 1 bit boolean
Reserved 8 bits uint
Creation Timestamp 43 bits uint

9.3.1.1 Block Type

Enum Mapping:

Integer Value Mapped Value
0 "Request"
1 "Response"
2 "Hello"
3 "Trace"
4 "TraceBack"

9.4 The Encrypted Header

Field Size Type Condition (for optional fields)
Flags 1 byte bitmask -
On Behalf Of 21 bytes endpoint Has On Behalf Of equals true

9.4.1 Flags

Field Size Type
User Agent 4 bits enum
Has On Behalf Of 1 bit boolean

9.4.1.1 User Agent

Enum Mapping:

Integer Value Mapped Value
0 "Unknown"
1 "Human"
2 "Bot"
3 "Service"