package tezos-bls12-381-polynomial

  1. Overview
  2. Docs
type fr = Fr.t
type fr_array = Carray.Stubs.fr_array
val degree : fr_array -> int -> int

degree p n returns the degree of a polynomial p

  • requires: size p = n
val of_sparse : fr_array -> (fr * int) array -> int -> unit

of_sparse res p n converts the sparse representation of a polynomial p to the dense representation, from an OCaml array p of size n to a C array res of size degree p + 1

requires:

  • degree of each coeff d_i >= 0 and d_i are unique
  • the result must be initialized with zero (as done by Carray.allocate)
  • size res = degree p + 1
  • size p = n
val add : fr_array -> fr_array -> fr_array -> int -> int -> unit

add res a b size_a size_b writes the result of polynomial addition of a and b in res

requires:

  • size a = size_a
  • size b = size_b
  • size res = max (size_a, size_b)
  • res, a and b are either pairwise disjoint or equal
val sub : fr_array -> fr_array -> fr_array -> int -> int -> unit

sub res a b size_a size_b writes the result of polynomial subtraction of b from a in res

requires:

  • size a = size_a
  • size b = size_b
  • size res = max (size_a, size_b)
  • res, a and b are either pairwise disjoint or equal
val mul : fr_array -> fr_array -> fr_array -> int -> int -> unit

mul res a b size_a size_b writes the result of polynomial multiplication of a by b in res

requires:

  • the result must be initialized with zero (as done by Carray.allocate)
  • size a = size_a
  • size b = size_b
  • size res = size_a + size_b - 1
val mul_by_scalar : fr_array -> fr -> fr_array -> int -> unit

mul_by_scalar res b a size_a writes the result of multiplying a polynomial a by a blst_fr element b in res

requires:

  • size a = size_a
  • size res = size_a
  • res and a either disjoint or equal
val linear : fr_array -> (fr_array * int * fr) array -> int -> unit

linear res poly_polylen_coeff nb_polys writes the result of computing λ₁·p₁(x) + λ₂·p₂(x) + … + λₖ·pₖ(x) in res, where

  • poly_polylen_coeff.[i] = (pᵢ, size_p_i, λᵢ)
  • nb_polys is a number of polynomials, i.e., i = 1..nb_polys

requires:

  • the result must be initialized with zero (as done by Carray.allocate)
  • size res = max (size_p_i)
  • size poly_polylen_coeff = nb_polys
  • size p_i = size_p_i
val negate : fr_array -> fr_array -> int -> unit

negate res p n writes the result of negating a polynomial p in res

requires:

  • size p = n
  • size res = n
  • res and p either disjoint or equal
val is_zero : fr_array -> int -> bool

is_zero p n checks whether a polynomial p is the zero polynomial

  • requires: size p = n
val evaluate : fr -> fr_array -> int -> fr -> unit

evaluate res p n x writes the result of evaluating a polynomial p at x in res

  • requires: size p = n and n > 0
val division_x_z : fr_array -> fr_array -> int -> fr -> unit

division_x_z res p n z writes the quotient of the division of a polynomial p by (X - z) in res

requires:

  • size p = n and n > 1
  • size res = n - 1
val division_zs : fr_array -> fr_array -> int -> int -> unit

division_zs res p n s writes the quotient of the division of a polynomial p by (X^s - 1) in res

requires:

  • size p = n and n >= 2s
  • size res = n - s
val mul_zs : fr_array -> fr_array -> int -> int -> unit

mul_zs res p n s writes the result of multiplying a polynomial p by (X^s - 1) in res

requires:

  • size p = n and n >= s
  • size res = n + s
val derivative : fr_array -> fr_array -> int -> unit
OCaml

Innovation. Community. Security.