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
  • 1. Decrypting FHERC20 Balance
  • 2. Claiming ERC20 Balance
  1. Using Redact

Decrypting

PreviousEncryptingNextConfidential Transfer (Sending)

Last updated 15 days ago

Decrypting is the process of converting your confidential FHERC20 balance back into a public ERC20 balance. This process has 2 steps:

  1. Decrypting some amount of FHERC20

  2. Claiming the decrypted amount as ERC20

When converting from a confidential balance to a public balance, we must perform an on-chain decryption using FHE.decrypt . In this case, we must use FHE.decrypt on the amount of token that has been transferred.

This decryption request is picked up by CoFHE, which will perform the decryption and post the result back on-chain.

This asynchronous on-chain decryption is what forces "Decrypt" and "Claim" to be handled by two separate transactions.

1. Decrypting FHERC20 Balance

After selecting the FHERC20 token to decrypt and the amount to decrypt, we execute the Decrypt transaction. In ConfidentialERC20.sol the function decrypt() is used, which burns the FHERC20 and requests an on-chain FHE decryption of the amount burned. Once the on-chain FHE decryption is finalized, that amount is marked as "Claimable" and can be claimed as the underlying ERC20 in the upcoming step.

In Redact, this is the expected Decrypt flow:

After the Decryption transaction has succeeded, you can note that in the wallet the public ERC20 balance has been replaced with two balances: The public balance, and the claimable balance.

You can claim these decrypted tokens either from the main page component, or from within the wallet using the CLAIM button

2. Claiming ERC20 Balance

After the successful on-chain FHE decryption has resolved, we are ready to claim the ERC20s. Claiming will add the claimable amount to your ERC20 balance, and in Redact it looks like this:

In order to encrypt (or wrap) your ERC20 tokens, they must first approve them for use in the ConfidentialERC20 smart contract. Only the amount to wrap must be approved.

In the Redact UI, this is step 2 of the wrapping process, and appears like so:

Notice that in the transaction above, it is public LINK that is being transferred during the claim flow.

TX:

Tx:

If you would like to read more about claiming take a look here:

https://sepolia.etherscan.io/tx/0x7a2...a71
https://sepolia.etherscan.io/tx/0x401...cc2
Claim System
Decryption flow diagram. (1) Initial, (2) Pending, (3) Success
Approval flow diagram. (1) Initial, (2) Pending, (3) Success