Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Canonical Msgpack

Algorand uses a version of MsgPack to produce canonical encodings of data.

Algorand’s msgpack encodings are valid msgpack encodings, but the encoding function is deterministic to ensure a canonical representation that can be reproduced to verify signatures.

A canonical msgpack encoding in Algorand must follow these rules:

  1. Maps MUST contain keys in lexicographic order;

  2. Maps MUST omit key-value pairs where the value is a zero-value, unless otherwise specified;

  3. Positive integer values MUST be encoded as unsigned in msgpack, regardless of whether the value space is semantically signed or unsigned;

  4. Integer values MUST be represented in the shortest possible encoding;

  5. Binary arrays MUST be represented using the bin format family (that is, use the most recent version of msgpack rather than the older msgpack version that had no bin family).