This repository has been archived by the owner on Oct 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 163
DAG-CBOR-encoded Ipld::Map does not strictly order keys #492
Labels
bug
Something isn't working
Comments
FYI: there are also test vectors for DAG-CBOR at https://github.com/ipld/codec-fixtures. I'm currently adding a test runner to run them against another IPLD implementation: https://github.com/ipld/codec-fixtures/tree/add-rust |
bors bot
added a commit
that referenced
this issue
Feb 1, 2022
493: Strict ordering for DAG-CBOR-encoded map keys r=koivunej a=cdata This change proposes a fix for #492 . `Ipld::Map` keys are sorted according to [the strictness guidelines in the DAG-CBOR spec](https://github.com/ipld/ipld/blob/master/specs/codecs/dag-cbor/spec.md#:~:text=The%20keys%20in,order%20sorts%20earlier.) when encoding them as DAG-CBOR. Co-authored-by: Chris Joel <[email protected]> Co-authored-by: Christopher Joel <[email protected]>
Keeping this issue open for a less wasteful implementation which would use a btreemap with correctly sorting keys newtype. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
TL;DR
Ipld::Map
does not strictly order keys, leading to inconsistency in content hashing between this implementation andgo-ipfs
(and probably others).Strictness errata for DAG-CBOR, including explicit key order, is detailed here: https://github.com/ipld/ipld/blob/master/specs/codecs/dag-cbor/spec.md#:~:text=The%20keys%20in,order%20sorts%20earlier.
To Reproduce
Output with current (incorrect) implementation:
Expected behavior
Expected output (created with patched implementation):
Environment (please complete the following information)
stable-x86_64-unknown-linux-gnu (default)
rustc 1.57.0 (f1edd0429 2021-11-29)
The text was updated successfully, but these errors were encountered: