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

Make BINARY_OUTPUT serialization formal compatible across word sizes and endianness #26

tromer opened this Issue May 4, 2016 · 1 comment


None yet
2 participants

tromer commented May 4, 2016

Currently the binary serialization format (BINARY_OUTPUT) is not compatible across machine with different word size. This is documented, but should be fixed.

The format may be endianness-dependent as well.

One place that causes the machine-dependence is the bigint serialization ( operator<<(std::ostream &out, const bigint<n> &b) and operator>>(std::istream &in, bigint<n> &b) in src/algebra/fields/bigint.tcc), which just copies the internal array of mp_limb_t limbs. This is easily fixed.

Are there additional places?


This comment has been minimized.


madars commented May 5, 2016

There are two things that are machine-dependent:

There is the easy-to-fix thing about lengths: it might be the case that 32 * (number of 32-bit limbs) != 64 * (number of 64-bit limbs), so one needs to trim upper bits appropriately. Similar about the endianness.

Another thing is the Montgomery form, which uses auxiliary modulus that is word-size dependent. It is very plausible that there is a relatively cheap conversion (esp. given that we probably only care about 32 and 64 bit architectures), but we haven't looked into it.

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