Closed dignifiedquire closed 7 years ago
Not sure if I understand this correctly, but objects (maps) in JS are not sorted. You cannot guarantee that the order will stay the same in JS-land
They need to be sorted manually when generating the raw cbor object.
This is a feature request for supporting canonical output as an option, not a bug. I'm happy to add that feature request to the backlog.
We need to prioritise this, @hildjj has a point, but we need CBOR to be canonical so that every objects generates the same hash, across language implementations.
@hildjj do you have a ETA for this feature? Need any help getting it done?
I may have some time to work on this in the next couple of days. I would take a PR, but it will need to be off by default with an option to enable, have full support for canonicalization, and a good set of tests.
I just sent myself a PR: https://github.com/hildjj/node-cbor/pull/36
Let me sit with this for a day or two, so I can see if there's a better way to solve canonicalizing floats. What I have is a massive hack that I barely understand.
closing this one as it is solved now. Thank you @hildjj :D
According to https://tools.ietf.org/html/rfc7049#section-3.9
all keys in maps need to be sorted. Looking at https://github.com/hildjj/node-cbor/blob/master/src/encoder.coffee#L238-L260 it does not look like this is currently happening.