HashSender

The HashSender circuit is designed to process and validate transfers from a sender, creating hashed versions of the amount transferred, the balance of the sender before and after the transfer, a nonce for transaction uniqueness, and a combined identifier hash.

Input Signals

The circuit accepts the following inputs:

  1. sender: The sender of the transaction.

  2. senderBalanceBeforeTransfer: The balance of the sender before the transaction.

  3. amount: The amount to be transferred.

  4. nonce: A unique identifier for each transaction.

signal input sender;
signal input senderBalanceBeforeTransfer;
signal input amount;  
signal input nonce;

Output Signals

The circuit outputs the following signals:

  1. senderBalanceBeforeTransferHash: The hash of the sender's balance before the transfer occurs.

  2. senderBalanceAfterTransferHash: The hash of the sender's balance after the transfer has occurred.

  3. amountHash: The hash of the amount that is transferred.

  4. nonceVerification: The nonce input passed straight through for verification.

  5. idHash: The hash of a combination of sender, sender balance before transfer, amount, and nonce.

Components

The circuit incorporates the following components:

  • comp1: A comparator ensuring that the amount is greater than or equal to zero.

  • comp2: A comparator checking if the senderBalanceBeforeTransfer is greater than or equal to the amount.

  • hashAmount: A Poseidon hashing function to create a hash of the amount.

  • hashBeforeBalance: A Poseidon hashing function to create a hash of the sender's balance before the transfer.

  • hashAfterBalance: A Poseidon hashing function to create a hash of the sender's balance after the transfer.

  • hashId: A Poseidon hashing function to create a hash of a combination of sender, sender balance before transfer, amount, and nonce.

External Circuit Inclusions

The circuit includes poseidon and comparators circuits from the circomlib library.

Main Component

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

The HashSender circuit is primarily used for hashing important aspects of a transaction from a sender, which includes the amount transferred, the sender's balance before and after the transfer, a nonce for each transaction, and a combined identifier hash. This allows for secure, reliable transaction verification and integrity checks within your application.

Last updated