by Retr0id · 8mo ago · 0 comments
Tangentially, depending on what your input and data model look like, canonicalisation takes O(nlogn) time (i.e. the cost of sorting your fields).
Here I describe an alternative approach that produces deterministic hashes without a distinct canonicalization step, using multiset hashing: https://www.da.vidbuchanan.co.uk/blog/signing-json.html
What's over my head possibly, from skimming it, about your multiset hashing is how it avoids the "these payloads have the same shape, so one could be re-sent as the other" issue? It seems like a solution to a different problem?
(I realise my comment reads a bit unclearly, it's basically two separate comments, split after the first paragraph)
(Not saying the signing problem in OP is invalid of course. Just a different problem.)