|
8 | 8 | //! `generated-bins/` in the project root for runtime access — but only during |
9 | 9 | //! normal builds, **not** during `cargo publish` verification where modifying the |
10 | 10 | //! source directory is forbidden. |
| 11 | +//! |
| 12 | +//! Set `SKIP_CIRCUIT_BUILD=1` to skip circuit generation (useful for CI jobs |
| 13 | +//! that don't need the circuits, like clippy/doc checks). |
11 | 14 |
|
12 | 15 | use std::{env, path::Path, time::Instant}; |
13 | 16 |
|
| 17 | +/// Compute Poseidon2 hash of bytes and return hex string |
| 18 | +fn poseidon_hex(data: &[u8]) -> String { |
| 19 | + let hash = qp_poseidon_core::hash_bytes(data); |
| 20 | + hex::encode(&hash[..16]) // first 16 bytes for shorter display |
| 21 | +} |
| 22 | + |
| 23 | +/// Print hash of a generated binary file |
| 24 | +fn print_bin_hash(dir: &Path, filename: &str) { |
| 25 | + let path = dir.join(filename); |
| 26 | + if let Ok(data) = std::fs::read(&path) { |
| 27 | + println!( |
| 28 | + "cargo:warning= {}: {} bytes, hash: {}", |
| 29 | + filename, |
| 30 | + data.len(), |
| 31 | + poseidon_hex(&data) |
| 32 | + ); |
| 33 | + } |
| 34 | +} |
| 35 | + |
14 | 36 | fn main() { |
| 37 | + // Allow skipping circuit generation for CI jobs that don't need it |
| 38 | + if env::var("SKIP_CIRCUIT_BUILD").is_ok() { |
| 39 | + println!( |
| 40 | + "cargo:warning=[quantus-cli] Skipping circuit generation (SKIP_CIRCUIT_BUILD is set)" |
| 41 | + ); |
| 42 | + return; |
| 43 | + } |
| 44 | + |
15 | 45 | let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set"); |
16 | 46 | let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"); |
17 | 47 |
|
@@ -49,6 +79,15 @@ fn main() { |
49 | 79 | elapsed.as_secs_f64() |
50 | 80 | ); |
51 | 81 |
|
| 82 | + // Print hashes of generated binaries |
| 83 | + print_bin_hash(&build_output_dir, "common.bin"); |
| 84 | + print_bin_hash(&build_output_dir, "verifier.bin"); |
| 85 | + print_bin_hash(&build_output_dir, "prover.bin"); |
| 86 | + print_bin_hash(&build_output_dir, "dummy_proof.bin"); |
| 87 | + print_bin_hash(&build_output_dir, "aggregated_common.bin"); |
| 88 | + print_bin_hash(&build_output_dir, "aggregated_verifier.bin"); |
| 89 | + print_bin_hash(&build_output_dir, "aggregated_prover.bin"); |
| 90 | + |
52 | 91 | // Copy bins to project root for runtime access, but NOT during `cargo publish` |
53 | 92 | // verification (manifest_dir is inside target/package/ in that case). |
54 | 93 | let project_bins = Path::new(&manifest_dir).join("generated-bins"); |
|
0 commit comments