Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add default configs for Gateway and FHEVM #608

Merged
Merged
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
70 changes: 70 additions & 0 deletions config/ZamaFHEVMConfig.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import {FHEVMConfig, TFHE} from "../lib/TFHE.sol";

/**
* @title ZamaFHEVMConfig.
* @notice This library returns the TFHE config for different networks
* with the contract addresses for
* (1) ACL, (2) TFHEExecutor, (3) FHEPayment, (4) KMSVerifier,
* which are deployed & maintained by Zama.
*/
library ZamaFHEVMConfig {
function getMockConfig() internal pure returns (FHEVMConfig.FHEVMConfigStruct memory) {
return
FHEVMConfig.FHEVMConfigStruct({
ACLAddress: 0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2,
TFHEExecutorAddress: 0x596E6682c72946AF006B27C131793F2b62527A4b,
FHEPaymentAddress: 0x6d5A11aC509C707c00bc3A0a113ACcC26c532547,
KMSVerifierAddress: 0x208De73316E44722e16f6dDFF40881A3e4F86104
});
}

function getSepoliaConfig() internal pure returns (FHEVMConfig.FHEVMConfigStruct memory) {
/// TODO
}

function getEthereumConfig() internal pure returns (FHEVMConfig.FHEVMConfigStruct memory) {
/// TODO
}
}

/**
* @title MockZamaFHEVMConfig.
* @dev This contract can be inherited by a contract wishing to use these contracts on the mock
* environment provided by Zama.
* Other providers may offer similar contracts deployed at different addresses.
* If you wish to use them, you should rely on the instructions from these providers.
*/
contract MockZamaFHEVMConfig {
constructor() {
TFHE.setFHEVM(ZamaFHEVMConfig.getMockConfig());
}
}

/**
* @title SepoliaZamaFHEVMConfig.
* @dev This contract can be inherited by a contract wishing to use the FHEVM contracts provided by Zama
* on the Sepolia network (chainId = 11155111).
* Other providers may offer similar contracts deployed at different addresses.
* If you wish to use them, you should rely on the instructions from these providers.
*/
contract SepoliaZamaFHEVMConfig {
constructor() {
TFHE.setFHEVM(ZamaFHEVMConfig.getSepoliaConfig());
}
}

/**
* @title EthereumZamaFHEVMConfig.
* @dev This contract can be inherited by a contract wishing to use the FHEVM contracts provided by Zama
* on the Ethereum (mainnet) network (chainId = 1).
* Other providers may offer similar contracts deployed at different addresses.
* If you wish to use them, you should rely on the instructions from these providers.
*/
contract EthereumZamaFHEVMConfig {
constructor() {
TFHE.setFHEVM(ZamaFHEVMConfig.getEthereumConfig());
}
}
63 changes: 63 additions & 0 deletions config/ZamaGatewayConfig.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import {Gateway} from "../gateway/lib/Gateway.sol";

/**
* @title ZamaGatewayConfig.
* @notice This library returns the Gateway config for different networks
* with the address of the Gateway contract, which is
* deployed & maintained by Zama.
*/
library ZamaGatewayConfig {
function getMockConfig() internal pure returns (address) {
return 0x096b4679d45fB675d4e2c1E4565009Cec99A12B1;
}

function getSepoliaConfig() internal pure returns (address) {
/// TODO
}

function getEthereumConfig() internal pure returns (address) {
/// TODO
}
}

/**
* @title MockZamaGatewayConfig
* @dev This contract can be inherited by a contract wishing to use the Gateway service
* on the mock environment provided by Zama.
* Other providers may offer other Gateways that are deployed at different addresses.
* If you wish to use them, you should rely on the instructions from these providers.
*/
contract MockZamaGatewayConfig {
constructor() {
Gateway.setGateway(ZamaGatewayConfig.getMockConfig());
}
}

/**
* @title SepoliaZamaGatewayConfig
* @dev This contract can be inherited by a contract wishing to use the Gateway service
* provided by Zama on the Sepolia network (chainId = 11155111).
* Other providers may offer other Gateways that are deployed at different addresses.
* If you wish to use them, you should rely on the instructions from these providers.
*/
contract SepoliaZamaGatewayConfig {
constructor() {
Gateway.setGateway(ZamaGatewayConfig.getSepoliaConfig());
}
}

/**
* @title EthereumZamaGatewayConfig
* @dev This contract can be inherited by a contract wishing to use the Gateway service
* provided by Zama on the Ethereum (mainnet) network (chainId = 1).
* Other providers may offer other Gateways that are deployed at different addresses.
* If you wish to use them, you should rely on the instructions from these providers.
*/
contract EthereumZamaGatewayConfig {
constructor() {
Gateway.setGateway(ZamaGatewayConfig.getEthereumConfig());
}
}