I'm working on an application which relies on stable hashes of encoded CBOR objects. To facilitate this, I'd like to both produce and require deterministically encoded CBOR[0], specified in RFC 8949.
When encoding, I'd like to produce deterministically encoded CBOR, e.g., integer types should be as small as possible, map keys should be sorted, etcetera. Sorting map keys could be expensive, so I'd be fine with opting-into an assert if I try to serialize maps in the wrong order, and it's on me to avoid it.
When decoding, I'd like to error on non-deterministically encoded CBOR.
This would certainly be an opt-in feature, since I don't think it's something that most people need or want. It would probably also only make sense for minicbor_derive and/or minicbor_serde, or at least be most easy to implement for them.
I'm hoping to be able to use minicbor_derive, since I like using small integer keys.
[0] This differs from RFC 7049 which uses the term "canonical CBOR". The major difference is that in canonical CBOR, shorter map keys sort before longer map keys, regardless of their byte value.
I'm working on an application which relies on stable hashes of encoded CBOR objects. To facilitate this, I'd like to both produce and require deterministically encoded CBOR[0], specified in RFC 8949.
When encoding, I'd like to produce deterministically encoded CBOR, e.g., integer types should be as small as possible, map keys should be sorted, etcetera. Sorting map keys could be expensive, so I'd be fine with opting-into an assert if I try to serialize maps in the wrong order, and it's on me to avoid it.
When decoding, I'd like to error on non-deterministically encoded CBOR.
This would certainly be an opt-in feature, since I don't think it's something that most people need or want. It would probably also only make sense for
minicbor_deriveand/orminicbor_serde, or at least be most easy to implement for them.I'm hoping to be able to use
minicbor_derive, since I like using small integer keys.[0] This differs from RFC 7049 which uses the term "canonical CBOR". The major difference is that in canonical CBOR, shorter map keys sort before longer map keys, regardless of their byte value.