Skip to content

Commit

Permalink
Merge pull request #686 from zama-ai/core070-3
Browse files Browse the repository at this point in the history
feat: new fhevm-core-contracts pre-release
  • Loading branch information
jatZama authored Jan 8, 2025
2 parents 8dd9f92 + 3173577 commit 89c3288
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 473 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export MNEMONIC="adapt mosquito move limb mobile illegal tree voyage juice mosquito burger raise father hope layer"
export PRIVATE_KEY_FHEVM_DEPLOYER="0c66d8cde71d2faa29d0cb6e3a567d31279b6eace67b0a9d9ba869c119843a5e"
export PRIVATE_KEY_DECRYPTION_ORACLE_DEPLOYER="717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6"
export PRIVATE_KEY_DECRYPTION_ORACLE_RELAYER="7ec931411ad75a7c201469a385d6f18a325d4923f9f213bd882bbea87e160b67"
export NUM_KMS_SIGNERS="1"
export PRIVATE_KEY_KMS_SIGNER_0="388b7680e4e1afa06efbfd45cdd1fe39f3c6af381df6555a19661f283b97de91"
Expand Down
33 changes: 9 additions & 24 deletions examples/TestAsyncDecrypt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -446,17 +446,13 @@ contract TestAsyncDecrypt is DecryptionOracleCaller {
/// @param input1 First additional input parameter for the callback function
/// @param input2 Second additional input parameter for the callback function
function requestMixed(uint32 input1, uint32 input2) public {
uint256[] memory cts = new uint256[](10);
uint256[] memory cts = new uint256[](6);
cts[0] = toUint256(xBool);
cts[1] = toUint256(xBool);
cts[2] = toUint256(xUint4);
cts[3] = toUint256(xUint8);
cts[4] = toUint256(xUint16);
cts[5] = toUint256(xUint32);
cts[6] = toUint256(xUint64);
cts[7] = toUint256(xUint64);
cts[8] = toUint256(xUint64);
cts[9] = toUint256(xAddress);
cts[1] = toUint256(xUint4);
cts[2] = toUint256(xUint8);
cts[3] = toUint256(xUint16);
cts[4] = toUint256(xUint32);
cts[5] = toUint256(xAddress);
uint256 requestID = requestDecryption(cts, this.callbackMixed.selector);
addParamsUint256(requestID, input1);
addParamsUint256(requestID, input2);
Expand All @@ -465,33 +461,24 @@ contract TestAsyncDecrypt is DecryptionOracleCaller {
/// @notice Callback function for mixed data type decryption
/// @dev Processes the decrypted values and performs some basic checks
/// @param requestID The ID of the decryption request
/// @param decBool_1 First decrypted boolean
/// @param decBool_2 Second decrypted boolean
/// @param decBool First decrypted boolean
/// @param decUint4 Decrypted 4-bit unsigned integer
/// @param decUint8 Decrypted 8-bit unsigned integer
/// @param decUint16 Decrypted 16-bit unsigned integer
/// @param decUint32 Decrypted 32-bit unsigned integer
/// @param decUint64_1 First decrypted 64-bit unsigned integer
/// @param decUint64_2 Second decrypted 64-bit unsigned integer
/// @param decUint64_3 Third decrypted 64-bit unsigned integer
/// @param decAddress Decrypted address
/// @return The decrypted 4-bit unsigned integer
function callbackMixed(
uint256 requestID,
bool decBool_1,
bool decBool_2,
bool decBool,
uint8 decUint4,
uint8 decUint8,
uint16 decUint16,
uint32 decUint32,
uint64 decUint64_1,
uint64 decUint64_2,
uint64 decUint64_3,
address decAddress,
bytes[] memory signatures
) public checkSignatures(requestID, signatures) returns (uint8) {
yBool = decBool_1;
require(decBool_1 == decBool_2, "Wrong decryption");
yBool = decBool;
yUint4 = decUint4;
yUint8 = decUint8;
yUint16 = decUint16;
Expand All @@ -500,8 +487,6 @@ contract TestAsyncDecrypt is DecryptionOracleCaller {
uint32 result = uint32(params[0]) + uint32(params[1]) + decUint32;
yUint32 = result;
}
yUint64 = decUint64_1;
require(decUint64_1 == decUint64_2 && decUint64_2 == decUint64_3, "Wrong decryption");
yAddress = decAddress;
return yUint4;
}
Expand Down
28 changes: 16 additions & 12 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import CustomProvider from './CustomProvider';
// Adjust the import path as needed
import './tasks/accounts';
import './tasks/getEthereumAddress';
import './tasks/taskDecryptionOracleRelayer';
import './tasks/taskDeploy';
import './tasks/taskTFHE';
import './tasks/taskUtils';

extendProvider((provider) => {
return new CustomProvider(provider);
Expand Down Expand Up @@ -95,17 +94,15 @@ task('test', async (_taskArgs, hre, runSuper) => {
// Run modified test task
if (hre.network.name === 'hardhat') {
// in fhevm mode all this block is done when launching the node via `pnmp fhevm:start`
const privKeyDecryptionOracleDeployer = process.env.PRIVATE_KEY_DECRYPTION_ORACLE_DEPLOYER;
const privKeyFhevmDeployer = process.env.PRIVATE_KEY_FHEVM_DEPLOYER;
const privKeyFhevmRelayer = process.env.PRIVATE_KEY_DECRYPTION_ORACLE_RELAYER;
await hre.run('task:faucetToPrivate', { privateKey: privKeyFhevmDeployer });
await hre.run('task:faucetToPrivate', { privateKey: privKeyFhevmRelayer });

if (!fs.existsSync('node_modules/fhevm-core-contracts/addresses')) {
fs.mkdirSync('node_modules/fhevm-core-contracts/addresses');
}
await hre.run('task:computeDecryptionOracleAddress', { privateKey: privKeyDecryptionOracleDeployer });
await hre.run('task:computeACLAddress', { privateKey: privKeyFhevmDeployer });
await hre.run('task:computeTFHEExecutorAddress', { privateKey: privKeyFhevmDeployer });
await hre.run('task:computeKMSVerifierAddress', { privateKey: privKeyFhevmDeployer });
await hre.run('task:computeInputVerifierAddress', { privateKey: privKeyFhevmDeployer, useAddress: false });
await hre.run('task:computeFHEGasLimitAddress', { privateKey: privKeyFhevmDeployer });

const sourceDir = path.resolve(__dirname, 'node_modules/fhevm-core-contracts/contracts');
const destinationDir = path.resolve(__dirname, 'fhevmTemp/contracts');
fs.copySync(sourceDir, destinationDir, { dereference: true });
Expand All @@ -115,22 +112,29 @@ task('test', async (_taskArgs, hre, runSuper) => {
const sourceDir3 = path.resolve(__dirname, 'node_modules/fhevm-core-contracts/decryptionOracle');
const destinationDir3 = path.resolve(__dirname, 'fhevmTemp/decryptionOracle');
fs.copySync(sourceDir3, destinationDir3, { dereference: true });

await hre.run('compile:specific', { contract: 'fhevmTemp/contracts/emptyProxy' });
await hre.run('task:deployEmptyUUPSProxies', { privateKey: privKeyFhevmDeployer, useCoprocessorAddress: false });

fs.copySync(destinationDir2, sourceDir2, { dereference: true });

await hre.run('compile:specific', { contract: 'fhevmTemp/contracts' });
await hre.run('compile:specific', { contract: 'fhevmTemp/decryptionOracle' });
await hre.run('compile:specific', { contract: 'lib' });
await hre.run('compile:specific', { contract: 'decryption' });
await hre.run('task:faucetToPrivate', { privateKey: privKeyFhevmDeployer });

await hre.run('task:deployACL', { privateKey: privKeyFhevmDeployer });
await hre.run('task:deployTFHEExecutor', { privateKey: privKeyFhevmDeployer });
await hre.run('task:deployKMSVerifier', { privateKey: privKeyFhevmDeployer });
await hre.run('task:deployInputVerifier', { privateKey: privKeyFhevmDeployer });
await hre.run('task:deployFHEGasLimit', { privateKey: privKeyFhevmDeployer });
await hre.run('task:deployDecryptionOracle', { privateKey: privKeyFhevmDeployer });

await hre.run('task:addSigners', {
numSigners: process.env.NUM_KMS_SIGNERS!,
privateKey: privKeyFhevmDeployer,
useAddress: false,
});
await hre.run('task:launchFhevm', { skipGetCoin: false, useAddress: false });
}
await hre.run('compile:specific', { contract: 'examples' });
await runSuper();
Expand Down Expand Up @@ -186,7 +190,7 @@ const config: HardhatUserConfig = {
enabled: true,
runs: 800,
},
viaIR: true,
viaIR: false,
evmVersion: 'cancun',
},
},
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"ethers": "^6.8.0",
"fhevm-core-contracts": "0.7.0-2",
"fhevm-core-contracts": "0.7.0-3",
"fhevmjs": "^0.6.0-8",
"hardhat": "^2.22.10",
"hardhat-deploy": "^0.11.29",
Expand Down
126 changes: 0 additions & 126 deletions tasks/taskDecryptionOracleRelayer.ts

This file was deleted.

Loading

0 comments on commit 89c3288

Please sign in to comment.