Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file main_protocol.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160(*****************************************************************************)(* *)(* MIT License *)(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)moduleSMap=Plonk.SMapmoduleMake_impl(Super_PP:Polynomial_protocol.SwithtypePC.Scalar.t=Plompiler.S.t)=structincludePlonk.Main_protocol.Make_impl(Super_PP)modulePP=Super_PPtypeprover_aux={answers:scalarSMap.tSMap.tlist;batch:scalarSMap.tlist;alpha:scalar;beta:scalar;gamma:scalar;delta:scalar;x:scalar;r:scalar;cm_answers:scalar;cm_pi:scalar;}typeverifier_aux={alpha:scalar;beta:scalar;gamma:scalar;delta:scalar;x:scalar;r:scalar;}letprove_list(pp:prover_public_parameters)~inputs=assert(SMap.cardinalpp.circuits_map=1);assert(SMap.cardinalinputs=1);(* Rename inputs as circuit *)letinputs=SMap.map(fun_->snd@@SMap.chooseinputs)pp.circuits_mapin(* TODO: can we commit only to the hidden pi?*)letcm_pi=SMap.bindingsinputs|>List.map(fun(_,i_l)->List.map(funi->i.public)i_l|>Array.concat)|>Array.concat|>Super_PP.poseidonin(* add the PI in the transcript *)lettranscript=Plonk.Utils.expand_transcriptScalar.tcm_pipp.transcriptinlet((pp_proof,Super_PP.{answers;batch;alpha;x;r;cm_answers}),(perm_and_plook,wires_cm,beta,gamma,delta))=Prover.prove_circuits~pp_prove:Super_PP.prove_super_aggregation((pp.common_pp,pp.circuits_map),transcript)~inputs_map:inputsin({perm_and_plook;wires_cm;pp_proof},{answers;batch;alpha;beta;gamma;delta;x;r;cm_answers;cm_pi})letverify_listpp~nb_proofs(proof,s_list,cm_answers,cm_pi)=assert(SMap.cardinalpp.circuits_map=1);(* add the PI in the transcript *)lettranscript=Plonk.Utils.expand_transcriptScalar.tcm_pipp.transcriptinletpublic_inputs=SMap.singleton(fst@@SMap.choosepp.circuits_map)(List.initnb_proofs(fun_->[||]))inlettranscript,_,beta,gamma,delta,commitments,eval_points=Verifier.verify_parameters((pp.common_pp,pp.circuits_map),transcript)~public_inputsproofinlet(kzg_verif,Super_PP.{alpha;x;r}),_transcript=Super_PP.verify_super_aggregationpp.common_pp.pp_public_parameterstranscript~n:pp.common_pp.n~generator:pp.common_pp.generator~commitments~eval_points~s_list~cm_answersproof.pp_proofin(kzg_verif,{alpha;beta;gamma;delta;x;r})letget_gen_n_t(prover_public_params:prover_public_parameters)=(Domain.getprover_public_params.common_pp.domain1,prover_public_params.common_pp.n,prover_public_params.common_pp.nb_of_t_chunks)endmoduletypeS=sigmodulePP:Polynomial_protocol.SincludePlonk.Main_protocol.SwithtypeScalar.t=PP.PC.Scalar.tmoduleGates:Plonk.Custom_gates.Aggregator_sigwithmodulePP:=PPmodulePerm:Plonk.Permutation_gate.SwithmodulePP:=PPvalget_gen_n_t:prover_public_parameters->scalar*int*inttypeprover_aux={answers:scalarSMap.tSMap.tlist;batch:scalarSMap.tlist;alpha:scalar;beta:scalar;gamma:scalar;delta:scalar;x:scalar;r:scalar;cm_answers:scalar;cm_pi:scalar;}typeverifier_aux={alpha:scalar;beta:scalar;gamma:scalar;delta:scalar;x:scalar;r:scalar;}valprove_list:prover_public_parameters->inputs:prover_inputs->proof*prover_auxvalverify_list:verifier_public_parameters->nb_proofs:int->proof*scalarSMap.tlist*scalar*scalar->bool*verifier_auxendmoduleMake:functor(PP:Polynomial_protocol.SwithtypePC.Scalar.t=Plompiler.S.t)->SwithmodulePP=PPandtypecircuit_verifier_input=PP.PC.Scalar.tarraylist=Make_implincludeMake(Polynomial_protocol)