From 0fbc500f885635917560f8aed037751c8ec45634 Mon Sep 17 00:00:00 2001 From: Andrew Tretyakov <42178850+0xAndoroid@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:52:11 -0500 Subject: [PATCH 1/2] fix: guard disk-persistence with not(target_arch = "wasm32") std::fs/std::env/std::path don't exist on wasm32-unknown-unknown. Add not(wasm32) guards so disk-persistence compiles as a no-op on WASM while remaining fully functional on native targets. --- src/backends/arkworks/ark_setup.rs | 2 +- src/lib.rs | 11 ++++------- src/primitives/transcript.rs | 2 +- src/setup.rs | 12 ++++++------ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/backends/arkworks/ark_setup.rs b/src/backends/arkworks/ark_setup.rs index cff54a8..ece2669 100644 --- a/src/backends/arkworks/ark_setup.rs +++ b/src/backends/arkworks/ark_setup.rs @@ -40,7 +40,7 @@ impl ArkworksProverSetup { } /// Load prover setup from disk cache, or generate and cache if not available - #[cfg(feature = "disk-persistence")] + #[cfg(all(feature = "disk-persistence", not(target_arch = "wasm32")))] pub fn new_from_urs(rng: &mut R, max_log_n: usize) -> Self { let (prover_setup, _) = crate::setup::(rng, max_log_n); Self(prover_setup) diff --git a/src/lib.rs b/src/lib.rs index 6adb0d0..f36b832 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -145,7 +145,7 @@ where ProverSetup: DorySerialize + DoryDeserialize, VerifierSetup: DorySerialize + DoryDeserialize, { - #[cfg(feature = "disk-persistence")] + #[cfg(all(feature = "disk-persistence", not(target_arch = "wasm32")))] { // Try to load from disk match setup::load_setup::(max_log_n) { @@ -161,10 +161,7 @@ where } // Setup not found on disk - generate new setup - tracing::info!( - "Setup not found on disk, generating new setup for max_log_n={}", - max_log_n - ); + tracing::info!("Setup not found on disk, generating new setup for max_log_n={}", max_log_n); let prover_setup = ProverSetup::new(rng, max_log_n); let verifier_setup = prover_setup.to_verifier_setup(); @@ -174,7 +171,7 @@ where (prover_setup, verifier_setup) } - #[cfg(not(feature = "disk-persistence"))] + #[cfg(any(not(feature = "disk-persistence"), target_arch = "wasm32"))] { tracing::info!("Generating new setup for max_log_n={}", max_log_n); @@ -203,7 +200,7 @@ where /// /// # Availability /// This function is only available when the `disk-persistence` feature is enabled. -#[cfg(feature = "disk-persistence")] +#[cfg(all(feature = "disk-persistence", not(target_arch = "wasm32")))] pub fn generate_urs( rng: &mut R, max_log_n: usize, diff --git a/src/primitives/transcript.rs b/src/primitives/transcript.rs index 8e020be..d745d5f 100644 --- a/src/primitives/transcript.rs +++ b/src/primitives/transcript.rs @@ -5,7 +5,7 @@ use crate::primitives::arithmetic::{Group, PairingCurve}; use crate::primitives::DorySerialize; -/// Transcript to standardize fiat shamir across different transcript impleemntations +/// Transcript to standardize fiat shamir across different transcript implementations pub trait Transcript { type Curve: PairingCurve; fn append_bytes(&mut self, label: &[u8], bytes: &[u8]); diff --git a/src/setup.rs b/src/setup.rs index 841bd45..6a60806 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -8,11 +8,11 @@ use crate::primitives::arithmetic::{Group, PairingCurve}; use crate::primitives::serialization::{DoryDeserialize, DorySerialize}; use rand_core::RngCore; -#[cfg(feature = "disk-persistence")] +#[cfg(all(feature = "disk-persistence", not(target_arch = "wasm32")))] use std::fs::{self, File}; -#[cfg(feature = "disk-persistence")] +#[cfg(all(feature = "disk-persistence", not(target_arch = "wasm32")))] use std::io::{BufReader, BufWriter}; -#[cfg(feature = "disk-persistence")] +#[cfg(all(feature = "disk-persistence", not(target_arch = "wasm32")))] use std::path::PathBuf; /// Prover setup parameters @@ -204,7 +204,7 @@ impl ProverSetup { /// - Windows: `{FOLDERID_LocalAppData}\dory\` /// /// Note: Detects OS at runtime by checking environment variables then chooses XDG cache directory for persistent storage. -#[cfg(feature = "disk-persistence")] +#[cfg(all(feature = "disk-persistence", not(target_arch = "wasm32")))] fn get_storage_path(max_log_n: usize) -> Option { let cache_directory = { // Check for Windows first (LOCALAPPDATA is Windows-specific) @@ -252,7 +252,7 @@ fn get_storage_path(max_log_n: usize) -> Option { /// - Directory creation fails /// - File creation fails /// - Serialization of prover or verifier setup fails -#[cfg(feature = "disk-persistence")] +#[cfg(all(feature = "disk-persistence", not(target_arch = "wasm32")))] pub fn save_setup( prover: &ProverSetup, verifier: &VerifierSetup, @@ -294,7 +294,7 @@ pub fn save_setup( /// - Setup file doesn't exist /// - File cannot be opened /// - Deserialization fails -#[cfg(feature = "disk-persistence")] +#[cfg(all(feature = "disk-persistence", not(target_arch = "wasm32")))] pub fn load_setup( max_log_n: usize, ) -> Result<(ProverSetup, VerifierSetup), crate::DoryError> From ba29eb9d0bd8203ec9fcd7357e10eff753ed2af8 Mon Sep 17 00:00:00 2001 From: Andrew Tretyakov <42178850+0xAndoroid@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:31:02 -0500 Subject: [PATCH 2/2] cargo fmt Signed-off-by: Andrew Tretyakov <42178850+0xAndoroid@users.noreply.github.com> --- rustfmt.toml | 3 +++ src/lib.rs | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..3237dad --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +use_small_heuristics = "Default" +struct_lit_width = 18 +use_field_init_shorthand = false diff --git a/src/lib.rs b/src/lib.rs index f36b832..ae90490 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -161,7 +161,10 @@ where } // Setup not found on disk - generate new setup - tracing::info!("Setup not found on disk, generating new setup for max_log_n={}", max_log_n); + tracing::info!( + "Setup not found on disk, generating new setup for max_log_n={}", + max_log_n + ); let prover_setup = ProverSetup::new(rng, max_log_n); let verifier_setup = prover_setup.to_verifier_setup();