package octez-libs

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Lib.NumSource

include module type of struct include C.Num end
type scalar = C.scalar

Element of the native scalar field.

type 'a repr = 'a C.repr

Representation of values.

type 'a t = 'a C.t

Plompiler program.

val constant : Csir.Scalar.t -> scalar repr t

constant s returns the constant value s.

val zero : scalar repr t

zero returns the value 0.

val one : scalar repr t

one returns the value 1.

val range_check : nb_bits:int -> scalar repr -> unit repr t

range_check ~nb_bits s asserts that s is in the range [0, 2^nb_bits).

val custom : ?qc:Csir.Scalar.t -> ?ql:Csir.Scalar.t -> ?qr:Csir.Scalar.t -> ?qo:Csir.Scalar.t -> ?qm:Csir.Scalar.t -> ?qx2b:Csir.Scalar.t -> ?qx5a:Csir.Scalar.t -> scalar repr -> scalar repr -> scalar repr t

custom ~qc ~ql ~qr ~qo ~qm ~qx2b ~qx5a a b returns a value c for which the following arithmetic constraint is added: qc + ql * a + qr * b + qo * c + qm * a * b + qx2b * b^2 + qx5a * a^5 = 0

Manually adding constraints can be error-prone. Handle with care.

val assert_custom : ?qc:Csir.Scalar.t -> ?ql:Csir.Scalar.t -> ?qr:Csir.Scalar.t -> ?qo:Csir.Scalar.t -> ?qm:Csir.Scalar.t -> scalar repr -> scalar repr -> scalar repr -> unit repr t

assert_custom ~qc ~ql ~qr ~qo ~qm a b c asserts the following arithmetic constraint: qc + ql * a + qr * b + qo * c + qm * a * b + qx2b * b^2 + qx5a * a^5 = 0

Manually adding constraints can be error-prone. Handle with care.

add ~qc ~ql ~qr a b returns a value c such that ql * a + qr * b + qc = c.

val add_constant : ?ql:Csir.Scalar.t -> Csir.Scalar.t -> scalar repr -> scalar repr t

add_constant ~ql k a returns a value c such that ql * a + k = c.

val mul : ?qm:Csir.Scalar.t -> scalar repr -> scalar repr -> scalar repr t

mul ~qm a b returns a value c such that qm * a * b = c.

val div : ?den_coeff:Csir.Scalar.t -> scalar repr -> scalar repr -> scalar repr t

div ~den_coeff a b asserts b is non-zero and returns a value c such that a / (b * den_coeff) = c.

val pow5 : scalar repr -> scalar repr t

pow5 a returns a value c such that a^5 = c.

val is_zero : scalar repr -> bool repr t

is_zero a returns a boolean c representing whether a is zero.

val is_not_zero : scalar repr -> bool repr t

is_not_zero a is the opposite of is_zero a.

val assert_nonzero : scalar repr -> unit repr t

assert_nonzero a asserts that a is not zero.

val assert_bool : scalar repr -> unit repr t

assert_bool a asserts that a is either zero or one.

Sourceval square : scalar repr -> scalar repr t
Sourceval pow : scalar repr -> bool Bool.repr list -> scalar repr t
Sourceval add_list : ?qc:Csir.Scalar.t -> ?coeffs:Csir.Scalar.t list -> C.Num.scalar list repr -> C.Num.scalar C.Num.repr t
Sourceval scalar_of_bytes : bool list repr -> scalar repr t
Sourceval is_eq_const : scalar repr -> Csir.Scalar.t -> bool repr t
Sourceval ignore_leading_zeros : nb_bits:int -> bound:Z.t -> 'a list repr -> 'a repr * ('a repr * bool) list
Sourceval is_upper_bounded_unsafe : ?nb_bits:int -> bound:Z.t -> scalar repr -> bool Bool.repr t
Sourceval is_upper_bounded : bound:Z.t -> scalar repr -> bool Bool.repr t
Sourceval geq : (C.Num.scalar C.Num.repr * Z.t) -> (C.Num.scalar C.Num.repr * Z.t) -> bool Bool.repr t
OCaml

Innovation. Community. Security.