Debug decrypt
This guide explains how to use the debug.decrypt[XX]
functions for debugging encrypted data in mocked environments during development with fhEVM.
[!WARNING] The
debug.decrypt[XX]
functions should not be used in production as they rely on private keys.
Overview
The debug.decrypt[XX]
functions allow you to decrypt encrypted handles into plaintext values. This feature is useful for debugging encrypted operations such as transfers, balance checks, and other computations involving FHE-encrypted data.
Key points
Environment: The
debug.decrypt[XX]
functions work only in mocked environments (e.g.,hardhat
network).Production limitation: In production, decryption is performed asynchronously via the Gateway and requires an authorized onchain request.
Encrypted types: The
debug.decrypt[XX]
functions supports various encrypted types, including integers, booleans, andebytesXX
.Bypass ACL authorization: The
debug.decrypt[XX]
functions allow decryption without ACL authorization, useful for verifying encrypted operations during development and testing.
Supported functions
Integer decryption
Decrypts encrypted integers of different bit-widths (euint4
, euint8
, ..., euint256
).
decrypt4
bigint
euint4
decrypt8
bigint
euint8
decrypt16
bigint
euint16
decrypt32
bigint
euint32
decrypt64
bigint
euint64
decrypt128
bigint
euint128
decrypt256
bigint
euint256
Boolean decryption
Decrypts encrypted booleans (ebool
).
decryptBool
boolean
ebool
Byte array decryption
Decrypts encrypted byte arrays of various sizes (ebytesXX
).
decryptEbytes64
string
ebytes64
decryptEbytes128
string
ebytes128
decryptEbytes256
string
ebytes256
Address decryption
Decrypts encrypted addresses.
decryptAddress
string
eaddress
Function usage
Example: decrypting encrypted values
[!NOTE] To utilize the debug functions, import the utils.ts file.
For a more complete example, refer to the ConfidentialERC20 test file.
Example: decrypting byte arrays
How it works
Verifying types
Each decryption function includes a type verification step to ensure the provided handle matches the expected encrypted type. If the type is mismatched, an error is thrown.
Environment checks
[!CAUTION] The functions only work in the
hardhat
network. Attempting to use them in a production environment will result in an error.
Best practices
Use only for debugging: These functions require access to private keys and are meant exclusively for local testing and debugging.
Production decryption: For production, always use the asynchronous Gateway-based decryption.
Last updated