package octez-plonk
Plonk zero-knowledge proving system
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-17.3.tar.gz
sha256=7062cd57addd452852598a2214ade393130efa087b99068d53713bdf912b3680
sha512=08e4091144a03ce3c107fb91a66501bd8b65ca3278917c455a2eaac6df3e108ade63f6ab8340a4bb152d60f404326e464d0ec95d26cafe8e82f870465d24a5fc
doc/src/octez-plonk.aggregation/main_protocol.ml.html
Source file main_protocol.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
(*****************************************************************************) (* *) (* 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. *) (* *) (*****************************************************************************) open Plonk.Bls open Plonk.Utils module SMap = Plonk.SMap module type S = sig module PP : Polynomial_protocol.S include Plonk.Main_protocol.S module Gates : Plonk.Custom_gates.S module Perm : Plonk.Permutation_gate.S with module PP := PP (** 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_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 val filter_prv_pp_circuits : prover_public_parameters -> 'a SMap.t -> prover_public_parameters val filter_vrf_pp_circuits : verifier_public_parameters -> 'a SMap.t -> verifier_public_parameters (** Auxiliary information needed by the prover for the meta-verification in aPlonK *) type prover_aux = { answers : scalar SMap.t SMap.t list; batch : scalar SMap.t list; alpha : scalar; beta : scalar; gamma : scalar; delta : scalar; x : scalar; r : scalar; cms_answers : PP.Answers_commitment.t SMap.t; cms_pi : PP.Answers_commitment.t SMap.t; ids_batch : (scalar * int) SMap.t; t_answers : scalar list; } (** Auxiliary information needed by the verifier for the meta-verification in aPlonK *) type verifier_aux = { alpha : scalar; beta : scalar; gamma : scalar; delta : scalar; x : scalar; r : scalar; } type input_commit_info = { nb_max_answers : int; nb_max_pi : int; func : ?size:int -> ?shift:int -> scalar array -> PP.Answers_commitment.t; } val prove_list : prover_public_parameters -> input_commit_infos:input_commit_info SMap.t -> inputs:prover_inputs -> proof * prover_aux val verify_list : verifier_public_parameters -> proof * scalar SMap.t list * PP.Answers_commitment.public SMap.t * PP.Answers_commitment.public SMap.t * scalar list * (scalar * int) SMap.t -> bool * verifier_aux end module Make_impl (Super_PP : Polynomial_protocol.S) = struct include Plonk.Main_protocol.Make_impl (Super_PP) module Input_commitment = Input_commitment module PP = Super_PP type prover_aux = { answers : scalar SMap.t SMap.t list; batch : scalar SMap.t list; alpha : scalar; beta : scalar; gamma : scalar; delta : scalar; x : scalar; r : scalar; cms_answers : PP.Answers_commitment.t SMap.t; cms_pi : PP.Answers_commitment.t SMap.t; ids_batch : (scalar * int) SMap.t; t_answers : scalar list; } type verifier_aux = { alpha : scalar; beta : scalar; gamma : scalar; delta : scalar; x : scalar; r : scalar; } type input_commit_info = { nb_max_answers : int; nb_max_pi : int; func : ?size:int -> ?shift:int -> scalar array -> Super_PP.Answers_commitment.t; } let hash_pi (pp : prover_public_parameters) ic_infos inputs = (* TODO: can we commit only to the hidden pi?*) let pi_infos = SMap.mapi (fun circuit_name inputs_list -> let ic_info = SMap.find circuit_name ic_infos in let c = SMap.find circuit_name pp.circuits_map in let ic_size = List.fold_left ( + ) 0 c.input_com_sizes in let pi = List.map (fun s -> Array.sub s.witness ic_size c.public_input_size) inputs_list in (pi, ic_info.func ~size:ic_info.nb_max_pi @@ Array.concat pi)) inputs in (SMap.map fst pi_infos, SMap.map snd pi_infos) let compute_ids_batch (pp : prover_public_parameters) rd alpha x public_inputs_map answers cms_answers = let n_gen = (pp.common_pp.n, Domain.get pp.common_pp.domain 1) in let identities = Verifier.build_identities (SMap.map Verifier.circuit_verifier_pp_of_circuit_prover_pp pp.circuits_map) n_gen rd public_inputs_map in let merged_answers = let f _key m1 m2 = Some (SMap.union_disjoint m1 m2) in List.fold_left (SMap.union f) SMap.empty answers in let evaluated_ids = identities x merged_answers in SMap.mapi (fun circuit_name _ -> let ids = SMap.Aggregation.filter_by_circuit_name circuit_name evaluated_ids in (Fr_generation.batch alpha (SMap.values ids), SMap.cardinal ids)) (* we use cms_answers cause it contains the circuit_names *) cms_answers let update_transcript_with_pi transcript cms_pi = SMap.fold (fun _ cm_pi transcript -> PP.Answers_commitment.(Transcript.expand public_t cm_pi) transcript) cms_pi transcript let update_prv_pp_transcript_with_pi (pp : prover_public_parameters) cms_pi = { pp with transcript = update_transcript_with_pi pp.transcript (SMap.map PP.Answers_commitment.(fun a -> a.public) cms_pi); } let commit_to_answers_map = SMap.map (fun ic_info -> ic_info.func ~shift:ic_info.nb_max_pi ~size:ic_info.nb_max_answers) let prove_list (pp : prover_public_parameters) ~input_commit_infos ~inputs = let public_inputs_map, cms_pi = hash_pi pp input_commit_infos inputs in (* add the PI in the transcript *) let pp = update_prv_pp_transcript_with_pi pp cms_pi in let commit_to_answers_map = commit_to_answers_map input_commit_infos in let ( ( pp_proof, Super_PP.{answers; batch; alpha; x; r; cms_answers; t_answers} ), (perm_and_plook, wires_cm, rd) ) = Prover.prove_parameters ~pp_prove:(Super_PP.prove_super_aggregation ~commit_to_answers_map) pp ~inputs_map:inputs in let ids_batch = compute_ids_batch pp rd alpha x public_inputs_map answers cms_answers in ( {perm_and_plook; wires_cm; pp_proof}, { answers; batch; alpha; beta = rd.beta_perm; gamma = rd.gamma_perm; delta = rd.delta; x; r; cms_answers; cms_pi; ids_batch; t_answers; } ) let verify_list pp (proof, s_list, cms_answers, cms_pi, t_answers, ids_batch) = (* add the PI in the transcript *) let transcript = update_transcript_with_pi pp.transcript cms_pi in let transcript, _, rd, commitments, eval_points = (* Note that we don’t care about inputs here, because verify_parameters only cares about input_coms & identities that we don’t have here *) Verifier.verify_parameters ((pp.common_pp, pp.circuits_map), transcript) SMap.empty proof in let (kzg_verif, Super_PP.{alpha; x; r}), _transcript = Super_PP.verify_super_aggregation pp.common_pp.pp_public_parameters transcript ~n:pp.common_pp.n ~generator:pp.common_pp.generator ~commitments ~eval_points ~s_list ~cms_answers ~t_answers ~ids_batch proof.pp_proof in ( kzg_verif, { alpha; beta = rd.beta_perm; gamma = rd.gamma_perm; delta = rd.delta; x; r; } ) let get_gen_n_prover (prover_public_params : prover_public_parameters) = ( Domain.get prover_public_params.common_pp.domain 1, prover_public_params.common_pp.n ) let get_gen_n_verifier (verifier_public_params : verifier_public_parameters) = ( verifier_public_params.common_pp.generator, verifier_public_params.common_pp.n ) end module Make : functor (PP : Polynomial_protocol.S) -> S with module PP = PP and type public_inputs = Scalar.t array list = Make_impl include Make (Polynomial_protocol)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>