Skip to content
Closed
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
128 changes: 74 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ env:
NODE_VERSION: 22
RUST_TOOLCHAIN: 1.86.0
NOIR_TOOLCHAIN: v1.0.0-beta.15
BB_VERSION: 3.0.0-nightly.20251104
HARDHAT_VAR_MNEMONIC: 'test test test test test test test test test test test junk'
HARDHAT_VAR_INFURA_API_KEY: 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
PRIVATE_KEY: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
Expand All @@ -32,7 +33,7 @@ permissions:
packages: write

jobs:
rust_unit:
rust_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -75,46 +76,6 @@ jobs:
- name: Run Unit Tests
run: 'cargo test --lib && cargo test --doc'

rust_integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Cache Rust dependencies
uses: ./.github/actions/cache-dependencies

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}

# We must install foundry in order to be able to test anvil
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install solc
run: |
sudo add-apt-repository ppa:ethereum/ethereum \
&& sudo apt-get update -y \
&& sudo apt-get install -y solc

- name: pnpm-setup
uses: pnpm/action-setup@v4

# We need to setup node in order to compile the hardhat contracts to get the artifacts
- name: 'Setup node'
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

- name: 'Install the dependencies'
run: 'pnpm install --frozen-lockfile'

- name: Checking code format rust
run: pnpm rust:lint

- name: Run Integration Tests
run: 'cargo test --test integration -- --nocapture'

Expand Down Expand Up @@ -310,14 +271,6 @@ jobs:
- name: 'Install the dependencies'
run: 'pnpm install --frozen-lockfile'

- name: 'Lint the code'
run: 'pnpm lint'

- name: 'Add lint summary'
run: |
echo "## Lint results" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

- name: 'Run prebuild'
run: 'pnpm test:integration prebuild'

Expand Down Expand Up @@ -611,7 +564,7 @@ jobs:
path: ./examples/CRISP/playwright-report/
retention-days: 30

test_enclave_circuits:
build_and_test_circuits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand All @@ -623,19 +576,85 @@ jobs:
with:
toolchain: ${{ env.NOIR_TOOLCHAIN }}

- name: Install Barretenberg (bb)
run: |
curl -fsSL "https://github.com/AztecProtocol/aztec-packages/releases/download/v${{ env.BB_VERSION }}/barretenberg-amd64-linux.tar.gz" -o bb.tar.gz
mkdir -p bb_extract && tar -xzf bb.tar.gz -C bb_extract
BB_BIN=$(find bb_extract -name bb -type f | head -n 1)
sudo mv "$BB_BIN" /usr/local/bin/bb
chmod +x /usr/local/bin/bb
bb --version

- name: Check formatting
run: ./scripts/lint-circuits.sh

- name: Test Noir circuits
run: ./scripts/test-circuits.sh

- name: Upload circuit artifacts
- name: pnpm-setup
uses: pnpm/action-setup@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build circuits
run: pnpm build:circuits

- name: Upload compiled circuit artifacts
uses: actions/upload-artifact@v4
with:
name: circuit-artifacts
path: circuits/target/
name: compiled-circuits
path: |
circuits/bin/dkg/target/
circuits/bin/threshold/target/
retention-days: 1
if-no-files-found: warn
if-no-files-found: error

zk_prover_e2e:
runs-on: ubuntu-latest
needs: [build_and_test_circuits]
steps:
- uses: actions/checkout@v6

- name: Cache Rust dependencies
uses: ./.github/actions/cache-dependencies

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Install Barretenberg (bb)
run: |
curl -fsSL "https://github.com/AztecProtocol/aztec-packages/releases/download/v${{ env.BB_VERSION }}/barretenberg-amd64-linux.tar.gz" -o bb.tar.gz
mkdir -p bb_extract && tar -xzf bb.tar.gz -C bb_extract
BB_BIN=$(find bb_extract -name bb -type f | head -n 1)
sudo mv "$BB_BIN" /usr/local/bin/bb
chmod +x /usr/local/bin/bb
bb --version

