Skip to content
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

Feature request: canonical (e.g., little-endian) binary archive #115

Closed
stanford-scs opened this issue Aug 12, 2014 · 3 comments
Closed
Milestone

Comments

@stanford-scs
Copy link

This is a feature request for a canonical binary archive, which would be useful in cases where people must cryptographically hash or digitally sign messages, or in which non-cryptographic hashes are used for the purposes of optimizing state reconciliation or otherwise bucketing data structures based on contents.

Currently the portable_binary archive uses a lazy optimization that makes for a different wire format on big and little endian machines. Hence, if a big- and little-endian machine both sign the same data structure serialized with a PortableBinaryOutputArchive, the actual signed bytes will be different. In the best case multiple copies of the same message can be sent around, which is wasteful. In other cases, things like threshold signatures, in which multiple machines of possibly different endianness collaborate to sign a single message, are effectively impossible with cereal.

The best canonical format would probably be an archive that produces and reads little endian format on all architectures.

@AzothAmmo AzothAmmo added this to the v1.2.0 milestone Aug 15, 2014
@c42f
Copy link

c42f commented Jul 2, 2015

To add to this: I currently have the need for a canonical big-endian reader: this is to deserialize messages from an embedded system I don't have direct control over. Granted, this may be more of a case of writing a custom archiver, but the embedded system produces very straightforward big endian binary so one might hope to get away with using a standard archiver. The one thing I know I'd need - which is different from the portable endian archiver - is the ability to omit the byte order marker from the start.

@AzothAmmo
Copy link
Contributor

To resolve this I'm going to modify the existing canonical archive to be parameterized on the desired input/output endianness, with conversion happening as required.

AzothAmmo added a commit that referenced this issue Dec 28, 2015
-added more tests
-should resolve #115
@AzothAmmo
Copy link
Contributor

Well I finally got around to doing this - you can now specify the desired input/output endianness in the portable binary archives. The archive is backwards compatible with the prior version and will still output one byte of metadata at the beginning of the serialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants