How to input external values and convert them to handles
newEuint256
to convert the input value into a handle.
newEuint256
takes two arguments, the encrypted input value (in the form of bytes
) and the address of the account doing the input (here msg.sender
).
This account should always be the one that created the input, it will be given decryption right over the handle.
Passing another address than the user doing the input would be a malicious implementation.
valueInput
has to be a ciphertext, meaning it has to be the value intended to be transferred,
encrypted in a way that Inco can understand. To do this, you can use the encrypt
method from the JavaScript SDK.
If the bytes memory valueInput
is malformed, Inco will fallback to the handle default value.
The default value of euint256
is 0
, and the default value of ebool
is false
.
newEuint256
has been used, the resulting handle can be used immediately, there is no need
for Inco to issue a confirmation to start using it in the contract logic. Inco will decrypt
the corresponding ciphertext safely inside its TEE after the transaction has been included onchain.
All operations onchain are performed virtually over identifiers, and reproduced over the actual
values by Inco asynchronously. We call this model “symbolic execution”.asEuint256
method.
This is sometimes called performing a “trivial encrypt” because the resulting handle will be of a known value.
We can see it in the constructor of the token example:
balanceOf[msg.sender]
is 1000 * 1e9
,
but after the deployer sends a few transfers, its balance will be unknown to the public.