package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/octez-libs.plompiler/Plompiler/LibCircuit/index.html
Module Plompiler.LibCircuit
Source
Circuit producing backend.
include LIB
Element of the native scalar field.
Inputs to a plompiler program have three kinds:
- Public: known by both the prover and verifier.
- Private: known only by the prover.
- InputCom: part of an Input Commitment. See
Lib_plonk.Input_commitment
.
The trace is the sequence of scalar values used in a Plompiler program. It includes the inputs and the intermediary variables. Inputs have to be a prefix of the trace, and public inputs come before private ones.
Representation of values.
Plompiler program.
with_bool_check c
adds an implicit boolean check computed by c
to the circuit. The computation of this check is delayed until the end of the circuit construction, which is useful for defining complex conditions while still processing inputs.
get_checks_wire
retrieves the boolean representing the conjunction of all previous implicit checks.
WARNING: This will "reset" the implicit check accumulator.
Type that describes an open input commitment.
serialize i
returns the array of scalars corresponding to its values.
input ~kind i
declares an input of a given kind
to the Plompiler program. It returns a Plompiler representation of the inputted value.
begin_input_com builder
starts a new input commitment. builder
is a function that takes the inputs to be committed one by one and returns the composite commitment.
An example of usage is
let* x1, x2 =
begin_input_com (fun a b -> (a, b))
|: Input.scalar x1 |: Input.scalar x2 |> end_input_com
in
ic |: i
adds i
to the input commitment ic
end_input_com ic
ends the declaration of an input commitment.
eq a b
returns the physical equality of a
and b
. Handle with care.
of_pair p
retrieves the values out of a pair value.
to_list l
makes a list value out of a list of values.
of_list v
retrieves a list of Plompiler values out of a list value.
scalar_of_bool b
converts a boolean value into a scalar.
unsafe_bool_of_scalar s
converts a scalar value into a bool.
WARNING: s
is expected to hold the values 0 or 1, but this is not checked.
Assertion that two values are (structurally) equal.
equal a b
computes the structural equality between a
and b
.
Returns a list of Boolean variables representing the little endian bit decomposition of the given scalar (with the least significant bit on the head).
with_label ~label c
adds a label
to the Plompiler computation c
. Useful for debugging and flamegraphs.
Prints on stdout the prefix string and the repr. It works only when running the Result interpreter, it has no effect in the Circuit interpreter.
Module for describing operations over fixed size integers
Helper functions for the Poseidon Hash defined over the scalar field of the BLS12-381 curve, using S-box function x -> x^5
.
Helper functions for the Anemoi Hash defined over the scalar field of the BLS12-381 curve.
foldiM
is the monadic version of a fold over a natural number.
fold2M
is the monadic version of List.fold_left2
.
map2M
is the monadic version of List.map2
.
iterM
is the monadic version of List.iter
.
iter2M
is the monadic version of List.iter2
.
This module is a more generic version of Bytes, where each scalar stores an nb_bits
-bit number.
add2 p1 p2
returns the pair (fst p1 + fst p2, snd p1 + snd p2)
.
deserialize scalars inpt
populates the structure of inpt
with the values from scalars
.
get_inputs c
returns the initial inputs for the computation c
, together with the number of those inputs that are public. This fuction is useful when the inputs used for the circuit definition have meaningful values (in contrast to the often used dummy inputs, as explained in Lang_core.COMMON.Input
).
type cs_result = {
nvars : int;
(*Number of variables in the
*)cs
witnessfree_wires : int list;
(*Wire indices that are not used in the
*)cs
, they have been freed by the optimizer.cs : Csir.CS.t;
(*Constraint system
*)public_input_size : int;
input_com_sizes : int list;
(*Sizes for input commitments
*)tables : Csir.Table.t list;
(*Tables for lookups
*)range_checks : (int * (int * int) list) list;
(*Range checks following the format: index of wire * (index in wire * bound)
*)range_checks_labels : (string list * int) list;
(*label trace that creates a range-check and the size of the range-check
*)solver : Solver.t;
(*Solver for the
*)cs
}
Constraint system and auxiliary data resulting from a Plompiler program.
get_cs ?optimize c
runs the computation c
generating a constraint system. If optimize
is true
, it will run the optimizer on the produced CS. The optimized CS will be cached in Utils.circuit_dir
, using the TMPDIR
environment variable.