Skip to content

Commit

Permalink
feat: update to new fhevmjs (WIP)
Browse files Browse the repository at this point in the history
chore: updated asyncDecrypt

chore: cleaner reject test
  • Loading branch information
jatZama committed Dec 4, 2024
1 parent a61e4d0 commit 98a05bf
Show file tree
Hide file tree
Showing 14 changed files with 886 additions and 674 deletions.
11 changes: 1 addition & 10 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
export MNEMONIC="exchange vintage ocean narrow danger return culture ignore trim solve clock hidden buddy wise emotion"
export PRIVATE_KEY_FHEVM_DEPLOYER="f2caf1b49a8f33e5a95fc55b0903daddd261d5a874ff154dc5d809a5f1c90449"
export PRIVATE_KEY_GATEWAY_DEPLOYER="e956ca0c96995551256523af64ac2f134c6b65d3e9d5c7b24ac4cd0a12f07bfd"
export PRIVATE_KEY_GATEWAY_RELAYER="049bdaae72bcc269f5edf17be5a01d61374e139b425984431242a3a74f73e92a"
export NUM_KMS_SIGNERS="1"
export PRIVATE_KEY_KMS_SIGNER_0="d5b160a52fe6015861d0a1bea9523aaab3699d52af8f3cede5fcdbdfdd4c77cc"
export PRIVATE_KEY_COPROCESSOR_ACCOUNT="83e0173b9d07abd53958da9f417df515b0957c4f8afd7171b518d192b52ae313"
export IS_COPROCESSOR="true"

export SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export ETHERSCAN_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
export SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
4 changes: 2 additions & 2 deletions contracts/EncryptedERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
pragma solidity ^0.8.24;

import "fhevm/lib/TFHE.sol";
import "fhevm/config/ZamaFHEVMConfig.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";

/// @notice This contract implements an encrypted ERC20-like token with confidential balances using Zama's FHE (Fully Homomorphic Encryption) library.

Check failure on line 9 in contracts/EncryptedERC20.sol

View workflow job for this annotation

GitHub Actions / ci

Line length must be no more than 120 but current length is 150
/// @dev It supports typical ERC20 functionality such as transferring tokens, minting, and setting allowances, but uses encrypted data types.

Check failure on line 10 in contracts/EncryptedERC20.sol

View workflow job for this annotation

GitHub Actions / ci

Line length must be no more than 120 but current length is 141
contract EncryptedERC20 is Ownable2Step {
contract EncryptedERC20 is SepoliaZamaFHEVMConfig, Ownable2Step {
/// @notice Emitted when tokens are transferred
event Transfer(address indexed from, address indexed to);
/// @notice Emitted when a spender is approved to spend tokens on behalf of an owner
Expand All @@ -34,7 +35,6 @@ contract EncryptedERC20 is Ownable2Step {
/// @param name_ The name of the token
/// @param symbol_ The symbol of the token
constructor(string memory name_, string memory symbol_) Ownable(msg.sender) {
TFHE.setFHEVM(FHEVMConfig.defaultConfig()); // Set up the FHEVM configuration for this contract
_name = name_;
_symbol = symbol_;
}
Expand Down
7 changes: 3 additions & 4 deletions contracts/TestAsyncDecrypt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
pragma solidity ^0.8.24;

import "fhevm/lib/TFHE.sol";
import "fhevm/config/ZamaFHEVMConfig.sol";
import "fhevm/config/ZamaGatewayConfig.sol";
import "fhevm/gateway/GatewayCaller.sol";

/// @notice Contract for testing asynchronous decryption using the Gateway
contract TestAsyncDecrypt is GatewayCaller {
contract TestAsyncDecrypt is SepoliaZamaFHEVMConfig, SepoliaZamaGatewayConfig, GatewayCaller {

Check warning on line 11 in contracts/TestAsyncDecrypt.sol

View workflow job for this annotation

GitHub Actions / ci

Contract has 28 states declarations but allowed no more than 15
/// @dev Encrypted state variables
ebool xBool;
euint4 xUint4;
Expand Down Expand Up @@ -43,9 +45,6 @@ contract TestAsyncDecrypt is GatewayCaller {

/// @notice Constructor to initialize the contract and set up encrypted values
constructor() {
TFHE.setFHEVM(FHEVMConfig.defaultConfig());
Gateway.setGateway(Gateway.defaultGatewayAddress());

/// @dev Initialize encrypted variables with sample values
xBool = TFHE.asEbool(true);
TFHE.allowThis(xBool);
Expand Down
31 changes: 15 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.6",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@nomicfoundation/hardhat-verify": "^1.0.0",
"@openzeppelin/contracts": "^5.0.2",
"@openzeppelin/contracts-upgradeable": "5.0.2",
"@openzeppelin/hardhat-upgrades": "^3.5.0",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.12",
"@openzeppelin/contracts": "^5.1.0",
"@openzeppelin/hardhat-upgrades": "^3.6.0",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@typechain/ethers-v6": "^0.4.0",
"@typechain/hardhat": "^8.0.0",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.4",
"@types/eslint__js": "^8.42.3",
"@types/fs-extra": "^9.0.13",
Expand All @@ -35,9 +34,10 @@
"eslint": "^9.9.0",
"eslint-config-prettier": "^8.5.0",
"ethers": "^6.8.0",
"fhevm": "^0.6.0-0",
"fhevm-core-contracts": "0.1.0-2",
"fhevmjs": "^0.6.0-4",
"extra-bigint": "^1.1.18",
"fhevm": "^0.6.0-8",
"fhevm-core-contracts": "0.6.0-5",
"fhevmjs": "^0.6.0-16",
"fs-extra": "^10.1.0",
"globals": "^15.9.0",
"hardhat": "^2.22.8",
Expand All @@ -50,14 +50,17 @@
"prettier": "^2.8.4",
"prettier-plugin-solidity": "^1.1.2",
"rimraf": "^4.1.2",
"sha3": "^2.1.4",
"solhint": "^3.4.0",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "0.8.12",
"sqlite3": "^5.1.7",
"ts-generator": "^0.1.1",
"ts-node": "^10.9.1",
"typechain": "^8.2.0",
"typescript": "^5.5.4",
"typescript-eslint": "^8.0.1"
"typescript-eslint": "^8.0.1",
"web3-validator": "^2.0.6"
},
"files": [
"contracts"
Expand All @@ -77,7 +80,7 @@
"access": "public"
},
"scripts": {
"clean": "rimraf ./fhevmTemp ./artifacts ./cache ./coverage ./types ./coverage.json && pnpm typechain",
"clean": "rimraf ./artifacts ./cache ./coverage ./types ./coverage.json && pnpm typechain",
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
"lint": "pnpm lint:sol && pnpm lint:ts && pnpm prettier:check",
"lint:sol": "solhint --max-warnings 25 \"contracts/**/*.sol\"",
Expand All @@ -88,9 +91,5 @@
"typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain",
"test": "hardhat test --network hardhat",
"coverage": "hardhat coverage"
},
"dependencies": {
"extra-bigint": "^1.1.18",
"sqlite3": "^5.1.7"
}
}
Loading

0 comments on commit 98a05bf

Please sign in to comment.