Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
c044781
first pass at integration test
Nov 5, 2025
bc79dc1
update tests
Nov 5, 2025
37c56e7
remove lines
Nov 5, 2025
06a09ac
remove lines
Nov 5, 2025
e1d554e
remove lines
Nov 5, 2025
b4828ec
Merge branch 'dev' into ry/785-integration
ryardley Nov 6, 2025
298d486
fix tests
Nov 6, 2025
7690263
Merge branch 'dev' into ry/785-integration
ryardley Nov 6, 2025
52db4d9
fix linting
Nov 6, 2025
4eb3747
lines
Nov 6, 2025
63fde17
lines
Nov 6, 2025
bd51564
lines
Nov 6, 2025
acf8707
lines
Nov 6, 2025
243091b
get integration tests working
Nov 6, 2025
eea7033
split the diff on submission window
Nov 6, 2025
aa3f491
extract constants
Nov 6, 2025
ac22ab6
use more nodes
Nov 6, 2025
7e8af15
add trbfv to crisp
Nov 6, 2025
40453b7
wait for ciphernodes to be ready
Nov 6, 2025
1cffb88
use file for ready
Nov 6, 2025
85ee377
chore: add logs for e3id
hmzakhalid Nov 6, 2025
8684fdc
chore: add logs for e3id
hmzakhalid Nov 6, 2025
04177a5
chore: increase e3 duration
hmzakhalid Nov 6, 2025
f66d41f
chore: increase e3 duration
hmzakhalid Nov 6, 2025
9d460c2
chore: derease e3 duration
hmzakhalid Nov 6, 2025
dc82125
chore: testing with 0 retries
hmzakhalid Nov 6, 2025
fe354b2
Merge remote-tracking branch 'origin/dev' into ry/785-integration
Nov 6, 2025
236f9c1
fix bad merge
Nov 6, 2025
26193a8
chore: increase timeout value
hmzakhalid Nov 6, 2025
bb40f3b
fix: lint error
hmzakhalid Nov 6, 2025
e51feaa
feat: remove timeouts from crisp test for evm calls
hmzakhalid Nov 6, 2025
20964f3
debug
ryardley Nov 6, 2025
ba0c506
more debug
ryardley Nov 6, 2025
a4c1ec7
more debug
ryardley Nov 6, 2025
46c6916
Merge branch 'dev' into ry/785-integration
ryardley Nov 7, 2025
f4c41c0
chore: add trbfv params and test changes
hmzakhalid Nov 7, 2025
9589a42
Merge branch 'dev' into ry/785-integration
ryardley Nov 7, 2025
4249dfd
add logging
ryardley Nov 7, 2025
887d26c
ensure building
ryardley Nov 7, 2025
7c83ffb
dont compile nargo stuff when nargo is not installed
ryardley Nov 7, 2025
3ee4d10
add more logging
ryardley Nov 7, 2025
08d8275
update parameter set
ryardley Nov 7, 2025
2359b4c
fix ts errors
ryardley Nov 7, 2025
51d0732
revert trbfv
ryardley Nov 7, 2025
bd852b8
use trbfv on template
ryardley Nov 7, 2025
ddee19f
use 5 nodes
ryardley Nov 7, 2025
f2bc2f1
fix broken import
ryardley Nov 7, 2025
fbe5981
chore: switch to trbfv params
hmzakhalid Nov 7, 2025
586c16c
fix: revert trbfv for e2e
hmzakhalid Nov 7, 2025
bfff1d9
fix: remove trbfv from integratin
hmzakhalid Nov 7, 2025
fd73168
fix template default test
ryardley Nov 7, 2025
d5cfc9c
test failures
ryardley Nov 7, 2025
cc7920c
Add debuging for publicKey
ryardley Nov 7, 2025
0206bd8
update threshold
ryardley Nov 7, 2025
7ea1554
tidy up types
ryardley Nov 7, 2025
a19513d
Merge branch 'dev' into ry/785-integration
ryardley Nov 7, 2025
1ca334f
tidy up encoding and decoding
ryardley Nov 8, 2025
ce220a2
remove debugging
ryardley Nov 8, 2025
505dd2e
found it
ryardley Nov 8, 2025
1b787cd
try adding a wait
ryardley Nov 8, 2025
8f3c8d6
try waiting more
ryardley Nov 8, 2025
3914701
remove logging
ryardley Nov 8, 2025
9b4ffb0
Update examples/CRISP/server/src/server/routes/voting.rs
ryardley Nov 8, 2025
9ce4387
remove import
ryardley Nov 8, 2025
aebbd07
ensure input is formed correctly
ryardley Nov 8, 2025
3feceaa
remove excessive logging
ryardley Nov 8, 2025
d33885d
fix compilation error
ryardley Nov 8, 2025
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
4 changes: 4 additions & 0 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion crates/aggregator/src/threshold_plaintext_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use e3_trbfv::{
TrBFVConfig, TrBFVRequest,
};
use e3_utils::utility_types::ArcBytes;
use tracing::{error, info, trace};
use tracing::{debug, error, info, trace};

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Collecting {
Expand Down Expand Up @@ -247,6 +247,12 @@ impl Handler<DecryptionshareCreated> for ThresholdPlaintextAggregator {
type Result = ResponseActFuture<Self, Result<()>>;

fn handle(&mut self, event: DecryptionshareCreated, _: &mut Self::Context) -> Self::Result {
let Some(ThresholdPlaintextAggregatorState::Collecting(Collecting { .. })) =
self.state.get()
else {
debug!(state=?self.state, "Aggregator has been closed for collecting so ignoring this event.");
return Box::pin(fut::ready(Ok(())));
};
info!(event=?event, "Processing DecryptionShareCreated...");
let address = event.node.clone();
let party_id = event.party_id;
Expand Down
3 changes: 2 additions & 1 deletion crates/bfv-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ rand.workspace = true
anyhow.workspace = true
fhe-util = { git = "https://github.com/gnosisguild/fhe.rs" }
fhe-math = { git = "https://github.com/gnosisguild/fhe.rs" }
greco = { package = "zkfhe-greco", git = "https://github.com/gnosisguild/zkfhe-generator"}
greco = { package = "zkfhe-greco", git = "https://github.com/gnosisguild/zkfhe-generator" }
num-bigint = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
hex.workspace = true
22 changes: 14 additions & 8 deletions crates/bfv-helpers/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ pub fn bfv_encrypt<T>(
public_key: Vec<u8>,
degree: usize,
plaintext_modulus: u64,
moduli: [u64; 1],
moduli: &[u64],
) -> Result<Vec<u8>>
where
Plaintext: for<'a> FheEncoder<&'a T, Error = FheError>,
{
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli, None);
let params = build_bfv_params_arc(degree, plaintext_modulus, moduli, None);

let pk = PublicKey::from_bytes(&public_key, &params)
.map_err(|e| anyhow!("Error deserializing public key:{e}"))?;
Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn bfv_verifiable_encrypt<T>(
public_key: Vec<u8>,
degree: usize,
plaintext_modulus: u64,
moduli: [u64; 1],
moduli: Vec<u64>,
) -> Result<VerifiableEncryptionResult>
where
Plaintext: for<'a> FheEncoder<&'a T, Error = FheError>,
Expand Down Expand Up @@ -146,7 +146,7 @@ mod tests {

let num = [1u64];
let encrypted_data =
bfv_encrypt(num, pk.to_bytes(), degree, plaintext_modulus, moduli).unwrap();
bfv_encrypt(num, pk.to_bytes(), degree, plaintext_modulus, &moduli).unwrap();

let ct = Ciphertext::from_bytes(&encrypted_data, &params).unwrap();
let pt = sk.try_decrypt(&ct).unwrap();
Expand Down Expand Up @@ -175,7 +175,7 @@ mod tests {
pk.to_bytes(),
degree,
plaintext_modulus,
moduli,
&moduli,
)
.unwrap();

Expand All @@ -202,8 +202,14 @@ mod tests {
let pk = PublicKey::new(&sk, &mut rng);

let num = [1u64];
let encrypted_data =
bfv_verifiable_encrypt(num, pk.to_bytes(), degree, plaintext_modulus, moduli).unwrap();
let encrypted_data = bfv_verifiable_encrypt(
num,
pk.to_bytes(),
degree,
plaintext_modulus,
moduli.to_vec(),
)
.unwrap();

let ct = Ciphertext::from_bytes(&encrypted_data.encrypted_data, &params).unwrap();
let pt = sk.try_decrypt(&ct).unwrap();
Expand Down Expand Up @@ -232,7 +238,7 @@ mod tests {
pk.to_bytes(),
degree,
plaintext_modulus,
moduli,
moduli.to_vec(),
)
.unwrap();

Expand Down
45 changes: 44 additions & 1 deletion crates/bfv-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,22 @@ mod util;

use alloy_dyn_abi::{DynSolType, DynSolValue};
use alloy_primitives::U256;
use fhe::bfv::{BfvParameters, BfvParametersBuilder};
use fhe::bfv::{BfvParameters, BfvParametersBuilder, Encoding, Plaintext};
use fhe_traits::FheDecoder;
use std::sync::Arc;
use thiserror::Error as ThisError;

#[derive(ThisError, Debug)]
pub enum Error {
#[error("Plaintext decoding failed")]
PlaintextDecodeFailed,
// TODO: add errors from client.rs
#[error("Input was not encoded correctly")]
BadEncoding,
}

/// Result that returns a type T or a BfvHelpersError
type Result<T> = std::result::Result<T, Error>;

/// Predefined BFV parameters for common use cases
pub mod params {
Expand Down Expand Up @@ -337,6 +351,35 @@ pub fn decode_bfv_params_arc(bytes: &[u8]) -> Arc<BfvParameters> {
Arc::new(decode_bfv_params(bytes))
}

/// Decode Plaintext to a Vec<u64>
pub fn decode_plaintext_to_vec_u64(value: &Plaintext) -> Result<Vec<u64>> {
let decoded = Vec::<u64>::try_decode(&value, Encoding::poly())
.map_err(|_| Error::PlaintextDecodeFailed)?;

Ok(decoded)
}

/// Convert from a Vec<u64> to Vec<u8>
pub fn encode_vec_u64_to_bytes(value: &[u64]) -> Vec<u8> {
let mut bytes = Vec::new();
for num in &value.to_vec() {
bytes.extend_from_slice(&num.to_le_bytes());
}
bytes
}

/// Decode bytes to Vec<u64>
pub fn decode_bytes_to_vec_u64(bytes: &[u8]) -> Result<Vec<u64>> {
if bytes.len() % 8 != 0 {
return Err(Error::BadEncoding);
}

Ok(bytes
.chunks_exact(8)
.map(|chunk| u64::from_le_bytes(chunk.try_into().unwrap()))
.collect())
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
11 changes: 7 additions & 4 deletions crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ pub struct Cli {
#[arg(long = "otel", global = true)]
pub otel: Option<ValidUrl>,

// TODO: expose this as a feature once we have this hooked up to the bin integration test
#[arg(long, hide = true)]
pub experimental_trbfv: Option<String>,
/// Enable the experimental TrBFV threshold feature.
#[arg(long, global = true)]
pub experimental_trbfv: bool,
}

impl Cli {
Expand Down Expand Up @@ -158,7 +158,9 @@ impl Cli {
}

match self.command {
Commands::Start { peers } => start::execute(config, peers).await?,
Commands::Start { peers } => {
start::execute(config, peers, self.experimental_trbfv).await?
}
Commands::Init { .. } => {
bail!("Cannot run `enclave init` when a configuration exists.");
}
Expand All @@ -180,6 +182,7 @@ impl Cli {
self.verbose,
self.config,
self.otel.clone().map(Into::into),
self.experimental_trbfv,
)
.await?
}
Expand Down
22 changes: 20 additions & 2 deletions crates/cli/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,33 @@ pub async fn execute(
verbose: u8,
config_string: Option<String>,
otel: Option<String>,
experimental_trbfv: bool,
) -> Result<()> {
match command {
NodeCommands::Up { detach, exclude } => {
nodes_up::execute(config, detach, exclude, verbose, config_string, otel).await?
nodes_up::execute(
config,
detach,
exclude,
verbose,
config_string,
otel,
experimental_trbfv,
)
.await?
}
NodeCommands::Down => nodes_down::execute().await?,
NodeCommands::Ps => nodes_ps::execute().await?,
NodeCommands::Daemon { exclude } => {
nodes_daemon::execute(config, exclude, verbose, config_string, otel).await?
nodes_daemon::execute(
config,
exclude,
verbose,
config_string,
otel,
experimental_trbfv,
)
.await?
}
NodeCommands::Start { id } => nodes_start::execute(&id).await?,
NodeCommands::Status { id } => nodes_status::execute(&id).await?,
Expand Down
11 changes: 10 additions & 1 deletion crates/cli/src/nodes_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ pub async fn execute(
verbose: u8,
config_string: Option<String>,
otel: Option<String>,
experimental_trbfv: bool,
) -> Result<()> {
daemon::execute(config, exclude, verbose, config_string, otel).await
daemon::execute(
config,
exclude,
verbose,
config_string,
otel,
experimental_trbfv,
)
.await
}
12 changes: 11 additions & 1 deletion crates/cli/src/nodes_up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ pub async fn execute(
verbose: u8,
config_string: Option<String>,
otel: Option<String>,
experimental_trbfv: bool,
) -> Result<()> {
up::execute(config, detach, exclude, verbose, config_string, otel).await
up::execute(
config,
detach,
exclude,
verbose,
config_string,
otel,
experimental_trbfv,
)
.await
}
11 changes: 9 additions & 2 deletions crates/cli/src/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ use e3_entrypoint::helpers::listen_for_shutdown;
use tracing::{info, instrument};

#[instrument(skip_all)]
pub async fn execute(mut config: AppConfig, peers: Vec<String>) -> Result<()> {
pub async fn execute(
mut config: AppConfig,
peers: Vec<String>,
experimental_trbfv: bool,
) -> Result<()> {
owo();

let Some(address) = config.address() else {
Expand All @@ -31,12 +35,15 @@ pub async fn execute(mut config: AppConfig, peers: Vec<String>) -> Result<()> {
&config,
pubkey_write_path,
plaintext_write_path,
experimental_trbfv,
)
.await?
}

// Launch in ciphernode configuration
NodeRole::Ciphernode => e3_entrypoint::start::start::execute(&config, address).await?,
NodeRole::Ciphernode => {
e3_entrypoint::start::start::execute(&config, address, experimental_trbfv).await?
}
};

info!(
Expand Down
15 changes: 14 additions & 1 deletion crates/entrypoint/src/nodes/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl LaunchCommand {
verbose: u8,
maybe_config_string: &Option<String>,
maybe_otel: &Option<String>,
experimental_trbfv: bool,
) -> Result<CommandParams> {
let enclave_bin = env::current_exe()?.display().to_string();
let mut args = vec![];
Expand Down Expand Up @@ -80,6 +81,10 @@ impl LaunchCommand {
args.push(peer.to_string());
}

if experimental_trbfv {
args.push("--experimental-trbfv".to_string());
}

Ok((enclave_bin, args))
}
}
Expand All @@ -91,6 +96,7 @@ fn extract_commands(
verbose: u8,
maybe_config_string: Option<String>,
maybe_otel: Option<String>,
experimental_trbfv: bool,
) -> Result<CommandMap> {
let mut exclude_list = exclude.clone();

Expand All @@ -111,7 +117,12 @@ fn extract_commands(

let mut cmds = HashMap::new();
for item in filtered.iter() {
let params = item.to_params(verbose, &maybe_config_string, &maybe_otel)?;
let params = item.to_params(
verbose,
&maybe_config_string,
&maybe_otel,
experimental_trbfv,
)?;
cmds.insert(item.name.clone(), params);
}

Expand All @@ -125,6 +136,7 @@ pub async fn execute(
verbose: u8,
maybe_config_string: Option<String>,
maybe_otel: Option<String>,
experimental_trbfv: bool,
) -> Result<()> {
let command_map = extract_commands(
config.nodes(),
Expand All @@ -133,6 +145,7 @@ pub async fn execute(
verbose,
maybe_config_string,
maybe_otel,
experimental_trbfv,
)?;

let process_manager = Arc::new(Mutex::new(ProcessManager::from(command_map)));
Expand Down
Loading
Loading