IxiBytes (Length-Prefixed Byte Array)
Finalized
IxiBytes is the standard format for serializing variable-length binary data, such as addresses, public keys, and signatures, within the Ixian protocol.
On-Wire Serialization Format
The format consists of two parts: a variable-length integer that specifies the length, followed by the raw data bytes.
| Part | Data Type | Description |
|---|---|---|
| Length | IxiVarUInt | The number of bytes (N) in the Data field. |
| Data | byte[N] | N bytes of raw binary data. |
Special Cases
- Empty or Null Data: If the byte array to be encoded is
nullor has a length of0, it is serialized as a singleIxiVarUIntwith the value0. NoDatapart follows. A decoder reading a length of0should interpret the result as a zero-length ornullbyte array.
Examples
Example 1: byte[] { 0xDE, 0xAD, 0xBE, 0xEF }
- Data:
DE AD BE EF - Length: The data has a length of
4. - Length as
IxiVarUInt:04 - Final Serialized Form:
04 DE AD BE EF
Example 2: An empty byte array byte[] {}
- Data: (empty)
- Length: The data has a length of
0. - Length as
IxiVarUInt:00 - Final Serialized Form:
00