From a7901e3b1b5a5d24e02478be0a92ecf616aa9627 Mon Sep 17 00:00:00 2001
From: Hanting Zhang <winston@lurk-lab.com>
Date: Tue, 20 Feb 2024 17:52:48 +0000
Subject: [PATCH] use home, non-wasm builds

---
 Cargo.toml  | 1 +
 src/data.rs | 3 ++-
 src/lib.rs  | 8 +++++++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index c10e90a8a..4fd353f17 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -52,6 +52,7 @@ camino = "1.1.6"
 # grumpkin-msm has been patched to support MSMs for the pasta curve cycle
 # see: https://github.com/lurk-lab/grumpkin-msm/pull/3
 grumpkin-msm = { git = "https://github.com/lurk-lab/grumpkin-msm", branch = "dev" }
+home = "0.5.9"
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 # see https://github.com/rust-random/rand/pull/948
diff --git a/src/data.rs b/src/data.rs
index 022074ed1..71b4d8bfc 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -30,7 +30,8 @@ pub struct DataConfig {
 /// Initializes the global configuration for Arecibo data storage, setting up the root directory
 /// and initializing counters. We create the root directory if it does not already exist.
 pub fn init_config() -> DataConfig {
-  let root_dir = Utf8PathBuf::from(ARECIBO_DATA);
+  let root_dir = home::home_dir().unwrap().join(ARECIBO_DATA);
+  let root_dir = Utf8PathBuf::from_path_buf(root_dir).unwrap();
   if !root_dir.exists() {
     fs::create_dir_all(&root_dir).expect("Failed to create arecibo data directory");
   }
diff --git a/src/lib.rs b/src/lib.rs
index 0b09b7bad..7e878fc98 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -25,12 +25,15 @@ pub mod r1cs;
 pub mod spartan;
 pub mod traits;
 
+#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
 pub mod data;
 pub mod supernova;
 
 use once_cell::sync::OnceCell;
 use traits::{CurveCycleEquipped, Dual};
 
+#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
+use crate::data::{write_arecibo_data, write_data};
 use crate::digest::{DigestComputer, SimpleDigestible};
 use crate::{
   bellpepper::{
@@ -38,7 +41,6 @@ use crate::{
     shape_cs::ShapeCS,
     solver::SatisfyingAssignment,
   },
-  data::{write_arecibo_data, write_data},
   r1cs::R1CSResult,
 };
 use abomonation::Abomonation;
@@ -496,7 +498,10 @@ where
     };
 
     let config = RecursiveSNARKConfig {
+      #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
       write_data: write_data(),
+      #[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
+      write_data: false,
     };
 
     Ok(Self {
@@ -606,6 +611,7 @@ where
       &mut self.buffer_primary.ABC_Z_2,
     )?;
 
+    #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
     if self.config.write_data {
       let W = l_w_primary.W;
       write_arecibo_data(