arnaucube
arnaucube/grapevine-sonobePublic Self-hosted repository
grapevine-sonobe/circom/node_modules/circomlib/circuits/mux1.circom
circom/node_modules/circomlib/circuits/mux1.circomRaw
 1/*
 2    Copyright 2018 0KIMS association.
 3
 4    This file is part of circom (Zero Knowledge Circuit Compiler).
 5
 6    circom is a free software: you can redistribute it and/or modify it
 7    under the terms of the GNU General Public License as published by
 8    the Free Software Foundation, either version 3 of the License, or
 9    (at your option) any later version.
10
11    circom is distributed in the hope that it will be useful, but WITHOUT
12    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14    License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with circom. If not, see <https://www.gnu.org/licenses/>.
18*/
19pragma circom 2.0.0;
20
21template MultiMux1(n) {
22    signal input c[n][2];  // Constants
23    signal input s;   // Selector
24    signal output out[n];
25
26    for (var i=0; i<n; i++) {
27
28        out[i] <== (c[i][1] - c[i][0])*s + c[i][0];
29
30    }
31}
32
33template Mux1() {
34    var i;
35    signal input c[2];  // Constants
36    signal input s;   // Selector
37    signal output out;
38
39    component mux = MultiMux1(1);
40
41    for (i=0; i<2; i++) {
42        mux.c[0][i] <== c[i];
43    }
44
45    s ==> mux.s;
46
47    mux.out[0] ==> out;
48}