Plonk.Main_protocolaPlonK is a PlonK-based proving system. As such, it provides a way to create succinct cryptographic proofs about a given predicate, which can be then verified with a low computational cost.
In this system, a predicate is represented by an arithmetic circuit, i.e. a collection of arithmetic gates operating over a prime field, connected through wires holding scalars from this field. For example, the following diagram illustrates a simple circuit checking that the addition of two scalars (w1 and w2) is equal to w0. Here, the add gate can be seen as taking two inputs and producing an output, while the eq gate just takes two inputs and asserts they're equal.
(w0)│ w1│ w2│
│ └───┐ ┌───┘
│ ┌─┴───┴─┐
│ │ add │
│ └───┬───┘
└──────┐ ┌───┘w3
┌─┴───┴─┐
│ eq │
└───────┘The wires of a circuit are called prover inputs, since the prover needs an assignment of all wires to produce a proof. The predicate also declares a subset of the wires called verifier inputs. In our example, wire w0 is the only verifier input, which is indicated by the parenthesis. A proof for a given w0 would prove the following statement: ∃ w1, w2, w3: w3 = w1 + w2 ∧ w0 = w3 This means that the verifier only needs a (typically small) subset of the inputs alongside the (succinct) proof to check the validity of the statement.
A more interesting example would be to replace the add gate by a more complicated hash circuit. This would prove the knowledge of the pre-image of a hash.
A simplified view of aPlonk's API consists of the following three functions:
val setup : circuit -> srs ->
(prover_public_parameters, verifier_public_parameters)
val prove : prover_public_parameters -> prover_inputs ->
private_inputs -> proof
val verify : verifier_public_parameters -> verifier_inputs ->
proof -> boolIn addition to the prove and verify, the interface provides a function to setup the system. The setup function requires a Structured Reference String. Two large SRSs were generated by the ZCash and Filecoin projects and are both used in aPlonK. Notice also that the circuit is used during setup only and, independently from its size, the resulting verifier_public_parameters will be a succinct piece of data that will be posted on-chain to allow verification and they are bound to the specific circuit that generated them. The prover_public_parameters's size is linear in the size of the circuit.
include module type of struct include Main_protocol_intf endmodule SMap = Plonk.Main_protocol_intf.SMapmodule type S = Main_protocol_intf.Smodule Make_impl (PP : Polynomial_protocol.S) : sig ... endmodule Make
(PP : Polynomial_protocol.S) :
S with type public_inputs = Kzg.Bls.Scalar.t array listinclude sig ... endmodule Input_commitment : sig ... endtype scalar = Kzg.Bls.Scalar.tval scalar_t : scalar Repr.tval scalar_encoding : scalar Data_encoding.ttype circuit_map = (Circuit.t * int) Kzg.SMap.ttype prover_public_parameters =
Make(Polynomial_protocol).prover_public_parametersval prover_public_parameters_t : prover_public_parameters Repr.ttype verifier_public_parameters =
Make(Polynomial_protocol).verifier_public_parametersval verifier_public_parameters_t : verifier_public_parameters Repr.tval verifier_public_parameters_encoding :
verifier_public_parameters Data_encoding.ttype proof = Make(Polynomial_protocol).proofval proof_t : proof Repr.tval proof_encoding : proof Data_encoding.ttype circuit_prover_input = Make(Polynomial_protocol).circuit_prover_input = {witness : scalar array;input_commitments : Input_commitment.t list;}val circuit_prover_input_t : circuit_prover_input Repr.ttype prover_inputs = circuit_prover_input list Kzg.SMap.tval prover_inputs_t : prover_inputs Repr.ttype public_inputs = Kzg.Bls.Scalar.t array listval public_inputs_t : public_inputs Repr.ttype circuit_verifier_input = Make(Polynomial_protocol).circuit_verifier_input =
{nb_proofs : int;public : public_inputs;commitments : Input_commitment.public list list;}val circuit_verifier_input_t : circuit_verifier_input Repr.ttype verifier_inputs = circuit_verifier_input Kzg.SMap.tval verifier_inputs_t : verifier_inputs Repr.tval to_verifier_inputs :
prover_public_parameters ->
prover_inputs ->
verifier_inputsval input_commit :
?size:int ->
?shift:int ->
prover_public_parameters ->
scalar array ->
Input_commitment.tval setup :
zero_knowledge:bool ->
circuit_map ->
srs:(Kzg.Bls.Srs.t * Kzg.Bls.Srs.t) ->
prover_public_parameters * verifier_public_parametersval update_prover_public_parameters :
'a Repr.ty ->
'a ->
prover_public_parameters ->
prover_public_parametersval update_verifier_public_parameters :
'a Repr.ty ->
'a ->
verifier_public_parameters ->
verifier_public_parametersval prove : prover_public_parameters -> inputs:prover_inputs -> proofval verify :
verifier_public_parameters ->
inputs:verifier_inputs ->
proof ->
boolmodule Internal_for_tests : sig ... end