Skip to content
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
4 changes: 2 additions & 2 deletions circuits/lib/src/configs/default/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.
//
// Unico punto in cui si cambia il param-set: re-esporta insecure o production
// (in futuro altri param-set). I circuiti usano tutti lib::configs::default::*.
// Only place where we change param-set: re-export insecure or production.
// (in future any other param-set). All circuits use lib::configs::default::*.

pub use super::committee::micro::{H, N_PARTIES, T};
pub use super::insecure::dkg;
Expand Down
7 changes: 6 additions & 1 deletion crates/aggregator/src/proof_fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use e3_events::{
prelude::*, BusHandle, ComputeRequest, CorrelationId, E3id, EventContext, Proof, Sequenced,
ZkRequest,
};
use e3_fhe_params::BfvPreset;
use tracing::{error, info};

/// Manages the state of a sequential `FoldProofs` operation.
Expand All @@ -29,17 +30,20 @@ pub struct ProofFoldState {
pub result: Option<Proof>,
/// `start` was called with zero proofs — folding is complete with no aggregate.
pub fold_input_was_empty: bool,
/// BFV preset for circuit artifact resolution.
params_preset: BfvPreset,
}

impl ProofFoldState {
pub fn new() -> Self {
pub fn new(params_preset: BfvPreset) -> Self {
ProofFoldState {
correlation: None,
accumulated: None,
remaining: Vec::new(),
total_steps: None,
result: None,
fold_input_was_empty: false,
params_preset,
}
}

Expand Down Expand Up @@ -196,6 +200,7 @@ impl ProofFoldState {
proof1: acc,
proof2: next,
target_evm,
params_preset: self.params_preset,
},
corr,
e3_id.clone(),
Expand Down
5 changes: 3 additions & 2 deletions crates/aggregator/src/publickey_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl PublicKeyAggregator {
share_proofs: party_proofs,
decryption_proofs: vec![],
pre_dishonest: no_proof_parties.into_iter().collect(),
params_preset: self.params_preset,
},
ec,
)?;
Expand Down Expand Up @@ -416,7 +417,7 @@ impl PublicKeyAggregator {
dkg_node_proofs: HashMap::new(),
honest_party_ids: honest_party_ids.clone(),
dishonest_parties: dishonest_parties.clone(),
cross_node_fold: ProofFoldState::new(),
cross_node_fold: ProofFoldState::new(self.params_preset),
c5_proof_pending: None,
last_ec: Some(ec.clone()),
})
Expand Down Expand Up @@ -611,7 +612,7 @@ impl PublicKeyAggregator {
};
if cross_node_fold.needs_restart() {
warn!("cross-node fold stuck mid-step on restart — resetting and re-folding from persisted proofs");
cross_node_fold = ProofFoldState::new();
cross_node_fold = ProofFoldState::new(self.params_preset);
}
cross_node_fold.start(
proofs,
Expand Down
3 changes: 2 additions & 1 deletion crates/aggregator/src/threshold_plaintext_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl ThresholdPlaintextAggregator {
e3_id: params.e3_id,
params_preset: params.params_preset,
state,
c6_fold: ProofFoldState::new(),
c6_fold: ProofFoldState::new(params.params_preset),
c7_proofs_pending: None,
last_ec: None,
}
Expand Down Expand Up @@ -352,6 +352,7 @@ impl ThresholdPlaintextAggregator {
share_proofs: party_proofs,
decryption_proofs: vec![],
pre_dishonest: BTreeSet::new(),
params_preset: self.params_preset,
},
ec,
)?;
Expand Down
5 changes: 5 additions & 0 deletions crates/events/src/enclave_event/compute_request/zk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub enum ZkRequest {
proof1: Proof,
proof2: Proof,
target_evm: bool,
params_preset: BfvPreset,
},
}

Expand Down Expand Up @@ -346,6 +347,8 @@ impl PkGenerationProofResponse {
pub struct VerifyShareProofsRequest {
/// Proofs grouped by sender party_id.
pub party_proofs: Vec<PartyProofsToVerify>,
/// BFV preset for parameter resolution (determines circuit artifact directory).
pub params_preset: BfvPreset,
}

/// All signed proofs from a single sender to verify.
Expand Down Expand Up @@ -386,6 +389,8 @@ pub struct PartyVerificationResult {
pub struct VerifyShareDecryptionProofsRequest {
/// C4 proofs grouped by sender party_id.
pub party_proofs: Vec<PartyShareDecryptionProofsToVerify>,
/// BFV preset for parameter resolution (determines circuit artifact directory).
pub params_preset: BfvPreset,
}

/// C4 proofs from a single sender to verify.
Expand Down
2 changes: 2 additions & 0 deletions crates/events/src/enclave_event/share_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub struct ShareVerificationDispatched {
/// Parties already identified as dishonest before verification
/// (e.g., missing/incomplete proofs). Merged into the final result.
pub pre_dishonest: BTreeSet<u64>,
/// BFV preset for circuit artifact resolution.
pub params_preset: e3_fhe_params::BfvPreset,
}

/// ShareVerificationActor → ThresholdKeyshare: verification results.
Expand Down
26 changes: 26 additions & 0 deletions crates/fhe-params/src/presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,18 @@ impl BfvPreset {
}
}

/// Returns the security tier for this preset.
pub fn security_tier(&self) -> SecurityTier {
self.metadata().security
}

/// Returns the directory name for circuit artifacts (e.g. `"insecure-512"`, `"secure-8192"`).
/// Threshold and DKG presets at the same degree share the same compiled circuits.
pub fn artifacts_dir(&self) -> String {
let meta = self.metadata();
format!("{}-{}", meta.security.as_config_str(), meta.degree)
}
Comment thread
ctrlc03 marked this conversation as resolved.

pub fn search_defaults(&self) -> Option<PresetSearchDefaults> {
match self {
BfvPreset::InsecureThreshold512 => Some(PresetSearchDefaults {
Expand Down Expand Up @@ -537,4 +549,18 @@ mod tests {
assert!(BfvPreset::InsecureDkg512.search_defaults().is_none());
assert!(BfvPreset::SecureDkg8192.search_defaults().is_none());
}

#[test]
fn test_artifacts_dir() {
assert_eq!(
BfvPreset::InsecureThreshold512.artifacts_dir(),
"insecure-512"
);
assert_eq!(BfvPreset::InsecureDkg512.artifacts_dir(), "insecure-512");
assert_eq!(
BfvPreset::SecureThreshold8192.artifacts_dir(),
"secure-8192"
);
assert_eq!(BfvPreset::SecureDkg8192.artifacts_dir(), "secure-8192");
}
}
2 changes: 2 additions & 0 deletions crates/keyshare/src/threshold_keyshare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,7 @@ impl ThresholdKeyshare {
share_proofs: party_proofs_to_verify,
decryption_proofs: Vec::new(),
pre_dishonest,
params_preset: self.share_enc_preset,
},
ec,
)?;
Expand Down Expand Up @@ -2048,6 +2049,7 @@ impl ThresholdKeyshare {
share_proofs: Vec::new(),
decryption_proofs: party_proofs,
pre_dishonest,
params_preset: self.share_enc_preset,
},
ec,
)?;
Expand Down
Loading
Loading