Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ hex = { version = "0.4", features = ["serde"] }
iai = "0.1"
itertools = "0.12.1"
js-sys = "=0.3.64"
web-sys = { version = "0.3.64", features = ["DedicatedWorkerGlobalScope", "console","MessageEvent"] }
libc = "=0.2.169"
libflate = "2"
log = "0.4.20"
Expand Down
1 change: 1 addition & 0 deletions plonk-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ base64.workspace = true
console_error_panic_hook.workspace = true
getrandom = { workspace = true, features = ["js"] }
js-sys.workspace = true
web-sys.workspace = true
libc.workspace = true
num-bigint.workspace = true
once_cell.workspace = true
Expand Down
19 changes: 19 additions & 0 deletions plonk-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ use wasm_bindgen::prelude::*;

mod wasm_vector;

use wasm_bindgen::JsValue;

use wasm_bindgen::JsCast;
use web_sys;

fn send_message_from_worker(msg: &JsValue) {
// TODO: Use a more structured approach and msg format
// also TODO: ideally use worker communication - look into how web_sys does it
// right now this looks to the console right away, which is cool, but having actual worker comms is more useful
web_sys::console::log_1(msg);
postMessageToMain(msg);
}

#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_name = postMessage)]
fn postMessageToMain(data: &JsValue);
}

#[wasm_bindgen]
extern "C" {
pub fn alert(s: &str);
Expand Down
18 changes: 17 additions & 1 deletion plonk-wasm/src/pasta_fp_plonk_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,16 @@ pub fn caml_pasta_fp_plonk_index_create(
lazy_mode: bool,
) -> Result<WasmPastaFpPlonkIndex, JsError> {
console_error_panic_hook::set_once();
let index = crate::rayon::run_in_pool(|| {
super::send_message_from_worker(&JsValue::from_str("hello from Rayon thread!"));
let index: Result<
ProverIndex<
ark_ec::short_weierstrass::Affine<VestaParameters>,
OpeningProof<ark_ec::short_weierstrass::Affine<VestaParameters>>,
>,
&str,
> = crate::rayon::run_in_pool(|| {
super::send_message_from_worker(&JsValue::from_str("hello from Rayon worker!"));

// flatten the permutation information (because OCaml has a different way of keeping track of permutations)
let gates: Vec<_> = gates
.0
Expand All @@ -123,6 +132,12 @@ pub fn caml_pasta_fp_plonk_index_create(
})
.collect();

super::send_message_from_worker(&JsValue::from_str("hello from Rayon again!"));
super::send_message_from_worker(&JsValue::from_str(&format!(
"logging something from rayon {:?}",
gates[0].typ
)));

let rust_runtime_table_cfgs: Vec<RuntimeTableCfg<Fp>> =
runtime_table_cfgs.into_iter().map(Into::into).collect();

Expand Down Expand Up @@ -160,6 +175,7 @@ pub fn caml_pasta_fp_plonk_index_create(
srs.0.clone(),
lazy_mode,
);

// Compute and cache the verifier index digest
index.compute_verifier_index_digest::<DefaultFqSponge<VestaParameters, PlonkSpongeConstantsKimchi>>();
Ok(index)
Expand Down
Loading