package octez-libs
A package that contains multiple base libraries used by the Octez suite
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/src/octez-libs.plonk/gates_common.ml.html
Source file gates_common.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
(*****************************************************************************) (* *) (* 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 Kzg.Bls open Identities module L = Plompiler.LibCircuit type public = {public_inputs : Scalar.t array; input_coms_size : int} let one = Scalar.one let mone = Scalar.negate one let two = Scalar.add one one let wire_name = Plompiler.Csir.wire_name let com_label = "com" let tmp_buffers = ref [||] type answers = {q : Scalar.t; wires : Scalar.t array; wires_g : Scalar.t array} type witness = {q : Evaluations.t; wires : Evaluations.t array} let get_buffers ~nb_buffers ~nb_ids = let precomputed = !tmp_buffers in let nb_precomputed = Array.length precomputed in let size_eval = Evaluations.length precomputed.(0) in let buffers = Array.init (max nb_buffers nb_precomputed) (fun i -> if i < nb_precomputed then precomputed.(i) else Evaluations.create size_eval) in tmp_buffers := buffers ; (buffers, Array.init nb_ids (fun _ -> Evaluations.create size_eval)) let get_answers ?(gx = false) ~q_label ~prefix ~prefix_common answers : answers = let dummy = Scalar.zero in let answer = get_answer answers in let answer_wire w = let w = wire_name w in let w' = prefix w in let x = answer X w' in let gx = if gx then answer GX w' else dummy in (x, gx) in let q = prefix_common q_label |> answer X in let wires, wires_g = Array.init Plompiler.Csir.nb_wires_arch answer_wire |> Array.split in {q; wires; wires_g} let get_evaluations ~q_label ~prefix ~prefix_common evaluations = let find_wire w = Evaluations.find_evaluation evaluations (prefix @@ wire_name w) in { q = Evaluations.find_evaluation evaluations (prefix_common q_label); wires = Array.init Plompiler.Csir.nb_wires_arch find_wire; } (* Block names to merge identities within, if identities are independent, use q_label instead. For instance, we want to have want AddLeft and Addright identities to be merged inside the Arithmetic block, we thus use "arith" as Map key for these gates identities. We also want to use the ECC point addition identity independently, as such we put ECCAdd gate's q_label as key. *) let arith = "Arith" let qadv_label = "qadv" let map_singleton m = let map f t = let open L in let* x = t in ret (f x) in map (fun x -> [x]) m module type Base_sig = sig val q_label : string val identity : string * int val index_com : int option val nb_advs : int val nb_buffers : int val gx_composition : bool val equations : q:Scalar.t -> wires:Scalar.t array -> wires_g:Scalar.t array -> ?precomputed_advice:Scalar.t SMap.t -> unit -> Scalar.t list val prover_identities : prefix_common:(string -> string) -> prefix:(string -> string) -> public:public -> domain:Domain.t -> prover_identities val verifier_identities : prefix_common:(string -> string) -> prefix:(string -> string) -> public:public -> generator:Scalar.t -> size_domain:int -> verifier_identities (* Give the size of the domain on which the identities of the gate need to have the evaluation of each of his polynomial divided by the size of the citcuit. *) val polynomials_degree : int SMap.t val cs : q:L.scalar L.repr -> wires:L.scalar L.repr array -> wires_g:L.scalar L.repr array -> ?precomputed_advice:L.scalar L.repr SMap.t -> unit -> L.scalar L.repr list L.t end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>