DataVerifier
The DataVerifier
circuit is a zkSNARKs 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.
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.
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.
signal output idHash[2];
signal output constraintHash[2];
Components
comp_upper: An array of
GreaterEqThan
components ofnLevel
size that checks if each constrained data entry is greater or equal to its respective upper constraint.comp_lower: An array of
LessEqThan
components ofnLevel
size that checks if each constrained data entry is less or equal to its respective lower constraint.hasher: A
Pedersen
hashing component that hashes thedata
input signal.chasher: A
Pedersen
hashing component that hashes the data entries with constraints.
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.
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.
// max size = 68,719,476,735 (68.7b)
var bitSize = 36;
Last updated