Skip to content

Commit 4f1eafd

Browse files
committed
Auto-format Python files with black
1 parent 9ebc48b commit 4f1eafd

3 files changed

Lines changed: 25 additions & 20 deletions

File tree

src/mandala/core/zk/circuits.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
zk_generate_cold_chain_proof,
2929
zk_load_proving_key,
3030
)
31+
3132
RUST_BACKEND_AVAILABLE = True
3233
log.info("zk.rust_backend.enabled")
3334
except ImportError:
@@ -116,7 +117,7 @@ def _generate_sync():
116117
breach_ts,
117118
pk_path,
118119
)
119-
120+
120121
# Convert Rust proof to Python format
121122
return ColdChainBreachProof(
122123
proof=proof.proof,

src/mandala/core/zk/verifier.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
zk_verify_cold_chain_proof,
2424
zk_verify_cold_chain_proof_with_timestamp_check,
2525
)
26+
2627
RUST_BACKEND_AVAILABLE = True
2728
log.info("zk.rust_backend.enabled")
2829
except ImportError:
@@ -74,6 +75,7 @@ def _verify_sync():
7475

7576
# Convert public inputs to JSON
7677
import json
78+
7779
public_inputs_json = json.dumps(proof.public_inputs)
7880

7981
# Call Rust verification

tests/test_zk_integration.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
zk_load_proving_key,
2222
zk_load_verification_key,
2323
)
24+
2425
RUST_BACKEND_AVAILABLE = True
2526
except ImportError:
2627
RUST_BACKEND_AVAILABLE = False
@@ -63,15 +64,16 @@ def test_generate_keys_breach_scenario(self, tmp_path):
6364
"""Test generating keys for a breach scenario."""
6465
pk_path = str(tmp_path / "test.pk")
6566
vk_path = str(tmp_path / "test.vk")
66-
67+
6768
# Generate keys
6869
zk_generate_keys_breach_scenario(pk_path, vk_path)
69-
70+
7071
# Verify files were created
7172
import os
73+
7274
assert os.path.exists(pk_path)
7375
assert os.path.exists(vk_path)
74-
76+
7577
# Verify files are not empty
7678
assert os.path.getsize(pk_path) > 0
7779
assert os.path.getsize(vk_path) > 0
@@ -80,14 +82,14 @@ def test_load_generated_keys(self, tmp_path):
8082
"""Test loading generated keys."""
8183
pk_path = str(tmp_path / "test.pk")
8284
vk_path = str(tmp_path / "test.vk")
83-
85+
8486
# Generate keys
8587
zk_generate_keys_breach_scenario(pk_path, vk_path)
86-
88+
8789
# Load keys
8890
pk_bytes = zk_load_proving_key(pk_path)
8991
vk_bytes = zk_load_verification_key(vk_path)
90-
92+
9193
assert len(pk_bytes) > 0
9294
assert len(vk_bytes) > 0
9395

@@ -102,7 +104,7 @@ def test_proof_generation_with_mock_keys(self, tmp_path):
102104
pk_path = str(tmp_path / "test.pk")
103105
vk_path = str(tmp_path / "test.vk")
104106
zk_generate_keys_breach_scenario(pk_path, vk_path)
105-
107+
106108
# Create mock event
107109
event = MandalaEvent(
108110
id="test-event-123",
@@ -112,10 +114,10 @@ def test_proof_generation_with_mock_keys(self, tmp_path):
112114
time=datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
113115
data={"temperature_c": -5.0},
114116
)
115-
117+
116118
# Create circuit
117119
circuit = ZKCircuit(event)
118-
120+
119121
# Generate proof
120122
try:
121123
proof = circuit.build_cold_chain_circuit(
@@ -124,7 +126,7 @@ def test_proof_generation_with_mock_keys(self, tmp_path):
124126
breach_timestamp=datetime(2024, 1, 1, 12, 5, 0, tzinfo=UTC),
125127
pk_path=pk_path,
126128
)
127-
129+
128130
# Verify proof structure
129131
assert isinstance(proof, ColdChainBreachProof)
130132
assert len(proof.proof) > 0
@@ -146,13 +148,13 @@ def test_verification_with_mock_proof(self, tmp_path):
146148
pk_path = str(tmp_path / "test.pk")
147149
vk_path = str(tmp_path / "test.vk")
148150
zk_generate_keys_breach_scenario(pk_path, vk_path)
149-
151+
150152
# Load verification key
151153
vk_bytes = zk_load_verification_key(vk_path)
152-
154+
153155
# Create verifier
154156
verifier = ZKVerifier(verification_key_path=vk_path)
155-
157+
156158
# Create mock proof (this would normally come from proof generation)
157159
# For now, we just test that the verifier can be instantiated
158160
assert verifier is not None
@@ -167,7 +169,7 @@ def test_verifier_fallback_on_error(self):
167169
"""Test that verifier falls back to subprocess on Rust error."""
168170
# Create verifier with invalid key path
169171
verifier = ZKVerifier(verification_key_path="/nonexistent/path.vk")
170-
172+
171173
# Create mock proof
172174
proof = ColdChainBreachProof(
173175
proof=b"mock_proof",
@@ -176,7 +178,7 @@ def test_verifier_fallback_on_error(self):
176178
proof_id="test-proof-123",
177179
generated_at=datetime.now(UTC),
178180
)
179-
181+
180182
# Try to verify (should fail gracefully)
181183
try:
182184
result = verifier._verify_with_rust(proof, None)
@@ -196,17 +198,17 @@ def test_full_pipeline_with_mock(self, tmp_path):
196198
pk_path = str(tmp_path / "test.pk")
197199
vk_path = str(tmp_path / "test.vk")
198200
zk_generate_keys_breach_scenario(pk_path, vk_path)
199-
201+
200202
# Load keys
201203
pk_bytes = zk_load_proving_key(pk_path)
202204
vk_bytes = zk_load_verification_key(vk_path)
203-
205+
204206
# Create verifier
205207
verifier = ZKVerifier(verification_key_path=vk_path)
206-
208+
207209
# Verify verifier is using Rust backend
208210
assert verifier._vk_path == vk_path
209-
211+
210212
# Note: Full proof generation test is skipped until circuit is fully implemented
211213
# This is a placeholder for the end-to-end test
212214

0 commit comments

Comments
 (0)