- name: Download compiled circuit artifacts
uses: actions/download-artifact@v4
with:
name: compiled-circuits
path: circuits/bin/

- name: Verify circuit artifacts
run: |
echo "DKG circuits:"
ls -la circuits/bin/dkg/target/*.json circuits/bin/dkg/target/*.vk
echo "Threshold circuits:"
ls -la circuits/bin/threshold/target/*.json circuits/bin/threshold/target/*.vk

- name: Run ZK prover e2e tests
run: cargo test -p e3-zk-prover --test local_e2e_tests -- --nocapture

build_e3_support_dev:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -888,3 +907,4 @@ jobs:
auto_detect_branch_protection: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

42 changes: 21 additions & 21 deletions crates/events/src/enclave_event/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ pub enum CircuitName {
SkShareComputation,
/// E_SM share computation proof (C2b).
ESmShareComputation,
/// Encrypted sk share proof (C3a).
SkShareEncryption,
/// Encrypted E_SM share proof (C3b).
ESmShareEncryption,
/// Sk share decryption proof (C4a).
DkgSkShareDecryption,
/// E_SM share decryption proof (C4b).
DkgESmShareDecryption,
/// Share encryption proof (C3).
ShareEncryption,
/// DKG share decryption proof (C4).
DkgShareDecryption,
/// Public key aggregation proof (C5).
PkAggregation,
/// Decryption share proof (C6).
ThresholdShareDecryption,
/// Decrypted shares aggregation proof (C7).
DecryptedSharesAggregation,
/// Decrypted shares aggregation proof — BigNum variant (C7a).
DecryptedSharesAggregationBn,
/// Decrypted shares aggregation proof — Modular variant (C7b).
DecryptedSharesAggregationMod,
/// User data encryption proof.
UserDataEncryption,
}

impl CircuitName {
Expand All @@ -67,13 +67,13 @@ impl CircuitName {
CircuitName::PkGeneration => "pk_generation",
CircuitName::SkShareComputation => "sk_share_computation",
CircuitName::ESmShareComputation => "e_sm_share_computation",
CircuitName::SkShareEncryption => "sk_share_encryption",
CircuitName::ESmShareEncryption => "e_sm_share_encryption",
CircuitName::DkgSkShareDecryption => "dkg_sk_share_decryption",
CircuitName::DkgESmShareDecryption => "dkg_e_sm_share_decryption",
CircuitName::ShareEncryption => "share_encryption",
CircuitName::DkgShareDecryption => "share_decryption",
CircuitName::PkAggregation => "pk_aggregation",
CircuitName::ThresholdShareDecryption => "threshold_share_decryption",
CircuitName::DecryptedSharesAggregation => "decrypted_shares_aggregation",
CircuitName::ThresholdShareDecryption => "share_decryption",
Comment on lines +70 to +73

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for all uses of as_str() on CircuitName
echo "=== Uses of as_str() (full context) ==="
rg -n --type rust 'as_str\(\)' -B 2 -A 2 -g '!target'

echo ""
echo "=== FromStr or from_str implementations ==="
rg -n --type rust 'impl.*FromStr|from_str|parse::<CircuitName' -g '!target'

echo ""
echo "=== String literals matching 'share_decryption' ==="
rg -n --type rust '"share_decryption"' -B 1 -A 1 -g '!target'

echo ""
echo "=== CircuitName enum definition and methods ==="
rg -n --type rust 'enum CircuitName|impl CircuitName' -A 30 -g '!target'

Repository: gnosisguild/enclave

Length of output: 42841


🏁 Script executed:

#!/bin/bash
# Check if DkgShareDecryption is actually used anywhere
echo "=== Uses of DkgShareDecryption variant ==="
rg -n 'DkgShareDecryption' --type rust -g '!target'

echo ""
echo "=== Check if there's actual DKG share_decryption circuit ==="
find . -name "*share*decryption*" -type f | grep -v target | head -20

Repository: gnosisguild/enclave

Length of output: 2040


as_str() collision between DkgShareDecryption and ThresholdShareDecryption affects logging only; file paths are unambiguous.

Both variants return "share_decryption" from as_str(), causing identical Display output. However, this is a clarity issue, not a functional defect: dir_path() correctly distinguishes them as "dkg/share_decryption" and "threshold/share_decryption". There is no deserialization path that would create ambiguity. Consider prefixing one (e.g., "dkg_share_decryption") to make Display output unambiguous in logs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/events/src/enclave_event/proof.rs` around lines 70 - 73, as_str() for
CircuitName returns the same string for CircuitName::DkgShareDecryption and
CircuitName::ThresholdShareDecryption causing identical Display output; change
the returned literal for one (e.g., make CircuitName::DkgShareDecryption ->
"dkg_share_decryption" or CircuitName::ThresholdShareDecryption ->
"threshold_share_decryption") in the as_str() match so the Display/printing is
unambiguous, and ensure any code that relies on those strings (the Display impl
or callers of as_str()) still compiles after the rename.

CircuitName::DecryptedSharesAggregationBn => "decrypted_shares_aggregation_bn",
CircuitName::DecryptedSharesAggregationMod => "decrypted_shares_aggregation_mod",
CircuitName::UserDataEncryption => "user_data_encryption",
}
}

Expand All @@ -82,14 +82,14 @@ impl CircuitName {
CircuitName::PkBfv => "dkg",
CircuitName::SkShareComputation => "dkg",
CircuitName::ESmShareComputation => "dkg",
CircuitName::SkShareEncryption => "dkg",
CircuitName::ESmShareEncryption => "dkg",
CircuitName::DkgSkShareDecryption => "dkg",
CircuitName::DkgESmShareDecryption => "dkg",
CircuitName::ShareEncryption => "dkg",
CircuitName::DkgShareDecryption => "dkg",
CircuitName::PkGeneration => "threshold",
CircuitName::ThresholdShareDecryption => "threshold",
CircuitName::PkAggregation => "threshold",
CircuitName::DecryptedSharesAggregation => "threshold",
CircuitName::DecryptedSharesAggregationBn => "threshold",
CircuitName::DecryptedSharesAggregationMod => "threshold",
CircuitName::UserDataEncryption => "threshold",
}
}

Expand Down
40 changes: 16 additions & 24 deletions crates/events/src/enclave_event/signed_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ pub enum ProofType {
T1SkShareComputation = 2,
/// T1 — Smudging noise share computation proof (Proof 2b).
T1ESmShareComputation = 3,
/// T1 — Secret key share encryption proof (Proof 3a).
T1SkShareEncryption = 4,
/// T1 — Smudging noise share encryption proof (Proof 3b).
T1ESmShareEncryption = 5,
/// T2 — Secret key share decryption proof (Proof 4a).
T2SkShareDecryption = 6,
/// T2 — Smudging noise share decryption proof (Proof 4b).
T2ESmShareDecryption = 7,
/// T5 — Share decryption proof (Proof 6).
T5ShareDecryption = 8,
/// T1 — Share encryption proof (Proof 3).
T1ShareEncryption = 4,
/// T2 — DKG share decryption proof (Proof 4).
T2DkgShareDecryption = 5,
/// T5 — Threshold share decryption proof (Proof 6).
T5ShareDecryption = 6,
/// T6 — Decrypted shares aggregation proof (Proof 7).
T6DecryptedSharesAggregation = 9,
T6DecryptedSharesAggregation = 7,
}

impl ProofType {
Expand All @@ -59,12 +55,10 @@ impl ProofType {
ProofType::T1PkGeneration => CircuitName::PkGeneration,
ProofType::T1SkShareComputation => CircuitName::SkShareComputation,
ProofType::T1ESmShareComputation => CircuitName::ESmShareComputation,
ProofType::T1SkShareEncryption => CircuitName::SkShareEncryption,
ProofType::T1ESmShareEncryption => CircuitName::ESmShareEncryption,
ProofType::T2SkShareDecryption => CircuitName::DkgSkShareDecryption,
ProofType::T2ESmShareDecryption => CircuitName::DkgESmShareDecryption,
ProofType::T1ShareEncryption => CircuitName::ShareEncryption,
ProofType::T2DkgShareDecryption => CircuitName::DkgShareDecryption,
ProofType::T5ShareDecryption => CircuitName::ThresholdShareDecryption,
ProofType::T6DecryptedSharesAggregation => CircuitName::DecryptedSharesAggregation,
ProofType::T6DecryptedSharesAggregation => CircuitName::DecryptedSharesAggregationBn,
}
}

Expand All @@ -75,10 +69,8 @@ impl ProofType {
| ProofType::T1PkGeneration
| ProofType::T1SkShareComputation
| ProofType::T1ESmShareComputation
| ProofType::T1SkShareEncryption
| ProofType::T1ESmShareEncryption
| ProofType::T2SkShareDecryption
| ProofType::T2ESmShareDecryption => "E3_BAD_DKG_PROOF",
| ProofType::T1ShareEncryption
| ProofType::T2DkgShareDecryption => "E3_BAD_DKG_PROOF",
ProofType::T5ShareDecryption => "E3_BAD_DECRYPTION_PROOF",
ProofType::T6DecryptedSharesAggregation => "E3_BAD_AGGREGATION_PROOF",
}
Expand Down Expand Up @@ -307,12 +299,12 @@ mod tests {
CircuitName::PkGeneration
);
assert_eq!(
ProofType::T1SkShareEncryption.circuit_name(),
CircuitName::SkShareEncryption
ProofType::T1ShareEncryption.circuit_name(),
CircuitName::ShareEncryption
);
assert_eq!(
ProofType::T2SkShareDecryption.circuit_name(),
CircuitName::DkgSkShareDecryption
ProofType::T2DkgShareDecryption.circuit_name(),
CircuitName::DkgShareDecryption
);
assert_eq!(
ProofType::T5ShareDecryption.circuit_name(),
Expand Down
20 changes: 11 additions & 9 deletions crates/tests/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,21 @@ async fn setup_test_zk_backend() -> (ZkBackend, tempfile::TempDir) {
#[cfg(not(unix))]
compile_error!("Integration tests require unix symlink support");

// Copy circuit fixtures from the zk-prover crate's test fixtures
let fixtures_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
// Copy circuit artifacts from the compiled circuit build output
let circuits_build_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("..")
.join("zk-prover")
.join("tests")
.join("fixtures");
.join("..")
.join("circuits")
.join("bin");

// Copy T0 (pk) circuit
let pk_circuit_dir = circuits_dir.join("dkg").join("pk");
tokio::fs::create_dir_all(&pk_circuit_dir).await.unwrap();
tokio::fs::copy(fixtures_dir.join("pk.json"), pk_circuit_dir.join("pk.json"))
let dkg_target = circuits_build_root.join("dkg").join("target");
tokio::fs::copy(dkg_target.join("pk.json"), pk_circuit_dir.join("pk.json"))
.await
.unwrap();
tokio::fs::copy(fixtures_dir.join("pk.vk"), pk_circuit_dir.join("pk.vk"))
tokio::fs::copy(dkg_target.join("pk.vk"), pk_circuit_dir.join("pk.vk"))
.await
.unwrap();

Expand All @@ -116,14 +117,15 @@ async fn setup_test_zk_backend() -> (ZkBackend, tempfile::TempDir) {
tokio::fs::create_dir_all(&pk_gen_circuit_dir)
.await
.unwrap();
let threshold_target = circuits_build_root.join("threshold").join("target");
tokio::fs::copy(
fixtures_dir.join("pk_generation.json"),
threshold_target.join("pk_generation.json"),
pk_gen_circuit_dir.join("pk_generation.json"),
)
.await
.unwrap();
tokio::fs::copy(
fixtures_dir.join("pk_generation.vk"),
threshold_target.join("pk_generation.vk"),
pk_gen_circuit_dir.join("pk_generation.vk"),
)
.await
Expand Down
Loading
Loading