123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117(*****************************************************************************)(* *)(* 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_PC:Polynomial_commitment.S)=structincludePlonk.Polynomial_protocol.Make_impl(Super_PC)modulePC=Super_PCtypeprover_aux={answers:PC.Scalar.tSMap.tSMap.tlist;batch:PC.Scalar.tSMap.tlist;alpha:PC.Scalar.t;x:PC.Scalar.t;r:PC.Scalar.t;cm_answers:PC.Scalar.t;}typeverifier_aux={alpha:PC.Scalar.t;x:PC.Scalar.t;r:PC.Scalar.t}letprove_super_aggregationpc_public_parameterstranscript~n~generator~secrets~eval_points~evaluations~identities~nb_of_t_chunks=let(((pc_proof,Super_PC.{r;s_list;cm_answers}),transcript),(a,x,answer_list,cm_t))=prove_aux~pc_function:Super_PC.prove_super_aggregationpc_public_parameterstranscriptngeneratorsecretseval_pointsevaluationsidentitiesnb_of_t_chunksin(({cm_t;pc_proof;pc_answers=[]},{answers=answer_list;batch=s_list;alpha=a;x;r;cm_answers}),transcript)letverify_super_aggregationpc_public_parameterstranscript~n:_~generator~commitments~eval_points~s_list~cm_answersproof=letalpha,x,transcript,cmts,query_list=verify_auxtranscriptgeneratorcommitmentseval_pointsproofin(* Step 2a: KZG.verify proofs for witness combinations *)letpc_verif,r,transcript=Super_PC.verify_super_aggregationpc_public_parameterstranscriptcmtsquery_lists_listcm_answersproof.pc_proofin((pc_verif,{alpha;x;r}),transcript)letposeidon=Super_PC.poseidonendmoduletypeS=sigmodulePC:Polynomial_commitment.SincludePlonk.Polynomial_protocol.SwithmodulePC:=PCtypeprover_aux={answers:PC.Scalar.tSMap.tSMap.tlist;batch:PC.Scalar.tSMap.tlist;alpha:PC.Scalar.t;x:PC.Scalar.t;r:PC.Scalar.t;cm_answers:PC.Scalar.t;}typeverifier_aux={alpha:PC.Scalar.t;x:PC.Scalar.t;r:PC.Scalar.t}valposeidon:PC.Scalar.tarray->PC.Scalar.tvalprove_super_aggregation:prover_public_parameters->transcript->n:int->generator:PC.Scalar.t->secrets:(PC.Polynomial.Polynomial.tSMap.t*PC.Commitment.prover_aux)list->eval_points:eval_pointlistlist->evaluations:Evaluations.tSMap.t->identities:prover_identities->nb_of_t_chunks:int->(proof*prover_aux)*transcriptvalverify_super_aggregation:verifier_public_parameters->transcript->n:int->generator:PC.Scalar.t->commitments:PC.Commitment.tlist->eval_points:eval_pointlistlist->s_list:PC.Scalar.tSMap.tlist->cm_answers:PC.Scalar.t->proof->(bool*verifier_aux)*PC.transcriptendmoduleMake_aggregation:functor(PC:Polynomial_commitment.S)->SwithmodulePC=PC=Make_implincludeMake_aggregation(Polynomial_commitment)