package octez-bls12-381-polynomial

  1. Overview
  2. Docs
type fr = Fr.t
type fr_array = Fr_carray.t
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 Fr_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 Fr_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 Fr_carray.allocate)
  • size res = max (size_p_i)
  • size poly_polylen_coeff = nb_polys
  • size p_i = size_p_i
val linear_with_powers : fr_array -> fr -> (fr_array * int) array -> int -> unit

linear_with_powers res c poly_polylen nb_polys writes the result of computing c⁰·p₀(x) + c¹·p₁(x) + … + cᵏ·pₖ(x) in res, where

  • poly_polylen.[i] = (pᵢ, size_p_i)
  • nb_polys is a number of polynomials

requires:

  • the result must be initialized with zero (as done by Fr_carray.allocate)
  • size res = max (size_p_i)
  • size poly_polylen = 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 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_xn : fr_array -> fr_array -> fr_array -> int -> (int * fr) -> unit

division_xn res_q res_r p size_p (n, c) writes the quotient and remainder of the division of a polynomial p by (X^n + c) in res

requires:

  • size p = size_p and size_p > n
  • size res_q = size_p - n
  • size res_r = n
val mul_xn : fr_array -> fr_array -> int -> int -> fr -> unit

mul_xn res p size_p n c writes the result of multiplying a polynomial p by (X^n + c) in res

requires:

  • res is initialized with bls-fr zeros
  • size p = size_p
  • size res = size_p + n
val derivative : fr_array -> fr_array -> int -> unit
OCaml

Innovation. Community. Security.