package tezos-bls12-381-polynomial

  1. Overview
  2. Docs
include Polynomial_sig with type scalar = Bls12_381.Fr.t
type scalar = Bls12_381.Fr.t
type t
val encoding : t Data_encoding.t
val allocate : int -> t

allocate len creates a zero polynomial of size len

val erase : t -> unit

erase p overwrites a polynomial p with a zero polynomial of the same size as the polynomial p

val length : t -> int

length p returns the length of a C array where a polynomial p is stored

val generate_random_polynomial : int -> t

generate_random_polynomial n generates a polynomial with a maximum size n

Note: generates more often the zero polynomial and polynomials with zero coefficients

val degree : t -> int

degree p returns the degree of a polynomial p. Returns -1 for the zero polynomial

val get : t -> int -> scalar

get p i returns the i-th element of a given array p, a coefficient of X^i in p

val to_string : t -> string

to_string p returns the string representation of a polynomial p

val copy : ?offset:int -> ?len:int -> t -> t

copy p returns a copy of a polynomial p

val to_dense_coefficients : t -> scalar array

to_dense_coefficients p returns the dense representation of a polynomial p, i.e., it converts a C array to an OCaml array

val of_dense : scalar array -> t

of_dense p creates a value of type t from the dense representation of a polynomial p, i.e., it converts an OCaml array to a C array

val of_coefficients : (scalar * int) list -> t

of_coefficients p creates a value of type t from the sparse representation of a polynomial p, i.e., it converts an OCaml array to a C array

val equal : t -> t -> bool

equal a b checks whether a polynomial a is equal to a polynomial b

val is_zero : t -> bool

is_zero p checks whether a polynomial p is the zero polynomial

val zero : t

zero is the zero polynomial, the neutral element for polynomial addition

val one : t

one is the constant polynomial one, the neutral element for polynomial multiplication

val add : t -> t -> t

add computes polynomial addition

val add_inplace : t -> t -> t -> unit

add_inplace res a b computes polynomial addition of a and b and writes the result in res

Note: res can be equal to either a or b

val sub : t -> t -> t

sub computes polynomial subtraction

val sub_inplace : t -> t -> t -> unit

sub_inplace res a b computes polynomial subtraction of a and b and writes the result in res

Note: res can be equal to either a or b

val mul : t -> t -> t

mul computes polynomial multiplication

Note: naive quadratic algorithm, result's size is the sum of arguments' size

val mul_by_scalar : scalar -> t -> t

mul_by_scalar computes multiplication of a polynomial by a blst_fr element

val mul_by_scalar_inplace : t -> scalar -> t -> unit

mul_by_scalar_inplace res s p computes multiplication of a polynomial p by a blst_fr element s and stores it in res

val linear : t list -> scalar list -> t

linear p s computes sum (mul p.(i) s.(i))

val opposite : t -> t

opposite computes polynomial negation

val opposite_inplace : t -> unit

opposite_inplace p computes polynomial negation

Note: The argument p is overwritten

val evaluate : t -> scalar -> scalar

evaluate p x evaluates a polynomial p at x

exception Rest_not_null of string
val division_x_z : t -> scalar -> t

division_x_z p z returns the quotient of the division of p by (X - z)

  • requires: length of p >= 2
  • Does NOT raise an error if p is not divisible.
val division_zs : t -> int -> t

division_zs p n returns the quotient of the division of p by (X^n - 1)

  • requires: length of p >= 2*n
  • Does NOT raise an error if p is not divisible, it can be checked using mul_zs.
val mul_zs : t -> int -> t

mul_zs p n returns the product of p and (X^n - 1)

  • requires: length of p >= n
val derivative : t -> t

derivative p returns the formal derivative of p

val split : int -> int -> t -> t list
val (=) : t -> t -> bool

Infix operator for equal

val (+) : t -> t -> t

Infix operator for add

val (-) : t -> t -> t

Infix operator for sub

val (*) : t -> t -> t

Infix operator for mul

val constant : scalar -> t

constant s creates a value of type t from a blst_fr element s

val to_carray : t -> Carray.t

to_carray p converts p from type t to type Carray.t

Note: to_carray p doesn't create a copy of p

val of_carray : Carray.t -> t

of_carray p converts p from type Carray.t to type t

Note: of_carray p doesn't create a copy of p

OCaml

Innovation. Community. Security.