Encrypted inputs
Inputs are a cornerstone of fhEVM: they allow users to push encrypted data onto the blockchain. To prevent any attacks, a user must provide proof of knowledge of the plaintext value underlying the ciphertext. This prevents the reuse of a ciphertext already stored on the blockchain.
All inputs are packed into a single ciphertext in a user-defined order, thereby minimizing the size and time required to create a zero-knowledge proof. When a function is called, there are two types of parameters: einput
, which is the index of the parameter, and bytes
, which contains the actual ciphertext and zero-knowledge proof.
For example, if a function requires 3 encrypted parameters, it could be written as follows:
Client Side
On client side for the previous function, using fhevmjs, the code will be:
Validate input
A contract can use an encrypted parameter by calling TFHE.asEuintXX(param, proof)
(or TFHE.asEbool
or TFHE.asEaddress
). This function will transform the input as a valid encrypted type.
Last updated