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
42 changes: 27 additions & 15 deletions crates/events/src/enclave_event/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,28 @@ impl Proof {
/// Circuit identifiers for ZK proofs.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CircuitName {
/// BFV public key proof (T0).
/// BFV public key proof (C0).
PkBfv,
/// TrBFV public key share proof (T1a).
/// TrBFV public key share proof (C1).
PkGeneration,
/// Sk Share computation proof (T1b).
/// Sk Share computation proof (C2a).
SkShareComputation,
/// E_SM share computation proof (T1c).
/// E_SM share computation proof (C2b).
ESmShareComputation,
/// Encrypted sk share proof (T1d).
/// Encrypted sk share proof (C3a).
SkShareEncryption,
/// Encrypted E_SM share proof (T1e).
/// Encrypted E_SM share proof (C3b).
ESmShareEncryption,
/// Decryption share proof (T4/T5).
DecShares,
/// Public key aggregation proof (T6).
PkAgg,
/// Sk share decryption proof (C4a).
DkgSkShareDecryption,
/// E_SM share decryption proof (C4b).
DkgESmShareDecryption,
/// Public key aggregation proof (C5).
PkAggregation,
/// Decryption share proof (C6).
ThresholdShareDecryption,
/// Decrypted shares aggregation proof (C7).
DecryptedSharesAggregation,
}

impl CircuitName {
Expand All @@ -63,21 +69,27 @@ impl CircuitName {
CircuitName::ESmShareComputation => "e_sm_share_computation",
CircuitName::SkShareEncryption => "sk_share_encryption",
CircuitName::ESmShareEncryption => "e_sm_share_encryption",
CircuitName::DecShares => "dec_shares",
CircuitName::PkAgg => "pk_agg",
CircuitName::DkgSkShareDecryption => "dkg_sk_share_decryption",
CircuitName::DkgESmShareDecryption => "dkg_e_sm_share_decryption",
CircuitName::PkAggregation => "pk_aggregation",
CircuitName::ThresholdShareDecryption => "threshold_share_decryption",
CircuitName::DecryptedSharesAggregation => "decrypted_shares_aggregation",
}
}

pub fn group(&self) -> &'static str {
match self {
CircuitName::PkBfv => "dkg",
CircuitName::PkGeneration => "threshold",
CircuitName::SkShareComputation => "dkg",
CircuitName::ESmShareComputation => "dkg",
CircuitName::SkShareEncryption => "dkg",
CircuitName::ESmShareEncryption => "dkg",
CircuitName::DecShares => "threshold",
CircuitName::PkAgg => "threshold",
CircuitName::DkgSkShareDecryption => "dkg",
CircuitName::DkgESmShareDecryption => "dkg",
CircuitName::PkGeneration => "threshold",
CircuitName::ThresholdShareDecryption => "threshold",
CircuitName::PkAggregation => "threshold",
CircuitName::DecryptedSharesAggregation => "threshold",
}
}

Expand Down
17 changes: 12 additions & 5 deletions crates/events/src/enclave_event/signed_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pub enum ProofType {
T2ESmShareDecryption = 7,
/// T5 — Share decryption proof (Proof 6).
T5ShareDecryption = 8,
/// T6 — Decrypted shares aggregation proof (Proof 7).
T6DecryptedSharesAggregation = 9,
}

impl ProofType {
Expand All @@ -59,10 +61,10 @@ impl ProofType {
ProofType::T1ESmShareComputation => CircuitName::ESmShareComputation,
ProofType::T1SkShareEncryption => CircuitName::SkShareEncryption,
ProofType::T1ESmShareEncryption => CircuitName::ESmShareEncryption,
ProofType::T2SkShareDecryption | ProofType::T2ESmShareDecryption => {
CircuitName::DecShares
}
ProofType::T5ShareDecryption => CircuitName::DecShares,
ProofType::T2SkShareDecryption => CircuitName::DkgSkShareDecryption,
ProofType::T2ESmShareDecryption => CircuitName::DkgESmShareDecryption,
ProofType::T5ShareDecryption => CircuitName::ThresholdShareDecryption,
ProofType::T6DecryptedSharesAggregation => CircuitName::DecryptedSharesAggregation,
}
}

