Skip to main content
Inco exposes mathematical and logical operations over encrypted data. Note that for each operation that takes 2 arguments (i.e binary types below), you can use either an e-type or a regular variable as the first or second argument. Each operation returns a single e-type as result.
Under the hood, all operations are performing a call to the Inco contract singleton. The Inco contract checks access control rules and emits an event for each operation

Example usage

euint256 a = e.asEuint256(2);
euint256 b = e.asEuint256(3);
euint256 c = a.add(b); // c = 5 (encrypted)

Supported math operations

All these operations return an euint256.
NameFunctionType
Additione.addBinary
Subtractione.subBinary
Multiplicatione.mulBinary
Divisione.divBinary
Remaindere.remBinary
BitAnde.andBinary
BitOre.orBinary
BitXore.xorBinary
Shift Righte.shrBinary
Shift Lefte.shlBinary
Rotate Righte.rotrBinary
Rotate Lefte.rotlBinary

Supported comparison operations

NameFunctionTypeReturns
Equale.eqBinaryebool
Not equale.neBinaryebool
Greater than or equale.geBinaryebool
Greater thane.gtBinaryebool
Less than or equale.leBinaryebool
Less thane.ltBinaryebool
Mine.minBinaryeuint256
Maxe.maxBinaryeuint256
Note.notUnaryebool

Random number generation

euint256 randomNumber = e.rand();
euint256 boundedRandom = e.randBounded(100); // Random number in [0, 100)
euint256 boundedRandomEncrypted = e.randBounded(encryptedUpperBound); // With encrypted upper bound
NameFunctionTypeReturns
Randome.rand()Unaryeuint256
Random Boundede.randBounded(uint256 upperBound)Unaryeuint256
Random Boundede.randBounded(euint256 upperBound)Unaryeuint256

Type conversion functions

Convert between regular types and encrypted types, or between different encrypted types.
euint256 a = e.asEuint256(42);
ebool b = e.asEbool(true);
eaddress c = e.asEaddress(0x123...);
ebool d = e.asEbool(encryptedUint); // Cast from euint256
euint256 e = e.asEuint256(encryptedBool); // Cast from ebool
NameFunctionTypeReturns
Convert to euint256e.asEuint256(uint256 a)Unaryeuint256
Convert to eboole.asEbool(bool a)Unaryebool
Convert to eaddresse.asEaddress(address a)Unaryeaddress
Cast euint256 to eboole.asEbool(euint256 a)Unaryebool
Cast ebool to euint256e.asEuint256(ebool a)Unaryeuint256

Reveal functions

Reveal encrypted values (decrypt and make public).
e.reveal(encryptedUint);
e.reveal(encryptedBool);
e.reveal(encryptedAddress);
NameFunctionTypeReturns
Reveale.reveal(euint256 a)Unaryvoid
Reveale.reveal(ebool a)Unaryvoid
Reveale.reveal(eaddress a)Unaryvoid

Additional type support

Comparison operations (e.eq and e.ne) also support eaddress comparisons in addition to euint256. Bitwise operations (e.and, e.or, e.xor) also support ebool operations in addition to euint256.