diff --git a/Cargo.lock b/Cargo.lock index 4f4c991bf..c080f0a4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,7 +182,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" dependencies = [ - "quote 1.0.26", + "quote 1.0.36", "syn 1.0.109", ] @@ -194,7 +194,7 @@ checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" dependencies = [ "num-bigint 0.4.3", "num-traits 0.2.15", - "quote 1.0.26", + "quote 1.0.36", "syn 1.0.109", ] @@ -356,8 +356,8 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -835,8 +835,8 @@ checksum = "c6dd675567eb3e35787bd2583d129e85fabc7503b0a093d08c51198a307e2091" dependencies = [ "heck", "proc-macro-error", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1048,7 +1048,7 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ - "quote 1.0.26", + "quote 1.0.36", "syn 1.0.109", ] @@ -1058,8 +1058,8 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1292,7 +1292,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5109f6bc9cd57feda665da326f3f6c57e0498c8fe9f7d12d7b8abc96719ca91b" dependencies = [ "execute-command-tokens", - "quote 1.0.26", + "quote 1.0.36", "syn 1.0.109", ] @@ -1324,8 +1324,8 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", "synstructure", ] @@ -1391,8 +1391,8 @@ dependencies = [ "num-bigint 0.3.3", "num-integer", "num-traits 0.2.15", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1405,8 +1405,8 @@ dependencies = [ "num-bigint 0.2.6", "num-integer", "num-traits 0.2.15", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -1748,8 +1748,8 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2165,8 +2165,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2247,8 +2247,8 @@ checksum = "451e629bf49b750254da26132f1a5a9d11fd8a95a3df51d15c4abd1ba154cb6c" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2352,8 +2352,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", "version_check", ] @@ -2364,8 +2364,8 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", "syn-mid", "version_check", @@ -2388,9 +2388,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -2417,11 +2417,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ - "proc-macro2 1.0.56", + "proc-macro2 1.0.85", ] [[package]] @@ -2739,13 +2739,24 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.160" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_cbor" version = "0.11.2" @@ -2758,13 +2769,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", ] [[package]] @@ -2953,19 +2964,19 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.15" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "unicode-ident", ] @@ -2975,8 +2986,8 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -2986,8 +2997,8 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", "unicode-xid 0.2.4", ] @@ -3054,9 +3065,9 @@ version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", ] [[package]] @@ -3113,8 +3124,8 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -3143,8 +3154,8 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b79e2e9c9ab44c6d7c20d5976961b47e8f49ac199154daa514b77cd1ab536625" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", "syn 1.0.109", ] @@ -3271,9 +3282,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.81" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if 1.0.0", "serde", @@ -3283,16 +3294,16 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.81" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", - "lazy_static", "log", - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "once_cell", + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", "wasm-bindgen-shared", ] @@ -3310,32 +3321,32 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.81" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ - "quote 1.0.26", + "quote 1.0.36", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.81" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 1.0.109", + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.81" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-bindgen-test" @@ -3357,8 +3368,8 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88ad594bf33e73cafcac2ae9062fc119d4f75f9c77e25022f91c9a64bd5b6463" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", + "proc-macro2 1.0.85", + "quote 1.0.36", ] [[package]] @@ -3585,9 +3596,9 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2 1.0.56", - "quote 1.0.26", - "syn 2.0.15", + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", ] [[package]] @@ -3911,6 +3922,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "serde", + "serde-wasm-bindgen", "serde_json", "toml", "typed-arena", diff --git a/zokrates_ark/src/lib.rs b/zokrates_ark/src/lib.rs index dba49e9a9..537bd80aa 100644 --- a/zokrates_ark/src/lib.rs +++ b/zokrates_ark/src/lib.rs @@ -91,7 +91,7 @@ impl<'a, T: Field + ArkFieldExtensions, I: IntoIterator> match cs { ConstraintSystemRef::CS(rc) => { let mut cs = rc.borrow_mut(); - symbols.extend(self.program.arguments.iter().enumerate().map(|(_, p)| { + symbols.extend(self.program.arguments.iter().map(|p| { let wire = match p.private { true => cs.new_witness_variable(|| { Ok(witness diff --git a/zokrates_ast/src/common/embed.rs b/zokrates_ast/src/common/embed.rs index 72dbd9505..b5352c03a 100644 --- a/zokrates_ast/src/common/embed.rs +++ b/zokrates_ast/src/common/embed.rs @@ -582,8 +582,7 @@ pub fn unpack_to_bitwidth<'ast, T: Field>( #[allow(clippy::needless_collect)] let outputs: Vec<_> = directive_outputs .iter() - .enumerate() - .map(|(_, o)| FlatExpression::identifier(*o)) + .map(|o| FlatExpression::identifier(*o)) .collect(); // o253, o252, ... o{253 - (bit_width - 1)} are bits diff --git a/zokrates_ast/src/common/position.rs b/zokrates_ast/src/common/position.rs index a817f0749..20a1282c4 100644 --- a/zokrates_ast/src/common/position.rs +++ b/zokrates_ast/src/common/position.rs @@ -173,7 +173,7 @@ impl LocalSourceSpan { impl Position { pub fn col(&self, delta: isize) -> Position { - assert!(self.col <= isize::max_value() as usize); + assert!(self.col <= isize::MAX as usize); assert!(self.col as isize >= delta); Position { line: self.line, diff --git a/zokrates_core/src/optimizer/redefinition.rs b/zokrates_core/src/optimizer/redefinition.rs index 55880465a..0fd8e536b 100644 --- a/zokrates_core/src/optimizer/redefinition.rs +++ b/zokrates_core/src/optimizer/redefinition.rs @@ -231,7 +231,7 @@ impl<'ast, T: Field> Folder<'ast, T> for RedefinitionOptimizer { match lc .value .iter() - .any(|(variable, _)| self.substitution.get(variable).is_some()) + .any(|(variable, _)| self.substitution.contains_key(variable)) { true => // for each summand, check if it is equal to a linear term in our substitution, otherwise keep it as is diff --git a/zokrates_js/Cargo.toml b/zokrates_js/Cargo.toml index 2ff4f49e0..223f19d32 100644 --- a/zokrates_js/Cargo.toml +++ b/zokrates_js/Cargo.toml @@ -11,7 +11,8 @@ crate-type = ["cdylib"] js-sys = "=0.3.58" serde = { version = "^1.0.59", features = ["derive"] } serde_json = { version = "1.0", features = ["preserve_order"] } -wasm-bindgen = { version = "=0.2.81", features = ["serde-serialize"] } +wasm-bindgen = { version = "=0.2.92", features = ["serde-serialize"] } +serde-wasm-bindgen = { version = "0.6"} typed-arena = "1.4.1" lazy_static = "1.4.0" zokrates_field = { path = "../zokrates_field" } @@ -37,4 +38,4 @@ zokrates_bellman = { path = "../zokrates_bellman", features = ["wasm"] } [build-dependencies] json = "0.12.4" walkdir = "2.3.2" -toml = "0.5.9" \ No newline at end of file +toml = "0.5.9" diff --git a/zokrates_js/src/lib.rs b/zokrates_js/src/lib.rs index d70e145bb..ce67162c9 100644 --- a/zokrates_js/src/lib.rs +++ b/zokrates_js/src/lib.rs @@ -7,6 +7,7 @@ use crate::util::normalize_path; use rand_0_8::{rngs::StdRng, SeedableRng}; use serde::{Deserialize, Serialize}; use serde_json::to_string_pretty; +use serde_wasm_bindgen::{from_value, to_value}; use std::convert::TryFrom; use std::io::{Cursor, Write}; use std::path::{Component, PathBuf}; @@ -57,7 +58,7 @@ impl CompilationResult { } pub fn abi(&self) -> JsValue { - JsValue::from_serde(&self.abi).unwrap() + to_value(&self.abi).unwrap() } pub fn snarkjs_program(&self) -> Option { @@ -69,7 +70,7 @@ impl CompilationResult { } pub fn constraint_count(&self) -> JsValue { - JsValue::from_serde(&self.constraint_count).unwrap() + to_value(&self.constraint_count).unwrap() } } @@ -189,7 +190,7 @@ impl<'a> Resolver for JsResolver<'a> { ))); } - let result: serde_json::Value = value.into_serde().unwrap(); + let result: serde_json::Value = from_value(value).unwrap(); let source = result .get("source") .ok_or_else(|| Error::new("missing field `source`"))? @@ -258,7 +259,7 @@ mod internal { config: JsValue, ) -> Result { let resolver = JsResolver::new(resolve_callback); - let config: serde_json::Value = config.into_serde().unwrap(); + let config: serde_json::Value = from_value(config).unwrap(); let with_snarkjs_program = config .get("snarkjs") .map(|v| *v == serde_json::Value::Bool(true)) @@ -308,14 +309,14 @@ mod internal { ) -> Result { let input = args.as_string().unwrap(); - let config: serde_json::Value = config.into_serde().unwrap(); + let config: serde_json::Value = from_value(config).unwrap(); let with_snarkjs_witness = config .get("snarkjs") .map(|v| *v == serde_json::Value::Bool(true)) .unwrap_or(false); let (inputs, signature) = if abi.is_object() { - let abi: Abi = abi.into_serde().map_err(|err| { + let abi: Abi = from_value(abi).map_err(|err| { JsValue::from_str(&format!("Could not deserialize `abi`: {}", err)) })?; @@ -389,7 +390,7 @@ mod internal { let keypair = B::setup(program, rng); let tagged_keypair = TaggedKeypair::::new(keypair); Keypair { - vk: JsValue::from_serde(&tagged_keypair.vk).unwrap(), + vk: to_value(&tagged_keypair.vk).unwrap(), pk: tagged_keypair.pk, } } @@ -407,7 +408,7 @@ mod internal { let keypair = B::setup(srs.to_vec(), program).map_err(|e| JsValue::from_str(&e))?; let tagged_keypair = TaggedKeypair::::new(keypair); Ok(Keypair { - vk: JsValue::from_serde(&tagged_keypair.vk).unwrap(), + vk: to_value(&tagged_keypair.vk).unwrap(), pk: tagged_keypair.pk, }) } @@ -434,7 +435,7 @@ mod internal { .map_err(|err| JsValue::from_str(&format!("Could not read witness: {}", err)))?; let proof = B::generate_proof(prog, ir_witness, pk, rng); - Ok(JsValue::from_serde(&TaggedProof::::new(proof.proof, proof.inputs)).unwrap()) + Ok(to_value(&TaggedProof::::new(proof.proof, proof.inputs)).unwrap()) } pub fn verify, B: Backend>( @@ -447,7 +448,7 @@ mod internal { serde_json::from_value(proof).map_err(|e| JsValue::from_str(&e.to_string()))?; let result = B::verify(vk, proof); - Ok(JsValue::from_serde(&result).unwrap()) + Ok(to_value(&result).unwrap()) } pub fn format_proof>( @@ -474,7 +475,7 @@ mod internal { json!([proof_vec]) }; - Ok(JsValue::from_serde(&result).unwrap()) + Ok(to_value(&result).unwrap()) } pub fn export_solidity_verifier>( @@ -544,9 +545,7 @@ pub fn compute_witness( #[wasm_bindgen] pub fn export_solidity_verifier(vk: JsValue) -> Result { - let vk: serde_json::Value = vk - .into_serde() - .map_err(|e| JsValue::from_str(&e.to_string()))?; + let vk: serde_json::Value = from_value(vk).map_err(|e| JsValue::from_str(&e.to_string()))?; let curve = CurveParameter::try_from( vk["curve"] @@ -577,7 +576,7 @@ pub fn export_solidity_verifier(vk: JsValue) -> Result { #[wasm_bindgen] pub fn setup(program: &[u8], entropy: JsValue, options: JsValue) -> Result { - let options: serde_json::Value = options.into_serde().unwrap(); + let options: serde_json::Value = from_value(options).unwrap(); let backend = BackendParameter::try_from( options["backend"] @@ -649,7 +648,7 @@ pub fn setup(program: &[u8], entropy: JsValue, options: JsValue) -> Result Result { - let options: serde_json::Value = options.into_serde().unwrap(); + let options: serde_json::Value = from_value(options).unwrap(); let scheme = SchemeParameter::try_from( options["scheme"] @@ -725,7 +724,7 @@ pub fn generate_proof( entropy: JsValue, options: JsValue, ) -> Result { - let options: serde_json::Value = options.into_serde().unwrap(); + let options: serde_json::Value = from_value(options).unwrap(); let backend = BackendParameter::try_from( options["backend"] @@ -812,7 +811,7 @@ pub fn generate_proof( #[wasm_bindgen] pub fn verify(vk: JsValue, proof: JsValue, options: JsValue) -> Result { - let options: serde_json::Value = options.into_serde().unwrap(); + let options: serde_json::Value = from_value(options).unwrap(); let backend = BackendParameter::try_from( options["backend"] .as_str() @@ -820,8 +819,8 @@ pub fn verify(vk: JsValue, proof: JsValue, options: JsValue) -> Result Result Result { - let proof: serde_json::Value = proof.into_serde().unwrap(); + let proof: serde_json::Value = from_value(proof).unwrap(); let curve = CurveParameter::try_from( proof["curve"] diff --git a/zokrates_proof_systems/src/lib.rs b/zokrates_proof_systems/src/lib.rs index da48851c8..82b1c70c8 100644 --- a/zokrates_proof_systems/src/lib.rs +++ b/zokrates_proof_systems/src/lib.rs @@ -13,6 +13,7 @@ use zokrates_ast::ir; use rand_0_8::{CryptoRng, RngCore}; use serde::{Deserialize, Serialize}; +use std::fmt::Display; use std::io::{Read, Write}; use zokrates_field::Field; @@ -55,11 +56,11 @@ pub enum G2Affine { Fq(G2AffineFq), } -impl ToString for G2Affine { - fn to_string(&self) -> String { +impl Display for G2Affine { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - G2Affine::Fq(e) => e.to_string(), - G2Affine::Fq2(e) => e.to_string(), + G2Affine::Fq(e) => e.fmt(f), + G2Affine::Fq2(e) => e.fmt(f), } } } @@ -72,20 +73,22 @@ pub struct G2AffineFq2(pub Fq2, pub Fq2); #[derive(Serialize, Deserialize, Clone)] pub struct G2AffineFq(pub Fq, pub Fq); -impl ToString for G1Affine { - fn to_string(&self) -> String { - format!("{}, {}", self.0, self.1) +impl Display for G1Affine { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}, {}", self.0, self.1) } } -impl ToString for G2AffineFq { - fn to_string(&self) -> String { - format!("{}, {}", self.0, self.1) +impl Display for G2AffineFq { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}, {}", self.0, self.1) } } -impl ToString for G2AffineFq2 { - fn to_string(&self) -> String { - format!( + +impl Display for G2AffineFq2 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, "[{}, {}], [{}, {}]", (self.0).0, (self.0).1,