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
28 changes: 26 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,33 @@ jobs:
- name: Verify circuit artifacts
run: |
echo "DKG circuits:"
ls -la circuits/bin/dkg/target/*.json circuits/bin/dkg/target/*.vk
ls -la circuits/bin/dkg/target/*.json \
circuits/bin/dkg/target/*.vk \
circuits/bin/dkg/target/*.vk_hash \
circuits/bin/dkg/target/*.vk_recursive \
circuits/bin/dkg/target/*.vk_recursive_hash \
circuits/bin/dkg/target/*.vk_noir \
circuits/bin/dkg/target/*.vk_noir_hash
echo "Threshold circuits:"
ls -la circuits/bin/threshold/target/*.json circuits/bin/threshold/target/*.vk
ls -la circuits/bin/threshold/target/*.json \
circuits/bin/threshold/target/*.vk \
circuits/bin/threshold/target/*.vk_hash \
circuits/bin/threshold/target/*.vk_recursive \
circuits/bin/threshold/target/*.vk_recursive_hash \
circuits/bin/threshold/target/*.vk_noir \
circuits/bin/threshold/target/*.vk_noir_hash

- name: Verify variant output directories
run: |
echo "Checking default/ variant (noir-recursive-no-zk VKs):"
find circuits/bin/default -name '*.json' | head -20
find circuits/bin/default -name '*.vk' | head -20
echo "Checking recursive/ variant (noir-recursive VKs):"
find circuits/bin/recursive -name '*.json' | head -20
find circuits/bin/recursive -name '*.vk' | head -20
echo "Checking evm/ variant (keccak VKs):"
find circuits/bin/evm -name '*.json' | head -20
find circuits/bin/evm -name '*.vk' | head -20

- name: Run ZK prover e2e tests
run: cargo test -p e3-zk-prover --test local_e2e_tests -- --nocapture
Expand Down
41 changes: 41 additions & 0 deletions crates/events/src/enclave_event/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,47 @@ impl Proof {
}
}

/// Circuit variants determine the hash oracle used for VK generation and proving.
///
/// - `Default`: poseidon/`noir-recursive-no-zk` — wrapper & fold proofs (no ZK blinding, efficient).
/// - `Recursive`: poseidon/`noir-recursive` — inner/base proofs fed into a wrapper (ZK blinding preserved).
/// - `Evm`: keccak/`evm` — on-chain EVM-verifiable proofs.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
pub enum CircuitVariant {
/// noir-recursive-no-zk: for wrapper & fold proofs — poseidon, no ZK blinding.
#[default]
Default,
/// noir-recursive: for inner/base proofs — poseidon with ZK blinding.
Recursive,
/// evm: keccak-based for on-chain Solidity verification.
Evm,
}

impl CircuitVariant {
pub fn as_str(&self) -> &'static str {
match self {
CircuitVariant::Default => "default",
CircuitVariant::Recursive => "recursive",
CircuitVariant::Evm => "evm",
}
}

/// Returns the bb verifier target flag value for this variant.
pub fn verifier_target(&self) -> &'static str {
match self {
CircuitVariant::Default => "noir-recursive-no-zk",
CircuitVariant::Recursive => "noir-recursive",
CircuitVariant::Evm => "evm",
}
}
}

impl fmt::Display for CircuitVariant {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}

/// Circuit identifiers for ZK proofs.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum CircuitName {
Expand Down
53 changes: 5 additions & 48 deletions crates/zk-prover/src/backend/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
use std::time::Duration;
use tar::Archive;
use tokio::fs;
use tracing::{info, warn};
use tracing::info;
use walkdir::WalkDir;

use super::ZkBackend;
Expand Down Expand Up @@ -107,17 +107,10 @@ impl ZkBackend {
info!("installed circuits v{}", version);
}
Err(e) => {
warn!(
"could not download circuits ({}), creating placeholder for testing",
e
);
create_placeholder_circuits(&self.circuits_dir).await?;

version_info.circuits_version = Some("0.0.0-placeholder".to_string());
version_info.last_updated = Some(chrono::Utc::now().to_rfc3339());
version_info.save(&self.version_file()).await?;

info!("created placeholder circuits (will retry download on next setup)");
return Err(ZkError::DownloadFailed(
url,
format!("could not download circuits: {}", e),
));
}
}

Expand Down Expand Up @@ -210,39 +203,3 @@ async fn download_with_progress(url: &str, message: &str) -> Result<Vec<u8>, ZkE
pb.finish_with_message("download complete");
Ok(bytes)
}

async fn create_placeholder_circuits(circuits_dir: &Path) -> Result<(), ZkError> {
fs::create_dir_all(circuits_dir).await?;

let placeholder = serde_json::json!({
"noir_version":"1.0.0-beta.15+83245db91dcf63420ef4bcbbd85b98f397fee663",
"hash":"15412581843239610929",
"abi":{
"parameters":[
{"name":"x","type":{"kind":"field"},"visibility":"private"},
{"name":"y","type":{"kind":"field"},"visibility":"private"},
{"name":"_sum","type":{"kind":"field"},"visibility":"public"}
],
"return_type":null,
"error_types":{}
},
"bytecode":"H4sIAAAAAAAA/5WOMQ5AMBRA/y8HMbIRRxCJSYwWg8RiIGIz9gjiAk4hHKeb0WLX0KHRDu1bXvL/y89H+HCFu7rtCTeCiiPsgRFo06LUhk0+smgN9iLdKC0rPz6z6RjmhN3LxffE/O7byg+hZv7nAb2HRPkUAQAA",
"debug_symbols":"jZDRCoMwDEX/Jc996MbG1F8ZQ2qNUghtie1giP++KLrpw2BPaXJ7bsgdocUm97XzXRiguo/QsCNyfU3BmuSCl+k4KdjaOjGijGCnCxUNo09Q+Uyk4GkoL5+GaPxSk2FRtQL0rVQx7Bzh/JrUl9a/0Vu5ssXlA1//psvbSp90ccAf0hnr+HAuaKjO0+zGzjSEawRd9naXSHrFTdkyixwstplxtls0WfAG",
"file_map":{
"50":{"source":"pub fn main(\n x: Field,\n y: Field,\n _sum: pub Field\n) {\n let sum = x + y;\n assert(sum == _sum);\n}\n",
"path":"./enclave/circuits/bin/dummy/src/main.nr"}
},"expression_width":{"Bounded":{"width":4}}
});

let circuit_path = circuits_dir.join("pk.json");
fs::write(&circuit_path, serde_json::to_string_pretty(&placeholder)?).await?;

fs::create_dir_all(circuits_dir.join("vk")).await?;

// Create a minimal placeholder VK file so proof generation doesn't fail
// This is just for testing when actual circuits can't be downloaded
let vk_path = circuits_dir.join("vk").join("pk.vk");
fs::write(&vk_path, b"placeholder_vk").await?;

Ok(())
}
Loading
Loading