Encrypted Types

The encrypted values are expressed as euint on fhEVM, and the largest supported encrypted integer is up to 32 bits with euint32. Larger encrypted integer types will be supported in the future. As of now, the available encrypted types include:

  • ebool

  • euint8

  • euint16

  • euint32

Please bear in mind that "revert on overflow" is not supported because it would leak information on the encrypted value.

Cipher texts generated on the client side are converted into euint types in the smart contract by casting with the TFHE.asEuint8 function. Here's an example:

function storeEncryptedValue(bytes calldata encryptedValue) public {
        euint8 hiddenScore = TFHE.asEuint8(encryptedValue);

The other casting functions include:

  • TFHE.asEuint8

  • TFHE.asEuint16

  • TFHE.asEuint32

  • TFHE.asEbool

To generate a cipher text on the client side, please refer to this document:


Please note that the number of bits of the cipher text should match the euint type. For example, the value generated by instance.encrypt32(10) with fhevmjs can be casted with TFHE.asEuint8 on the smart contract.

Last updated