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 + nLevelsize, which contains the data entries that the circuit will process.code: An array of
tLevel + nLevelsize, which serves as a form of mask for the data.constraint_upper: An array of
nLevelsize, which specifies the upper bound for the respective data entry.constraint_lower: An array of
nLevelsize, 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
datainput 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
GreaterEqThancomponents ofnLevelsize that checks if each constrained data entry is greater or equal to its respective upper constraint.comp_lower: An array of
LessEqThancomponents ofnLevelsize that checks if each constrained data entry is less or equal to its respective lower constraint.hasher: A
Pedersenhashing component that hashes thedatainput signal.chasher: A
Pedersenhashing 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