LogoLogo
  • Introduction
  • Motivation
  • Roadmap
  • FAQ
  • Technical Walkthrough
  • Using Redact
    • Confidential Balances (Wallet)
    • Encrypting
    • Decrypting
    • Confidential Transfer (Sending)
  • Architecture
    • FHERC20 Token Standard
    • FHERC20.sol
    • ConfidentialERC20.sol
      • RedactCore.sol
    • CoFHE Overview
Powered by GitBook
On this page
  • Overview
  • Key Concepts
  • External Functions
  • ConfidentialETH
  • Claim System Details (ConfidentialClaim.sol)
  • Events
  1. Architecture

ConfidentialERC20.sol

PreviousFHERC20.solNextRedactCore.sol

Last updated 16 days ago

Overview

(and ) is an implementation of the FHERC20 standard that enables confidential token operations for any ERC20 token. It wraps existing ERC20 tokens to provide confidential balance and transfer functionality while maintaining compatibility with the original token's properties.

Key Concepts

Token Wrapping

  • ConfidentialERC20 wraps existing ERC20 tokens to provide confidential functionality

  • The wrapped token maintains the same name (prefixed with "Confidential") and symbol (prefixed with "e")

  • Decimals are preserved from the original token

  • The original token can be deposited and withdrawn through the contract using encrypt and decrypt

Confidential Balances

  • Inherits all FHE functionality from FHERC20

  • Balances are stored as encrypted values (euint128)

  • Uses indicated balances for UI/UX compatibility

  • See FHERC20 Documentation for detailed balance mechanics: FHERC20.sol

Claim System

The contract implements a claim system through the ConfidentialClaim.sol contract that enables:

  • Creation of confidential claims for token amounts

  • Decryption of claimed amounts

  • Tracking of user claims

  • Batch claiming functionality

External Functions

View Functions

underlying()

  • Returns the address of the underlying ERC20 token

  • Used to identify the original token being wrapped

isConfidentialERC20()

  • Returns true to indicate this is a ConfidentialERC20 token

getClaim(uint256 ctHash)

  • Returns claim information for a specific encrypted amount

  • Includes requested amount, decrypted amount, and claim status

  • Only accessible to authorized parties

getUserClaims(address user)

  • Returns all claims associated with a user

  • Includes both pending and claimed amounts

  • Only accessible to authorized parties

State-Changing Functions

encrypt(address to, uint128 amount)

  • Deposits the specified amount of the underlying token

  • Mints an equivalent amount of confidential tokens

  • Requires approval of the underlying ERC20

decrypt(address to, uint128 amount)

  • Burns the specified amount of confidential tokens

  • Transfers the equivalent amount of the underlying token

  • Requires sufficient confidential token balance

ConfidentialETH

ConfidentialETH is a special case of ConfidentialERC20 that wraps the native ETH token. ConfidentialETH allows encrypting of both ETH (using encryptETH ) and WETH (using encryptWETH). When decrypting ConfidentialETH, it is always decrypted as ETH, never WETH.

Symbol

  • ConfidentialETH symbol is eETH

Encrypt Process

  • Uses msg.value instead of token approval when encrypting ETH into eETH

  • No need for separate token approval

Withdrawal Process

  • Unwraps WETH back to ETH

  • Sends native ETH to the recipient

  • Handles gas considerations for ETH transfers

Claim System Details (ConfidentialClaim.sol)

Claim Structure

struct Claim {
    uint256 ctHash;           // Hash of the encrypted amount
    uint128 requestedAmount;  // Original requested amount
    uint128 decryptedAmount;  // Decrypted amount after processing
    bool decrypted;           // Whether the amount has been decrypted
    address to;               // Claim recipient
    bool claimed;             // Whether the claim has been processed
}

Claim Process

  1. Creation

    • A claim is created with an encrypted amount

    • The claim is associated with a specific recipient

    • The encrypted amount is stored with its hash

  2. Decryption

    • The encrypted amount is decrypted using FHE

    • The decrypted amount is verified against the original request

    • The claim status is updated

  3. Processing

    • The decrypted amount is transferred to the recipient

    • The claim is marked as claimed

    • The claim is removed from the user's active claims

Batch Operations

  • Users can claim multiple amounts in a single transaction

  • Gas efficient for processing multiple claims

  • Maintains confidentiality of individual amounts

Events

Deposit(address indexed user, uint256 amount)

  • Emitted when underlying tokens are deposited

  • Includes the deposit amount

Withdraw(address indexed user, uint256 amount)

  • Emitted when confidential tokens are withdrawn

  • Includes the withdrawal amount

ClaimCreated(address indexed user, uint256 ctHash, uint256 amount)

  • Emitted when a new claim is created

  • Includes the claim hash and amount

ClaimProcessed(address indexed user, uint256 ctHash, uint256 amount)

  • Emitted when a claim is processed

  • Includes the claim hash and decrypted amount

ConfidentialERC20.sol
ConfidentialETH.sol