> For the complete documentation index, see [llms.txt](https://docs.notcentralised.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.notcentralised.com/circuits/dataverifier.md).

# DataVerifier

The `DataVerifier` circuit is a  [zkSNARK](https://en.wikipedia.org/wiki/Non-interactive_zero-knowledge_proof)s circuit is responsible for verifying certain constraints over the provided data and returning hash values for further usage.

### Template Parameters

The circuit is defined with two parameters:

* **tLevel**: Total number of data entries.
* **nLevel**: Number of data entries with constraints.

```circom
template DataVerifier (tLevel, nLevel) { /*...*/ }
```

### Input Signals

The circuit takes in the following input signals:

* **data**: An array of `tLevel + nLevel` size, which contains the data entries that the circuit will process.
* **code**: An array of `tLevel + nLevel` size, which serves as a form of mask for the data.
* **constraint\_upper**: An array of `nLevel` size, which specifies the upper bound for the respective data entry.
* **constraint\_lower**: An array of `nLevel` size, which specifies the lower bound for the respective data entry.

```circom
signal input data[tLevel + nLevel];
signal input code[tLevel + nLevel];
signal input constraint_upper[nLevel];
signal input constraint_lower[nLevel];
```

### Output Signals

The circuit produces two output signals:

* **idHash**: A 2-element array which holds the hash of the `data` input signal.
* **constraintHash**: A 2-element array which holds the hash of the data entries with constraints.

```circom
signal output idHash[2];
signal output constraintHash[2];
```

### Components

* **comp\_upper**: An array of `GreaterEqThan` components of `nLevel` size that checks if each constrained data entry is greater or equal to its respective upper constraint.
* **comp\_lower**: An array of `LessEqThan` components of `nLevel` size that checks if each constrained data entry is less or equal to its respective lower constraint.
* **hasher**: A `Pedersen` hashing component that hashes the `data` input signal.
* **chasher**: A `Pedersen` hashing component that hashes the data entries with constraints.

```circom
component comp_upper[nLevel];
component comp_lower[nLevel];
component hasher = Pedersen(tLevel + nLevel);
component chasher = Pedersen(tLevel);
```

### Inclusion of External Circuits

The circuit makes use of the `comparators` and `pedersen` circuits from the `circomlib` library.

```circom
include "../../node_modules/circomlib/circuits/comparators.circom";
include "../../node_modules/circomlib/circuits/pedersen.circom";
```

### BitSize Variable

A variable `bitSize` is declared and initialized with `36`. This bitSize is the maximum bit length of data the `GreaterEqThan` and `LessEqThan` components can handle.

```circom
// max size = 68,719,476,735 (68.7b)
var bitSize = 36;
```
