ExEcc.BLS.PointCompression (ExEcc v0.1.0)

View Source

Summary

Functions

If z2 is None, the given z1 is a G1 point. Else, (z1, z2) is a G2 point.

The compressed point (z1, z2) has the bit order: z1: (c_flag1, b_flag1, a_flag1, x1) z2: (c_flag2, b_flag2, a_flag2, x2) where

A compressed point is a 384-bit integer with the bit order (c_flag, b_flag, a_flag, x), where the c_flag bit is always set to 1, the b_flag bit indicates infinity when set to 1, the a_flag bit helps determine the y-coordinate when decompressing, and the 381-bit integer x is the x-coordinate of the point.

Recovers x and y coordinates from the compressed point (z1, z2).

The most-significant three bits of a G1 or G2 encoding should be masked away before the coordinate(s) are interpreted. These bits are used to unambiguously represent the underlying element The format: (c_flag, b_flag, a_flag, x) https://github.com/zcash/librustzcash/blob/6e0364cd42a2b3d2b958a54771ef51a8db79dd29/pairing/src/bls12_381/README.md#bls12-381-instantiation # noqa: E501

If z2 is None, the given z1 is a G1 point. Else, (z1, z2) is a G2 point.

Given value=x, returns the value y such that y**2 % q == x, and None if this is not possible. In cases where there are two solutions, the value with higher imaginary component is favored; if both solutions have equal imaginary component the value with higher real component is favored.

Functions

compress_g1(pt)

If z2 is None, the given z1 is a G1 point. Else, (z1, z2) is a G2 point.

compress_g2(pt)

The compressed point (z1, z2) has the bit order: z1: (c_flag1, b_flag1, a_flag1, x1) z2: (c_flag2, b_flag2, a_flag2, x2) where

  • c_flag1 is always set to 1
  • b_flag1 indicates infinity when set to 1
  • a_flag1 helps determine the y-coordinate when decompressing,
  • a_flag2, b_flag2, and c_flag2 are always set to 0

decompress_g1(z)

A compressed point is a 384-bit integer with the bit order (c_flag, b_flag, a_flag, x), where the c_flag bit is always set to 1, the b_flag bit indicates infinity when set to 1, the a_flag bit helps determine the y-coordinate when decompressing, and the 381-bit integer x is the x-coordinate of the point.

decompress_g2(p)

Recovers x and y coordinates from the compressed point (z1, z2).

get_flags(z)

The most-significant three bits of a G1 or G2 encoding should be masked away before the coordinate(s) are interpreted. These bits are used to unambiguously represent the underlying element The format: (c_flag, b_flag, a_flag, x) https://github.com/zcash/librustzcash/blob/6e0364cd42a2b3d2b958a54771ef51a8db79dd29/pairing/src/bls12_381/README.md#bls12-381-instantiation # noqa: E501

is_point_at_infinity(z1, z2 \\ nil)

If z2 is None, the given z1 is a G1 point. Else, (z1, z2) is a G2 point.

modular_squareroot_in_FQ2(value)

Given value=x, returns the value y such that y**2 % q == x, and None if this is not possible. In cases where there are two solutions, the value with higher imaginary component is favored; if both solutions have equal imaginary component the value with higher real component is favored.