hashberg-io / dag-cbor

Python implementation of the DAG-CBOR codec for IPLD.
https://dag-cbor.readthedocs.io
MIT License
13 stars 6 forks source link

bug: maps have not been in canonical order #3

Closed d70-t closed 2 years ago

d70-t commented 2 years ago

According to the spec

The keys in every map must be sorted length-first by the byte representation of the string keys, where:

  • If two keys have different lengths, the shorter one sorts earlier;
  • If two keys have the same length, the one with the lower value in (byte-wise) lexical order sorts earlier.

Previous to this PR, maps have been sorted purely in byte-wise lexical order, which is incorrect if keys are not of equal length.

Previous to this PR, DAG-CBOR which was created using go-ipfs v0.11.0 could not be read using dag-cbor (this library).