mirror of
https://github.com/vacp2p/zerokit.git
synced 2026-01-09 13:47:58 -05:00
Compare commits
9 Commits
rustup-rem
...
feat/paral
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
936b7fc3cb | ||
|
|
cf7e2de380 | ||
|
|
4fbb1525ea | ||
|
|
a7f6d63060 | ||
|
|
95f895c64c | ||
|
|
228ccba90a | ||
|
|
e04fa2c7a5 | ||
|
|
6539bb4d5e | ||
|
|
5394050c0b |
5
rln-wasm/.cargo/config
Normal file
5
rln-wasm/.cargo/config
Normal file
@@ -0,0 +1,5 @@
|
||||
[target.wasm32-unknown-unknown]
|
||||
rustflags = ["-C", "target-feature=+atomics,+bulk-memory,+mutable-globals"]
|
||||
|
||||
[unstable]
|
||||
build-std = ["panic_abort", "std"]
|
||||
@@ -11,12 +11,13 @@ crate-type = ["cdylib", "rlib"]
|
||||
default = ["console_error_panic_hook"]
|
||||
|
||||
[dependencies]
|
||||
rln = { path = "../rln", default-features = false, features = ["wasm"] }
|
||||
rln = { path = "../rln", default-features = false, features = ["wasm", "parallel"] }
|
||||
num-bigint = { version = "0.4", default-features = false, features = ["rand", "serde"] }
|
||||
wasmer = { version = "2.3", default-features = false, features = ["js", "std"] }
|
||||
wasmer = { version = "3.1.1", default-features = false, features = ["js", "std"] }
|
||||
web-sys = {version = "0.3", features=["console"]}
|
||||
getrandom = { version = "0.2.7", default-features = false, features = ["js"] }
|
||||
wasm-bindgen = "0.2.63"
|
||||
wasm-bindgen-rayon = "1.0.3"
|
||||
serde-wasm-bindgen = "0.4"
|
||||
js-sys = "0.3.59"
|
||||
serde_json = "1.0.85"
|
||||
|
||||
@@ -14,7 +14,7 @@ dependencies = [
|
||||
|
||||
[tasks.test]
|
||||
command = "wasm-pack"
|
||||
args = ["test", "--release", "--node"]
|
||||
args = ["test", "--release", "--firefox", "--headless"]
|
||||
dependencies = ["build"]
|
||||
|
||||
[tasks.login]
|
||||
|
||||
1
rln-wasm/rust-toolchain
Normal file
1
rln-wasm/rust-toolchain
Normal file
@@ -0,0 +1 @@
|
||||
nightly-2022-12-12
|
||||
@@ -8,6 +8,8 @@ use num_bigint::BigInt;
|
||||
use rln::public::RLN;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
pub use wasm_bindgen_rayon::init_thread_pool;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn init_panic_hook() {
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const fs = require("fs");
|
||||
const rln_wasm = require("/pkg/rln_wasm.js");
|
||||
|
||||
// Utils functions for loading circom witness calculator and reading files from test
|
||||
|
||||
@@ -7,8 +8,12 @@ module.exports = {
|
||||
return fs.readFileSync(path);
|
||||
},
|
||||
|
||||
calculateWitness: async function(circom_path, inputs){
|
||||
const wc = require("resources/witness_calculator.js");
|
||||
initWasm: async function() {
|
||||
await rln_wasm();
|
||||
},
|
||||
|
||||
calculateWitness: async function(circom_path, inputs) {
|
||||
const wc = require("/resources/witness_calculator.js");
|
||||
const wasmFile = fs.readFileSync(circom_path);
|
||||
const wasmFileBuffer = wasmFile.slice(wasmFile.byteOffset, wasmFile.byteOffset + wasmFile.byteLength);
|
||||
const witnessCalculator = await wc(wasmFileBuffer);
|
||||
|
||||
@@ -8,18 +8,27 @@ mod tests {
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsValue;
|
||||
use wasm_bindgen_test::wasm_bindgen_test;
|
||||
use wasm_bindgen_rayon::init_thread_pool;
|
||||
|
||||
#[wasm_bindgen(module = "src/utils.js")]
|
||||
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[wasm_bindgen(module = "/src/utils.js")]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(catch)]
|
||||
fn read_file(path: &str) -> Result<Uint8Array, JsValue>;
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
async fn calculateWitness(circom_path: &str, input: Object) -> Result<JsValue, JsValue>;
|
||||
async fn initWasm() -> Result<(), JsValue>;
|
||||
|
||||
#[wasm_bindgen(catch)]
|
||||
async fn calculateWitness(circom_path: &str, inputs: Object) -> Result<JsValue, JsValue>;
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
pub async fn test_basic_flow() {
|
||||
initWasm().await.unwrap();
|
||||
wasm_bindgen_futures::JsFuture::from(init_thread_pool(4)).await.unwrap();
|
||||
|
||||
let tree_height = TEST_TREE_HEIGHT;
|
||||
let circom_path = format!("../rln/resources/tree_height_{TEST_TREE_HEIGHT}/rln.wasm");
|
||||
let zkey_path = format!("../rln/resources/tree_height_{TEST_TREE_HEIGHT}/rln_final.zkey");
|
||||
|
||||
@@ -37,14 +37,13 @@ once_cell = "1.14.0"
|
||||
rand = "0.8"
|
||||
rand_chacha = "0.3.1"
|
||||
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
|
||||
utils = { path = "../utils/", default-features = false }
|
||||
utils = { path = "../utils", default-features = false }
|
||||
|
||||
# serialization
|
||||
serde_json = "1.0.48"
|
||||
|
||||
[dev-dependencies]
|
||||
pmtree = { git = "https://github.com/Rate-Limiting-Nullifier/pmtree" }
|
||||
sled = "0.34.7"
|
||||
|
||||
[features]
|
||||
default = ["parallel", "wasmer/sys-default"]
|
||||
|
||||
Reference in New Issue
Block a user