Tezex.Crypto.BLS.Fr (tezex v5.0.0)

Copy Markdown View Source

Scalar field Fr for BLS12-381 (curve order).

This is the field of scalars used for private keys and in elliptic curve operations.

Summary

Functions

Creates a field element from a binary (32 bytes, big-endian). Rejects values outside [0, @order).

Creates a field element from an integer.

One element of the field.

Converts a field element to 32-byte big-endian binary.

Converts a field element to integer.

Zero element of the field.

Checks if a field element is zero.

Types

t()

@type t() :: binary()

Functions

from_bytes(bytes)

@spec from_bytes(binary()) :: {:ok, t()} | {:error, :invalid_size | :out_of_range}

Creates a field element from a binary (32 bytes, big-endian). Rejects values outside [0, @order).

from_integer(n)

@spec from_integer(non_neg_integer()) :: t()

Creates a field element from an integer.

one()

@spec one() :: t()

One element of the field.

to_bytes(fr)

@spec to_bytes(t()) :: binary()

Converts a field element to 32-byte big-endian binary.

to_integer(fr)

@spec to_integer(t()) :: non_neg_integer()

Converts a field element to integer.

zero()

@spec zero() :: t()

Zero element of the field.

zero?(fr)

@spec zero?(t()) :: boolean()

Checks if a field element is zero.