# 0xPARC ZK Learning Group

<figure><img src="/files/sAqTBk7PasEylrwMg8c1" 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://calnix.gitbook.io/zk-notes/0xparc-zk-learning-group.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
