diff --git a/docs/devdocs/Solidity API/FHE.md b/docs/devdocs/Solidity API/FHE.md index 7ba36339..87c9a1b4 100644 --- a/docs/devdocs/Solidity API/FHE.md +++ b/docs/devdocs/Solidity API/FHE.md @@ -2782,6 +2782,338 @@ Pure in this function is marked as a hack/workaround - note that this function i | ---- | ---- | ----------- | | [0] | euint128 | The result of the operation | +### rol + +```solidity +function rol(euint8 lhs, euint8 rhs) internal pure returns (euint8) +``` + +This function performs the rol operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint8 | The first input | +| rhs | euint8 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint8 | The result of the operation | + +### rol + +```solidity +function rol(euint16 lhs, euint16 rhs) internal pure returns (euint16) +``` + +This function performs the rol operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint16 | The first input | +| rhs | euint16 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint16 | The result of the operation | + +### rol + +```solidity +function rol(euint32 lhs, euint32 rhs) internal pure returns (euint32) +``` + +This function performs the rol operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint32 | The first input | +| rhs | euint32 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint32 | The result of the operation | + +### rol + +```solidity +function rol(euint64 lhs, euint64 rhs) internal pure returns (euint64) +``` + +This functions performs the rol operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint64 | The first input | +| rhs | euint64 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint64 | The result of the operation | + +### rol + +```solidity +function rol(euint128 lhs, euint128 rhs) internal pure returns (euint128) +``` + +This functions performs the rol operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint128 | The first input | +| rhs | euint128 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint128 | The result of the operation | + +### ror + +```solidity +function ror(euint8 lhs, euint8 rhs) internal pure returns (euint8) +``` + +This function performs the ror operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint8 | The first input | +| rhs | euint8 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint8 | The result of the operation | + +### ror + +```solidity +function ror(euint16 lhs, euint16 rhs) internal pure returns (euint16) +``` + +This function performs the ror operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint16 | The first input | +| rhs | euint16 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint16 | The result of the operation | + +### ror + +```solidity +function ror(euint32 lhs, euint32 rhs) internal pure returns (euint32) +``` + +This function performs the ror operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint32 | The first input | +| rhs | euint32 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint32 | The result of the operation | + +### ror + +```solidity +function ror(euint64 lhs, euint64 rhs) internal pure returns (euint64) +``` + +This functions performs the ror operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint64 | The first input | +| rhs | euint64 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint64 | The result of the operation | + +### ror + +```solidity +function ror(euint128 lhs, euint128 rhs) internal pure returns (euint128) +``` + +This functions performs the ror operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| lhs | euint128 | The first input | +| rhs | euint128 | The second input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint128 | The result of the operation | + +### square + +```solidity +function square(euint8 value) internal pure returns (euint8) +``` + +This function performs the square operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ------ | ------ | ----------- | +| vaulue | euint8 | The input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint8 | The result of the operation | + +### square + +```solidity +function square(euint16 value) internal pure returns (euint16) +``` + +This function performs the square operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------- | +| vaulue | euint16 | The input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint16 | The result of the operation | + +### square + +```solidity +function square(euint32 value) internal pure returns (euint32) +``` + +This function performs the square operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------- | +| vaulue | euint32 | The input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint32 | The result of the operation | + +### square + +```solidity +function square(euint64 value) internal pure returns (euint64) +``` + +This functions performs the square operation + +_If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext +Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access_ + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------- | +| vaulue | euint64 | The input | + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | euint64 | The result of the operation | + ### not ```solidity diff --git a/docs/devdocs/Writing Smart Contracts/Gas-and-Benchmarks.md b/docs/devdocs/Writing Smart Contracts/Gas-and-Benchmarks.md index 31f82869..73fa826f 100644 --- a/docs/devdocs/Writing Smart Contracts/Gas-and-Benchmarks.md +++ b/docs/devdocs/Writing Smart Contracts/Gas-and-Benchmarks.md @@ -14,21 +14,21 @@ The new formula offers a discount of 75% for any data over 64KB, with default EV The gas costs for the FHE operations are as follows: -| FHE.sol function | euint8 | euint16 | euint32 | euint64 | euint128 | euint256 | ebool | eaddress | -|-------------------|---------|---------|-----------|---------|----------|----------|---------|----------| -| add, sub | 50,000 | 65,000 | 120,000 | 175,000 | 290,000 | n/a | n/a | n/a | -| asEuint (inEuint) | 65,000 | 65,000 | 65,000 | 300,000 | 300,000 | 300,000 | n/a | 300,000 | -| asEuint (euint) | 75,000 | 85,000 | 105,000 | 120,000 | 140,000 | 175,000 | n/a | 150,000 | -| asEuint (uint) | 20,000 | 20,000 | 30,000 | 35,000 | 65,000 | 70,000 | n/a | 70,000 | -| sealOutput | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | -| decrypt | 25,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | -| mul | 40,000 | 70,000 | 125,000 | 280,000 | n/a | n/a | n/a | n/a | -| lt, lte, gt, gte | 40,000 | 50,000 | 75,000 | 125,000 | 190,000 | n/a | n/a | n/a | -| select | 55,000 | 55,000 | 85,000 | 125,000 | 225,000 | n/a | 35,000 | n/a | -| require | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | -| div, rem | 125,000 | 335,000 | 1,003,000 | n/a | n/a | n/a | n/a | n/a | -| and, or, xor | 40,000 | 50,000 | 70,000 | 130,000 | 200,000 | n/a | 35,000 | n/a | -| ne, eq | 40,000 | 50,000 | 65,000 | 120,000 | 180,000 | 260,000 | 35,000 | 210,000 | -| min, max | 45,000 | 55,000 | 100,000 | 145,000 | 250,000 | n/a | n/a | n/a | -| shl, shr | 65,000 | 90,000 | 130,000 | 210,000 | 355,000 | n/a | n/a | n/a | -| not | 42,000 | 35,000 | 49,000 | 85,000 | 120,000 | n/a | 28,000 | n/a | +| FHE.sol function | euint8 | euint16 | euint32 | euint64 | euint128 | euint256 | ebool | eaddress | +|--------------------|---------|---------|-----------|---------|----------|----------|---------|----------| +| add, sub | 50,000 | 65,000 | 120,000 | 175,000 | 290,000 | n/a | n/a | n/a | +| asEuint (inEuint) | 65,000 | 65,000 | 65,000 | 300,000 | 300,000 | 300,000 | n/a | 300,000 | +| asEuint (euint) | 75,000 | 85,000 | 105,000 | 120,000 | 140,000 | 175,000 | n/a | 150,000 | +| asEuint (uint) | 20,000 | 20,000 | 30,000 | 35,000 | 65,000 | 70,000 | n/a | 70,000 | +| sealOutput | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | +| decrypt | 25,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | +| mul, square | 40,000 | 70,000 | 125,000 | 280,000 | n/a | n/a | n/a | n/a | +| lt, lte, gt, gte | 40,000 | 50,000 | 75,000 | 125,000 | 190,000 | n/a | n/a | n/a | +| select | 55,000 | 55,000 | 85,000 | 125,000 | 225,000 | n/a | 35,000 | n/a | +| require | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | 150,000 | +| div, rem | 125,000 | 335,000 | 1,003,000 | n/a | n/a | n/a | n/a | n/a | +| and, or, xor | 40,000 | 50,000 | 70,000 | 130,000 | 200,000 | n/a | 35,000 | n/a | +| ne, eq | 40,000 | 50,000 | 65,000 | 120,000 | 180,000 | 260,000 | 35,000 | 210,000 | +| min, max | 45,000 | 55,000 | 100,000 | 145,000 | 250,000 | n/a | n/a | n/a | +| shl, shr, rol, ror | 65,000 | 90,000 | 130,000 | 210,000 | 355,000 | n/a | n/a | n/a | +| not | 42,000 | 35,000 | 49,000 | 85,000 | 120,000 | n/a | 28,000 | n/a | diff --git a/docs/devdocs/Writing Smart Contracts/Types-and-Operators.md b/docs/devdocs/Writing Smart Contracts/Types-and-Operators.md index 1755c9cd..5134e458 100644 --- a/docs/devdocs/Writing Smart Contracts/Types-and-Operators.md +++ b/docs/devdocs/Writing Smart Contracts/Types-and-Operators.md @@ -115,8 +115,11 @@ Note that all functions are supported in both direct function calls and library | Bitwise Xor | `xor` | `^` | | | | | | | | n/a | | Division | `div` | `/` | | | | | | | n/a | n/a | | Remainder | `rem` | `%` | | | | | | | n/a | n/a | +| Square | `square` | n/a | | | | | | | n/a | n/a | | Shift Right | `shr` | n/a | | | | | | | n/a | n/a | | Shift Left | `shl` | n/a | | | | | | | n/a | n/a | +| Rotate Right | `ror` | n/a | | | | | | | n/a | n/a | +| Rotate Left | `rol` | n/a | | | | | | | n/a | n/a | | Equal | `eq` | n/a | | | | | | | | | | Not equal | `ne` | n/a | | | | | | | | | | Greater than or equal | `gte` | n/a | | | | | | | n/a | n/a |