HashApprover

The HashApprover is a zkSNARKs circuit is responsible for generating the hash of a key-value pair using the Poseidon hash function.

Input Signals

The circuit takes in the following input signals:

  • key: Represents the key for which the hash will be generated.

  • value: Represents the value that is paired with the key for the hash generation.

signal input key;
signal input value;

Output Signals

The circuit produces two output signals:

  • hash: The generated hash of the input key-value pair.

  • keyOut: A pass-through of the input key signal.

signal output hash;
signal output keyOut;

Components

  • hasher: A Poseidon hashing component that takes two inputs: key and value, and outputs the hash.

component hasher = Poseidon(2);
hasher.inputs[0] <== key;
hasher.inputs[1] <== value;
hash <== hasher.out;

Inclusion of External Circuits

The circuit makes use of the poseidon circuit from the circomlib library.

include "../../node_modules/circomlib/circuits/poseidon.circom";

Main Component

The main component of this circuit file is the HashApprover template.

component main = HashApprover();

This circuit is straightforward and primarily used for hashing a key-value pair using the Poseidon hash function and passing through the key. The output hash can be used for further data verification processes, while the output key can be used for mapping and data storage purposes.

Last updated