From db6e214c4c38c63ae1fdbbb068d942080bef6cfb Mon Sep 17 00:00:00 2001 From: Hamza Khalid Date: Tue, 1 Oct 2024 15:18:01 +0500 Subject: [PATCH 1/5] Add EVM caller functionality: Implement new module for interacting with EVM-compatible blockchains, including contract deployment, transaction sending, and event listening. updates dependencies --- packages/ciphernode/core/src/events.rs | 1 - packages/ciphernode/core/src/evm_caller.rs | 150 ++++++++++++++++++ packages/ciphernode/core/src/evm_contracts.rs | 85 ++++++++++ packages/ciphernode/core/src/lib.rs | 2 + .../ciphernode/core/src/main_ciphernode.rs | 5 +- packages/ciphernode/core/src/sortition.rs | 18 +++ 6 files changed, 257 insertions(+), 4 deletions(-) create mode 100644 packages/ciphernode/core/src/evm_caller.rs create mode 100644 packages/ciphernode/core/src/evm_contracts.rs diff --git a/packages/ciphernode/core/src/events.rs b/packages/ciphernode/core/src/events.rs index 0bd50b22..6bb33b9d 100644 --- a/packages/ciphernode/core/src/events.rs +++ b/packages/ciphernode/core/src/events.rs @@ -3,7 +3,6 @@ use alloy::{hex, primitives::Uint}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use std::{ - error::Error, fmt::{self, Display}, hash::{DefaultHasher, Hash, Hasher}, }; diff --git a/packages/ciphernode/core/src/evm_caller.rs b/packages/ciphernode/core/src/evm_caller.rs new file mode 100644 index 00000000..1e04fdb2 --- /dev/null +++ b/packages/ciphernode/core/src/evm_caller.rs @@ -0,0 +1,150 @@ +use actix::prelude::*; +use alloy::primitives::{Address, Bytes, U256}; +use std::collections::HashMap; +use std::sync::Arc; + +use crate::{ + events::EnclaveEvent, + evm_contracts::EVMContract, + sortition::{GetNodes, Sortition}, + EventBus, +}; +pub struct EvmCaller { + contracts: HashMap>, + bus: Addr, + sortition: Addr, +} + +impl Actor for EvmCaller { + type Context = Context; +} + +impl EvmCaller { + pub fn new( + bus: Addr, + sortition: Addr, + ) -> Self { + Self { + contracts: HashMap::new(), + bus, + sortition, + } + } + + pub fn add_contract(&mut self, name: &str, contract: Arc) { + self.contracts.insert(name.to_string(), contract); + } + + pub fn attach( + bus: Addr, + sortition: Addr, + ) -> Addr { + let addr = Self::new(bus.clone(), sortition).start(); + + bus.do_send(crate::Subscribe::new( + "PublicKeyAggregated", + addr.clone().recipient(), + )); + + bus.do_send(crate::Subscribe::new( + "PlaintextAggregated", + addr.clone().recipient(), + )); + + addr + } +} + +#[derive(Message)] +#[rtype(result = "()")] +pub struct AddContract { + pub name: String, + pub contract: Arc, +} + +impl Handler for EvmCaller { + type Result = (); + + fn handle(&mut self, msg: AddContract, _: &mut Self::Context) -> Self::Result { + self.add_contract(&msg.name, msg.contract); + } +} + +impl Handler for EvmCaller { + type Result = ResponseActFuture; + + fn handle(&mut self, msg: EnclaveEvent, _ctx: &mut Self::Context) -> Self::Result { + let contracts = self.contracts.clone(); + let sortition = self.sortition.clone(); + + Box::pin( + async move { + match msg { + EnclaveEvent::PublicKeyAggregated { data, .. } => { + if let Some(contract) = contracts.get("registry") { + let nodes = sortition.send(GetNodes).await.unwrap_or_default(); + let nodes: Vec
= nodes + .into_iter() + .filter_map(|node| node.parse().ok()) + .collect(); + + if let Err(e) = contract + .publish_committee( + U256::from_str_radix(&data.e3_id.0, 10).unwrap(), + nodes, + Bytes::from(data.pubkey), + ) + .await + { + eprintln!("Failed to publish committee public key: {:?}", e); + } + } + } + EnclaveEvent::PlaintextAggregated { data, .. } => { + if let Some(contract) = contracts.get("enclave") { + if let Err(e) = contract + .publish_plaintext_output( + U256::from_str_radix(&data.e3_id.0, 10).unwrap(), + Bytes::from(data.decrypted_output), + Bytes::default(), // TODO: Implement proof generation + ) + .await + { + eprintln!("Failed to publish plaintext: {:?}", e); + } + } + } + _ => {} + } + } + .into_actor(self) + .map(|_, _, _| ()), + ) + } +} + + +pub async fn connect_evm_caller( + bus: Addr, + sortition: Addr, + rpc_url: &str, + enclave_contract: Address, + registry_contract: Address, +) -> Result, anyhow::Error> { + let evm_caller = EvmCaller::attach(bus.clone(), sortition.clone()); + + let enclave_instance = EVMContract::new(rpc_url, enclave_contract).await?; + let registry_instance = EVMContract::new(rpc_url, registry_contract).await?; + + evm_caller.send(AddContract { + name: "enclave".to_string(), + contract: Arc::new(enclave_instance), + }).await?; + + evm_caller.send(AddContract { + name: "registry".to_string(), + contract: Arc::new(registry_instance), + }).await?; + + Ok(evm_caller) +} \ No newline at end of file diff --git a/packages/ciphernode/core/src/evm_contracts.rs b/packages/ciphernode/core/src/evm_contracts.rs new file mode 100644 index 00000000..d38ea758 --- /dev/null +++ b/packages/ciphernode/core/src/evm_contracts.rs @@ -0,0 +1,85 @@ +use alloy::{ + network::{Ethereum, EthereumWallet}, + primitives::{Address, Bytes, U256}, + providers::{ + fillers::{ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, WalletFiller}, + Identity, ProviderBuilder, RootProvider, + }, + rpc::types::TransactionReceipt, + signers::local::PrivateKeySigner, + sol, + transports::BoxTransport, +}; +use anyhow::Result; +use std::env; +use std::sync::Arc; + +sol! { + #[derive(Debug)] + #[sol(rpc)] + contract Enclave { + function publishPlaintextOutput(uint256 e3Id, bytes memory plaintextOutput, bytes memory proof) external returns (bool success); + } + + #[derive(Debug)] + #[sol(rpc)] + contract RegistryFilter { + function publishCommittee(uint256 e3Id, address[] memory nodes, bytes memory publicKey) external onlyOwner; + } +} + +type ContractProvider = FillProvider< + JoinFill< + JoinFill, NonceFiller>, ChainIdFiller>, + WalletFiller, + >, + RootProvider, + BoxTransport, + Ethereum, +>; + +pub struct EVMContract { + pub provider: Arc, + pub contract_address: Address, +} + +impl EVMContract { + pub async fn new(rpc_url: &str, contract_address: Address) -> Result { + let signer: PrivateKeySigner = env::var("PRIVATE_KEY")?.parse()?; + let wallet = EthereumWallet::from(signer.clone()); + let provider = ProviderBuilder::new() + .with_recommended_fillers() + .wallet(wallet) + .on_builtin(rpc_url) + .await?; + + Ok(Self { + provider: Arc::new(provider), + contract_address: contract_address, + }) + } + + pub async fn publish_plaintext_output( + &self, + e3_id: U256, + plaintext_output: Bytes, + proof: Bytes, + ) -> Result { + let contract = Enclave::new(self.contract_address, &self.provider); + let builder = contract.publishPlaintextOutput(e3_id, plaintext_output, proof); + let receipt = builder.send().await?.get_receipt().await?; + Ok(receipt) + } + + pub async fn publish_committee( + &self, + e3_id: U256, + nodes: Vec
, + public_key: Bytes, + ) -> Result { + let contract = RegistryFilter::new(self.contract_address, &self.provider); + let builder = contract.publishCommittee(e3_id, nodes, public_key); + let receipt = builder.send().await?.get_receipt().await?; + Ok(receipt) + } +} \ No newline at end of file diff --git a/packages/ciphernode/core/src/lib.rs b/packages/ciphernode/core/src/lib.rs index 7b04a6b6..89feb3d8 100644 --- a/packages/ciphernode/core/src/lib.rs +++ b/packages/ciphernode/core/src/lib.rs @@ -12,6 +12,8 @@ mod evm_ciphernode_registry; mod evm_enclave; mod evm_listener; mod evm_manager; +mod evm_caller; +mod evm_contracts; mod fhe; mod keyshare; mod logger; diff --git a/packages/ciphernode/core/src/main_ciphernode.rs b/packages/ciphernode/core/src/main_ciphernode.rs index 81a09095..bf9b00ad 100644 --- a/packages/ciphernode/core/src/main_ciphernode.rs +++ b/packages/ciphernode/core/src/main_ciphernode.rs @@ -1,9 +1,7 @@ use std::sync::{Arc, Mutex}; use crate::{ - evm_ciphernode_registry::connect_evm_ciphernode_registry, evm_enclave::connect_evm_enclave, - CiphernodeSelector, CommitteeMetaFactory, Data, E3RequestManager, EventBus, FheFactory, - KeyshareFactory, P2p, SimpleLogger, Sortition, + evm_caller::{connect_evm_caller, EvmCaller}, evm_ciphernode_registry::connect_evm_ciphernode_registry, evm_contracts::EVMContract, evm_enclave::connect_evm_enclave, CiphernodeSelector, CommitteeMetaFactory, Data, E3RequestManager, EventBus, FheFactory, KeyshareFactory, P2p, SimpleLogger, Sortition }; use actix::{Actor, Addr, Context}; use alloy::primitives::Address; @@ -62,6 +60,7 @@ impl MainCiphernode { connect_evm_enclave(bus.clone(), rpc_url, enclave_contract).await; let _ = connect_evm_ciphernode_registry(bus.clone(), rpc_url, registry_contract).await; + let _ = connect_evm_caller(bus.clone(), sortition.clone(), rpc_url, enclave_contract, registry_contract).await; let e3_manager = E3RequestManager::builder(bus.clone()) .add_hook(CommitteeMetaFactory::create()) diff --git a/packages/ciphernode/core/src/sortition.rs b/packages/ciphernode/core/src/sortition.rs index d82b2913..2fbd6418 100644 --- a/packages/ciphernode/core/src/sortition.rs +++ b/packages/ciphernode/core/src/sortition.rs @@ -62,6 +62,11 @@ impl SortitionList for SortitionModule { } } +#[derive(Message)] +#[rtype(result = "Vec")] +pub struct GetNodes; + + pub struct Sortition { list: SortitionModule, } @@ -78,6 +83,10 @@ impl Sortition { bus.do_send(Subscribe::new("CiphernodeAdded", addr.clone().into())); addr } + + pub fn get_nodes(&self) -> Vec { + self.list.nodes.clone().into_iter().collect() + } } impl Default for Sortition { @@ -121,3 +130,12 @@ impl Handler for Sortition { self.list.contains(msg.seed, msg.size, msg.address) } } + +impl Handler for Sortition { + type Result = Vec; + + fn handle(&mut self, _msg: GetNodes, _ctx: &mut Self::Context) -> Self::Result { + self.get_nodes() + } +} + From 0012a63fe13a7d5b8ebb7e075fe5cc9eb3b64327 Mon Sep 17 00:00:00 2001 From: Hamza Khalid Date: Tue, 1 Oct 2024 15:22:21 +0500 Subject: [PATCH 2/5] Move connection to aggregator --- packages/ciphernode/core/src/main_aggregator.rs | 2 ++ packages/ciphernode/core/src/main_ciphernode.rs | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/ciphernode/core/src/main_aggregator.rs b/packages/ciphernode/core/src/main_aggregator.rs index bb25d0ad..4edb0f70 100644 --- a/packages/ciphernode/core/src/main_aggregator.rs +++ b/packages/ciphernode/core/src/main_aggregator.rs @@ -3,6 +3,7 @@ use crate::{ evm_enclave::connect_evm_enclave, public_key_writer::PublicKeyWriter, E3RequestManager, EventBus, FheFactory, P2p, PlaintextAggregatorFactory, PlaintextWriter, PublicKeyAggregatorFactory, SimpleLogger, Sortition, + evm_caller::connect_evm_caller, }; use actix::{Actor, Addr, Context}; use alloy::primitives::Address; @@ -52,6 +53,7 @@ impl MainAggregator { connect_evm_enclave(bus.clone(), rpc_url, enclave_contract).await; let _ = connect_evm_ciphernode_registry(bus.clone(), rpc_url, registry_contract).await; + let _ = connect_evm_caller(bus.clone(), sortition.clone(), rpc_url, enclave_contract, registry_contract).await; let e3_manager = E3RequestManager::builder(bus.clone()) .add_hook(CommitteeMetaFactory::create()) diff --git a/packages/ciphernode/core/src/main_ciphernode.rs b/packages/ciphernode/core/src/main_ciphernode.rs index bf9b00ad..8b65987a 100644 --- a/packages/ciphernode/core/src/main_ciphernode.rs +++ b/packages/ciphernode/core/src/main_ciphernode.rs @@ -1,7 +1,9 @@ use std::sync::{Arc, Mutex}; use crate::{ - evm_caller::{connect_evm_caller, EvmCaller}, evm_ciphernode_registry::connect_evm_ciphernode_registry, evm_contracts::EVMContract, evm_enclave::connect_evm_enclave, CiphernodeSelector, CommitteeMetaFactory, Data, E3RequestManager, EventBus, FheFactory, KeyshareFactory, P2p, SimpleLogger, Sortition + evm_caller::connect_evm_caller, evm_ciphernode_registry::connect_evm_ciphernode_registry, + evm_enclave::connect_evm_enclave, CiphernodeSelector, CommitteeMetaFactory, Data, + E3RequestManager, EventBus, FheFactory, KeyshareFactory, P2p, SimpleLogger, Sortition, }; use actix::{Actor, Addr, Context}; use alloy::primitives::Address; @@ -60,7 +62,14 @@ impl MainCiphernode { connect_evm_enclave(bus.clone(), rpc_url, enclave_contract).await; let _ = connect_evm_ciphernode_registry(bus.clone(), rpc_url, registry_contract).await; - let _ = connect_evm_caller(bus.clone(), sortition.clone(), rpc_url, enclave_contract, registry_contract).await; + let _ = connect_evm_caller( + bus.clone(), + sortition.clone(), + rpc_url, + enclave_contract, + registry_contract, + ) + .await; let e3_manager = E3RequestManager::builder(bus.clone()) .add_hook(CommitteeMetaFactory::create()) From d5e99e62c9e79e45aa640d1072ac2edd40a30c2a Mon Sep 17 00:00:00 2001 From: Hamza Khalid Date: Tue, 1 Oct 2024 16:41:39 +0500 Subject: [PATCH 3/5] Update tests --- packages/ciphernode/core/src/evm_caller.rs | 15 +++++++++------ packages/ciphernode/core/src/main_aggregator.rs | 3 ++- packages/ciphernode/core/src/main_ciphernode.rs | 10 +--------- .../enclave_node/src/bin/aggregator.rs | 16 ++++++++++++---- packages/ciphernode/enclave_node/src/bin/node.rs | 8 ++++---- tests/basic_integration/test.sh | 13 ++++--------- 6 files changed, 32 insertions(+), 33 deletions(-) diff --git a/packages/ciphernode/core/src/evm_caller.rs b/packages/ciphernode/core/src/evm_caller.rs index 1e04fdb2..1a3d7149 100644 --- a/packages/ciphernode/core/src/evm_caller.rs +++ b/packages/ciphernode/core/src/evm_caller.rs @@ -88,29 +88,32 @@ impl Handler for EvmCaller { .filter_map(|node| node.parse().ok()) .collect(); - if let Err(e) = contract + match contract .publish_committee( U256::from_str_radix(&data.e3_id.0, 10).unwrap(), nodes, Bytes::from(data.pubkey), ) - .await + .await { - eprintln!("Failed to publish committee public key: {:?}", e); + Ok(tx) => println!("Published committee public key {:?}", tx.transaction_hash), + Err(e) => eprintln!("Failed to publish committee public key: {:?}", e), } } } EnclaveEvent::PlaintextAggregated { data, .. } => { if let Some(contract) = contracts.get("enclave") { - if let Err(e) = contract + println!("Publishing plaintext output {:?}", data.e3_id); + match contract .publish_plaintext_output( U256::from_str_radix(&data.e3_id.0, 10).unwrap(), Bytes::from(data.decrypted_output), - Bytes::default(), // TODO: Implement proof generation + Bytes::from(vec![1]), // TODO: Implement proof generation ) .await { - eprintln!("Failed to publish plaintext: {:?}", e); + Ok(tx) => println!("Published plaintext output {:?}", tx.transaction_hash), + Err(e) => eprintln!("Failed to publish plaintext: {:?}", e), } } } diff --git a/packages/ciphernode/core/src/main_aggregator.rs b/packages/ciphernode/core/src/main_aggregator.rs index 4edb0f70..743414f5 100644 --- a/packages/ciphernode/core/src/main_aggregator.rs +++ b/packages/ciphernode/core/src/main_aggregator.rs @@ -41,6 +41,7 @@ impl MainAggregator { rpc_url: &str, enclave_contract: Address, registry_contract: Address, + registry_filter_contract: Address, pubkey_write_path: Option<&str>, plaintext_write_path: Option<&str>, ) -> (Addr, JoinHandle<()>) { @@ -53,7 +54,7 @@ impl MainAggregator { connect_evm_enclave(bus.clone(), rpc_url, enclave_contract).await; let _ = connect_evm_ciphernode_registry(bus.clone(), rpc_url, registry_contract).await; - let _ = connect_evm_caller(bus.clone(), sortition.clone(), rpc_url, enclave_contract, registry_contract).await; + let _ = connect_evm_caller(bus.clone(), sortition.clone(), rpc_url, enclave_contract, registry_filter_contract).await; let e3_manager = E3RequestManager::builder(bus.clone()) .add_hook(CommitteeMetaFactory::create()) diff --git a/packages/ciphernode/core/src/main_ciphernode.rs b/packages/ciphernode/core/src/main_ciphernode.rs index 8b65987a..ceb399c6 100644 --- a/packages/ciphernode/core/src/main_ciphernode.rs +++ b/packages/ciphernode/core/src/main_ciphernode.rs @@ -1,7 +1,7 @@ use std::sync::{Arc, Mutex}; use crate::{ - evm_caller::connect_evm_caller, evm_ciphernode_registry::connect_evm_ciphernode_registry, + evm_ciphernode_registry::connect_evm_ciphernode_registry, evm_enclave::connect_evm_enclave, CiphernodeSelector, CommitteeMetaFactory, Data, E3RequestManager, EventBus, FheFactory, KeyshareFactory, P2p, SimpleLogger, Sortition, }; @@ -62,14 +62,6 @@ impl MainCiphernode { connect_evm_enclave(bus.clone(), rpc_url, enclave_contract).await; let _ = connect_evm_ciphernode_registry(bus.clone(), rpc_url, registry_contract).await; - let _ = connect_evm_caller( - bus.clone(), - sortition.clone(), - rpc_url, - enclave_contract, - registry_contract, - ) - .await; let e3_manager = E3RequestManager::builder(bus.clone()) .add_hook(CommitteeMetaFactory::create()) diff --git a/packages/ciphernode/enclave_node/src/bin/aggregator.rs b/packages/ciphernode/enclave_node/src/bin/aggregator.rs index e46327e6..54b70c61 100644 --- a/packages/ciphernode/enclave_node/src/bin/aggregator.rs +++ b/packages/ciphernode/enclave_node/src/bin/aggregator.rs @@ -5,13 +5,15 @@ use enclave_core::MainAggregator; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { - #[arg(short = 'n', long)] + #[arg(short = 'r', long)] rpc: String, - #[arg(short, long = "enclave-contract")] + #[arg(short = 'e', long = "enclave-contract")] enclave_contract: String, - #[arg(short, long = "registry-contract")] + #[arg(short = 'c', long = "registry-contract")] registry_contract: String, - #[arg(short, long = "pubkey-write-path")] + #[arg(short = 'f', long = "registry-filter-contract")] + registry_filter_contract: String, + #[arg(short = 'p', long = "pubkey-write-path")] pubkey_write_path: Option, #[arg(short = 't', long = "plaintext-write-path")] plaintext_write_path: Option, @@ -23,12 +25,18 @@ async fn main() -> Result<(), Box> { println!("LAUNCHING AGGREGATOR"); let registry_contract = Address::parse_checksummed(&args.registry_contract, None).expect("Invalid address"); + let registry_filter_contract = Address::parse_checksummed( + &args.registry_filter_contract, + None, + ) + .expect("Invalid address"); let enclave_contract = Address::parse_checksummed(&args.enclave_contract, None).expect("Invalid address"); let (_, handle) = MainAggregator::attach( &args.rpc, enclave_contract, registry_contract, + registry_filter_contract, args.pubkey_write_path.as_deref(), args.plaintext_write_path.as_deref() ) diff --git a/packages/ciphernode/enclave_node/src/bin/node.rs b/packages/ciphernode/enclave_node/src/bin/node.rs index ceddcf85..a3432110 100644 --- a/packages/ciphernode/enclave_node/src/bin/node.rs +++ b/packages/ciphernode/enclave_node/src/bin/node.rs @@ -5,13 +5,13 @@ use enclave_core::MainCiphernode; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { - #[arg(short, long)] + #[arg(short = 'a', long)] address: String, - #[arg(short='n', long)] + #[arg(short='r', long)] rpc: String, - #[arg(short, long="enclave-contract")] + #[arg(short = 'e', long = "enclave-contract")] enclave_contract: String, - #[arg(short, long="registry-contract")] + #[arg(short = 'c', long = "registry-contract")] registry_contract: String } diff --git a/tests/basic_integration/test.sh b/tests/basic_integration/test.sh index 97b6f5b7..9b4c96c7 100755 --- a/tests/basic_integration/test.sh +++ b/tests/basic_integration/test.sh @@ -18,6 +18,7 @@ export RPC_URL="ws://localhost:8545" # We _may_ wish to get these off the hardhat environment somehow? export ENCLAVE_CONTRACT="0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" export REGISTRY_CONTRACT="0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9" +export REGISTRY_FILTER_CONTRACT="0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" export INPUT_VALIDATOR_CONTRACT="0x8A791620dd6260079BF849Dc5567aDC3F2FdC318" # These are random addresses for now export CIPHERNODE_ADDRESS_1="0x2546BcD3c84621e976D8185a91A922aE77ECEc30" @@ -105,7 +106,7 @@ heading "Launch ciphernode $CIPHERNODE_ADDRESS_4" yarn ciphernode:launch --address $CIPHERNODE_ADDRESS_4 --rpc "$RPC_URL" --enclave-contract $ENCLAVE_CONTRACT --registry-contract $REGISTRY_CONTRACT & # NOTE: This node is configured to be an aggregator -yarn ciphernode:aggregator --rpc "$RPC_URL" --enclave-contract $ENCLAVE_CONTRACT --registry-contract $REGISTRY_CONTRACT --pubkey-write-path "$SCRIPT_DIR/output/pubkey.bin" --plaintext-write-path "$SCRIPT_DIR/output/plaintext.txt" & +yarn ciphernode:aggregator --rpc "$RPC_URL" --enclave-contract $ENCLAVE_CONTRACT --registry-contract $REGISTRY_CONTRACT --registry-filter-contract $REGISTRY_FILTER_CONTRACT --pubkey-write-path "$SCRIPT_DIR/output/pubkey.bin" --plaintext-write-path "$SCRIPT_DIR/output/plaintext.txt" & sleep 1 @@ -130,18 +131,13 @@ ENCODED_PARAMS=0x$($SCRIPT_DIR/lib/pack_e3_params.sh --moduli 0x3FFFFFFF000001 - yarn committee:new --network localhost --duration 4 --e3-params "$ENCODED_PARAMS" waiton "$SCRIPT_DIR/output/pubkey.bin" +PUBLIC_KEY=$(xxd -p -c 10000000 "$SCRIPT_DIR/output/pubkey.bin") heading "Mock encrypted plaintext" - $SCRIPT_DIR/lib/fake_encrypt.sh --input "$SCRIPT_DIR/output/pubkey.bin" --output "$SCRIPT_DIR/output/output.bin" --plaintext $PLAINTEXT -heading "Mock publish committee key" - -yarn committee:publish --e3-id 0 --nodes $CIPHERNODE_ADDRESS_1,$CIPHERNODE_ADDRESS_2,$CIPHERNODE_ADDRESS_3,$CIPHERNODE_ADDRESS_4 --public-key 0x12345678 --network localhost - heading "Mock activate e3-id" - -yarn e3:activate --e3-id 0 --public-key 0x12345678 --network localhost +yarn e3:activate --e3-id 0 --public-key "0x$PUBLIC_KEY" --network localhost heading "Mock publish input e3-id" yarn e3:publishInput --network localhost --e3-id 0 --data 0x12345678 @@ -151,7 +147,6 @@ sleep 4 # wait for input deadline to pass waiton "$SCRIPT_DIR/output/output.bin" heading "Publish ciphertext to EVM" - yarn e3:publishCiphertext --e3-id 0 --network localhost --data-file "$SCRIPT_DIR/output/output.bin" --proof 0x12345678 waiton "$SCRIPT_DIR/output/plaintext.txt" From 43453c198d0ad2acc9cef0bc00a2832ee30ed1cb Mon Sep 17 00:00:00 2001 From: Hamza Khalid Date: Tue, 1 Oct 2024 17:12:12 +0500 Subject: [PATCH 4/5] Wait for pubkey to be published --- tests/basic_integration/test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/basic_integration/test.sh b/tests/basic_integration/test.sh index 9b4c96c7..14325d15 100755 --- a/tests/basic_integration/test.sh +++ b/tests/basic_integration/test.sh @@ -130,6 +130,8 @@ ENCODED_PARAMS=0x$($SCRIPT_DIR/lib/pack_e3_params.sh --moduli 0x3FFFFFFF000001 - yarn committee:new --network localhost --duration 4 --e3-params "$ENCODED_PARAMS" +sleep 4 # wait for public key to be published by aggregator + waiton "$SCRIPT_DIR/output/pubkey.bin" PUBLIC_KEY=$(xxd -p -c 10000000 "$SCRIPT_DIR/output/pubkey.bin") From b336b2129b14aeb7765d7340f592729d1999427e Mon Sep 17 00:00:00 2001 From: Hamza Khalid Date: Tue, 1 Oct 2024 17:29:11 +0500 Subject: [PATCH 5/5] Update CI Workflow --- .github/workflows/integration.yml | 1 + tests/basic_integration/test.sh | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 1a667c1f..0861cc5c 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -3,6 +3,7 @@ name: "INTEGRATION" env: HARDHAT_VAR_MNEMONIC: "test test test test test test test test test test test junk" HARDHAT_VAR_INFURA_API_KEY: "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # Uncomment the following lines to set your configuration variables using # GitHub secrets (https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) # diff --git a/tests/basic_integration/test.sh b/tests/basic_integration/test.sh index 14325d15..9b4c96c7 100755 --- a/tests/basic_integration/test.sh +++ b/tests/basic_integration/test.sh @@ -130,8 +130,6 @@ ENCODED_PARAMS=0x$($SCRIPT_DIR/lib/pack_e3_params.sh --moduli 0x3FFFFFFF000001 - yarn committee:new --network localhost --duration 4 --e3-params "$ENCODED_PARAMS" -sleep 4 # wait for public key to be published by aggregator - waiton "$SCRIPT_DIR/output/pubkey.bin" PUBLIC_KEY=$(xxd -p -c 10000000 "$SCRIPT_DIR/output/pubkey.bin")