ginger-lib icon indicating copy to clipboard operation
ginger-lib copied to clipboard

Uniform endianness of bits/bytes serialization

Open 95DDB opened this issue 4 years ago • 0 comments

Currently:

  • All the primitive/gadget functions dealing with serialization to/from bytes, will output LE bytes;
  • All the primitive/gadget functions dealing with serialization to/from bits, will output BE bits.

This discrepancy is often cause of errors and confusion, especially because function names and comments are generic and don't specify that. We can:

  1. Assume everything to be in LE. This requires to modify all the primitive/gadget functions dealing with serialization to/from bits and also all the places, in all repositories, in which they are used. Let's also modify primitive/gadgets function taking Boolean or UInt8 gadget arrays, dropping any pre-existing assumption on their endianness and assuming them to always be in LE. This is a breaking change.
  2. Simply add to the primitive/gadget traits dealing with serialization to/from bits a "to_bits_le()" and "from_bits_le()" variation.

95DDB avatar Dec 22 '21 09:12 95DDB