arnaucube
arnaucube/circomlibPublic Self-hosted repository
circomlib/circuits/switcher.circom
circuits/switcher.circomRaw
 1/*
 2    Assume sel is binary.
 3
 4    If sel == 0 then outL = L and outR=R
 5    If sel == 1 then outL = R and outR=L
 6
 7 */
 8
 9template Switcher() {
10    signal input sel;
11    signal input L;
12    signal input R;
13    signal output outL;
14    signal output outR;
15
16    signal aux;
17
18    aux <== (R-L)*sel;    // We create aux in order to have only one multiplication
19    outL <==  aux + L;
20    outR <== -aux + R;
21}