Skip to content

Commit

Permalink
Merge pull request #32 from FhenixProtocol/update_docs
Browse files Browse the repository at this point in the history
Add rol,ror,square to docs
  • Loading branch information
toml01 authored Oct 7, 2024
2 parents 4efa5c9 + 5fadc35 commit daf0055
Show file tree
Hide file tree
Showing 3 changed files with 353 additions and 18 deletions.
332 changes: 332 additions & 0 deletions docs/devdocs/Solidity API/FHE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 18 additions & 18 deletions docs/devdocs/Writing Smart Contracts/Gas-and-Benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
3 changes: 3 additions & 0 deletions docs/devdocs/Writing Smart Contracts/Types-and-Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ Note that all functions are supported in both direct function calls and library
| Bitwise Xor | `xor` | `^` | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <r>✘</r> | <g>✔</g> | n/a |
| Division | `div` | `/` | <g>✔</g> | <g>✔</g> | <g>✔</g> | <r>✘</r> | <r>✘</r> | <r>✘</r> | n/a | n/a |
| Remainder | `rem` | `%` | <g>✔</g> | <g>✔</g> | <g>✔</g> | <r>✘</r> | <r>✘</r> | <r>✘</r> | n/a | n/a |
| Square | `square` | n/a | <g>✔</g> | <g>✔</g> | <g>✔</g> | <r>✔</r> | <r>✘</r> | <r>✘</r> | n/a | n/a |
| Shift Right | `shr` | n/a | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <r>✘</r> | n/a | n/a |
| Shift Left | `shl` | n/a | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <r>✘</r> | n/a | n/a |
| Rotate Right | `ror` | n/a | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <r>✘</r> | n/a | n/a |
| Rotate Left | `rol` | n/a | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <r>✘</r> | n/a | n/a |
| Equal | `eq` | n/a | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> |
| Not equal | `ne` | n/a | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> |
| Greater than or equal | `gte` | n/a | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <r>✘</r> | n/a | n/a |
Expand Down

0 comments on commit daf0055

Please sign in to comment.