package bls12-381

  1. Overview
  2. Docs

Prime subgroup of Fq12, of order Fr.order, represented additively

exception Not_in_group of Bytes.t
type t

Represents an element in the prime subgroup

val order : Z.t

The order of the group. It is the same than Fr.order

val size_in_bytes : int

Minimal number of bytes required to encode a value of the group

val size_in_memory : int

Actual number of bytes allocated for a value of type t

val check_bytes : Bytes.t -> bool

Checks the bytes represent a point in the prime subgroup. The expected encoding is the same than Fq12.of_bytes_exn.

val of_bytes_exn : Bytes.t -> t

Same than Fq12.of_bytes_exn but also verifies the element is in the prime subgroup. Raise Not_in_group if the element is not in the prime subgroup.

val of_bytes_opt : Bytes.t -> t option

Same than of_bytes_exn but returns an option instead of an exception.

val to_bytes : t -> Bytes.t

Same than Fq12.to_bytes.

val eq : t -> t -> bool
val zero : t

The neutral element of the subgroup. It is equal to

val is_zero : t -> bool

is_zero x is equivalent to eq x zero

val one : t

A generator of the group. It is set to the result of Pairing.pairing

val is_one : t -> bool

is_one x is equivalent to eq x one

val random : ?state:Random.State.t -> unit -> t

Generate a random element. The function ensures the element is in the prime subgroup.

The routines in the module Random.State are used to generate the elements. A state can be given to the function to be used. If no state is given, Random.get_state is used.

To create a value of type Random.State.t, you can use Random.State.make [|42|].

val add : t -> t -> t

add x y returns the sum of x and y. It is equivalent to Fq12.mul x y.

val negate : t -> t

negate x returns the opposite of x. It is equivalent to Fq12.inverse_exn x.

val mul : t -> Fr.t -> t

mul x n returns [n] x, i.e. the result of adding x n-times with itself. It is equivalent to Fq12.pow x (Fr.to_z n)