This PR follows up the serialization issue that was brought up in #109.
This PR applies the proposed solution for serialization of EC defined over prime fields with 0, 1 or 2 spare bits. (Bls12-381 has its own standard and has been left out).
Here is a summary with the main changes:
For the serialization of elliptic curve points defined over prime fields:
Keep using LE.
Keep using the hash-to-curve sgn0 definition.
Change in flags:
Sign in 7th bit for 0, 1, 2 spare bits.
Identity in 6th bit for 0, 2 bits.
⚠️ This changes the serialization of compressed Bn254 points. The flag bits are now flipped.
Uncompressed format does not use flags. The spare bits must be set to 0.
This PR follows up the serialization issue that was brought up in #109.
This PR applies the proposed solution for serialization of EC defined over prime fields with 0, 1 or 2 spare bits. (Bls12-381 has its own standard and has been left out).
Here is a summary with the main changes:
For the serialization of elliptic curve points defined over prime fields:
Change in flags:
Sign in 7th bit for 0, 1, 2 spare bits.
Identity in 6th bit for 0, 2 bits. ⚠️ This changes the serialization of compressed Bn254 points. The flag bits are now flipped.
Uncompressed format does not use flags. The spare bits must be set to 0.
Flag bits, according to the number of spare bits.
1 Spare bit.
Compressed format
Uncompressed format
b
must be != 0.2 Spare bits.
Compressed format
Uncompressed format Spare bits are set to 0.
0 Spare bits.
Add an extra byte in the compressed format to hold the flags. Then follow the 2 spare bit flag format.
Compressed format
Same as 2 spare bits, with padding:
Uncompressed format