Installation
- npm
- yarn
- bun
Types
ebool: Encryptedbooleuint256: Encrypteduint256eaddress: Encryptedaddress
Math operations
All arithmetic operations return aneuint256.
All binary operations may use either an euint256 or a regular uint256 as the first or second argument, or two euint256s.
Bitwise operations work on both euint256 and ebool types, and may use either encrypted or plain values as arguments.
| Name | Function | Type | Returns |
|---|---|---|---|
| Addition | e.add | Binary | euint256 |
| Subtraction | e.sub | Binary | euint256 |
| Multiplication | e.mul | Binary | euint256 |
| Division | e.div | Binary | euint256 |
| Remainder | e.rem | Binary | euint256 |
| BitAnd | e.and | Binary | euint256 or ebool |
| BitOr | e.or | Binary | euint256 or ebool |
| BitXor | e.xor | Binary | euint256 or ebool |
| Shift Right | e.shr | Binary | euint256 |
| Shift Left | e.shl | Binary | euint256 |
| Rotate Right | e.rotr | Binary | euint256 |
| Rotate Left | e.rotl | Binary | euint256 |
Comparison operations
| Name | Function | Type | Returns | Notes |
|---|---|---|---|---|
| Equal | e.eq | Binary | ebool | Works with euint256, eaddress, and combinations with plain types |
| Not equal | e.ne | Binary | ebool | Works with euint256, eaddress, and combinations with plain types |
| Greater than or equal | e.ge | Binary | ebool | euint256 only |
| Greater than | e.gt | Binary | ebool | euint256 only |
| Less than or equal | e.le | Binary | ebool | euint256 only |
| Less than | e.lt | Binary | ebool | euint256 only |
| Min | e.min | Binary | euint256 | euint256 only |
| Max | e.max | Binary | euint256 | euint256 only |
| Not | e.not | Unary | ebool | ebool only |
Multiplexer
e.select(ebool, euint256, euint256) returns(euint256): Select between twoeuint256s based on aneboolconditione.select(ebool, ebool, ebool) returns(ebool): Select between twoebools based on aneboolconditione.select(ebool, eaddress, eaddress) returns(eaddress): Select between twoeaddresses based on aneboolcondition
Random Functions
All random functions require payment of the Inco fee.e.rand() returns(euint256): Generate a randomeuint256valuee.randBounded(uint256) returns(euint256): Generate a randomeuint256value bounded by auint256upper limite.randBounded(euint256) returns(euint256): Generate a randomeuint256value bounded by aneuint256upper limit
Inputs
e.asEuint256(uint256) returns(euint256): Convert auint256to aneuint256(trivial encrypt)e.asEbool(bool) returns(ebool): Convert aboolto anebool(trivial encrypt)e.asEaddress(address) returns(eaddress): Convert anaddressto aneaddress(trivial encrypt)e.newEuint256(bytes memory input) returns(euint256): Create a neweuint256from a ciphertexte.newEbool(bytes memory input) returns(ebool): Create a neweboolfrom a ciphertexte.newEaddress(bytes memory input) returns(eaddress): Create a neweaddressfrom a ciphertext
Type Casting
e.asEbool(euint256) returns(ebool): Cast aneuint256to aneboole.asEuint256(ebool) returns(euint256): Cast aneboolto aneuint256
Access control
e.allow(euint256, address): Allow a user to access aneuint256value permanentlye.allow(ebool, address): Allow a user to access aneboolvalue permanentlye.allow(eaddress, address): Allow a user to access aneaddressvalue permanentlye.allowThis(euint256): Allow the current contract to access aneuint256value permanentlye.allowThis(ebool): Allow the current contract to access aneboolvalue permanentlye.allowThis(eaddress): Allow the current contract to access aneaddressvalue permanentlye.reveal(euint256): Make aneuint256value publicly accessiblee.reveal(ebool): Make aneboolvalue publicly accessiblee.reveal(eaddress): Make aneaddressvalue publicly accessiblee.isAllowed(address, euint256) returns(bool): Check if a user is allowed to access aneuint256value