Skip to content

Commit

Permalink
Merge branch 'main' of github.com:zama-ai/fhevm into fhevm06docs
Browse files Browse the repository at this point in the history
  • Loading branch information
poppyseedDev committed Nov 29, 2024
2 parents 411816c + bc50734 commit 8be84e4
Show file tree
Hide file tree
Showing 61 changed files with 1,071 additions and 2,377 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
const RuleConfigSeverity = require("@commitlint/types").RuleConfigSeverity;
import { RuleConfigSeverity } from '@commitlint/types';

const Configuration = {
/*
* Resolve and load @commitlint/config-conventional from node_modules.
* Referenced packages must be installed
*/
extends: ["@commitlint/config-conventional"],
extends: ['@commitlint/config-conventional'],
/*
* Resolve and load conventional-changelog-atom from node_modules.
* Referenced packages must be installed
*/
parserPreset: "conventional-changelog-conventionalcommits",
parserPreset: 'conventional-changelog-conventionalcommits',
/*
* Resolve and load @commitlint/format from node_modules.
* Referenced package must be installed
*/
formatter: "@commitlint/format",
formatter: '@commitlint/format',
/*
* Any rules defined here will override rules from @commitlint/config-conventional
*/
rules: {
"type-empty": [RuleConfigSeverity.Error, "never"],
'type-empty': [RuleConfigSeverity.Error, 'never'],
},
};

