Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions docs/devdocs/Solidity API/Experimental/FHERC20.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### _encBalances

```solidity
mapping(address => euint32) _encBalances
mapping(address => euint128) _encBalances
```

### constructor
Expand All @@ -15,7 +15,7 @@ constructor(string name, string symbol) public
### _allowanceEncrypted

```solidity
function _allowanceEncrypted(address owner, address spender) public view virtual returns (euint32)
function _allowanceEncrypted(address owner, address spender) internal view returns (euint128)
```

### allowanceEncrypted
Expand All @@ -33,7 +33,7 @@ This value changes when [approveEncrypted](#approveencrypted) or [transferFromEn
### approveEncrypted

```solidity
function approveEncrypted(address spender, struct inEuint32 value) public virtual returns (bool)
function approveEncrypted(address spender, inEuint128 calldata value) public virtual returns (bool)
```

_Sets a `value` amount of tokens as the allowance of `spender` over the
Expand All @@ -53,25 +53,25 @@ Emits an `ApprovalEncrypted` event._
### _approve

```solidity
function _approve(address owner, address spender, euint32 value) internal
function _approve(address owner, address spender, euint128 value) internal
```

### _spendAllowance

```solidity
function _spendAllowance(address owner, address spender, euint32 value) internal virtual returns (euint32)
function _spendAllowance(address owner, address spender, euint128 value) internal virtual returns (euint128)
```

### transferFromEncrypted

```solidity
function transferFromEncrypted(address from, address to, euint32 value) public virtual returns (euint32)
function transferFromEncrypted(address from, address to, euint128 value) public virtual returns (euint128)
```

### transferFromEncrypted

```solidity
function transferFromEncrypted(address from, address to, struct inEuint32 value) public virtual returns (euint32)
function transferFromEncrypted(address from, address to, inEuint128 calldata value) public virtual returns (euint128)
```

_Moves a `value` amount of tokens from `from` to `to` using the
Expand All @@ -97,25 +97,25 @@ function unwrap(uint32 amount) public
### _mintEncrypted

```solidity
function _mintEncrypted(address to, struct inEuint32 encryptedAmount) internal
function _mintEncrypted(address to, inEuint128 calldata encryptedAmount) internal
```

### transferEncrypted

```solidity
function transferEncrypted(address to, struct inEuint32 encryptedAmount) public returns (euint32)
function transferEncrypted(address to, inEuint128 calldata encryptedAmount) public returns (euint128)
```

### transferEncrypted

```solidity
function transferEncrypted(address to, euint32 amount) public returns (euint32)
function transferEncrypted(address to, euint128 amount) public returns (euint128)
```

### _transferImpl

```solidity
function _transferImpl(address from, address to, euint32 amount) internal returns (euint32)
function _transferImpl(address from, address to, euint128 amount) internal returns (euint128)
```

### balanceOfEncrypted
Expand Down
10 changes: 5 additions & 5 deletions docs/devdocs/Solidity API/Experimental/IFHERC20.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ _Returns the value of tokens owned by `account`, sealed and encrypted for the ca
### transferEncrypted

```solidity
function transferEncrypted(address to, struct inEuint32 value) external returns (euint32)
function transferEncrypted(address to, inEuint128 calldata value) external returns (euint128)
```

_Moves a `value` amount of tokens from the caller's account to `to`.
Expand All @@ -45,7 +45,7 @@ Emits a `TransferEncrypted` event._
### transferEncrypted

```solidity
function transferEncrypted(address to, euint32 value) external returns (euint32)
function transferEncrypted(address to, euint128 value) external returns (euint128)
```

### allowanceEncrypted
Expand All @@ -63,7 +63,7 @@ This value changes when [approveEncrypted](#approveencrypted) or [transferFromEn
### approveEncrypted

```solidity
function approveEncrypted(address spender, struct inEuint32 value) external returns (bool)
function approveEncrypted(address spender, inEuint128 calldata value) external returns (bool)
```

_Sets a `value` amount of tokens as the allowance of `spender` over the
Expand All @@ -83,7 +83,7 @@ Emits an `ApprovalEncrypted` event._
### transferFromEncrypted

```solidity
function transferFromEncrypted(address from, address to, struct inEuint32 value) external returns (euint32)
function transferFromEncrypted(address from, address to, inEuint128 calldata value) external returns (euint128)
```

_Moves a `value` amount of tokens from `from` to `to` using the
Expand All @@ -97,6 +97,6 @@ Emits a `TransferEncrypted` event._
### transferFromEncrypted

```solidity
function transferFromEncrypted(address from, address to, euint32 value) external returns (euint32)
function transferFromEncrypted(address from, address to, euint128 value) external returns (euint128)
```

4 changes: 2 additions & 2 deletions docs/devdocs/Tutorials/Basic/Adding View Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ We'll start by adding a new function to our `WrappingERC20` contract. This funct
public
view
onlySender(perm)
returns (uint256) {
returns (uint32) {
return FHE.decrypt(_encBalances[msg.sender]);
}
```
Expand Down Expand Up @@ -81,7 +81,7 @@ contract WrappingERC20 is ERC20, Permissioned {
public
view
onlySender(perm)
returns (uint256) {
returns (uint32) {
return FHE.decrypt(_encBalances[msg.sender]);
}
}
Expand Down
15 changes: 5 additions & 10 deletions docs/devdocs/Writing Smart Contracts/Debug-Logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,21 @@ When working with encrypted numbers in smart contracts, having robust logging me
Here's an example demonstrating how logging might be used in the context of encrypted number operations:

```solidity
import "@fhenixprotocol/contracts/utils/debug/Console.sol";
import { FHE } from "@fhenixprotocol/contracts/FHE.sol";
import { Console } from "@fhenixprotocol/contracts/utils/debug/Console.sol";
import { FHE, euint64, inEuint64 } from "@fhenixprotocol/contracts/FHE.sol";

contract EncryptedNumberContract {
using EncryptedNumberLibrary for EncryptedNumber;

function computeWithEncryptedNumbers(inEuint64 encryptedA, inEuint64 encryptedB) public {
function computeWithEncryptedNumbers(inEuint64 calldata encryptedA, inEuint64 calldata encryptedB) public {

// Perform some operations
euint64 result = FHE.asEuint64(encryptedA) + FHE.asEuint64(encryptedB);

// DEBUG: Log the intermediate result
// DEBUG: decrypt and log the intermediate result
uint256 debug_Result = FHE.decrypt(result);
// Log the result
Console.log(result);
Console.log(int256(debug_Result));

// Perform more operations
euint64 finalResult = result * FHE.asEuint64(encryptedA);

return finalResult;
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/devdocs/Writing Smart Contracts/Returning-Data.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Metamask's `eth_getEncryptionPublicKey` and `eth_decrypt` methods are deprecated
import {FHE} from "@fhenixprotocol/contracts";

function sealoutputExample(bytes32 pubkey) public pure returns (bytes memory reencrypted) {
euint8 memory foo = asEuint8(100);
euint8 foo = FHE.asEuint8(100);
return foo.seal(pubkey);
}
```
Expand All @@ -72,7 +72,7 @@ function sealoutputExample(bytes32 pubkey) public pure returns (bytes memory ree
import {FHE} from "@fhenixprotocol/contracts";

function sealoutputExample() public pure returns (uint8 decrypted) {
euint8 memory foo = asEuint8(100);
euint8 foo = FHE.asEuint8(100);
return FHE.decrypt(foo);
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/devdocs/Writing Smart Contracts/Security-Zones.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ Whether you are porting a contract from a previous Fhenix version, or creating a
## Code Example

```sol title="Contract.sol"
function addSecZone0(n1 inEuint32, n2 inEuint32) {
function addSecZone0(inEuint32 calldata n1, inEuint32 calldata n2) external {
euint32 first = FHE.asEuint32(n1); // This implicitly uses Security Zone 0
euint32 second = FHE.asEuint32(n2, 0); // This also uses Security Zone 0

euint32 result = first + second; // `result` will be marked 'security zone 0' automatically
}

function addSecZone1(n1 inEuint32, n2 inEuint32) {
function addSecZone1(inEuint32 calldata n1, inEuint32 calldata n2) external {
euint32 first = FHE.asEuint32(n1, 1); // To use a non-default SZ, you have to be explicit
euint32 second = FHE.asEuint32(n2, 1);

Expand All @@ -60,7 +60,7 @@ let second = await client.encrypt_uint32(1332, 0); // This implicitly uses Secur
await contract.addSecZone0(first, second);

first = await client.encrypt_uint32(5, 1); // To use a non-default SZ, you have to be explicit
econd = await client.encrypt_uint32(1332, 1);
second = await client.encrypt_uint32(1332, 1);
await contract.addSecZone1(first, second);
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ 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 |
| Square | `square` | n/a | <g>✔</g> | <g>✔</g> | <g>✔</g> | <g>✔</g> | <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 |
Expand Down