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:
-
Maps MUST contain keys in lexicographic order;
-
Maps MUST omit key-value pairs where the value is a zero-value, unless otherwise specified;
-
Positive integer values MUST be encoded as
unsigned
in msgpack, regardless of whether the value space is semantically signed or unsigned; -
Integer values MUST be represented in the shortest possible encoding;
-
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 nobin
family).