E-Types

At the top of the confidential token implementation, we can see that we are importing new types of variables:

import {euint256, ebool, e} from "@inco/lightning/Lib.sol";

euint256 and ebool are the hidden counterparts of uint256 and bool, respectively. They are used to represent hidden values in the contract. The e- types are the hidden counterparts of the standard types in Solidity.

In our token example, the user balances are notably represented as euint256:

mapping(address => euint256) public balanceOf;

If we look into Inco’s library, we can see how euint256 and ebool are defined:

type euint256 is bytes32;
type ebool is bytes32;

If we try looking up on a block explorer the raw value returned by calling balanceOf, we will get something like:

0xa8d84064218bfc979af10dccc8153c9ab8a15068c3d64cb63927aca8ad1a3c9c

This gibberish value gives us no information about the actual balance of the user.

What is a Handle?

A handle is a unique identifier for an immutable piece of hidden data. In our token example, the balance of each user is represented as a handle, ebool success, euint256 value, etc. are also handles. The onchain smart contract is manipulating identifiers for a piece of hidden data (a balance, a boolean, etc.), and the actual data is safely stored offchain in an encrypted manner. Whenever an operation is performed over encrypted data types, the result is also a handle, like so:

euint256 senderNewBalance = balanceOf[msg.sender].sub(transferredValue);

A handle is immutable. If we were to reassigning a variable like so:

balanceOf[msg.sender] = balanceOf[msg.sender].sub(transferredValue);

balanceOf[msg.sender] would get assigned a new handle. It is important to keep in mind that the handle representing the old balance still exists, and still corresponds to the encrypted value of the old balance, even if the contract is not keeping track of it. We will see later in this guide that the value of handles are never lost and can still be accessed. From Inco’s standpoint, handles get created but never deleted.