diff --git a/Cargo.lock b/Cargo.lock index b39dc503..13b7de0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -127,6 +127,7 @@ dependencies = [ "blake2 0.9.2", "derivative", "digest 0.9.0", + "rayon", "tracing", ] @@ -141,6 +142,7 @@ dependencies = [ "ark-std", "derivative", "num-traits 0.2.15", + "rayon", "zeroize", ] @@ -158,6 +160,7 @@ dependencies = [ "num-bigint 0.4.3", "num-traits 0.2.15", "paste", + "rayon", "rustc_version", "zeroize", ] @@ -199,6 +202,7 @@ dependencies = [ "ark-serialize", "ark-std", "derivative", + "rayon", "tracing", ] @@ -215,6 +219,7 @@ dependencies = [ "ark-relations", "ark-serialize", "ark-std", + "rayon", ] [[package]] @@ -230,6 +235,7 @@ dependencies = [ "ark-std", "derivative", "digest 0.9.0", + "rayon", ] [[package]] @@ -261,6 +267,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.11.2", + "rayon", ] [[package]] @@ -271,11 +278,14 @@ checksum = "a71ddfa72bad1446cab7bbecb6018dbbdc9abcbc3a0065483ae5186ad2a64dcd" dependencies = [ "ark-ec", "ark-ff", + "ark-nonnative-field", "ark-poly", + "ark-relations", "ark-serialize", "ark-std", "derivative", "digest 0.9.0", + "rayon", "tracing", ] @@ -304,6 +314,7 @@ dependencies = [ "ark-ff", "ark-std", "tracing", + "tracing-subscriber", ] [[package]] @@ -347,6 +358,7 @@ checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "num-traits 0.2.15", "rand 0.8.5", + "rayon", ] [[package]] @@ -738,11 +750,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" dependencies = [ "cfg-if 0.1.10", - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-epoch", + "crossbeam-channel 0.4.4", + "crossbeam-deque 0.7.4", + "crossbeam-epoch 0.8.2", "crossbeam-queue", - "crossbeam-utils", + "crossbeam-utils 0.7.2", ] [[package]] @@ -751,21 +763,42 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" dependencies = [ - "crossbeam-utils", + "crossbeam-utils 0.7.2", "maybe-uninit", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils 0.8.14", +] + [[package]] name = "crossbeam-deque" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed" dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", + "crossbeam-epoch 0.8.2", + "crossbeam-utils 0.7.2", "maybe-uninit", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch 0.9.13", + "crossbeam-utils 0.8.14", +] + [[package]] name = "crossbeam-epoch" version = "0.8.2" @@ -774,10 +807,23 @@ checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ "autocfg", "cfg-if 0.1.10", - "crossbeam-utils", + "crossbeam-utils 0.7.2", "lazy_static", "maybe-uninit", - "memoffset", + "memoffset 0.5.6", + "scopeguard", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "crossbeam-utils 0.8.14", + "memoffset 0.7.1", "scopeguard", ] @@ -788,7 +834,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" dependencies = [ "cfg-if 0.1.10", - "crossbeam-utils", + "crossbeam-utils 0.7.2", "maybe-uninit", ] @@ -803,6 +849,15 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -1513,6 +1568,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "miniz_oxide" version = "0.5.3" @@ -1970,6 +2034,28 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" +dependencies = [ + "crossbeam-channel 0.5.6", + "crossbeam-deque 0.8.2", + "crossbeam-utils 0.8.14", + "num_cpus", +] + [[package]] name = "rdrand" version = "0.4.0" @@ -2488,6 +2574,19 @@ name = "tracing-core" version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "tracing-core", +] [[package]] name = "typed-arena" @@ -2570,6 +2669,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vec_map" version = "0.8.2" @@ -2932,6 +3037,7 @@ dependencies = [ "zokrates_circom", "zokrates_common", "zokrates_core", + "zokrates_embed", "zokrates_field", "zokrates_fs_resolver", "zokrates_interpreter", @@ -3079,6 +3185,7 @@ dependencies = [ "zokrates_circom", "zokrates_common", "zokrates_core", + "zokrates_embed", "zokrates_field", "zokrates_interpreter", "zokrates_proof_systems", diff --git a/Cargo.toml b/Cargo.toml index 76122270..d521322d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] - +resolver = "2" members = [ "zokrates_common", "zokrates_core", diff --git a/changelogs/unreleased/1261-dark64 b/changelogs/unreleased/1261-dark64 new file mode 100644 index 00000000..63a2acae --- /dev/null +++ b/changelogs/unreleased/1261-dark64 @@ -0,0 +1 @@ +Use multicore feature in ark and bellman to improve performance diff --git a/zokrates_ark/Cargo.toml b/zokrates_ark/Cargo.toml index 86508b55..6069009a 100644 --- a/zokrates_ark/Cargo.toml +++ b/zokrates_ark/Cargo.toml @@ -3,7 +3,18 @@ name = "zokrates_ark" version = "0.1.1" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +default = [] +multicore = [ + "ark-ff/parallel", + "ark-ec/parallel", + "ark-groth16/parallel", + "ark-gm17/parallel", + "ark-marlin/parallel", + "ark-poly/parallel", + "ark-poly-commit/parallel", + "ark-crypto-primitives/parallel", +] [dependencies] zokrates_field = { version = "0.5", path = "../zokrates_field", default-features = false } diff --git a/zokrates_bellman/Cargo.toml b/zokrates_bellman/Cargo.toml index 68448f4b..84e477e9 100644 --- a/zokrates_bellman/Cargo.toml +++ b/zokrates_bellman/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [features] +default = [] wasm = ["bellman/nolog", "bellman/wasm"] multicore = ["bellman/multicore", "phase2/multicore"] diff --git a/zokrates_cli/Cargo.toml b/zokrates_cli/Cargo.toml index 58fcb919..960a1b92 100644 --- a/zokrates_cli/Cargo.toml +++ b/zokrates_cli/Cargo.toml @@ -17,12 +17,13 @@ cfg-if = "0.1" clap = "2.26.2" serde_cbor = "0.11.2" regex = "0.2" -zokrates_field = { version = "0.5", path = "../zokrates_field", default-features = false } +zokrates_field = { version = "0.5", path = "../zokrates_field", features = ["multicore"] } zokrates_abi = { version = "0.1", path = "../zokrates_abi" } zokrates_core = { version = "0.7", path = "../zokrates_core", default-features = false } zokrates_ast = { version = "0.1", path = "../zokrates_ast", default-features = false } zokrates_interpreter = { version = "0.1", path = "../zokrates_interpreter", default-features = false } zokrates_circom = { version = "0.1", path = "../zokrates_circom", default-features = false } +zokrates_embed = { version = "0.1", path = "../zokrates_embed", features = ["multicore"] } typed-arena = "1.4.1" zokrates_fs_resolver = { version = "0.5", path = "../zokrates_fs_resolver"} zokrates_common = { version = "0.1", path = "../zokrates_common", default-features = false } @@ -39,8 +40,8 @@ sha2 = "0.10.0" # Backends zokrates_proof_systems = { version = "0.1", path = "../zokrates_proof_systems", default-features = false } -zokrates_ark = { version = "0.1", path = "../zokrates_ark", default-features = false, optional = true } -zokrates_bellman = { version = "0.1", path = "../zokrates_bellman", default-features = false, optional = true } +zokrates_ark = { version = "0.1", path = "../zokrates_ark", features = ["multicore"], optional = true } +zokrates_bellman = { version = "0.1", path = "../zokrates_bellman", features = ["multicore"], optional = true } [dev-dependencies] glob = "0.2.11" diff --git a/zokrates_embed/Cargo.toml b/zokrates_embed/Cargo.toml index 9249b907..9b1da6a7 100644 --- a/zokrates_embed/Cargo.toml +++ b/zokrates_embed/Cargo.toml @@ -8,8 +8,17 @@ edition = "2018" default = ["ark", "bellman"] ark = ["ark-bls12-377", "ark-bw6-761", "ark-gm17", "ark-relations", "ark-crypto-primitives", "ark-r1cs-std", "ark-std", "ark-ec", "ark-ff", "sapling-crypto_ce"] bellman = ["bellman_ce"] -wasm = ["bellman_ce/wasm", "sapling-crypto_ce/wasm"] -multicore = ["bellman_ce/multicore", "sapling-crypto_ce/multicore"] +wasm = ["bellman_ce/nolog", "bellman_ce/wasm", "sapling-crypto_ce/wasm"] +multicore = [ + "bellman_ce/multicore", + "sapling-crypto_ce/multicore", + "ark-gm17/parallel", + "ark-crypto-primitives/parallel", + "ark-r1cs-std/parallel", + "ark-std/parallel", + "ark-ec/parallel", + "ark-ff/parallel" +] [dependencies] zokrates_field = { version = "0.5.0", path = "../zokrates_field", default-features = false } diff --git a/zokrates_field/Cargo.toml b/zokrates_field/Cargo.toml index 87c98f36..65825f00 100644 --- a/zokrates_field/Cargo.toml +++ b/zokrates_field/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" [features] default = ["bellman"] bellman = ["bellman_ce"] +multicore = ["ark-ff/parallel", "ark-ec/parallel"] [dependencies] serde = "1.0" diff --git a/zokrates_js/Cargo.toml b/zokrates_js/Cargo.toml index 7d60150e..6c499fd1 100644 --- a/zokrates_js/Cargo.toml +++ b/zokrates_js/Cargo.toml @@ -14,21 +14,26 @@ serde_json = { version = "1.0", features = ["preserve_order"] } wasm-bindgen = { version = "0.2.46", features = ["serde-serialize"] } typed-arena = "1.4.1" lazy_static = "1.4.0" +zokrates_field = { path = "../zokrates_field" } rand_0_8 = { version = "0.8", package = "rand" } getrandom = { version = "0.2.8", features = ["js"] } zokrates_core = { path = "../zokrates_core", default-features = false, features = ["ark", "bellman"] } -zokrates_ark = { path = "../zokrates_ark", default-features = false} -zokrates_bellman = { path = "../zokrates_bellman", default-features = false} +zokrates_ark = { path = "../zokrates_ark", default-features = false } +zokrates_embed = { path = "../zokrates_embed", default-features = false } +zokrates_bellman = { path = "../zokrates_bellman", default-features = false } zokrates_common = { path = "../zokrates_common", default-features = false, features = ["ark", "bellman"] } zokrates_proof_systems = { path = "../zokrates_proof_systems", default-features = false } zokrates_ast = { path = "../zokrates_ast", default-features = false, features = ["ark", "bellman"] } zokrates_interpreter = { path = "../zokrates_interpreter", default-features = false, features = ["ark", "bellman"] } -zokrates_field = { path = "../zokrates_field", default-features = false } zokrates_abi = { path = "../zokrates_abi", default-features = false, features = ["ark", "bellman"] } zokrates_circom = { path = "../zokrates_circom" } console_error_panic_hook = "0.1.6" indexmap = "~1.6.2" # see https://github.com/rustwasm/wasm-bindgen/issues/2770#issuecomment-1041102532 +[target.'cfg(target_arch = "wasm32")'.dependencies] +zokrates_embed = { path = "../zokrates_embed", features = ["wasm"] } +zokrates_bellman = { path = "../zokrates_bellman", features = ["wasm"] } + [build-dependencies] json = "0.12.4" walkdir = "2.3.2" diff --git a/zokrates_js/package.json b/zokrates_js/package.json index 18ac0e5b..27967df0 100644 --- a/zokrates_js/package.json +++ b/zokrates_js/package.json @@ -33,7 +33,7 @@ "prebuild": "npm install", "build": "npm run wasm-pack -- --release && npm run patch && npm run bundle", "build:dev": "npm run wasm-pack -- --dev && npm run patch && npm run bundle", - "pretest": "npm run build", + "pretest": "npm run build:dev", "test": "npm run run-tests", "run-tests": "mocha --timeout 100000 --recursive tests", "patch": "node patch.js", diff --git a/zokrates_js/tests/tests.js b/zokrates_js/tests/tests.js index e067d2fa..ad43c5db 100644 --- a/zokrates_js/tests/tests.js +++ b/zokrates_js/tests/tests.js @@ -38,25 +38,21 @@ describe("tests", () => { describe("compilation", () => { it("should compile", () => { - assert.doesNotThrow(() => { - const artifacts = zokratesProvider.compile( - "def main() -> field { return 42; }" - ); - assert.ok(artifacts); - assert.ok(artifacts.snarkjs === undefined); - assert.equal(artifacts.constraintCount, 1); - }); + const artifacts = zokratesProvider.compile( + "def main() -> field { return 42; }" + ); + assert.ok(artifacts); + assert.ok(artifacts.snarkjs === undefined); + assert.equal(artifacts.constraintCount, 1); }); it("should compile with snarkjs output", () => { - assert.doesNotThrow(() => { - const artifacts = zokratesProvider.compile( - "def main() -> field { return 42; }", - { snarkjs: true } - ); - assert.ok(artifacts); - assert.ok(artifacts.snarkjs.program !== undefined); - }); + const artifacts = zokratesProvider.compile( + "def main() -> field { return 42; }", + { snarkjs: true } + ); + assert.ok(artifacts); + assert.ok(artifacts.snarkjs.program !== undefined); }); it("should throw on invalid code", () => { @@ -64,26 +60,22 @@ describe("tests", () => { }); it("should resolve stdlib module", () => { - assert.doesNotThrow(() => { - const code = `import "utils/pack/bool/unpack" as unpack;\ndef main() {}`; - zokratesProvider.compile(code); - }); + const code = `import "utils/pack/bool/unpack_unchecked";\ndef main() {}`; + zokratesProvider.compile(code); }); it("should resolve user module", () => { - assert.doesNotThrow(() => { - const code = - 'import "./test" as test;\ndef main() -> field { return test(); }'; - const options = { - resolveCallback: (_, path) => { - return { - source: "def main() -> field { return 1; }", - location: path, - }; - }, - }; - zokratesProvider.compile(code, options); - }); + const code = + 'import "./test" as test;\ndef main() -> field { return test(); }'; + const options = { + resolveCallback: (_, path) => { + return { + source: "def main() -> field { return 1; }", + location: path, + }; + }, + }; + zokratesProvider.compile(code, options); }); it("should throw on unresolved module", () => { @@ -97,29 +89,25 @@ describe("tests", () => { describe("computation", () => { it("should compute with valid inputs", () => { - assert.doesNotThrow(() => { - const code = "def main(private field a) -> field { return a * a; }"; - const artifacts = zokratesProvider.compile(code); - const result = zokratesProvider.computeWitness(artifacts, ["2"]); - const output = JSON.parse(result.output); - assert.deepEqual(output, "4"); - assert.ok(result.snarkjs === undefined); - }); + const code = "def main(private field a) -> field { return a * a; }"; + const artifacts = zokratesProvider.compile(code); + const result = zokratesProvider.computeWitness(artifacts, ["2"]); + const output = JSON.parse(result.output); + assert.deepEqual(output, "4"); + assert.ok(result.snarkjs === undefined); }); it("should compute with valid inputs with snarkjs output", () => { - assert.doesNotThrow(() => { - const code = "def main(private field a) -> field { return a * a; }"; - const artifacts = zokratesProvider.compile(code); + const code = "def main(private field a) -> field { return a * a; }"; + const artifacts = zokratesProvider.compile(code); - const result = zokratesProvider.computeWitness(artifacts, ["2"], { - snarkjs: true, - }); - - const output = JSON.parse(result.output); - assert.deepEqual(output, "4"); - assert.ok(result.snarkjs.witness !== undefined); + const result = zokratesProvider.computeWitness(artifacts, ["2"], { + snarkjs: true, }); + + const output = JSON.parse(result.output); + assert.deepEqual(output, "4"); + assert.ok(result.snarkjs.witness !== undefined); }); it("should throw on invalid input count", () => { @@ -139,19 +127,17 @@ describe("tests", () => { }); it("should log in debug", () => { - assert.doesNotThrow(() => { - const code = 'def main() { log("{}", 1f); log("{}", 2f); return; }'; - const artifacts = zokratesProvider.compile(code, { - config: { debug: true }, - }); - let logs = []; - zokratesProvider.computeWitness(artifacts, [], { - logCallback: (l) => { - logs.push(l); - }, - }); - assert.deepEqual(logs, ['"1"', '"2"']); + const code = 'def main() { log("{}", 1f); log("{}", 2f); return; }'; + const artifacts = zokratesProvider.compile(code, { + config: { debug: true }, }); + let logs = []; + zokratesProvider.computeWitness(artifacts, [], { + logCallback: (l) => { + logs.push(l); + }, + }); + assert.deepEqual(logs, ['"1"', '"2"']); }); }); @@ -167,61 +153,53 @@ describe("tests", () => { }); it("compile", () => { - assert.doesNotThrow(() => { - const code = `def main(private field a, field b) -> bool { - bool check = if (a == 0) { true } else { a * a == b }; - assert(check); - return true; - }`; - artifacts = provider.compile(code, { snarkjs: true }); - }); + const code = `def main(private field a, field b) -> bool { + bool check = if (a == 0) { true } else { a * a == b }; + assert(check); + return true; + }`; + artifacts = provider.compile(code, { snarkjs: true }); }); it("compute witness", () => { - assert.doesNotThrow(() => { - computationResult = provider.computeWitness( - artifacts, - ["337", "113569"], - { - snarkjs: true, - } - ); - }); + computationResult = provider.computeWitness( + artifacts, + ["337", "113569"], + { + snarkjs: true, + } + ); }); it("setup", () => { - assert.doesNotThrow(() => { - if (options.scheme === "marlin") { - const srs = provider.universalSetup(4); - const srs2 = provider.universalSetup(4); - // second call should return a new srs - assert.notDeepEqual(srs, srs2); - keypair = provider.setupWithSrs(srs, artifacts.program); - } else { - keypair = provider.setup(artifacts.program); - const keypair2 = provider.setup(artifacts.program); - // second call should return a new keypair - assert.notDeepEqual(keypair, keypair2); - } - }); + if (options.scheme === "marlin") { + const srs = provider.universalSetup(4); + const srs2 = provider.universalSetup(4); + // second call should return a new srs + assert.notDeepEqual(srs, srs2); + keypair = provider.setupWithSrs(srs, artifacts.program); + } else { + keypair = provider.setup(artifacts.program); + const keypair2 = provider.setup(artifacts.program); + // second call should return a new keypair + assert.notDeepEqual(keypair, keypair2); + } }); it("setup with user-provided entropy", () => { - assert.doesNotThrow(() => { - let entropy = "f5c51ca46c331965"; - if (options.scheme === "marlin") { - const srs = provider.universalSetup(4, entropy); - const srs2 = provider.universalSetup(4, entropy); - // second call with the same entropy should return the same srs - assert.deepEqual(srs, srs2); - keypair = provider.setupWithSrs(srs, artifacts.program); - } else { - keypair = provider.setup(artifacts.program, entropy); - const keypair2 = provider.setup(artifacts.program, entropy); - // second call with the same entropy should return the same keypair - assert.deepEqual(keypair, keypair2); - } - }); + let entropy = "f5c51ca46c331965"; + if (options.scheme === "marlin") { + const srs = provider.universalSetup(4, entropy); + const srs2 = provider.universalSetup(4, entropy); + // second call with the same entropy should return the same srs + assert.deepEqual(srs, srs2); + keypair = provider.setupWithSrs(srs, artifacts.program); + } else { + keypair = provider.setup(artifacts.program, entropy); + const keypair2 = provider.setup(artifacts.program, entropy); + // second call with the same entropy should return the same keypair + assert.deepEqual(keypair, keypair2); + } }); if (options.scheme === "g16" && options.curve == "bn128") { @@ -244,54 +222,48 @@ describe("tests", () => { if (options.curve === "bn128" && ["g16", "gm17"].includes(options.scheme)) { it("export verifier", () => { - assert.doesNotThrow(() => { - let verifier = provider.exportSolidityVerifier(keypair.vk); - assert.ok(verifier.includes("contract")); - }); + let verifier = provider.exportSolidityVerifier(keypair.vk); + assert.ok(verifier.includes("contract")); }); } it("generate proof", () => { - assert.doesNotThrow(() => { - proof = provider.generateProof( - artifacts.program, - computationResult.witness, - keypair.pk - ); - assert.ok(proof !== undefined); - assert.equal(proof.inputs.length, 2); + proof = provider.generateProof( + artifacts.program, + computationResult.witness, + keypair.pk + ); + assert.ok(proof !== undefined); + assert.equal(proof.inputs.length, 2); - // second call should return a new proof - let proof2 = provider.generateProof( - artifacts.program, - computationResult.witness, - keypair.pk - ); - assert.notDeepEqual(proof, proof2); - }); + // second call should return a new proof + let proof2 = provider.generateProof( + artifacts.program, + computationResult.witness, + keypair.pk + ); + assert.notDeepEqual(proof, proof2); }); it("generate proof with user-provided entropy", () => { - assert.doesNotThrow(() => { - let entropy = "326e2c864f414ffb"; - proof = provider.generateProof( - artifacts.program, - computationResult.witness, - keypair.pk, - entropy - ); - assert.ok(proof !== undefined); - assert.equal(proof.inputs.length, 2); + let entropy = "326e2c864f414ffb"; + proof = provider.generateProof( + artifacts.program, + computationResult.witness, + keypair.pk, + entropy + ); + assert.ok(proof !== undefined); + assert.equal(proof.inputs.length, 2); - // second call with the same entropy should return the same proof - let proof2 = provider.generateProof( - artifacts.program, - computationResult.witness, - keypair.pk, - entropy - ); - assert.deepEqual(proof, proof2); - }); + // second call with the same entropy should return the same proof + let proof2 = provider.generateProof( + artifacts.program, + computationResult.witness, + keypair.pk, + entropy + ); + assert.deepEqual(proof, proof2); }); if (options.scheme === "g16" && options.curve == "bn128") { @@ -319,9 +291,7 @@ describe("tests", () => { } it("verify", () => { - assert.doesNotThrow(() => { - assert(provider.verify(keypair.vk, proof) === true); - }); + assert(provider.verify(keypair.vk, proof) === true); }); };