From f72c480df94651ce49fcd5f56a232fd112a7541c Mon Sep 17 00:00:00 2001 From: arnaucube Date: Sat, 28 Dec 2024 13:07:47 +0100 Subject: [PATCH] add html frontend to run it in the browser --- README.md | 6 ++ index.html | 202 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 14 +++- src/utils.rs | 2 +- 4 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 index.html diff --git a/README.md b/README.md index 83d0b40..2c033a3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,13 @@ # ethdos-fold +Follows the ideas of ETHdos (https://ethdos.xyz/blog), but using folding schemes. +It uses Sonobe under the hood, compiled to WASM. +## Usage - run native tests: `cargo test --release -- --nocapture` - build wasm: `wasm-pack build --target web` - serve the web: `python -m http.server 8080` - go to http://127.0.0.1:8080/index.html + +## Acknowledgements +Thanks to Michael Chu for proposing to build this prototype. This repo uses [Sonobe](https://github.com/privacy-scaling-explorations/sonobe), which relies on [arkworks-rs](https://github.com/arkworks-rs), and for the BabyJubJub EdDSA it uses [kilic/arkeddsa](https://github.com/kilic/arkeddsa). diff --git a/index.html b/index.html new file mode 100644 index 0000000..c136822 --- /dev/null +++ b/index.html @@ -0,0 +1,202 @@ + + + + + + ETHdos fold + + + + + + + + + +
+
+
+
+
+

ETHdos fold

+

Follows the ideas of ETHdos (https://ethdos.xyz/blog), but using Folding Schemes.

+

It uses Sonobe under the hood, compiled to WASM. +

+ Current version does not parallelize in wasm. Same execution can be run natively (no wasm), instructions in the repo.
+ In the same laptop, natively takes ~290ms per step, in-browser takes ~1700ms per step. +

+ + + +
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + +
+
+ logs: + +

(Open the browser console to see the execution logs)

+
+ (logs will appear after the execution of each button ends) +
+
+
+
+ + + + + + + diff --git a/src/lib.rs b/src/lib.rs index 5155b11..1bb5c4e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,6 +79,15 @@ pub fn gen_params() -> Vec { elapsed(start) )); + dbg(format!( + "prover_params size: {} mb", + prover_params_serialized.len() / (1024 * 1024) + )); + dbg(format!( + "verifier_params size: {} mb", + verifier_params_serialized.len() / (1024 * 1024) + )); + vec![ b64.encode(&prover_params_serialized), b64.encode(&prover_params_serialized), @@ -98,7 +107,6 @@ pub fn gen_sigs(n_steps: usize) -> Vec { #[wasm_bindgen] pub fn fold_sigs(params: Vec, sigs_pks: Vec) -> String { dbg("starting fold_sigs (rust)".to_string()); - dbg(format!("received sigs: {:?}", sigs_pks)); let poseidon_config = poseidon_canonical_config::(); @@ -164,6 +172,10 @@ pub fn fold_sigs(params: Vec, sigs_pks: Vec) -> String { ivc_proof .serialize_compressed(&mut ivc_proof_bytes) .unwrap(); + dbg(format!( + "ivc_proof size: {} mb", + ivc_proof_bytes.len() / (1024 * 1024) + )); b64.encode(ivc_proof_bytes) } diff --git a/src/utils.rs b/src/utils.rs index 8197dda..62af75a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -48,7 +48,7 @@ pub fn elapsed(start: u64) -> u64 { #[cfg(target_arch = "wasm32")] fn get_wasm_time() -> u64 { - use web_sys::{window, Performance}; + use web_sys::window; let window = window().expect("should have a window in this context"); let performance = window .performance()