Module crrl::jq255e

source ·
Expand description

Jq255e implementation.

This module implements generic group operations on the jq255e group, which is itself isomorphic to a subgroup of the double-odd elliptic curve of equation y^2 = x*(x^2 - 2) over the finite field GF(2^255 - 18651). This group is described on the double-odd site. The group has a prime order order r (an integer slightly below 2^254). A conventional base point is defined; like all non-neutral elements in a prime order group, it generates the whole group.

A group element is represented by the Point structure. Group elements are called “points” because they are internally represented by points on an elliptic curve; however, the Point structure, by construction, contains only proper representatives of the group element, not just any point. Point instances can be used in additions and subtractions with the usual + and - operators; all combinations of raw values and references are accepted, as well as compound assignment operators += and -=. Specialized functions are available, in particular for point doubling (Point::double()) and for sequences of successive doublings (Point::xdouble()), the latter using some extra optimizations. Multiplication by an integer (u64 type) or a scalar (Scalar structure) is also accepted, using the * and *= operators. Scalars are integers modulo r. The Scalar structure represents such a value; it implements all usual arithmetic operators (+, -, * and /, as well as +=, -=, *= and /=).

Scalars can be encoded over 32 bytes (using unsigned little-endian convention) and decoded back. Encoding is always canonical, and decoding always verifies that the value is indeed in the canonical range.

Points can be encoded over 32 bytes, and decoded back. As with scalars, encoding is always canonical, and verified upon decoding. Point encoding uses only 255 bits; the top bit (most significant bit of the last byte) is always zero. The decoding process verifies that the top bit is indeed zero.

Structs

Type Definitions

  • Integers modulo r = 2^254 - 131528281291764213006042413802501683931.