> For the complete documentation index, see [llms.txt](https://sacred.gitbook.io/sacred-technical-private-doc/aoErdM4nGaDgTMKPJV7E/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sacred.gitbook.io/sacred-technical-private-doc/aoErdM4nGaDgTMKPJV7E/what-is-sacred/circuits-summary.md).

# Circuits Summary

The Sacred Finance project makes use of circom circuits for two aspects:&#x20;

* Mixing&#x20;
* Anonymity mining

Anonymity mining makes use of the following circuits:&#x20;

* MerkleTreeUpdater.circom&#x20;
  * Adds a new leaf to a merkle tree&#x20;
* TreeUpdate.circom&#x20;
  * Instantiation of the MerkleTreeUpdater template&#x20;
* Withdraw\.circom&#x20;
  * Fork of Tornado.cash’s anonymity mining withdrawal circuit but implements the shares of staked seconds model described previously&#x20;
* Reward.circom&#x20;
  * Fork of Tornado.cash’s anonymity mining reward circuit but implements the shares of staked second model described previously

Mixing functionality makes use of the following circuits:&#x20;

* Withdraw\.circom&#x20;
  * Deposits take in a&#x20;
    * root of the deposit merkle tree in order to ensure that the user is withdrawing assets for which there indeed was a deposit and that the user doing the withdrawal owns the assets to be withdrawn.&#x20;
    * nullifierHash as part of the SacredCommitmentHasher&#x20;
  * In order to withdraw funds from Sacred.finance, you need&#x20;
    * Merkle path: purported path from the leaf node to the root&#x20;
    * Root: root of the deposit tree&#x20;
    * Leaf: the leaf is a commitment as specified in Utils.circom&#x20;
    * Nullifier: nullifier is to ensure that funds are withdrawn exactly once and is revealed once the withdrawal is done&#x20;
  * These properties enable a user to prove that they have a priori deposited into Sacred.Finance&#x20;
  * In order to ensure that the proof is dependent on the recipient and fee, the withdrawal circuit also contains extra constraints to invalidate the withdrawal snark proof.&#x20;

Circuits that are common to both the anonymity mining and mixing are:

* Utils.circom&#x20;
  * Contains the circuit for enforcing the correctness of the commitments generated in Sacred. Commitments are of the form H(nullifier, secret), H is the pedersen hash function and nullifiers are hashed using the pedersen hash function.&#x20;
  * Merkletree.circom&#x20;
    * Leafs are of the form (commitment)

Both the mixing and anonymity mining make use of the same merkletree.circom circuit. This circuit verifies that a given root along with a merkle path was indeed computed correctly. The merkle tree has the following properties:&#x20;

* Binary merkle tree&#x20;
* Leaf nodes are hashed using the poseidon hash function
