Module Cryptobox.Verifier

type t = t

A precomputed set of constants

type parameters = Mavryk_crypto_dal_mavkit_dal_config.Dal_config.parameters = {
  1. redundancy_factor : int;
  2. page_size : int;
  3. slot_size : int;
  4. number_of_shards : int;
}

Parameters to build a value of type t

type ('a, 'b) error_container = ('a, 'b) error_container = {
  1. given : 'a;
  2. expected : 'b;
}
val parameters_encoding : parameters Data_encoding.t

An encoding for values of type parameters.

val make : parameters -> (t, [> `Fail of string ]) Stdlib.result

make precomputes the set of values needed by the cryptographic primitives defined in this module and stores them in a value of type t

val parameters : t -> parameters

parameters t returns the parameters given when t was initialised with the function make

type commitment = commitment

Commitment to a polynomial.

type commitment_proof = commitment_proof

A proof that the polynomial associated to some commitment is bounded by a constant.

val verify_commitment : t -> commitment -> commitment_proof -> bool

verify_commitment t commitment proof returns true if and only if the size of the data committed via commitment does not exceed the slot_size declared in t.

The verification time is constant.

type page = bytes

The original slot can be split into a list of pages of fixed size. This size is given by the parameter page_size given to the function make.

type page_proof = page_proof

A proof that the evaluation of points of a polynomial is part of a commitment.

val page_proof_encoding : page_proof Data_encoding.t

An encoding for the proof of a page.

val pages_per_slot : parameters -> int

pages_per_slot t returns the number of expected pages per slot.

val verify_page : t -> commitment -> page_index:int -> page -> page_proof -> (unit, [> `Invalid_degree_strictly_less_than_expected of (int, int) error_container | `Invalid_page | `Page_length_mismatch | `Page_index_out_of_range ]) Stdlib.Result.t

verify_page t commitment ~page_index page proof returns Ok () if the proof certifies that the page is the page_index-th page of the slot with the given commitment.

Fails with:

  • Error `Invalid_page if the verification Fails
  • Error `Invalid_degree_strictly_less_than_expected _ if the SRS contained in t is too small to proceed with the verification
  • Error `Page_length_mismatch if the page is not of the expected length page_size given for the initialisation of t
  • Error `Page_index_out_of_range if page_index is out of the range 0, slot_size/page_size - 1 where slot_size and page_size are given for the initialisation of t

Ensures:

  • verify_page t commitment ~page_index page proof = Ok () if and only if page = Bytes.sub slot (page_index * t.page_size) t.page_size), proof = prove_page t polynomial page_index, p = polynomial_from_slot t slot, and commitment = commit t p.