matrix-org / python-canonicaljson

Canonical JSON
Apache License 2.0
31 stars 15 forks source link

Align with JavaScript serialization? #16

Closed leplatrem closed 4 years ago

leplatrem commented 6 years ago

We have a similar module in some of our project at Mozilla but would be happy to use yours instead of our own :)

Our main use-case is to be able to verify a signature on a list of objects. One is computed on a canonical JSON on the server, and same is done on the client side.

There are a few things we had to tighten for floats, Nan, Infinity on the Python side to mach with JS Number#toString()... We also decided to use lowercase escape codes...

Would you be interested if we contribute those to your lib?

Basically our current code is this: https://github.com/Kinto/kinto-signer/blob/0ede045/kinto_signer/canonicaljson.py https://github.com/Kinto/kinto-signer/blob/0ede045/tests/test_canonicaljson.py

richvdh commented 6 years ago

Hi @leplatrem! Certainly we'd be interested in merging this code - the world doesn't need a million canonical json implementations.

The only thing is that our grammar (https://matrix.org/docs/spec/appendices.html#canonical-json) explicitly forbids floats, NaNs, Infinity, etc, so I think these would need to be configurable behaviour.

clokep commented 4 years ago

I'm going to close this due to no response. Please feel free to re-open if you're interested in contributing these changes!