🚧 This documentation is currently under development. Content may be incomplete or subject to change. 🚧
Skip to content

Comparisons ​

Compare two encrypted values and return an encrypted boolean. Both operands must be of the same type. The result is always an ebool, regardless of the operand type. Comparison semantics depend on the type: unsigned for euintN, signed for eintN.

Comparison results are typically used with select for encrypted conditional logic.

Supported types: euint16, euint256, eint16, eint256

Usage ​

solidity
// Check if balance is sufficient and conditionally apply a transfer
ebool hasEnough = Nox.ge(balance, amount);
euint256 newBalance = Nox.select(hasEnough, Nox.sub(balance, amount), balance);
Nox.allowThis(newBalance);

eq ​

solidity
function eq(euint256 a, euint256 b) internal returns (ebool)

Returns encrypted true when a == b.

Example (Uint8)ResultReason
Eq(42, 42)trueEqual values
Eq(0, 255)falseDifferent values

ne ​

solidity
function ne(euint256 a, euint256 b) internal returns (ebool)

Returns encrypted true when a != b.

Example (Uint8)ResultReason
Ne(42, 42)falseEqual values
Ne(0, 255)trueDifferent values

lt ​

solidity
function lt(euint256 a, euint256 b) internal returns (ebool)

Returns encrypted true when a < b.

Example (Uint8)ResultReason
Lt(10, 200)true10 < 200 (unsigned)
Lt(200, 10)false200 < 10 is false
Example (Int8)ResultReason
Lt(-56, 10)true-56 < 10 (signed)
Lt(127, -128)false127 < -128 is false

le ​

solidity
function le(euint256 a, euint256 b) internal returns (ebool)

Returns encrypted true when a <= b.

Example (Uint8)ResultReason
Le(10, 10)trueEqual values
Le(200, 10)false200 <= 10 is false

gt ​

solidity
function gt(euint256 a, euint256 b) internal returns (ebool)

Returns encrypted true when a > b.

Example (Uint8)ResultReason
Gt(200, 10)true200 > 10 (unsigned)
Gt(10, 200)false10 > 200 is false
Example (Int8)ResultReason
Gt(10, -56)true10 > -56 (signed)
Gt(-128, 127)false-128 > 127 is false

ge ​

solidity
function ge(euint256 a, euint256 b) internal returns (ebool)

Returns encrypted true when a >= b.

Example (Uint8)ResultReason
Ge(10, 10)trueEqual values
Ge(10, 200)false10 >= 200 is false