-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
non-canonical encoding #31
Comments
@vmx do we not sort maps when it comes from a struct? It should be the first of these encodings for both cases. |
Thanks for the bug report and the test to reproduce it. I can see where the problem is, I'm working on a fix, which hopefully also catches all other cases. |
vmx
added a commit
that referenced
this issue
Apr 22, 2024
Rust structs have their entries ordered the same way as they are defined. When serialized to CBOR, they become maps by default. In DAG-CBOR the maps need to have a specific order, hence the keys might need to be re-ordered, so that they are independent of the order they were defined. This commit makes sure that it's actually the case. Fixes #31.
vmx
added a commit
that referenced
this issue
Apr 22, 2024
Rust structs have their entries ordered the same way as they are defined. When serialized to CBOR, they become maps by default. In DAG-CBOR the maps need to have a specific order, hence the keys might need to be re-ordered, so that they are independent of the order they were defined. This commit makes sure that it's actually the case. Fixes #31.
vmx
added a commit
that referenced
this issue
Apr 24, 2024
Rust structs have their entries ordered the same way as they are defined. When serialized to CBOR, they become maps by default. In DAG-CBOR the maps need to have a specific order, hence the keys might need to be re-ordered, so that they are independent of the order they were defined. This commit makes sure that it's actually the case. Fixes #31.
Fantastic! Thanks for the quick turnaround. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey there. I've been using the ipld/dag-cbor library to encode my data.
I just tried using this crate to encode the same data and noticed that it encodes it in the order the struct is declared in.
Here's a test you can run:
it fails with:
The text was updated successfully, but these errors were encountered: