package octez-bls12-381-polynomial

  1. Overview
  2. Docs
include Carray.Carray_sig with type elt = Bls12_381.G1.t
type t
type elt = Bls12_381.G1.t
val t : t Repr.t
val empty : t
val allocate : int -> t

allocate len creates a C array of size len initialized with zeros.

val init : int -> (int -> elt) -> t

init n f returns a fresh C array of length n, with element number i initialized to the result of f i.

val degree : t -> int

degree p returns the index of the last non-zero element of p. Returns -1 if all elements of p are zero.

val erase : t -> int -> unit

erase p n fills with zeros the first n elements of p.

val length : t -> int

length c returns the length of a C array c

val get : t -> int -> elt

get c i returns the i-th element of a C array c

val get_inplace : t -> int -> elt -> unit

get_inplace c i res copies the i-th element of a C array c in res

val iter_copy_elt : (elt -> unit) -> t -> unit

iter_copy_elt f a applies function f in turn to a **copy** of all the elements of a. It is equivalent to f a.(0); f a.(1); ...; f a.(length a - 1); ().

val iteri_copy_elt : (int -> elt -> unit) -> t -> unit

Same as iter_copy_elt, but the function is applied to the index of the element as first argument, and a **copy** of the element itself as second argument.

val set : t -> elt -> int -> unit
val copy : ?offset:int -> ?len:int -> t -> t

copy c copies len elements from a C array c starting from position offset

val blit : t -> src_off:int -> t -> dst_off:int -> len:int -> unit

blit src src_off dst dst_off len copies len elements from src to dst starting at the respective offsets.

val equal : t -> offset1:int -> t -> offset2:int -> len:int -> bool

equal a offset1 b offset2 returns true if the segments of len elements of a and b are equal starting from their respective offsets offset1 (for a) and offset2 (for b).

val to_array : ?offset:int -> ?len:int -> t -> elt array

to_array c converts a C array c to an OCaml array

val of_array : elt array -> t

of_array c converts an OCaml array c to a C array

val of_bigstring : Bigstringaf.t -> t
val to_bigstring : t -> Bigstringaf.t
val eq : t -> t -> bool

eq a b returns true if C arrays a and b are equals

val sub : t -> off:int -> len:int -> t

sub a off len extracts a sub-array of a

val fold_left_map : ('acc -> elt -> 'acc * elt) -> 'acc -> t -> 'acc * t

fold_left_map is a combination of fold_left and map that threads an accumulator through calls to f.

type domain = Domain.t
val evaluation_ecfft : domain:domain -> points:t -> t

evaluation_ecfft domain points computes the ECFFT. domain can be obtained using Domain.build.

The ECFFT computes the G-linear map G^n -> G^n : (P_i)_=0,...,n-1 |-> (sum_=0^n-1 domain.(i*j mod n)P_i)_j=0,...,n-1.

where aP denotes the elliptic curve point multiplication.

Note:

  • size of domain must be a power of two
  • degree of polynomial must be strictly less than the size of domain
val interpolation_ecfft_inplace : domain:domain -> points:t -> unit

interpolation_ecfft_inplace domain points computes the inverse ECFFT. domain can be obtained using Domain.build.

It is the inverse function of evaluation_ecfft_inplace.

Note:

  • size of domain must be a power of two
  • size of a polynomial must be equal to size of domain
val add_arrays_inplace : t -> t -> unit

add_arrays_inplace a b writes the element-wise sum of the input vectors a and b into a

type evaluations = Evaluations.t
val mul_arrays : evaluations:evaluations array -> arrays:t array -> t array

mul_arrays evaluations arrays computes the EC point multiplication given the scalar multipliers evaluations and the points arrays

OCaml

Innovation. Community. Security.