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
Supported math operations
All these operations return an euint256.
| Name | Function | Type |
|---|
| Addition | e.add | Binary |
| Subtraction | e.sub | Binary |
| Multiplication | e.mul | Binary |
| Division | e.div | Binary |
| Remainder | e.rem | Binary |
| BitAnd | e.and | Binary |
| BitOr | e.or | Binary |
| BitXor | e.xor | Binary |
| Shift Right | e.shr | Binary |
| Shift Left | e.shl | Binary |
| Rotate Right | e.rotr | Binary |
| Rotate Left | e.rotl | Binary |
Supported comparison operations
| Name | Function | Type | Returns |
|---|
| Equal | e.eq | Binary | ebool |
| Not equal | e.ne | Binary | ebool |
| Greater than or equal | e.ge | Binary | ebool |
| Greater than | e.gt | Binary | ebool |
| Less than or equal | e.le | Binary | ebool |
| Less than | e.lt | Binary | ebool |
| Min | e.min | Binary | euint256 |
| Max | e.max | Binary | euint256 |
| Not | e.not | Unary | ebool |
Random number generation
| Name | Function | Type | Returns |
|---|
| Random | e.rand() | Unary | euint256 |
| Random Bounded | e.randBounded(uint256 upperBound) | Unary | euint256 |
| Random Bounded | e.randBounded(euint256 upperBound) | Unary | euint256 |
Type conversion functions
Convert between regular types and encrypted types, or between different encrypted types.
| Name | Function | Type | Returns |
|---|
| Convert to euint256 | e.asEuint256(uint256 a) | Unary | euint256 |
| Convert to ebool | e.asEbool(bool a) | Unary | ebool |
| Convert to eaddress | e.asEaddress(address a) | Unary | eaddress |
| Cast euint256 to ebool | e.asEbool(euint256 a) | Unary | ebool |
| Cast ebool to euint256 | e.asEuint256(ebool a) | Unary | euint256 |
Reveal functions
Reveal encrypted values (decrypt and make public).
| Name | Function | Type | Returns |
|---|
| Reveal | e.reveal(euint256 a) | Unary | void |
| Reveal | e.reveal(ebool a) | Unary | void |
| Reveal | e.reveal(eaddress a) | Unary | void |
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.