Vault

ConfidentialVault Contract

The ConfidentialVault contract is a crucial component of the NotVault SDK. This contract is responsible for private token management. It maintains private balances and executes private transactions using zkSNARKs proofs. It is specifically designed to interact with ERC20 tokens.

Structure Definitions

  • CreateRequestMessage: This structure is used for creating a request for a confidential transfer. It contains recipient, denomination, and other related details of a private transfer.

  • SendRequest: This structure keeps the record of the confidential transfer requests. It contains details like the sender, recipient, and the amount of the transfer.

Public Functions

  • privateBalanceOf: This function returns the private balance of a given account in a specified denomination.

    function privateBalanceOf(
        address account,
        address denomination
    ) public view returns (string memory);
  • getSendRequestBySender: This function returns all the SendRequest made by a given account.

    function getSendRequestBySender(
            address account
    ) public view returns (SendRequest[] memory);
  • getSendRequestByReceiver: This function returns all the SendRequest which have a given account as the receiver.

    function getSendRequestByReceiver(
        address account
    ) public view returns (SendRequest[] memory);
  • getSendRequest: This function returns the details of a SendRequest based on a given idHash.

    function getSendRequest(
        uint256 idHash
    ) public view returns (SendRequest memory);
  • getNonce: This function returns the nonce of a given account.

    function getNonce(address account) public view returns (uint256);
  • deposit: This function deposits an amount of a specific ERC20 token from the sender's address into the contract and updates the sender's private and hash balances. A zkSNARKs proof and its corresponding input are required for this operation to ensure confidentiality.

    function deposit(
        address denomination,
        uint256 amount,
        string memory privateNewBalance,
        bytes calldata proof,
        uint[3] memory input
    );
  • withdraw: This function withdraws an amount of a specific ERC20 token from the contract to the sender's address and updates the sender's private and hash balances. A zkSNARKs proof and its corresponding input are required for this operation to ensure confidentiality.

    function withdraw(
        address denomination,
        uint256 amount,
        string memory privateNewBalance,
        bytes calldata proof,
        uint[5] memory input
    ); 
  • createRequest: This function creates multiple SendRequest using an array of CreateRequestMessage. It also updates the sender's private and hash balances for each request.

    function createRequest(
        CreateRequestMessage[] memory cr
    );
  • acceptRequest: This function is used to accept a SendRequest. The function takes the idHash of the SendRequest, the new private balance of the receiver, a zkSNARKs proof and its corresponding inputs as arguments. It verifies the proof, checks if the request is valid and active, and then updates the private and hash balances of the receiver.

    function acceptRequest(
        uint256 idHash,
        string memory privateNewBalance,
        bytes calldata proof,
        uint[3] memory input
    );

Last updated