Tornado Cash Official Logo

Tornado Cash Official

Smart Contracts in Tornado Cash Official

Tornado Cash Official’s smart contracts, written in Solidity, enable private transactions on Ethereum and Binance Smart Chain. This page provides an overview of their structure and functionality.

Overview

The smart contracts manage anonymity pools, zk-SNARK verification, and interactions with relayers. They are open-source and audited for security.

Key Contracts

Contract Functionality

The Tornado Pool contract, for example, includes:

Warning: Always verify contract addresses on GitHub to avoid interacting with malicious contracts.

Example: Tornado Pool Contract

Below is a simplified snippet of a Tornado Pool contract:

pragma solidity ^0.8.0;

contract TornadoPool {
    mapping(bytes32 => bool) public nullifierHashes;
    bytes32[] public commitments;

    function deposit(bytes32 _commitment) external payable {
        require(msg.value == 1 ether, "Invalid deposit amount");
        commitments.push(_commitment);
        // Emit event for note generation
    }

    function withdraw(bytes32 _nullifierHash, bytes calldata _proof) external {
        require(!nullifierHashes[_nullifierHash], "Nullifier already used");
        // Verify zk-SNARK proof
        nullifierHashes[_nullifierHash] = true;
        // Transfer funds
    }
}
            

Security and Audits

The contracts are audited by third parties, but users should:

Further Reading

Explore related topics: