# 0xPARC ZK Learning Group

<figure><img src="https://1983523492-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0nwEx8a60yETwfNYnenT%2Fuploads%2FnXJwfJogTWW6fc4denp2%2Fimage.png?alt=media&#x26;token=ff220efa-cb4e-4c78-a05c-a9fc201341b2" alt=""><figcaption></figcaption></figure>

* x is declared as public input
* if not declared, assumes inputs are private.

#### Public vs Private inputs

* `public` and `private` inputs to the circuit.&#x20;
* Public signals are variables that are public for everyone, if one takes a look on the blockchain, one can see these public variables are open for everyone to see.&#x20;
* Private values are only available to the proof creator.&#x20;

{% hint style="info" %}
all output signals of the main component are public (and cannot be made private),
{% endhint %}

For example, you want to prove you know a `x` such that `y = f(x)`,  x would be private, but y would be public.&#x20;

* out would be y \[`signal output out`]

## Examples

#### NonEqual

```solidity
pragma circom 2.0.0

template NonEqual(){
    signal input in0;
    signal input in1;
    
    // check that (in0-in1) is non-zero: check tt they not same
    signal inverse;
    // assign inverse value
    inverse <-- 1 / (in0 - in1);
    // create constraint
    inverse * (in0 - in1) === 1;
            
}
```

* Template NonEqual checks that in0 and in1 are not equal to each other.
* If they are not equal, the difference btw the signals is non-zero.
* To check that the signals are non-zero, we verify that the inverse exists.

#### Distinct

* Checks if all elements of an array are unique.
* Takes an array of n signals as input.

```solidity
template Distinct(){
    
    signal input in[n];
    //declare a component
    component nonEqual[n][n];

    for (var i = 0, i < n, i++){

        for (var j = 0, j < i, j++){
            // create a subcircuit
            nonEqual[i][j] = NonEqual();
            // assign input values + set contraints
            nonEqual[i][j].in0 <== in[i];
            nonEqual[i][j].in1 <== in[j];
        }
    }
}
```

* i,j a pair signals&#x20;
* for each pair, we want to check that they are not unique.&#x20;
* for each pair we will create a non-zero sub-circuit; and wire it up
