Fields

limbs: [5]u64,

Functions

fn abs(a: Fe) Fe

Return the absolute value of a field element

inline fn add(a: Fe, b: Fe) Fe

Add a field element

inline fn cMov(fe: *Fe, a: Fe, c: u64) void

Conditonally replace a field element with a if c is positive

fn cSwap2(a0: *Fe, b0: *Fe, a1: *Fe, b1: *Fe, c: u64) void

Conditionally swap two pairs of field elements if c is positive

inline fn equivalent(a: Fe, b: Fe) bool

Return true if both field elements are equivalent

fn fromBytes(s: [32]u8) Fe

Unpack a field element

fn fromBytes64(s: [64]u8) Fe

Map a 64 bytes big endian string into a field element

fn invert(a: Fe) Fe

Return the inverse of a field element, or 0 if a=0.

inline fn isNegative(a: Fe) bool

Return true if a field element is negative

fn isSquare(a: Fe) bool

Return true if the field element is a square

inline fn isZero(fe: Fe) bool

Return true if the field element is zero

fn mul(a: Fe, b: Fe) callconv(bloaty_inline) Fe

Multiply two field elements

inline fn mul32(a: Fe, comptime n: u32) Fe

Multiply a field element with a small (32-bit) integer

inline fn neg(a: Fe) Fe

Negate a field element

fn pow2523(a: Fe) Fe

Return a^((p-5)/8) = a^(2^252-3) Used to compute square roots since we have p=5…

Return a^((p-5)/8) = a^(2^252-3) Used to compute square roots since we have p=5 (mod 8); see Cohen and Frey.

fn rejectNonCanonical(s: [32]u8, comptime ignore_extra_bit: bool) NonCanonicalError!void

Reject non-canonical encodings of an element, possibly ignoring the top bit

inline fn sq(a: Fe) Fe

Square a field element

inline fn sq2(a: Fe) Fe

Square and double a field element

fn sqrt(x2: Fe) NotSquareError!Fe

Compute the square root of x2, returning error.NotSquare if x2 was not a s…

Compute the square root of x2, returning error.NotSquare if x2 was not a square

inline fn sub(a: Fe, b: Fe) Fe

Subtract a field element

fn toBytes(fe: Fe) [32]u8

Pack a field element

Values

curve25519BasePoint
Fe

The Curve25519 base point

edwards25519a
Fe

Edwards25519 A

edwards25519a_32
u32

Edwards25519 A, as a single limb

edwards25519d
Fe

Edwards25519 d = 370957059346694393431380835087545651895421138798432190163887855…

edwards25519d2
Fe

Edwards25519 2d

edwards25519eonemsqd
Fe

Edwards25519 1-d^2

edwards25519sqdmone
Fe

Edwards25519 (d-1)^2

edwards25519sqrtadm1
Fe

Edwards25519 sqrt(ad-1) with a = -1 (mod p)

edwards25519sqrtam2
Fe

Edwards25519 sqrt(A-2)

edwards25519sqrtamd
Fe

Edwards25519 1/sqrt(a-d)

one
Fe

1

sqrtm1
Fe

sqrt(-1)

zero
Fe

0