Make_impl.Main_Pack
module PP :
Aggregation.Polynomial_protocol.S
with module Answers_commitment = Main_KZG.Input_commitment
include Plonk.Main_protocol.S
with type public_inputs = Kzg.Bls.Scalar.t array list
Raised by the prover when the provided inputs are not a satisfying assignment of the circuit.
Raised by the prover when the provided inputs are not a satisfying assignment of the circuit when using Plookup.
module Input_commitment : Plonk.Input_commitment.S
type scalar = Kzg.Bls.Scalar.t
val scalar_t : scalar Repr.t
val scalar_encoding : scalar Data_encoding.t
type circuit_map = (Plonk.Circuit.t * int) Plonk.Main_protocol_intf.SMap.t
Before proving and verifying, circuits go through a pre-processing step called setup
. The setup
takes as input a circuit_map
, which associates an identifier to a circuit and the number of statements that can be proved with that circuit. This produces a set of public_parameters
which are bound to the circuits and can be reused.
Set of public_parameters
needed by the prover. Its size is linear in the size of the circuits.
val prover_public_parameters_t : prover_public_parameters Repr.t
Set of public_parameters
needed by the verifier. Its size is constant w.r.t. the size of the circuits.
val verifier_public_parameters_t : verifier_public_parameters Repr.t
val verifier_public_parameters_encoding :
verifier_public_parameters Data_encoding.t
val proof_t : proof Repr.t
val proof_encoding : proof Data_encoding.t
Witness is the whole trace for the circuit, including input_commitment values first, followed by public input values and followed by the rest of the trace. This is the prover input for a single proof.
val circuit_prover_input_t : circuit_prover_input Repr.t
type prover_inputs = circuit_prover_input list Plonk.Main_protocol_intf.SMap.t
Map where each circuit identifier is bound to a list of circuit_prover_input
for a list of statements.
val prover_inputs_t : prover_inputs Repr.t
type public_inputs = Kzg.Bls.Scalar.t array list
The public inputs for one circuit & several statements
val public_inputs_t : public_inputs Repr.t
type circuit_verifier_input = {
nb_proofs : int;
public : public_inputs;
commitments : Input_commitment.public list list;
}
The verifier input for a circuit, represented as the actual number of proofs that have been proved by the prover, the public inputs & the input commitments
val circuit_verifier_input_t : circuit_verifier_input Repr.t
type verifier_inputs = circuit_verifier_input Plonk.Main_protocol_intf.SMap.t
The verifier inputs, represented as a map where each circuit is binded to the verifier inputs for this circuit.
val verifier_inputs_t : verifier_inputs Repr.t
val to_verifier_inputs :
prover_public_parameters ->
prover_inputs ->
verifier_inputs
Conversion from prover_inputs
to verifier_inputs
.
val input_commit :
?size:int ->
?shift:int ->
prover_public_parameters ->
scalar array ->
Input_commitment.t
input_commit ~shift pp secret
produces a commitment to the secret
array and additional prover information. This commitment is designed to be easily involved in a PlonK proof. In particular, the values of secret
will be added to the arithmetic identity in such a way that secret.(i)
participates in constraint number shift + i
, where equality will be asserted with respect to a PlonK variable in the same constraint. This allows us to "load" the value of secret.(i)
into the variable, which may be reused across the circuit. The optional argument shift
has a default value of 0. The commitment is relative to a certain domain size n
, included in pp
, the secret will remain information-theoretically hidden as long as the commitment is involved in at most n - |secret|
different proofs. If the optionnal argument size
is given, the secret will be padded with zeros to have the length size
(note that an error will be risen if size is smaller than the secret length).
val setup :
zero_knowledge:bool ->
circuit_map ->
srs:(Kzg.Bls.Srs.t * Kzg.Bls.Srs.t) ->
prover_public_parameters * verifier_public_parameters
setup ~zero_knowledge circuit_map ~srs
pre-processes the circuit_map
producing the public parameters. The SRSs of ZCash and Filecoin can be loaded from file using the Bls12_381_polynomial
library. Activating zero_knowledge
adds an overhead in proving time.
val update_prover_public_parameters :
'a Repr.ty ->
'a ->
prover_public_parameters ->
prover_public_parameters
Enrich the prover_public_parameters
with extra application data to prevent replay attacks. The same data must be used for updating the prover and verifier public parameters.
val update_verifier_public_parameters :
'a Repr.ty ->
'a ->
verifier_public_parameters ->
verifier_public_parameters
Enrich the verifier_public_parameters
with extra application data to prevent replay attacks. The same data must be used for updating the prover and verifier public parameters.
val prove : prover_public_parameters -> inputs:prover_inputs -> proof
prove public_parameters ~inputs
produces a proof for the collection of statements implied by inputs
and the circuits used for generating public_parameters
.
val verify :
verifier_public_parameters ->
inputs:verifier_inputs ->
proof ->
bool
verify public_parameters ~inputs proof
checks the validity of the proof
with regards to public_parameters
and inputs
.
module Internal_for_tests : sig ... end
module Gates : Plonk.Custom_gates.S
module Perm : Plonk.Permutation_gate.S with module PP := PP
module RangeCheck : Plonk.Range_check_gate.S with module PP := PP
val get_gen_n_prover : prover_public_parameters -> scalar * int
Returns (g, n), where n is the size of the circuit padded to the next power of two & g is a primitive n-th root of unity
val get_gen_n_verifier : verifier_public_parameters -> scalar * int
Returns (g, n), where n is the size of the circuit padded to the next power of two & g is a primitive n-th root of unity
val filter_prv_pp_circuits :
prover_public_parameters ->
'a Aggregation.Main_protocol.SMap.t ->
prover_public_parameters
val filter_vrf_pp_circuits :
verifier_public_parameters ->
'a Aggregation.Main_protocol.SMap.t ->
verifier_public_parameters
type prover_aux = {
answers : scalar Aggregation.Main_protocol.SMap.t
Aggregation.Main_protocol.SMap.t
list;
batch : scalar Aggregation.Main_protocol.SMap.t list;
alpha : scalar;
beta : scalar;
gamma : scalar;
delta : scalar;
x : scalar;
r : scalar;
cms_answers : PP.Answers_commitment.t Aggregation.Main_protocol.SMap.t;
cms_pi : PP.Answers_commitment.t Aggregation.Main_protocol.SMap.t;
ids_batch : (scalar * int) Aggregation.Main_protocol.SMap.t;
t_answers : scalar list;
}
Auxiliary information needed by the prover for the meta-verification in aPlonK
Auxiliary information needed by the verifier for the meta-verification in aPlonK
type input_commit_funcs = {
pi : scalar array -> PP.Answers_commitment.t;
answers : Kzg.Bls.Scalar.t Aggregation.Main_protocol.SMap.t
Aggregation.Main_protocol.SMap.t
list ->
PP.Answers_commitment.t;
}
val prove_list :
prover_public_parameters ->
input_commit_funcs:input_commit_funcs Aggregation.Main_protocol.SMap.t ->
inputs:prover_inputs ->
proof * prover_aux
val verify_list :
verifier_public_parameters ->
(proof
* scalar Aggregation.Main_protocol.SMap.t list
* PP.Answers_commitment.public Aggregation.Main_protocol.SMap.t
* PP.Answers_commitment.public Aggregation.Main_protocol.SMap.t
* scalar list
* (scalar * int) Aggregation.Main_protocol.SMap.t) ->
bool * verifier_aux