bls12_381/notes/
serialization.rs

1//! # BLS12-381 serialization
2//!
3//! * $\mathbb{F}\_p$ elements are encoded in big-endian form. They occupy 48
4//!   bytes in this form.
5//! * $\mathbb{F}\_{p^2}$ elements are encoded in big-endian form, meaning that
6//!   the $\mathbb{F}\_{p^2}$ element $c\_0 + c\_1 \cdot u$ is represented by the
7//!   $\mathbb{F}\_p$ element $c\_1$ followed by the $\mathbb{F}\_p$ element $c\_0$.
8//!   This means $\mathbb{F}_{p^2}$ elements occupy 96 bytes in this form.
9//! * The group $\mathbb{G}\_1$ uses $\mathbb{F}\_p$ elements for coordinates. The
10//!   group $\mathbb{G}\_2$ uses $\mathbb{F}_{p^2}$ elements for coordinates.
11//! * $\mathbb{G}\_1$ and $\mathbb{G}\_2$ elements can be encoded in uncompressed
12//!   form (the x-coordinate followed by the y-coordinate) or in compressed form
13//!   (just the x-coordinate). $\mathbb{G}\_1$ elements occupy 96 bytes in
14//!   uncompressed form, and 48 bytes in compressed form. $\mathbb{G}\_2$
15//!   elements occupy 192 bytes in uncompressed form, and 96 bytes in compressed
16//!   form.
17//!
18//! The most-significant three bits of a $\mathbb{G}\_1$ or $\mathbb{G}\_2$
19//!   encoding should be masked away before the coordinate(s) are interpreted.
20//!   These bits are used to unambiguously represent the underlying element:
21//! * The most significant bit, when set, indicates that the point is in
22//!   compressed form. Otherwise, the point is in uncompressed form.
23//! * The second-most significant bit indicates that the point is at infinity.
24//!   If this bit is set, the remaining bits of the group element's encoding
25//!   should be set to zero.
26//! * The third-most significant bit is set if (and only if) this point is in
27//!   compressed form _and_ it is not the point at infinity _and_ its
28//!   y-coordinate is the lexicographically largest of the two associated with
29//!   the encoded x-coordinate.