Expand All @@ -78,6 +80,7 @@ impl ProofType {
| ProofType::T2SkShareDecryption
| ProofType::T2ESmShareDecryption => "E3_BAD_DKG_PROOF",
ProofType::T5ShareDecryption => "E3_BAD_DECRYPTION_PROOF",
ProofType::T6DecryptedSharesAggregation => "E3_BAD_AGGREGATION_PROOF",
}
}
}
Expand Down Expand Up @@ -309,7 +312,11 @@ mod tests {
);
assert_eq!(
ProofType::T2SkShareDecryption.circuit_name(),
CircuitName::DecShares
CircuitName::DkgSkShareDecryption
);
assert_eq!(
ProofType::T5ShareDecryption.circuit_name(),
CircuitName::ThresholdShareDecryption
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ pub struct ShareDecryptionCircuitData {
pub secret_key: SecretKey,
/// Ciphertexts from H honest parties: [party_idx][mod_idx] (one ciphertext per party per TRBFV modulus).
pub honest_ciphertexts: Vec<Vec<Ciphertext>>,
/// Which input type (SecretKey or SmudgingNoise) to resolve circuit path.
pub dkg_input_type: DkgInputType,
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl ShareDecryptionCircuitData {
Ok(ShareDecryptionCircuitData {
honest_ciphertexts,
secret_key: dkg_secret_key,
dkg_input_type,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/zk-prover/src/circuits/dkg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

mod pk;
mod share_computation;
mod share_decryption;
mod share_encryption;
1 change: 0 additions & 1 deletion crates/zk-prover/src/circuits/dkg/share_computation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use e3_zk_helpers::computation::DkgInputType;
use e3_zk_helpers::dkg::share_computation::{
Inputs, ShareComputationCircuit, ShareComputationCircuitData,
};
use noirc_abi::InputMap;

impl Provable for ShareComputationCircuit {
type Params = BfvPreset;
Expand Down
37 changes: 37 additions & 0 deletions crates/zk-prover/src/circuits/dkg/share_decryption.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: LGPL-3.0-only
//
// This file is provided WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE

use crate::traits::Provable;
use e3_events::CircuitName;
use e3_fhe_params::BfvPreset;
use e3_zk_helpers::computation::DkgInputType;
use e3_zk_helpers::dkg::share_decryption::{
Inputs, ShareDecryptionCircuit, ShareDecryptionCircuitData,
};

impl Provable for ShareDecryptionCircuit {
type Params = BfvPreset;
type Input = ShareDecryptionCircuitData;
type Inputs = Inputs;

fn resolve_circuit_name(&self, input: &Self::Input) -> CircuitName {
match input.dkg_input_type {
DkgInputType::SecretKey => CircuitName::DkgSkShareDecryption,
DkgInputType::SmudgingNoise => CircuitName::DkgESmShareDecryption,
}
}

fn valid_circuits(&self) -> Vec<CircuitName> {
vec![
CircuitName::DkgSkShareDecryption,
CircuitName::DkgESmShareDecryption,
]
}

fn circuit(&self) -> CircuitName {
CircuitName::DkgSkShareDecryption
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: LGPL-3.0-only
//
// This file is provided WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE

use crate::traits::Provable;
use e3_events::CircuitName;
use e3_fhe_params::BfvPreset;
use e3_zk_helpers::circuits::threshold::decrypted_shares_aggregation::circuit::{
DecryptedSharesAggregationCircuit, DecryptedSharesAggregationCircuitData,
};
use e3_zk_helpers::circuits::threshold::decrypted_shares_aggregation::computation::Inputs;

impl Provable for DecryptedSharesAggregationCircuit {
type Params = BfvPreset;
type Input = DecryptedSharesAggregationCircuitData;
type Inputs = Inputs;

fn circuit(&self) -> CircuitName {
CircuitName::DecryptedSharesAggregation
}
}
3 changes: 3 additions & 0 deletions crates/zk-prover/src/circuits/threshold/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.

mod decrypted_shares_aggregation;
mod pk_aggregation;
mod pk_generation;
mod share_decryption;
23 changes: 23 additions & 0 deletions crates/zk-prover/src/circuits/threshold/pk_aggregation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: LGPL-3.0-only
//
// This file is provided WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE

use crate::traits::Provable;
use e3_events::CircuitName;
use e3_fhe_params::BfvPreset;
use e3_zk_helpers::circuits::threshold::pk_aggregation::circuit::{
PkAggregationCircuit, PkAggregationCircuitData,
};
use e3_zk_helpers::circuits::threshold::pk_aggregation::computation::Inputs;

impl Provable for PkAggregationCircuit {
type Params = BfvPreset;
type Input = PkAggregationCircuitData;
type Inputs = Inputs;

fn circuit(&self) -> CircuitName {
CircuitName::PkAggregation
}
}
23 changes: 23 additions & 0 deletions crates/zk-prover/src/circuits/threshold/share_decryption.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: LGPL-3.0-only
//
// This file is provided WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE

use crate::traits::Provable;
use e3_events::CircuitName;
use e3_fhe_params::BfvPreset;
use e3_zk_helpers::circuits::threshold::share_decryption::circuit::{
ShareDecryptionCircuit, ShareDecryptionCircuitData,
};
use e3_zk_helpers::circuits::threshold::share_decryption::computation::Inputs;

impl Provable for ShareDecryptionCircuit {
type Params = BfvPreset;
type Input = ShareDecryptionCircuitData;
type Inputs = Inputs;

fn circuit(&self) -> CircuitName {
CircuitName::ThresholdShareDecryption
}
}
84 changes: 84 additions & 0 deletions crates/zk-prover/tests/fixtures/decrypted_shares_aggregation.json

Large diffs are not rendered by default.

Binary file not shown.
61 changes: 61 additions & 0 deletions crates/zk-prover/tests/fixtures/dkg_e_sm_share_decryption.json

Large diffs are not rendered by default.

Binary file not shown.
61 changes: 61 additions & 0 deletions crates/zk-prover/tests/fixtures/dkg_sk_share_decryption.json

Large diffs are not rendered by default.

Binary file not shown.
Loading
Loading