module.exports = Configuration;
export default Configuration;
2 changes: 1 addition & 1 deletion .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
run: |
npm install -g @commitlint/cli@^18
- name: Validate all commits from PR
run: npx commitlint --config .github/config/commitlint.config.js --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
run: npx commitlint --config .github/config/commitlint.config.ts --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.{js,json,md,sol,ts,yml}": ["npm run prettier -- --write"]
}
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*
!lib/**
!gateway/**
!config/**
!package.json
!README.md
!LICENSE
18 changes: 8 additions & 10 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module.exports = {
istanbulReporter: ["html", "lcov"],
providerOptions: {
mnemonic: process.env.MNEMONIC,
},
skipFiles: ["test"],
mocha: {
fgrep: "[skip-on-coverage]",
invert: true,
},
export const istanbulReporter = ["html", "lcov"];
export const providerOptions = {
mnemonic: process.env.MNEMONIC,
};
export const skipFiles = ["test"];
export const mocha = {
fgrep: "[skip-on-coverage]",
invert: true,
};
25 changes: 0 additions & 25 deletions ci/scripts/run_ERC20.sh

This file was deleted.

28 changes: 0 additions & 28 deletions ci/scripts/run_ERC20_ci_test.sh

This file was deleted.

28 changes: 0 additions & 28 deletions ci/scripts/run_ERC20_e2e_test.sh

This file was deleted.

32 changes: 26 additions & 6 deletions codegen/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ type ebytes128 is uint256;
type ebytes256 is uint256;
type einput is bytes32;
/**
* @title Common
* @notice This library contains all the values used to communicate types to the run time.
*/
library Common {
// Values used to communicate types to the runtime.
uint8 internal constant ebool_t = 0;
uint8 internal constant euint4_t = 1;
uint8 internal constant euint8_t = 2;
Expand Down Expand Up @@ -69,7 +72,6 @@ export function implSol(operators: Operator[]): string {

res.push(`
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;
import "./TFHE.sol";
Expand All @@ -79,8 +81,12 @@ ${coprocessorInterface}
${aclInterface}
/**
* @title Impl
* @notice This library is the core implementation for computing FHE operations (e.g. add, sub, xor).
*/
library Impl {
// keccak256(abi.encode(uint256(keccak256("fhevm.storage.FHEVMConfig")) - 1)) & ~bytes32(uint256(0xff))
/// @dev keccak256(abi.encode(uint256(keccak256("fhevm.storage.FHEVMConfig")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant FHEVMConfigLocation = 0xed8d60e34876f751cc8b014c560745351147d9de11b9347c854e881b128ea600;
function getFHEVMConfig() internal pure returns (FHEVMConfig.FHEVMConfigStruct storage $) {
Expand Down Expand Up @@ -159,7 +165,13 @@ function generateImplFhevmLibInterface(operators: Operator[]): string {
function generateImplCoprocessorInterface(operators: Operator[]): string {
const res: string[] = [];

res.push('interface ITFHEExecutor {');
res.push(`
/**
* @title ITFHEExecutor
* @notice This interface contains all functions to conduct FHE operations.
*/
interface ITFHEExecutor {`);

operators.forEach((op) => {
let functionName = operatorFheLibFunction(op);
const tail = 'external returns (uint256 result);';
Expand Down Expand Up @@ -205,6 +217,11 @@ function coprocessorInterfaceCustomFunctions(): string {

function generateACLInterface(): string {
return `
/**
* @title IACL
* @notice This interface contains all functions that are used to conduct operations
* with the ACL contract.
*/
interface IACL {
function allowTransient(uint256 ciphertext, address account) external;
function allow(uint256 handle, address account) external;
Expand All @@ -224,7 +241,6 @@ export function tfheSol(
const res: string[] = [];

res.push(`// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;
import "./Impl.sol";
Expand All @@ -234,7 +250,11 @@ import "./FHEVMConfig.sol";
${commonSolLib()}
/**
* @title TFHE
* @notice This library is the interaction point for all smart contract developers
* that interact with TFHE.
*/
library TFHE {
function setFHEVM(FHEVMConfig.FHEVMConfigStruct memory fhevmConfig) internal {
Impl.setFHEVM(fhevmConfig);
Expand Down
14 changes: 14 additions & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { UserConfig } from '@commitlint/types';

const Configuration: UserConfig = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
['ci', 'chore', 'docs', 'ticket', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test'],
],
},
};

export default Configuration;
16 changes: 8 additions & 8 deletions config/ZamaFHEVMConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ library ZamaFHEVMConfig {
function getMockConfig() internal pure returns (FHEVMConfig.FHEVMConfigStruct memory) {
return
FHEVMConfig.FHEVMConfigStruct({
ACLAddress: 0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2,
TFHEExecutorAddress: 0x596E6682c72946AF006B27C131793F2b62527A4b,
FHEPaymentAddress: 0x6d5A11aC509C707c00bc3A0a113ACcC26c532547,
KMSVerifierAddress: 0x208De73316E44722e16f6dDFF40881A3e4F86104
ACLAddress: 0xB4d8d77f7F9B465B60c190480c6160b69d695c9D,
TFHEExecutorAddress: 0xFdee168C46e1dFD082E78192b3C622cA78B58669,
FHEPaymentAddress: 0x2527DD76195fD3BFdd2c76D821e1f5d433d82C25,
KMSVerifierAddress: 0x89842EA0b44EF85391Bd1A9f3AC8B382CCF0d3F1
});
}

function getSepoliaConfig() internal pure returns (FHEVMConfig.FHEVMConfigStruct memory) {
return
FHEVMConfig.FHEVMConfigStruct({
ACLAddress: 0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2,
TFHEExecutorAddress: 0x596E6682c72946AF006B27C131793F2b62527A4b,
FHEPaymentAddress: 0x6d5A11aC509C707c00bc3A0a113ACcC26c532547,
KMSVerifierAddress: 0x208De73316E44722e16f6dDFF40881A3e4F86104
ACLAddress: 0x9479B455904dCccCf8Bc4f7dF8e9A1105cBa2A8e,
TFHEExecutorAddress: 0x199fB61DFdfE46f9F90C9773769c28D9623Bb90e,
FHEPaymentAddress: 0x25FE5d92Ae6f89AF37D177cF818bF27EDFe37F7c,
KMSVerifierAddress: 0x904Af2B61068f686838bD6257E385C2cE7a09195
});
}

Expand Down
4 changes: 2 additions & 2 deletions config/ZamaGatewayConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import {Gateway} from "../gateway/lib/Gateway.sol";
*/
library ZamaGatewayConfig {
function getMockConfig() internal pure returns (address) {
return 0x096b4679d45fB675d4e2c1E4565009Cec99A12B1;
return 0x2C19507EEAd017495e23a98DB1ff20c7eD599ee1;
}

function getSepoliaConfig() internal pure returns (address) {
return 0x096b4679d45fB675d4e2c1E4565009Cec99A12B1;
return 0x7455c89669cdE1f7Cb6D026DFB87263422D821ca;
}

function getEthereumConfig() internal pure returns (address) {
Expand Down
18 changes: 0 additions & 18 deletions deploy/deploy.ts

This file was deleted.

32 changes: 0 additions & 32 deletions examples/ACLUpgradedExample.sol

This file was deleted.

32 changes: 0 additions & 32 deletions examples/ACLUpgradedExample2.sol

This file was deleted.

Loading

0 comments on commit 8be84e4

Please sign in to comment.