diff --git a/.circleci/config.yml b/.circleci/config.yml index 08cdc0a63..3f7cb80a6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,23 +48,6 @@ jobs: no_output_timeout: 1h command: RUSTFLAGS="-D warnings" ./test.sh - save-sccache-cache - wasm_test: - docker: - - image: zokrates/env:latest - resource_class: large - steps: - - checkout - - run: - name: Version information - command: rustc --version; cargo --version; rustup --version - - setup-sccache - - restore-sccache-cache - - run: - name: Test on firefox - command: | - cd zokrates_test - wasm-pack test --firefox --headless - - save-sccache-cache integration_test: docker: - image: zokrates/env:latest @@ -250,7 +233,6 @@ workflows: jobs: - build - test - # - wasm_test - integration_test - zokrates_js_build - zokrates_js_test @@ -308,7 +290,6 @@ workflows: requires: - build - test - # - wasm_test - integration_test - zokrates_js_build - zokrates_js_test diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fffeb93f..2b5d241d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. ## [Unreleased] https://github.com/Zokrates/ZoKrates/compare/latest...develop +## [0.8.8] - 2023-11-09 + +### Release +- https://github.com/Zokrates/ZoKrates/releases/tag/0.8.8 + +### Changes +- Improve safety in range checks (#1309, @dark64) +- Remove expensive and buggy branch isolation (#1353, @dark64) +- Short-circuit on compile-time constant branch conditions (#1315, @schaeff) +- Fix invalid constant in mimc7 (#1317, @dark64) +- Allow composite type in assembly assignment statement (#1318, @dark64) +- Fix panic in case of nested assembly blocks (#1322, @dark64) +- Detect division by zero on compile-time (#1326, @dark64) +- Set webcrypto only if crypto instance is not available (nodejs) (#1338, @dark64) +- Add missing source information (#1340, @dark64) +- Propagate embed call (#1313, @schaeff) + ## [0.8.7] - 2023-04-22 ### Release diff --git a/Cargo.lock b/Cargo.lock index ec284223e..c6b43224b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -487,9 +487,9 @@ dependencies = [ [[package]] name = "bellperson" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1a8623f815c0b1fd89efd9b5f4afbb937f91f51c1ebe3f6dda399c69fa938f3" +checksum = "93eaee4b4753554139ae52ecf0e8b8c128cbc561b32e1bfaa32f70cba8518c1f" dependencies = [ "bincode 1.3.3", "blake2s_simd 1.0.1", @@ -499,11 +499,11 @@ dependencies = [ "digest 0.10.6", "ec-gpu", "ec-gpu-gen", - "ff", - "group", + "ff 0.13.0", + "group 0.13.0", "log", "memmap2", - "pairing", + "pairing 0.23.0", "rand 0.8.5", "rand_core 0.6.4", "rayon", @@ -695,15 +695,15 @@ dependencies = [ [[package]] name = "blstrs" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ecb6f3a9429706971633edf4b84f922aba9d2e3a7d71bfb450337e64ccb7df0" +checksum = "33149fccb7f93271f0192614b884430cf274e880506bbd171cbc8918dcc95b14" dependencies = [ "blst", "byte-slice-cast", - "ff", - "group", - "pairing", + "ff 0.13.0", + "group 0.13.0", + "pairing 0.23.0", "rand_core 0.6.4", "serde", "subtle 2.5.0", @@ -1137,16 +1137,16 @@ checksum = "bd63582de2b59ea1aa48d7c1941b5d87618d95484397521b3acdfa0e1e9f5e45" [[package]] name = "ec-gpu-gen" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd09bf9d5313ad60379f70250590bccc10f7a04e2773062ac13255a37022584e" +checksum = "892df2aa20abec5b816e15d5d6383892ca142077708efa3067dd3ac44b75c664" dependencies = [ "bitvec", "crossbeam-channel 0.5.8", "ec-gpu", "execute", - "ff", - "group", + "ff 0.13.0", + "group 0.13.0", "hex 0.4.3", "log", "num_cpus", @@ -1350,6 +1350,16 @@ name = "ff" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle 2.5.0", +] + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "bitvec", "byteorder", @@ -1372,9 +1382,9 @@ dependencies = [ [[package]] name = "ff_derive" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17db6fa0748f1f66e9dbafba1881009b50614948c0e900f59083afff2f8d784b" +checksum = "e9f54704be45ed286151c5e11531316eaef5b8f5af7d597b806fdb8af108d84a" dependencies = [ "addchain", "cfg-if 1.0.0", @@ -1400,23 +1410,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "fil_pasta_curves" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3303ea3c462ab949ab95b49f6e6d255d8d9396ebd4f1626ccb34c7037615aa8f" -dependencies = [ - "blake2b_simd", - "ff", - "group", - "hex 0.4.3", - "lazy_static", - "rand 0.8.5", - "serde", - "static_assertions", - "subtle 2.5.0", -] - [[package]] name = "fixed-hash" version = "0.7.0" @@ -1445,7 +1438,7 @@ version = "0.10.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" dependencies = [ - "spin", + "spin 0.9.8", ] [[package]] @@ -1610,7 +1603,18 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ - "ff", + "ff 0.12.1", + "rand_core 0.6.4", + "subtle 2.5.0", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", "rand 0.8.5", "rand_core 0.6.4", "rand_xorshift", @@ -1841,6 +1845,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] [[package]] name = "libc" @@ -1873,19 +1880,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "lurk-pasta-msm" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12992280292a2a4ff84591308c426029245d49094c75df079b286f1bb8496e6c" -dependencies = [ - "cc", - "fil_pasta_curves", - "semolina", - "sppark", - "which", -] - [[package]] name = "maybe-uninit" version = "2.0.0" @@ -1936,20 +1930,19 @@ dependencies = [ [[package]] name = "neptune" -version = "8.1.1" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d47b29bc49c7d957eb446e298f96cd7088829e2d7a549ab04b36bc82434e27b" +checksum = "4227e5557caad6d2a910b7770f2479f0c9aeb8ddc1dc537623cb6ffec7f01d31" dependencies = [ "bellperson", "blake2s_simd 0.5.11", "blstrs", "byteorder", - "ff", - "fil_pasta_curves", + "ff 0.13.0", "generic-array 0.14.7", "itertools 0.8.2", - "lazy_static", "log", + "pasta_curves", "serde", "trait-set", ] @@ -1962,25 +1955,25 @@ checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" [[package]] name = "nova-snark" -version = "0.20.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09c8cf02c93500dee9244cd73547f20d133ca6d3fbbe9eae0205e5b2db05f36" +checksum = "d6247c61ab29e5da01c8f80403c25c40956045f0343d79793a2675bf7775dd80" dependencies = [ "bellperson", "bincode 1.3.3", "bitvec", "byteorder", "digest 0.8.1", - "ff", - "fil_pasta_curves", + "ff 0.13.0", "flate2", "generic-array 0.14.7", "itertools 0.9.0", - "lurk-pasta-msm", "neptune", "num-bigint 0.4.3", "num-integer", "num-traits 0.2.15", + "pasta-msm", + "pasta_curves", "rand_chacha", "rand_core 0.6.4", "rayon", @@ -2128,7 +2121,16 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "135590d8bdba2b31346f9cd1fb2a912329f5135e832a4f422942eb6ead8b6b3b" dependencies = [ - "group", + "group 0.12.1", +] + +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group 0.13.0", ] [[package]] @@ -2168,6 +2170,36 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "pasta-msm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e85d75eba3e7e9ee3bd11342b669185e194dadda3557934bc1000d9b87159d3" +dependencies = [ + "cc", + "pasta_curves", + "semolina", + "sppark", + "which", +] + +[[package]] +name = "pasta_curves" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "hex 0.4.3", + "lazy_static", + "rand 0.8.5", + "serde", + "static_assertions", + "subtle 2.5.0", +] + [[package]] name = "paste" version = "1.0.12" @@ -2670,9 +2702,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semolina" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90759f733a01b95d6ba70180b954d1d96e3e7e11f86c3fb0da0231300972e05" +checksum = "2b0111fd4fa831becb0606b9a2285ef3bee3c6a70d690209b8ae9514e9befe23" dependencies = [ "cc", "glob 0.3.1", @@ -2849,6 +2881,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "spin" version = "0.9.8" @@ -3585,7 +3623,7 @@ dependencies = [ [[package]] name = "zokrates_analysis" -version = "0.1.3" +version = "0.1.4" dependencies = [ "cfg-if 0.1.10", "lazy_static", @@ -3631,7 +3669,7 @@ dependencies = [ [[package]] name = "zokrates_ast" -version = "0.1.7" +version = "0.1.8" dependencies = [ "ark-bls12-377", "byteorder", @@ -3666,15 +3704,15 @@ dependencies = [ [[package]] name = "zokrates_bellperson" -version = "0.1.0" +version = "0.1.1" dependencies = [ "bellperson", - "ff", - "fil_pasta_curves", + "ff 0.13.0", "getrandom", "hex 0.4.3", "nova-snark", - "pairing", + "pairing 0.22.0", + "pasta_curves", "rand 0.4.6", "serde", "typed-arena", @@ -3698,7 +3736,7 @@ dependencies = [ [[package]] name = "zokrates_cli" -version = "0.8.7" +version = "0.8.8" dependencies = [ "assert_cli", "blake2 0.8.1", @@ -3742,7 +3780,7 @@ dependencies = [ [[package]] name = "zokrates_codegen" -version = "0.1.3" +version = "0.1.4" dependencies = [ "zokrates_ast", "zokrates_common", @@ -3753,14 +3791,14 @@ dependencies = [ [[package]] name = "zokrates_common" -version = "0.1.3" +version = "0.1.4" dependencies = [ "serde", ] [[package]] name = "zokrates_core" -version = "0.7.6" +version = "0.7.7" dependencies = [ "cfg-if 0.1.10", "lazy_static", @@ -3782,7 +3820,7 @@ dependencies = [ [[package]] name = "zokrates_core_test" -version = "0.2.11" +version = "0.2.12" dependencies = [ "zokrates_test", "zokrates_test_derive", @@ -3790,7 +3828,7 @@ dependencies = [ [[package]] name = "zokrates_embed" -version = "0.1.10" +version = "0.1.11" dependencies = [ "ark-bls12-377", "ark-bw6-761", @@ -3808,7 +3846,7 @@ dependencies = [ [[package]] name = "zokrates_field" -version = "0.5.5" +version = "0.5.6" dependencies = [ "ark-bls12-377", "ark-bls12-381", @@ -3822,14 +3860,14 @@ dependencies = [ "bellman_ce", "bellperson", "bincode 0.8.0", - "ff", - "fil_pasta_curves", + "ff 0.13.0", "lazy_static", "nova-snark", "num-bigint 0.2.6", "num-integer", "num-traits 0.2.15", - "pairing", + "pairing 0.22.0", + "pasta_curves", "rand 0.4.6", "serde", "serde_derive", @@ -3847,7 +3885,7 @@ dependencies = [ [[package]] name = "zokrates_interpreter" -version = "0.1.5" +version = "0.1.6" dependencies = [ "ark-bls12-377", "num", @@ -3863,7 +3901,7 @@ dependencies = [ [[package]] name = "zokrates_js" -version = "1.1.8" +version = "1.1.9" dependencies = [ "console_error_panic_hook", "getrandom", @@ -3902,7 +3940,7 @@ dependencies = [ [[package]] name = "zokrates_pest_ast" -version = "0.3.3" +version = "0.3.4" dependencies = [ "from-pest", "glob 0.2.11", @@ -3921,7 +3959,7 @@ dependencies = [ [[package]] name = "zokrates_proof_systems" -version = "0.1.3" +version = "0.1.4" dependencies = [ "blake2 0.8.1", "byteorder", @@ -3938,7 +3976,7 @@ dependencies = [ [[package]] name = "zokrates_stdlib" -version = "0.3.3" +version = "0.3.4" dependencies = [ "fs_extra", "zokrates_test", diff --git a/scripts/one_liner.sh b/scripts/one_liner.sh index d06a97096..152638003 100755 --- a/scripts/one_liner.sh +++ b/scripts/one_liner.sh @@ -265,7 +265,7 @@ main() { url="$url/releases" - tag=$(curl -Ls -w %{url_effective} -o /dev/null "$url/latest" | cut -d'"' -f2 | rev | cut -d'/' -f1 | rev) + tag=$(curl -Ls -w %{url_effective} -o /dev/null "$url/latest" | awk -F'tag/' '{print $2}') say_err "Tag: latest ($tag)" # detect host architecture diff --git a/zokrates_analysis/Cargo.toml b/zokrates_analysis/Cargo.toml index 1a55312a8..ad57cbb51 100644 --- a/zokrates_analysis/Cargo.toml +++ b/zokrates_analysis/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_analysis" -version = "0.1.3" +version = "0.1.4" edition = "2021" [features] diff --git a/zokrates_analysis/src/boolean_array_comparator.rs b/zokrates_analysis/src/boolean_array_comparator.rs index 72c158193..e549917be 100644 --- a/zokrates_analysis/src/boolean_array_comparator.rs +++ b/zokrates_analysis/src/boolean_array_comparator.rs @@ -22,7 +22,7 @@ pub struct BooleanArrayComparator; impl BooleanArrayComparator { pub fn simplify(p: TypedProgram) -> TypedProgram { - Self::default().fold_program(p) + Self.fold_program(p) } } @@ -141,7 +141,7 @@ mod tests { ]), )); - let res = BooleanArrayComparator::default().fold_boolean_expression(e); + let res = BooleanArrayComparator.fold_boolean_expression(e); assert_eq!(res, expected); } @@ -171,7 +171,7 @@ mod tests { ]), )); - let res = BooleanArrayComparator::default().fold_boolean_expression(e); + let res = BooleanArrayComparator.fold_boolean_expression(e); assert_eq!(res, expected); } diff --git a/zokrates_analysis/src/branch_isolator.rs b/zokrates_analysis/src/branch_isolator.rs deleted file mode 100644 index 6b6789ec6..000000000 --- a/zokrates_analysis/src/branch_isolator.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Isolate branches means making sure that any branch is enclosed in a block. -// This is important, because we want any statement resulting from inlining any branch to be isolated from the coller, so that its panics can be conditional to the branch being logically run - -// `if c then a else b fi` becomes `if c then { a } else { b } fi`, and down the line any statements resulting from trating `a` and `b` can be safely kept inside the respective blocks. - -use zokrates_ast::common::{Fold, WithSpan}; -use zokrates_ast::typed::folder::*; -use zokrates_ast::typed::*; -use zokrates_field::Field; - -pub struct Isolator; - -impl Isolator { - pub fn isolate(p: TypedProgram) -> TypedProgram { - let mut isolator = Isolator; - isolator.fold_program(p) - } -} - -impl<'ast, T: Field> Folder<'ast, T> for Isolator { - fn fold_conditional_expression< - E: Expr<'ast, T> + Block<'ast, T> + Fold + Conditional<'ast, T>, - >( - &mut self, - _: &E::Ty, - e: ConditionalExpression<'ast, T, E>, - ) -> ConditionalOrExpression<'ast, T, E> { - let span = e.get_span(); - - let consequence_span = e.consequence.get_span(); - let alternative_span = e.alternative.get_span(); - - ConditionalOrExpression::Conditional( - ConditionalExpression::new( - self.fold_boolean_expression(*e.condition), - E::block(vec![], e.consequence.fold(self)).span(consequence_span), - E::block(vec![], e.alternative.fold(self)).span(alternative_span), - e.kind, - ) - .span(span), - ) - } -} diff --git a/zokrates_analysis/src/flatten_complex_types.rs b/zokrates_analysis/src/flatten_complex_types.rs index 64705d1ad..3aa597cba 100644 --- a/zokrates_analysis/src/flatten_complex_types.rs +++ b/zokrates_analysis/src/flatten_complex_types.rs @@ -510,6 +510,38 @@ pub struct ArgumentFinder<'ast, T> { } impl<'ast, T: Field> Folder<'ast, T> for ArgumentFinder<'ast, T> { + fn fold_assembly_block( + &mut self, + s: zir::AssemblyBlockStatement<'ast, T>, + ) -> Vec> { + let mut statements: Vec<_> = s + .inner + .into_iter() + .rev() + .flat_map(|s| self.fold_assembly_statement(s)) + .collect(); + statements.reverse(); + vec![zir::ZirStatement::Assembly( + zir::AssemblyBlockStatement::new(statements), + )] + } + + fn fold_assembly_assignment( + &mut self, + s: zir::AssemblyAssignment<'ast, T>, + ) -> Vec> { + let assignees: Vec> = s + .assignee + .into_iter() + .map(|v| self.fold_assignee(v)) + .collect(); + let expr = self.fold_function(s.expression); + for a in &assignees { + self.identifiers.remove(&a.id); + } + vec![zir::ZirAssemblyStatement::assignment(assignees, expr)] + } + fn fold_statement(&mut self, s: zir::ZirStatement<'ast, T>) -> Vec> { match s { zir::ZirStatement::Definition(s) => { @@ -620,7 +652,7 @@ fn fold_statement<'ast, T: Field>( let e = f.fold_expression(statements_buffer, e); assert_eq!(a.len(), e.len()); a.into_iter() - .zip(e.into_iter()) + .zip(e) .map(|(a, e)| zir::ZirStatement::definition(a, e)) .collect() } @@ -991,7 +1023,7 @@ fn fold_conditional_expression<'ast, T: Field, E: Flatten<'ast, T>>( consequence .into_iter() - .zip(alternative.into_iter()) + .zip(alternative) .map(|(c, a)| match (c, a) { (zir::ZirExpression::FieldElement(c), zir::ZirExpression::FieldElement(a)) => { zir::FieldElementExpression::conditional(condition.clone(), c, a) diff --git a/zokrates_analysis/src/lib.rs b/zokrates_analysis/src/lib.rs index 2cf0c24fc..bd3efa097 100644 --- a/zokrates_analysis/src/lib.rs +++ b/zokrates_analysis/src/lib.rs @@ -6,7 +6,6 @@ mod assembly_transformer; mod boolean_array_comparator; -mod branch_isolator; mod condition_redefiner; mod constant_argument_checker; mod constant_resolver; @@ -25,7 +24,6 @@ mod variable_write_remover; mod zir_propagation; use self::boolean_array_comparator::BooleanArrayComparator; -use self::branch_isolator::Isolator; use self::condition_redefiner::ConditionRedefiner; use self::constant_argument_checker::ConstantArgumentChecker; use self::flatten_complex_types::Flattener; @@ -132,17 +130,6 @@ pub fn analyse<'ast, T: Field>( let r = ConstantResolver::inline(p); log::trace!("\n{}", r); - // isolate branches - let r = if config.isolate_branches { - log::debug!("Static analyser: Isolate branches"); - let r = Isolator::isolate(r); - log::trace!("\n{}", r); - r - } else { - log::debug!("Static analyser: Branch isolation skipped"); - r - }; - // include logs let r = if config.debug { log::debug!("Static analyser: Include logs"); diff --git a/zokrates_analysis/src/log_ignorer.rs b/zokrates_analysis/src/log_ignorer.rs index 2c8aa5a8c..06bd520cb 100644 --- a/zokrates_analysis/src/log_ignorer.rs +++ b/zokrates_analysis/src/log_ignorer.rs @@ -6,7 +6,7 @@ pub struct LogIgnorer; impl LogIgnorer { pub fn ignore(p: TypedProgram) -> TypedProgram { - Self::default().fold_program(p) + Self.fold_program(p) } } diff --git a/zokrates_analysis/src/out_of_bounds.rs b/zokrates_analysis/src/out_of_bounds.rs index 7ed8613a7..e00cf1793 100644 --- a/zokrates_analysis/src/out_of_bounds.rs +++ b/zokrates_analysis/src/out_of_bounds.rs @@ -18,7 +18,7 @@ impl fmt::Display for Error { } impl OutOfBoundsChecker { pub fn check(p: TypedProgram) -> Result, Error> { - Self::default().fold_program(p) + Self.fold_program(p) } } diff --git a/zokrates_analysis/src/propagation.rs b/zokrates_analysis/src/propagation.rs index 35a048e08..03c98c38b 100644 --- a/zokrates_analysis/src/propagation.rs +++ b/zokrates_analysis/src/propagation.rs @@ -33,6 +33,7 @@ pub enum Error { InvalidValue(String), OutOfBounds(u128, u128), VariableLength(String), + DivisionByZero, } impl fmt::Display for Error { @@ -47,6 +48,9 @@ impl fmt::Display for Error { index, size ), Error::VariableLength(message) => write!(f, "{}", message), + Error::DivisionByZero => { + write!(f, "Division by zero detected during static analysis",) + } } } } @@ -55,7 +59,7 @@ impl fmt::Display for Error { pub struct Propagator<'ast, T> { // constants keeps track of constant expressions // we currently do not support partially constant expressions: `field [x, 1][1]` is not considered constant, `field [0, 1][1]` is - constants: Constants<'ast, T>, + pub constants: Constants<'ast, T>, } impl<'ast, T: Field> Propagator<'ast, T> { @@ -181,26 +185,22 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for Propagator<'ast, T> { _: &E::Ty, e: ConditionalExpression<'ast, T, E>, ) -> Result, Self::Error> { - Ok( - match ( - self.fold_boolean_expression(*e.condition)?, - e.consequence.fold(self)?, - e.alternative.fold(self)?, - ) { - (BooleanExpression::Value(v), consequence, _) if v.value => { - ConditionalOrExpression::Expression(consequence.into_inner()) - } - (BooleanExpression::Value(v), _, alternative) if !v.value => { - ConditionalOrExpression::Expression(alternative.into_inner()) - } - (_, consequence, alternative) if consequence == alternative => { + Ok(match self.fold_boolean_expression(*e.condition)? { + BooleanExpression::Value(v) if v.value => { + ConditionalOrExpression::Expression(e.consequence.fold(self)?.into_inner()) + } + BooleanExpression::Value(v) if !v.value => { + ConditionalOrExpression::Expression(e.alternative.fold(self)?.into_inner()) + } + condition => match (e.consequence.fold(self)?, e.alternative.fold(self)?) { + (consequence, alternative) if consequence == alternative => { ConditionalOrExpression::Expression(consequence.into_inner()) } - (condition, consequence, alternative) => ConditionalOrExpression::Conditional( + (consequence, alternative) => ConditionalOrExpression::Conditional( ConditionalExpression::new(condition, consequence, alternative, e.kind), ), }, - ) + }) } fn fold_assembly_assignment( @@ -928,12 +928,16 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for Propagator<'ast, T> { let left = self.fold_field_expression(*e.left)?; let right = self.fold_field_expression(*e.right)?; - Ok(match (left, right) { - (FieldElementExpression::Value(n1), FieldElementExpression::Value(n2)) => { - FieldElementExpression::Value(ValueExpression::new(n1.value / n2.value)) + match (left, right) { + (_, FieldElementExpression::Value(n)) if n.value == T::from(0) => { + Err(Error::DivisionByZero) } - (e1, e2) => e1 / e2, - }) + (e, FieldElementExpression::Value(n)) if n.value == T::from(1) => Ok(e), + (FieldElementExpression::Value(n1), FieldElementExpression::Value(n2)) => Ok( + FieldElementExpression::Value(ValueExpression::new(n1.value / n2.value)), + ), + (e1, e2) => Ok(e1 / e2), + } } FieldElementExpression::Neg(e) => match self.fold_field_expression(*e.inner)? { FieldElementExpression::Value(n) => { @@ -1575,15 +1579,31 @@ mod tests { #[test] fn div() { - let e = FieldElementExpression::div( - FieldElementExpression::value(Bn128Field::from(6)), - FieldElementExpression::value(Bn128Field::from(2)), - ); + let mut propagator = Propagator::default(); assert_eq!( - Propagator::default().fold_field_expression(e), + propagator.fold_field_expression(FieldElementExpression::div( + FieldElementExpression::value(Bn128Field::from(6)), + FieldElementExpression::value(Bn128Field::from(2)), + )), Ok(FieldElementExpression::value(Bn128Field::from(3))) ); + + assert_eq!( + propagator.fold_field_expression(FieldElementExpression::div( + FieldElementExpression::identifier("a".into()), + FieldElementExpression::value(Bn128Field::from(1)), + )), + Ok(FieldElementExpression::identifier("a".into())) + ); + + assert_eq!( + propagator.fold_field_expression(FieldElementExpression::div( + FieldElementExpression::value(Bn128Field::from(6)), + FieldElementExpression::value(Bn128Field::from(0)), + )), + Err(Error::DivisionByZero) + ); } #[test] diff --git a/zokrates_analysis/src/reducer/mod.rs b/zokrates_analysis/src/reducer/mod.rs index 585966858..2c2c37e07 100644 --- a/zokrates_analysis/src/reducer/mod.rs +++ b/zokrates_analysis/src/reducer/mod.rs @@ -213,6 +213,8 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Reducer<'ast, 'a, T> { let return_value = self.fold_expression(return_value)?; + let return_value = self.propagator.fold_expression(return_value)?; + Ok(FunctionCallOrExpression::Expression( E::from(return_value).into_inner(), )) @@ -226,22 +228,28 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Reducer<'ast, 'a, T> { FunctionCallExpression::<_, E>::new(e.function_key, generics, arguments) ))), Err(InlineError::Flat(embed, generics, output_type)) => { - let identifier = self.ssa.issue_next_identifier(CoreIdentifier::Call(0)); + let identifier = self.ssa.issue_next_identifier(CoreIdentifier::Call); let var = Variable::new(identifier.clone(), output_type); let v: TypedAssignee<'ast, T> = var.clone().into(); - self.statement_buffer.push( - TypedStatement::embed_call_definition( - v, - EmbedCall::new(embed, generics, arguments), - ) - .span(span), - ); - Ok(FunctionCallOrExpression::Expression( - E::identifier(identifier).span(span), - )) + let definition = TypedStatement::embed_call_definition( + v, + EmbedCall::new(embed, generics, arguments), + ) + .span(span); + + let definition = self.propagator.fold_statement(definition)?; + + self.statement_buffer.extend(definition); + + let e = match self.propagator.constants.get(&identifier) { + Some(v) => E::try_from(v.clone()).unwrap().into_inner(), + None => E::identifier(identifier), + }; + + Ok(FunctionCallOrExpression::Expression(e.span(span))) } }; diff --git a/zokrates_analysis/src/variable_write_remover.rs b/zokrates_analysis/src/variable_write_remover.rs index 2d9ce8685..8880fc225 100644 --- a/zokrates_analysis/src/variable_write_remover.rs +++ b/zokrates_analysis/src/variable_write_remover.rs @@ -101,6 +101,7 @@ impl<'ast> VariableWriteRemover { .span(span), ConditionalKind::IfElse, ) + .span(span) .into(), Type::Struct(..) => StructExpression::conditional( BooleanExpression::uint_eq( @@ -114,7 +115,6 @@ impl<'ast> VariableWriteRemover { UExpression::from(i).span(span), ) .span(span) - .span(span) .into(), tail.clone(), new_expression.clone(), @@ -134,6 +134,7 @@ impl<'ast> VariableWriteRemover { .span(span), ConditionalKind::IfElse, ) + .span(span) .into(), Type::Tuple(..) => TupleExpression::conditional( BooleanExpression::uint_eq( @@ -166,6 +167,7 @@ impl<'ast> VariableWriteRemover { .span(span), ConditionalKind::IfElse, ) + .span(span) .into(), Type::FieldElement => FieldElementExpression::conditional( BooleanExpression::uint_eq( @@ -198,6 +200,7 @@ impl<'ast> VariableWriteRemover { .span(span), ConditionalKind::IfElse, ) + .span(span) .into(), Type::Boolean => BooleanExpression::conditional( BooleanExpression::uint_eq( @@ -230,6 +233,7 @@ impl<'ast> VariableWriteRemover { .span(span), ConditionalKind::IfElse, ) + .span(span) .into(), Type::Uint(..) => UExpression::conditional( BooleanExpression::uint_eq( @@ -262,10 +266,12 @@ impl<'ast> VariableWriteRemover { .span(span), ConditionalKind::IfElse, ) + .span(span) .into(), }) .collect::>(), ) + .span(span) .annotate(ArrayType::new(inner_ty.clone(), size)) .into() } @@ -394,6 +400,7 @@ impl<'ast> VariableWriteRemover { }) .collect(), ) + .span(span) .annotate(members) .into(), _ => unreachable!(), @@ -512,6 +519,7 @@ impl<'ast> VariableWriteRemover { }) .collect(), ) + .span(span) .annotate(tuple_ty) .into(), _ => unreachable!(), diff --git a/zokrates_analysis/src/zir_propagation.rs b/zokrates_analysis/src/zir_propagation.rs index 0d3fb1c73..d826099d5 100644 --- a/zokrates_analysis/src/zir_propagation.rs +++ b/zokrates_analysis/src/zir_propagation.rs @@ -64,12 +64,14 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for ZirPropagator<'ast, T> { &mut self, f: ZirFunction<'ast, T>, ) -> Result, Self::Error> { + let (arguments, inputs) = f + .arguments + .into_iter() + .zip(f.signature.inputs.iter().cloned()) + .filter(|(p, _)| !self.constants.contains_key(&p.id.id)) + .unzip(); Ok(ZirFunction { - arguments: f - .arguments - .into_iter() - .filter(|p| !self.constants.contains_key(&p.id.id)) - .collect(), + arguments, statements: f .statements .into_iter() @@ -78,7 +80,28 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for ZirPropagator<'ast, T> { .into_iter() .flatten() .collect(), - ..f + signature: f.signature.inputs(inputs), + }) + } + + fn fold_assembly_block( + &mut self, + s: zokrates_ast::zir::AssemblyBlockStatement<'ast, T>, + ) -> Result>, Self::Error> { + let block: Vec<_> = s + .inner + .into_iter() + .map(|s| self.fold_assembly_statement(s)) + .collect::, _>>()? + .into_iter() + .flatten() + .collect(); + + Ok(match block.is_empty() { + true => vec![], + false => vec![ZirStatement::Assembly( + zokrates_ast::zir::AssemblyBlockStatement::new(block), + )], }) } @@ -884,7 +907,8 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for ZirPropagator<'ast, T> { )) } else { Ok(ConditionalOrExpression::Conditional( - ConditionalExpression::new(condition, consequence, alternative), + ConditionalExpression::new(condition, consequence, alternative) + .span(e.span), )) } } diff --git a/zokrates_ast/Cargo.toml b/zokrates_ast/Cargo.toml index dbbb44bed..6dcd027a7 100644 --- a/zokrates_ast/Cargo.toml +++ b/zokrates_ast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_ast" -version = "0.1.7" +version = "0.1.8" edition = "2021" [features] diff --git a/zokrates_ast/src/common/error.rs b/zokrates_ast/src/common/error.rs index 82a201881..6f799fd8b 100644 --- a/zokrates_ast/src/common/error.rs +++ b/zokrates_ast/src/common/error.rs @@ -18,7 +18,7 @@ pub enum RuntimeError { BranchIsolation, ConstantLtBitness, ConstantLtSum, - LtFinalSum, + LtSum, LtSymetric, Or, Xor, @@ -83,7 +83,7 @@ impl fmt::Display for RuntimeError { BranchIsolation => "Branch isolation failed", ConstantLtBitness => "Bitness check failed in constant Lt check", ConstantLtSum => "Sum check failed in constant Lt check", - LtFinalSum => "Sum check failed in final Lt check", + LtSum => "Sum check failed in Lt check", LtSymetric => "Symetrical check failed in Lt check", Or => "Or check failed", Xor => "Xor check failed", diff --git a/zokrates_ast/src/common/solvers.rs b/zokrates_ast/src/common/solvers.rs index 9c6e9bbcc..eaaf2a70b 100644 --- a/zokrates_ast/src/common/solvers.rs +++ b/zokrates_ast/src/common/solvers.rs @@ -5,7 +5,7 @@ use std::fmt; #[derive(Clone, PartialEq, Debug, Serialize, Deserialize, Hash, Eq)] pub struct RefCall { pub index: usize, - pub argument_count: usize, + pub signature: (usize, usize), } #[derive(Clone, PartialEq, Debug, Serialize, Deserialize, Hash, Eq)] @@ -39,7 +39,7 @@ impl<'ast, T> fmt::Display for Solver<'ast, T> { Solver::ShaCh => write!(f, "ShaCh"), Solver::EuclideanDiv => write!(f, "EuclideanDiv"), Solver::Zir(_) => write!(f, "Zir(..)"), - Solver::Ref(call) => write!(f, "Ref@{}({})", call.index, call.argument_count), + Solver::Ref(call) => write!(f, "Ref@{}", call.index), #[cfg(feature = "bellman")] Solver::Sha256Round => write!(f, "Sha256Round"), #[cfg(feature = "ark")] @@ -59,8 +59,8 @@ impl<'ast, T> Solver<'ast, T> { Solver::ShaAndXorAndXorAnd => (3, 1), Solver::ShaCh => (3, 1), Solver::EuclideanDiv => (2, 2), - Solver::Zir(f) => (f.arguments.len(), 1), - Solver::Ref(c) => (c.argument_count, 1), + Solver::Zir(f) => (f.signature.inputs.len(), f.signature.outputs.len()), + Solver::Ref(c) => c.signature, #[cfg(feature = "bellman")] Solver::Sha256Round => (768, 26935), #[cfg(feature = "ark")] diff --git a/zokrates_ast/src/ir/clean.rs b/zokrates_ast/src/ir/clean.rs index 1c58faff6..ac1bcbd06 100644 --- a/zokrates_ast/src/ir/clean.rs +++ b/zokrates_ast/src/ir/clean.rs @@ -16,7 +16,7 @@ impl<'ast, T: Field, I: IntoIterator>> ProgIterator<'a statements: self .statements .into_iter() - .flat_map(|s| Cleaner::default().fold_statement(s)), + .flat_map(|s| Cleaner.fold_statement(s)), solvers: self.solvers, } } diff --git a/zokrates_ast/src/ir/mod.rs b/zokrates_ast/src/ir/mod.rs index 46c99b13f..7118c6f6e 100644 --- a/zokrates_ast/src/ir/mod.rs +++ b/zokrates_ast/src/ir/mod.rs @@ -74,7 +74,7 @@ impl fmt::Display for ConstraintStatement { self.error .as_ref() .map(|e| format!(" // {}", e)) - .unwrap_or_else(|| "".to_string()) + .unwrap_or_default() ) } } diff --git a/zokrates_ast/src/ir/solver_indexer.rs b/zokrates_ast/src/ir/solver_indexer.rs index 334da750b..2ef8994ae 100644 --- a/zokrates_ast/src/ir/solver_indexer.rs +++ b/zokrates_ast/src/ir/solver_indexer.rs @@ -31,9 +31,9 @@ impl<'ast, T: Field> Folder<'ast, T> for SolverIndexer<'ast, T> { &mut self, d: DirectiveStatement<'ast, T>, ) -> Vec> { + let signature = d.solver.get_signature(); let res = match d.solver { Solver::Zir(f) => { - let argument_count = f.arguments.len(); let h = hash(&f); let index = match self.index_map.entry(h) { Entry::Occupied(v) => *v.get(), @@ -46,10 +46,7 @@ impl<'ast, T: Field> Folder<'ast, T> for SolverIndexer<'ast, T> { }; DirectiveStatement::new( d.outputs, - Solver::Ref(RefCall { - index, - argument_count, - }), + Solver::Ref(RefCall { index, signature }), d.inputs, ) } diff --git a/zokrates_ast/src/lib.rs b/zokrates_ast/src/lib.rs index 084173f84..bf97b93f6 100644 --- a/zokrates_ast/src/lib.rs +++ b/zokrates_ast/src/lib.rs @@ -1,3 +1,6 @@ +// see https://github.com/mcarton/rust-derivative/issues/115 +#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)] + pub mod common; pub mod flat; pub mod ir; diff --git a/zokrates_ast/src/typed/identifier.rs b/zokrates_ast/src/typed/identifier.rs index d23a9b3b7..f4e433db6 100644 --- a/zokrates_ast/src/typed/identifier.rs +++ b/zokrates_ast/src/typed/identifier.rs @@ -8,7 +8,7 @@ pub type SourceIdentifier<'ast> = std::borrow::Cow<'ast, str>; pub enum CoreIdentifier<'ast> { #[serde(borrow)] Source(ShadowedIdentifier<'ast>), - Call(usize), + Call, Constant(CanonicalConstantIdentifier<'ast>), Condition(usize), } @@ -17,7 +17,7 @@ impl<'ast> fmt::Display for CoreIdentifier<'ast> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { CoreIdentifier::Source(s) => write!(f, "{}", s), - CoreIdentifier::Call(i) => write!(f, "#CALL_RETURN_AT_INDEX_{}", i), + CoreIdentifier::Call => write!(f, "#CALL_RETURN"), CoreIdentifier::Constant(c) => write!(f, "{}/{}", c.module.display(), c.id), CoreIdentifier::Condition(i) => write!(f, "#CONDITION_{}", i), } diff --git a/zokrates_ast/src/typed/integer.rs b/zokrates_ast/src/typed/integer.rs index d5ba9ad58..b2d1f0371 100644 --- a/zokrates_ast/src/typed/integer.rs +++ b/zokrates_ast/src/typed/integer.rs @@ -107,7 +107,7 @@ impl<'ast, T: Clone> IntegerInference for StructType<'ast, T> { members: self .members .into_iter() - .zip(other.members.into_iter()) + .zip(other.members) .map(|(m_t, m_u)| match m_t.ty.get_common_pattern(*m_u.ty) { Ok(ty) => DeclarationStructMember { ty: Box::new(ty), diff --git a/zokrates_ast/src/typed/mod.rs b/zokrates_ast/src/typed/mod.rs index e8072ba14..11786660c 100644 --- a/zokrates_ast/src/typed/mod.rs +++ b/zokrates_ast/src/typed/mod.rs @@ -3464,6 +3464,20 @@ impl<'ast, T: Field> Block<'ast, T> for StructExpression<'ast, T> { } } +impl<'ast, T: Field> Block<'ast, T> for TypedExpression<'ast, T> { + fn block(statements: Vec>, value: Self) -> Self { + match value { + TypedExpression::Boolean(e) => BooleanExpression::block(statements, e).into(), + TypedExpression::FieldElement(e) => FieldElementExpression::block(statements, e).into(), + TypedExpression::Uint(e) => UExpression::block(statements, e).into(), + TypedExpression::Array(e) => ArrayExpression::block(statements, e).into(), + TypedExpression::Struct(e) => StructExpression::block(statements, e).into(), + TypedExpression::Tuple(e) => TupleExpression::block(statements, e).into(), + TypedExpression::Int(e) => unreachable!("{}", e), + } + } +} + pub trait Constant: Sized { // return whether this is constant fn is_constant(&self) -> bool; diff --git a/zokrates_ast/src/typed/types.rs b/zokrates_ast/src/typed/types.rs index ece3547e7..8a0614a0b 100644 --- a/zokrates_ast/src/typed/types.rs +++ b/zokrates_ast/src/typed/types.rs @@ -942,6 +942,23 @@ impl GType { } } +impl GType { + pub fn is_composite_of_field(&self) -> bool { + match self { + GType::Array(array_type) => array_type.ty.is_composite_of_field(), + GType::Tuple(tuple_typle) => tuple_typle + .elements + .iter() + .all(|e| e.is_composite_of_field()), + GType::Struct(struct_type) => struct_type + .members + .iter() + .all(|m| m.ty.is_composite_of_field()), + other => other.eq(&Self::FieldElement), + } + } +} + impl<'ast, T: fmt::Display + PartialEq + fmt::Debug> Type<'ast, T> { pub fn can_be_specialized_to(&self, other: &DeclarationType<'ast, T>) -> bool { use self::GType::*; @@ -1360,7 +1377,7 @@ pub mod signature { constants.0.extend( decl_generics - .zip(values.into_iter()) + .zip(values) .filter_map(|(g, v)| v.map(|v| (g, v))), ); diff --git a/zokrates_ast/src/untyped/mod.rs b/zokrates_ast/src/untyped/mod.rs index c0f77ea64..46fa1e10f 100644 --- a/zokrates_ast/src/untyped/mod.rs +++ b/zokrates_ast/src/untyped/mod.rs @@ -543,11 +543,8 @@ impl<'ast> fmt::Display for Range<'ast> { self.from .as_ref() .map(|e| e.to_string()) - .unwrap_or_else(|| "".to_string()), - self.to - .as_ref() - .map(|e| e.to_string()) - .unwrap_or_else(|| "".to_string()) + .unwrap_or_default(), + self.to.as_ref().map(|e| e.to_string()).unwrap_or_default() ) } } diff --git a/zokrates_ast/src/zir/canonicalizer.rs b/zokrates_ast/src/zir/canonicalizer.rs index 61bf1970a..0e4ffe562 100644 --- a/zokrates_ast/src/zir/canonicalizer.rs +++ b/zokrates_ast/src/zir/canonicalizer.rs @@ -9,11 +9,16 @@ pub struct ZirCanonicalizer<'ast> { impl<'ast, T: Field> Folder<'ast, T> for ZirCanonicalizer<'ast> { fn fold_parameter(&mut self, p: Parameter<'ast>) -> Parameter<'ast> { - let new_id = self.identifier_map.len(); - self.identifier_map.insert(p.id.id.clone(), new_id); - + let id = match self.identifier_map.get(&p.id.id) { + Some(v) => Identifier::internal(*v), + None => { + let new_id = self.identifier_map.len(); + self.identifier_map.insert(p.id.id.clone(), new_id); + Identifier::internal(new_id) + } + }; Parameter { - id: Variable::with_id_and_type(Identifier::internal(new_id), p.id.ty), + id: Variable::with_id_and_type(id, p.id.ty), ..p } } diff --git a/zokrates_ast/src/zir/mod.rs b/zokrates_ast/src/zir/mod.rs index a7cc08019..62025adf0 100644 --- a/zokrates_ast/src/zir/mod.rs +++ b/zokrates_ast/src/zir/mod.rs @@ -63,8 +63,8 @@ pub struct ZirFunction<'ast, T> { pub type IdentifierOrExpression<'ast, T, E> = expressions::IdentifierOrExpression, E, >::Inner>; -impl<'ast, T: fmt::Display> fmt::Display for ZirFunction<'ast, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl<'ast, T: fmt::Display> ZirFunction<'ast, T> { + fn fmt_indented(&self, f: &mut fmt::Formatter, depth: usize) -> fmt::Result { writeln!( f, "({}) -> ({}) {{", @@ -82,11 +82,17 @@ impl<'ast, T: fmt::Display> fmt::Display for ZirFunction<'ast, T> { )?; for s in &self.statements { - s.fmt_indented(f, 1)?; + s.fmt_indented(f, depth + 1)?; writeln!(f)?; } - write!(f, "}}") + write!(f, "{}}}", "\t".repeat(depth)) + } +} + +impl<'ast, T: fmt::Display> fmt::Display for ZirFunction<'ast, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.fmt_indented(f, 0) } } @@ -174,19 +180,30 @@ impl<'ast, T> WithSpan for ZirAssemblyStatement<'ast, T> { } } -impl<'ast, T: fmt::Display> fmt::Display for ZirAssemblyStatement<'ast, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl<'ast, T: fmt::Display> ZirAssemblyStatement<'ast, T> { + fn fmt_indented(&self, f: &mut fmt::Formatter, depth: usize) -> fmt::Result { + write!(f, "{}", "\t".repeat(depth))?; match *self { ZirAssemblyStatement::Assignment(ref s) => { write!( f, - "{} <-- {};", + "{} <-- (", s.assignee .iter() .map(|a| a.to_string()) .collect::>() - .join(", "), + .join(", ") + )?; + s.expression.fmt_indented(f, depth)?; + write!( + f, + ")({});", s.expression + .arguments + .iter() + .map(|a| a.id.id.to_string()) + .collect::>() + .join(", ") ) } ZirAssemblyStatement::Constraint(ref s) => { @@ -196,6 +213,12 @@ impl<'ast, T: fmt::Display> fmt::Display for ZirAssemblyStatement<'ast, T> { } } +impl<'ast, T: fmt::Display> fmt::Display for ZirAssemblyStatement<'ast, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.fmt_indented(f, 0) + } +} + pub type DefinitionStatement<'ast, T> = common::expressions::DefinitionStatement, ZirExpression<'ast, T>>; pub type AssertionStatement<'ast, T> = @@ -282,7 +305,7 @@ impl<'ast, T: fmt::Display> fmt::Display for MultipleDefinitionStatement<'ast, T write!(f, ", ")?; } } - write!(f, " = {};", self.rhs) + write!(f, " = {}", self.rhs) } } @@ -418,7 +441,7 @@ impl<'ast, T: fmt::Display> ZirStatement<'ast, T> { write!(f, ";") } ZirStatement::Definition(ref s) => { - write!(f, "{}", s) + write!(f, "{};", s) } ZirStatement::IfElse(ref s) => { writeln!(f, "if {} {{", s.condition)?; @@ -441,7 +464,7 @@ impl<'ast, T: fmt::Display> ZirStatement<'ast, T> { } } ZirStatement::MultipleDefinition(ref s) => { - write!(f, "{}", s) + write!(f, "{};", s) } ZirStatement::Log(ref e) => write!( f, @@ -462,7 +485,8 @@ impl<'ast, T: fmt::Display> ZirStatement<'ast, T> { ZirStatement::Assembly(s) => { writeln!(f, "asm {{")?; for s in &s.inner { - writeln!(f, "{}{}", "\t".repeat(depth + 1), s)?; + s.fmt_indented(f, depth + 1)?; + writeln!(f)?; } write!(f, "{}}}", "\t".repeat(depth)) } diff --git a/zokrates_bellperson/Cargo.toml b/zokrates_bellperson/Cargo.toml index 126017071..fd86d93d2 100644 --- a/zokrates_bellperson/Cargo.toml +++ b/zokrates_bellperson/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_bellperson" -version = "0.1.0" +version = "0.1.1" edition = "2021" [features] @@ -9,13 +9,13 @@ edition = "2021" zokrates_field = { version = "0.5", path = "../zokrates_field", features = ["bellperson_extensions"] } zokrates_ast = { version = "0.1", path = "../zokrates_ast", features = ["bellperson"] } # zokrates_proof_systems = { version = "0.1", path = "../zokrates_proof_systems", default-features = false } -bellperson = { package = "bellperson", version = "^0.24", default-features = false } +bellperson = { package = "bellperson", version = "^0.25", default-features = false } rand_0_4 = { version = "0.4", package = "rand" }# getrandom = { version = "0.2", features = ["js", "wasm-bindgen"] } hex = "0.4.2" pairing = "0.22" -ff = { version = "0.12.0", default-features = false } -nova-snark = { version = "0.20.3" } +ff = { version = "0.13.0", default-features = false } +nova-snark = { version = "0.21.0" } zokrates_interpreter = { version = "0.1", path = "../zokrates_interpreter" } serde = { version = "1.0", features = ["derive"] } @@ -26,7 +26,7 @@ rand_0_4 = { version = "0.4", package = "rand" } getrandom = { version = "0.2", features = ["js", "wasm-bindgen"] } hex = "0.4.2" pairing = "0.22" -pasta_curves = { version = "0.5.2", features = ["repr-c", "serde"], package = "fil_pasta_curves"} +pasta_curves = { version = "0.5", features = ["repr-c", "serde"] } zokrates_core = { version = "0.7.3", path = "../zokrates_core" } diff --git a/zokrates_bellperson/src/nova.rs b/zokrates_bellperson/src/nova.rs index ad7f51e31..ae4b619c3 100644 --- a/zokrates_bellperson/src/nova.rs +++ b/zokrates_bellperson/src/nova.rs @@ -105,7 +105,7 @@ pub fn verify( arguments: Vec, ) -> Result, Error> { let z0_primary: Vec<_> = arguments.into_iter().map(|a| a.into_bellperson()).collect(); - let z0_secondary = vec![<::Point as Group>::Base::one()]; + let z0_secondary = vec![<::Point as Group>::Base::ONE]; proof .proof @@ -149,7 +149,7 @@ pub fn verify_compressed<'ast, T: NovaField>( step_count: usize, ) -> bool { let z0_primary: Vec<_> = arguments.into_iter().map(|a| a.into_bellperson()).collect(); - let z0_secondary = vec![<::Point as Group>::Base::one()]; + let z0_secondary = vec![<::Point as Group>::Base::ONE]; proof .verify(vk, step_count, z0_primary, z0_secondary) @@ -166,7 +166,7 @@ pub fn prove<'ast, T: NovaField>( let c_primary = NovaComputation::try_from(Computation::without_witness(program))?; let c_secondary = TrivialTestCircuit::default(); let z0_primary: Vec<_> = arguments.into_iter().map(|a| a.into_bellperson()).collect(); - let z0_secondary = vec![<::Point as Group>::Base::one()]; + let z0_secondary = vec![<::Point as Group>::Base::ONE]; for steps_private in steps { let mut c_primary = c_primary.clone(); diff --git a/zokrates_book/src/language/assembly.md b/zokrates_book/src/language/assembly.md index da3e71e52..3fdbcad77 100644 --- a/zokrates_book/src/language/assembly.md +++ b/zokrates_book/src/language/assembly.md @@ -17,9 +17,19 @@ Assigning a value, in general, should be combined with adding a constraint: {{#include ../../../zokrates_cli/examples/book/assembly/division.zok}} ``` -> The operator `<--` can be sometimes misused, as this operator does not generate any constraints, resulting in unconstrained variables in the constraint system. +> Note that operator `<--` is used for unconstrained assignment and can be easily misused. This operator does not generate constraints, which could result in unconstrained variables in the constraint system. -In some cases we can combine the witness assignment and constraint generation with the `<==` operator: +Unconstrained assignment `<--` allows assignment to variables with complex types. The type must consist of field elements only (eg. `field[3]`): + +```zok +field[3] mut c = [0; 3]; +asm { + c <-- [2, 2, 4]; + c[0] * c[1] === c[2]; +} +``` + +In some cases we can combine the witness assignment and constraint generation with the `<==` operator (constrained assignment): ```zok asm { @@ -36,6 +46,8 @@ asm { } ``` +In the case of constrained assignment `<==`, both sides of the statement have to be of type `field`. + A constraint can contain arithmetic expressions that are built using multiplication, addition, and other variables or `field` values. Only quadratic expressions are allowed to be included in constraints. Non-quadratic expressions or usage of other arithmetic operators like division or power are not allowed as constraints, but can be used in the witness assignment expression. The following code is not allowed: diff --git a/zokrates_book/src/language/control_flow.md b/zokrates_book/src/language/control_flow.md index 6e7929cc1..2a50e2f83 100644 --- a/zokrates_book/src/language/control_flow.md +++ b/zokrates_book/src/language/control_flow.md @@ -47,9 +47,8 @@ Now the two caveats: ```zokrates {{#include ../../../zokrates_cli/examples/book/conditional_panic.zok}} ``` -The experimental flag `--branch-isolation` can be activated in the CLI in order to restrict any unsatisfied constraint to make the execution fail only if it is in a logically executed branch. This way, the execution of the program above will always succeed. ->The reason for these caveats is that the program is compiled down to an arithmetic circuit. This construct does not support jumping to a branch depending on a condition as you could do on traditional architectures. Instead, all branches are inlined as if they were printed on a circuit board. The `branch-isolation` feature comes with overhead for each assertion in each branch, and this overhead compounds when deeply nesting conditionals. +>The reason for these caveats is that the program is compiled down to an arithmetic circuit. This construct does not support jumping to a branch depending on a condition as you could do on traditional architectures. Instead, all branches are inlined as if they were printed on a circuit board. ### For loops diff --git a/zokrates_book/src/language/types.md b/zokrates_book/src/language/types.md index 8eee2ce62..8daf8c63a 100644 --- a/zokrates_book/src/language/types.md +++ b/zokrates_book/src/language/types.md @@ -25,7 +25,7 @@ Booleans are available in ZoKrates. When a boolean is used as a parameter of the ### `u8/u16/u32/u64` -Unsigned integers represent positive numbers of the interval `[0, 2 ** bitwidth[`, where `bitwidth` is specified in the type's name, e.g., 32 bits in the case of u32. Their arithmetics are defined modulo `2 ** bitwidth`. +Unsigned integers represent positive numbers of the interval `[0, 2 ** bitwidth)`, where `bitwidth` is specified in the type's name, e.g., 32 bits in the case of u32. Their arithmetics are defined modulo `2 ** bitwidth`. Internally, they use a binary encoding, which makes them particularly efficient for implementing programs that operate on that binary representation, e.g., the SHA256 hash function. diff --git a/zokrates_cli/Cargo.toml b/zokrates_cli/Cargo.toml index 31f182443..0fcda00f6 100644 --- a/zokrates_cli/Cargo.toml +++ b/zokrates_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_cli" -version = "0.8.7" +version = "0.8.8" authors = ["Jacob Eberhardt ", "Dennis Kuhnert ", "Thibaut Schaeffer "] repository = "https://github.com/Zokrates/ZoKrates.git" edition = "2018" diff --git a/zokrates_cli/examples/compile_errors/assembly/unallowed_type_in_assignment.zok b/zokrates_cli/examples/compile_errors/assembly/unallowed_type_in_assignment.zok new file mode 100644 index 000000000..d3c1c2329 --- /dev/null +++ b/zokrates_cli/examples/compile_errors/assembly/unallowed_type_in_assignment.zok @@ -0,0 +1,6 @@ +def main(bool a) { + bool mut b = false; + asm { + b <-- a; + } +} \ No newline at end of file diff --git a/zokrates_cli/examples/compile_errors/assembly/unallowed_type_in_constrained_assignment.zok b/zokrates_cli/examples/compile_errors/assembly/unallowed_type_in_constrained_assignment.zok new file mode 100644 index 000000000..f17a895f2 --- /dev/null +++ b/zokrates_cli/examples/compile_errors/assembly/unallowed_type_in_constrained_assignment.zok @@ -0,0 +1,6 @@ +def main() { + field[2] mut a = [0; 2]; + asm { + a <== [1, 2]; + } +} \ No newline at end of file diff --git a/zokrates_cli/src/ops/check.rs b/zokrates_cli/src/ops/check.rs index c2cada4d6..1172f0307 100644 --- a/zokrates_cli/src/ops/check.rs +++ b/zokrates_cli/src/ops/check.rs @@ -44,11 +44,6 @@ pub fn subcommand() -> App<'static, 'static> { .possible_values(cli_constants::CURVES) .default_value(BN128), ) - .arg(Arg::with_name("isolate-branches") - .long("isolate-branches") - .help("Isolate the execution of branches: a panic in a branch only makes the program panic if this branch is being logically executed") - .required(false) - ) } pub fn exec(sub_matches: &ArgMatches) -> Result<(), String> { @@ -94,17 +89,13 @@ fn cli_check(sub_matches: &ArgMatches) -> Result<(), String> { )), }?; - let config = - CompileConfig::default().isolate_branches(sub_matches.is_present("isolate-branches")); - + let config = CompileConfig::default(); let resolver = FileSystemResolver::with_stdlib_root(stdlib_path); + check::(source, path, Some(&resolver), &config).map_err(|e| { format!( "Check failed:\n\n{}", - e.0.iter() - .map(|e| fmt_error(e)) - .collect::>() - .join("\n\n") + e.0.iter().map(fmt_error).collect::>().join("\n\n") ) })?; diff --git a/zokrates_cli/src/ops/compile.rs b/zokrates_cli/src/ops/compile.rs index 5265aed72..449f7ac64 100644 --- a/zokrates_cli/src/ops/compile.rs +++ b/zokrates_cli/src/ops/compile.rs @@ -18,62 +18,71 @@ use zokrates_fs_resolver::FileSystemResolver; pub fn subcommand() -> App<'static, 'static> { SubCommand::with_name("compile") .about("Compiles into a runnable constraint system") - .arg(Arg::with_name("input") - .short("i") - .long("input") - .help("Path of the source code") - .value_name("FILE") - .takes_value(true) - .required(true) - ).arg(Arg::with_name("stdlib-path") - .long("stdlib-path") - .help("Path to the standard library") - .value_name("PATH") - .takes_value(true) - .required(false) - .env("ZOKRATES_STDLIB") - .default_value(cli_constants::DEFAULT_STDLIB_PATH.as_str()) - ).arg(Arg::with_name("abi-spec") - .short("s") - .long("abi-spec") - .help("Path of the ABI specification") - .value_name("FILE") - .takes_value(true) - .required(false) - .default_value(cli_constants::ABI_SPEC_DEFAULT_PATH) - ).arg(Arg::with_name("output") - .short("o") - .long("output") - .help("Path of the output binary") - .value_name("FILE") - .takes_value(true) - .required(false) - .default_value(cli_constants::FLATTENED_CODE_DEFAULT_PATH) - ).arg(Arg::with_name("r1cs") - .short("r1cs") - .long("r1cs") - .help("Path of the output r1cs file") - .value_name("FILE") - .takes_value(true) - .required(false) - .default_value(cli_constants::CIRCOM_R1CS_DEFAULT_PATH) -).arg(Arg::with_name("curve") - .short("c") - .long("curve") - .help("Curve to be used in the compilation") - .takes_value(true) - .required(false) - .possible_values(cli_constants::CURVES) - .default_value(BN128) - ).arg(Arg::with_name("isolate-branches") - .long("isolate-branches") - .help("Isolate the execution of branches: a panic in a branch only makes the program panic if this branch is being logically executed") - .required(false) - ).arg(Arg::with_name("debug") - .long("debug") - .help("Include logs") - .required(false) -) + .arg( + Arg::with_name("input") + .short("i") + .long("input") + .help("Path of the source code") + .value_name("FILE") + .takes_value(true) + .required(true), + ) + .arg( + Arg::with_name("stdlib-path") + .long("stdlib-path") + .help("Path to the standard library") + .value_name("PATH") + .takes_value(true) + .required(false) + .env("ZOKRATES_STDLIB") + .default_value(cli_constants::DEFAULT_STDLIB_PATH.as_str()), + ) + .arg( + Arg::with_name("abi-spec") + .short("s") + .long("abi-spec") + .help("Path of the ABI specification") + .value_name("FILE") + .takes_value(true) + .required(false) + .default_value(cli_constants::ABI_SPEC_DEFAULT_PATH), + ) + .arg( + Arg::with_name("output") + .short("o") + .long("output") + .help("Path of the output binary") + .value_name("FILE") + .takes_value(true) + .required(false) + .default_value(cli_constants::FLATTENED_CODE_DEFAULT_PATH), + ) + .arg( + Arg::with_name("r1cs") + .short("r1cs") + .long("r1cs") + .help("Path of the output r1cs file") + .value_name("FILE") + .takes_value(true) + .required(false) + .default_value(cli_constants::CIRCOM_R1CS_DEFAULT_PATH), + ) + .arg( + Arg::with_name("curve") + .short("c") + .long("curve") + .help("Curve to be used in the compilation") + .takes_value(true) + .required(false) + .possible_values(cli_constants::CURVES) + .default_value(BN128), + ) + .arg( + Arg::with_name("debug") + .long("debug") + .help("Include logs") + .required(false), + ) } pub fn exec(sub_matches: &ArgMatches) -> Result<(), String> { @@ -124,10 +133,7 @@ fn cli_compile(sub_matches: &ArgMatches) -> Result<(), String> { )), }?; - let config = CompileConfig::default() - .isolate_branches(sub_matches.is_present("isolate-branches")) - .debug(sub_matches.is_present("debug")); - + let config = CompileConfig::default().debug(sub_matches.is_present("debug")); let resolver = FileSystemResolver::with_stdlib_root(stdlib_path); log::debug!("Compile"); @@ -138,10 +144,7 @@ fn cli_compile(sub_matches: &ArgMatches) -> Result<(), String> { .map_err(|e| { format!( "Compilation failed:\n\n{}", - e.0.iter() - .map(|e| fmt_error(e)) - .collect::>() - .join("\n\n") + e.0.iter().map(fmt_error).collect::>().join("\n\n") ) })?; diff --git a/zokrates_cli/tests/code/taxation.smt2 b/zokrates_cli/tests/code/taxation.smt2 index 7935ade77..19b00772b 100644 --- a/zokrates_cli/tests/code/taxation.smt2 +++ b/zokrates_cli/tests/code/taxation.smt2 @@ -1,6 +1,6 @@ ; Auto generated by ZoKrates -; Number of circuit variables: 260 -; Number of equalities: 261 +; Number of circuit variables: 764 +; Number of equalities: 769 (declare-const |~prime| Int) (declare-const |~out_0| Int) (declare-const |~one| Int) @@ -261,7 +261,511 @@ (declare-const |_254| Int) (declare-const |_257| Int) (declare-const |_258| Int) +(declare-const |_259| Int) +(declare-const |_260| Int) +(declare-const |_261| Int) +(declare-const |_262| Int) +(declare-const |_263| Int) (declare-const |_264| Int) +(declare-const |_265| Int) +(declare-const |_266| Int) +(declare-const |_267| Int) +(declare-const |_268| Int) +(declare-const |_269| Int) +(declare-const |_270| Int) +(declare-const |_271| Int) +(declare-const |_272| Int) +(declare-const |_273| Int) +(declare-const |_274| Int) +(declare-const |_275| Int) +(declare-const |_276| Int) +(declare-const |_277| Int) +(declare-const |_278| Int) +(declare-const |_279| Int) +(declare-const |_280| Int) +(declare-const |_281| Int) +(declare-const |_282| Int) +(declare-const |_283| Int) +(declare-const |_284| Int) +(declare-const |_285| Int) +(declare-const |_286| Int) +(declare-const |_287| Int) +(declare-const |_288| Int) +(declare-const |_289| Int) +(declare-const |_290| Int) +(declare-const |_291| Int) +(declare-const |_292| Int) +(declare-const |_293| Int) +(declare-const |_294| Int) +(declare-const |_295| Int) +(declare-const |_296| Int) +(declare-const |_297| Int) +(declare-const |_298| Int) +(declare-const |_299| Int) +(declare-const |_300| Int) +(declare-const |_301| Int) +(declare-const |_302| Int) +(declare-const |_303| Int) +(declare-const |_304| Int) +(declare-const |_305| Int) +(declare-const |_306| Int) +(declare-const |_307| Int) +(declare-const |_308| Int) +(declare-const |_309| Int) +(declare-const |_310| Int) +(declare-const |_311| Int) +(declare-const |_312| Int) +(declare-const |_313| Int) +(declare-const |_314| Int) +(declare-const |_315| Int) +(declare-const |_316| Int) +(declare-const |_317| Int) +(declare-const |_318| Int) +(declare-const |_319| Int) +(declare-const |_320| Int) +(declare-const |_321| Int) +(declare-const |_322| Int) +(declare-const |_323| Int) +(declare-const |_324| Int) +(declare-const |_325| Int) +(declare-const |_326| Int) +(declare-const |_327| Int) +(declare-const |_328| Int) +(declare-const |_329| Int) +(declare-const |_330| Int) +(declare-const |_331| Int) +(declare-const |_332| Int) +(declare-const |_333| Int) +(declare-const |_334| Int) +(declare-const |_335| Int) +(declare-const |_336| Int) +(declare-const |_337| Int) +(declare-const |_338| Int) +(declare-const |_339| Int) +(declare-const |_340| Int) +(declare-const |_341| Int) +(declare-const |_342| Int) +(declare-const |_343| Int) +(declare-const |_344| Int) +(declare-const |_345| Int) +(declare-const |_346| Int) +(declare-const |_347| Int) +(declare-const |_348| Int) +(declare-const |_349| Int) +(declare-const |_350| Int) +(declare-const |_351| Int) +(declare-const |_352| Int) +(declare-const |_353| Int) +(declare-const |_354| Int) +(declare-const |_355| Int) +(declare-const |_356| Int) +(declare-const |_357| Int) +(declare-const |_358| Int) +(declare-const |_359| Int) +(declare-const |_360| Int) +(declare-const |_361| Int) +(declare-const |_362| Int) +(declare-const |_363| Int) +(declare-const |_364| Int) +(declare-const |_365| Int) +(declare-const |_366| Int) +(declare-const |_367| Int) +(declare-const |_368| Int) +(declare-const |_369| Int) +(declare-const |_370| Int) +(declare-const |_371| Int) +(declare-const |_372| Int) +(declare-const |_373| Int) +(declare-const |_374| Int) +(declare-const |_375| Int) +(declare-const |_376| Int) +(declare-const |_377| Int) +(declare-const |_378| Int) +(declare-const |_379| Int) +(declare-const |_380| Int) +(declare-const |_381| Int) +(declare-const |_382| Int) +(declare-const |_383| Int) +(declare-const |_384| Int) +(declare-const |_385| Int) +(declare-const |_386| Int) +(declare-const |_387| Int) +(declare-const |_388| Int) +(declare-const |_389| Int) +(declare-const |_390| Int) +(declare-const |_391| Int) +(declare-const |_392| Int) +(declare-const |_393| Int) +(declare-const |_394| Int) +(declare-const |_395| Int) +(declare-const |_396| Int) +(declare-const |_397| Int) +(declare-const |_398| Int) +(declare-const |_399| Int) +(declare-const |_400| Int) +(declare-const |_401| Int) +(declare-const |_402| Int) +(declare-const |_403| Int) +(declare-const |_404| Int) +(declare-const |_405| Int) +(declare-const |_406| Int) +(declare-const |_407| Int) +(declare-const |_408| Int) +(declare-const |_409| Int) +(declare-const |_410| Int) +(declare-const |_411| Int) +(declare-const |_412| Int) +(declare-const |_413| Int) +(declare-const |_414| Int) +(declare-const |_415| Int) +(declare-const |_416| Int) +(declare-const |_417| Int) +(declare-const |_418| Int) +(declare-const |_419| Int) +(declare-const |_420| Int) +(declare-const |_421| Int) +(declare-const |_422| Int) +(declare-const |_423| Int) +(declare-const |_424| Int) +(declare-const |_425| Int) +(declare-const |_426| Int) +(declare-const |_427| Int) +(declare-const |_428| Int) +(declare-const |_429| Int) +(declare-const |_430| Int) +(declare-const |_431| Int) +(declare-const |_432| Int) +(declare-const |_433| Int) +(declare-const |_434| Int) +(declare-const |_435| Int) +(declare-const |_436| Int) +(declare-const |_437| Int) +(declare-const |_438| Int) +(declare-const |_439| Int) +(declare-const |_440| Int) +(declare-const |_441| Int) +(declare-const |_442| Int) +(declare-const |_443| Int) +(declare-const |_444| Int) +(declare-const |_445| Int) +(declare-const |_446| Int) +(declare-const |_447| Int) +(declare-const |_448| Int) +(declare-const |_449| Int) +(declare-const |_450| Int) +(declare-const |_451| Int) +(declare-const |_452| Int) +(declare-const |_453| Int) +(declare-const |_454| Int) +(declare-const |_455| Int) +(declare-const |_456| Int) +(declare-const |_457| Int) +(declare-const |_458| Int) +(declare-const |_459| Int) +(declare-const |_460| Int) +(declare-const |_461| Int) +(declare-const |_462| Int) +(declare-const |_463| Int) +(declare-const |_464| Int) +(declare-const |_465| Int) +(declare-const |_466| Int) +(declare-const |_467| Int) +(declare-const |_468| Int) +(declare-const |_469| Int) +(declare-const |_470| Int) +(declare-const |_471| Int) +(declare-const |_472| Int) +(declare-const |_473| Int) +(declare-const |_474| Int) +(declare-const |_475| Int) +(declare-const |_476| Int) +(declare-const |_477| Int) +(declare-const |_478| Int) +(declare-const |_479| Int) +(declare-const |_480| Int) +(declare-const |_481| Int) +(declare-const |_482| Int) +(declare-const |_483| Int) +(declare-const |_484| Int) +(declare-const |_485| Int) +(declare-const |_486| Int) +(declare-const |_487| Int) +(declare-const |_488| Int) +(declare-const |_489| Int) +(declare-const |_490| Int) +(declare-const |_491| Int) +(declare-const |_492| Int) +(declare-const |_493| Int) +(declare-const |_494| Int) +(declare-const |_495| Int) +(declare-const |_496| Int) +(declare-const |_497| Int) +(declare-const |_498| Int) +(declare-const |_499| Int) +(declare-const |_500| Int) +(declare-const |_501| Int) +(declare-const |_502| Int) +(declare-const |_503| Int) +(declare-const |_504| Int) +(declare-const |_505| Int) +(declare-const |_506| Int) +(declare-const |_507| Int) +(declare-const |_508| Int) +(declare-const |_509| Int) +(declare-const |_510| Int) +(declare-const |_511| Int) +(declare-const |_512| Int) +(declare-const |_513| Int) +(declare-const |_514| Int) +(declare-const |_515| Int) +(declare-const |_516| Int) +(declare-const |_517| Int) +(declare-const |_518| Int) +(declare-const |_519| Int) +(declare-const |_520| Int) +(declare-const |_521| Int) +(declare-const |_522| Int) +(declare-const |_523| Int) +(declare-const |_524| Int) +(declare-const |_525| Int) +(declare-const |_526| Int) +(declare-const |_527| Int) +(declare-const |_528| Int) +(declare-const |_529| Int) +(declare-const |_530| Int) +(declare-const |_531| Int) +(declare-const |_532| Int) +(declare-const |_533| Int) +(declare-const |_534| Int) +(declare-const |_535| Int) +(declare-const |_536| Int) +(declare-const |_537| Int) +(declare-const |_538| Int) +(declare-const |_539| Int) +(declare-const |_540| Int) +(declare-const |_541| Int) +(declare-const |_542| Int) +(declare-const |_543| Int) +(declare-const |_544| Int) +(declare-const |_545| Int) +(declare-const |_546| Int) +(declare-const |_547| Int) +(declare-const |_548| Int) +(declare-const |_549| Int) +(declare-const |_550| Int) +(declare-const |_551| Int) +(declare-const |_552| Int) +(declare-const |_553| Int) +(declare-const |_554| Int) +(declare-const |_555| Int) +(declare-const |_556| Int) +(declare-const |_557| Int) +(declare-const |_558| Int) +(declare-const |_559| Int) +(declare-const |_560| Int) +(declare-const |_561| Int) +(declare-const |_562| Int) +(declare-const |_563| Int) +(declare-const |_564| Int) +(declare-const |_565| Int) +(declare-const |_566| Int) +(declare-const |_567| Int) +(declare-const |_568| Int) +(declare-const |_569| Int) +(declare-const |_570| Int) +(declare-const |_571| Int) +(declare-const |_572| Int) +(declare-const |_573| Int) +(declare-const |_574| Int) +(declare-const |_575| Int) +(declare-const |_576| Int) +(declare-const |_577| Int) +(declare-const |_578| Int) +(declare-const |_579| Int) +(declare-const |_580| Int) +(declare-const |_581| Int) +(declare-const |_582| Int) +(declare-const |_583| Int) +(declare-const |_584| Int) +(declare-const |_585| Int) +(declare-const |_586| Int) +(declare-const |_587| Int) +(declare-const |_588| Int) +(declare-const |_589| Int) +(declare-const |_590| Int) +(declare-const |_591| Int) +(declare-const |_592| Int) +(declare-const |_593| Int) +(declare-const |_594| Int) +(declare-const |_595| Int) +(declare-const |_596| Int) +(declare-const |_597| Int) +(declare-const |_598| Int) +(declare-const |_599| Int) +(declare-const |_600| Int) +(declare-const |_601| Int) +(declare-const |_602| Int) +(declare-const |_603| Int) +(declare-const |_604| Int) +(declare-const |_605| Int) +(declare-const |_606| Int) +(declare-const |_607| Int) +(declare-const |_608| Int) +(declare-const |_609| Int) +(declare-const |_610| Int) +(declare-const |_611| Int) +(declare-const |_612| Int) +(declare-const |_613| Int) +(declare-const |_614| Int) +(declare-const |_615| Int) +(declare-const |_616| Int) +(declare-const |_617| Int) +(declare-const |_618| Int) +(declare-const |_619| Int) +(declare-const |_620| Int) +(declare-const |_621| Int) +(declare-const |_622| Int) +(declare-const |_623| Int) +(declare-const |_624| Int) +(declare-const |_625| Int) +(declare-const |_626| Int) +(declare-const |_627| Int) +(declare-const |_628| Int) +(declare-const |_629| Int) +(declare-const |_630| Int) +(declare-const |_631| Int) +(declare-const |_632| Int) +(declare-const |_633| Int) +(declare-const |_634| Int) +(declare-const |_635| Int) +(declare-const |_636| Int) +(declare-const |_637| Int) +(declare-const |_638| Int) +(declare-const |_639| Int) +(declare-const |_640| Int) +(declare-const |_641| Int) +(declare-const |_642| Int) +(declare-const |_643| Int) +(declare-const |_644| Int) +(declare-const |_645| Int) +(declare-const |_646| Int) +(declare-const |_647| Int) +(declare-const |_648| Int) +(declare-const |_649| Int) +(declare-const |_650| Int) +(declare-const |_651| Int) +(declare-const |_652| Int) +(declare-const |_653| Int) +(declare-const |_654| Int) +(declare-const |_655| Int) +(declare-const |_656| Int) +(declare-const |_657| Int) +(declare-const |_658| Int) +(declare-const |_659| Int) +(declare-const |_660| Int) +(declare-const |_661| Int) +(declare-const |_662| Int) +(declare-const |_663| Int) +(declare-const |_664| Int) +(declare-const |_665| Int) +(declare-const |_666| Int) +(declare-const |_667| Int) +(declare-const |_668| Int) +(declare-const |_669| Int) +(declare-const |_670| Int) +(declare-const |_671| Int) +(declare-const |_672| Int) +(declare-const |_673| Int) +(declare-const |_674| Int) +(declare-const |_675| Int) +(declare-const |_676| Int) +(declare-const |_677| Int) +(declare-const |_678| Int) +(declare-const |_679| Int) +(declare-const |_680| Int) +(declare-const |_681| Int) +(declare-const |_682| Int) +(declare-const |_683| Int) +(declare-const |_684| Int) +(declare-const |_685| Int) +(declare-const |_686| Int) +(declare-const |_687| Int) +(declare-const |_688| Int) +(declare-const |_689| Int) +(declare-const |_690| Int) +(declare-const |_691| Int) +(declare-const |_692| Int) +(declare-const |_693| Int) +(declare-const |_694| Int) +(declare-const |_695| Int) +(declare-const |_696| Int) +(declare-const |_697| Int) +(declare-const |_698| Int) +(declare-const |_699| Int) +(declare-const |_700| Int) +(declare-const |_701| Int) +(declare-const |_702| Int) +(declare-const |_703| Int) +(declare-const |_704| Int) +(declare-const |_705| Int) +(declare-const |_706| Int) +(declare-const |_707| Int) +(declare-const |_708| Int) +(declare-const |_709| Int) +(declare-const |_710| Int) +(declare-const |_711| Int) +(declare-const |_712| Int) +(declare-const |_713| Int) +(declare-const |_714| Int) +(declare-const |_715| Int) +(declare-const |_716| Int) +(declare-const |_717| Int) +(declare-const |_718| Int) +(declare-const |_719| Int) +(declare-const |_720| Int) +(declare-const |_721| Int) +(declare-const |_722| Int) +(declare-const |_723| Int) +(declare-const |_724| Int) +(declare-const |_725| Int) +(declare-const |_726| Int) +(declare-const |_727| Int) +(declare-const |_728| Int) +(declare-const |_729| Int) +(declare-const |_730| Int) +(declare-const |_731| Int) +(declare-const |_732| Int) +(declare-const |_733| Int) +(declare-const |_734| Int) +(declare-const |_735| Int) +(declare-const |_736| Int) +(declare-const |_737| Int) +(declare-const |_738| Int) +(declare-const |_739| Int) +(declare-const |_740| Int) +(declare-const |_741| Int) +(declare-const |_742| Int) +(declare-const |_743| Int) +(declare-const |_744| Int) +(declare-const |_745| Int) +(declare-const |_746| Int) +(declare-const |_747| Int) +(declare-const |_748| Int) +(declare-const |_749| Int) +(declare-const |_750| Int) +(declare-const |_751| Int) +(declare-const |_752| Int) +(declare-const |_753| Int) +(declare-const |_754| Int) +(declare-const |_755| Int) +(declare-const |_756| Int) +(declare-const |_757| Int) +(declare-const |_758| Int) +(declare-const |_759| Int) +(declare-const |_760| Int) +(declare-const |_761| Int) +(declare-const |_762| Int) +(declare-const |_768| Int) (assert (and (= |~prime| 21888242871839275222246405745257275088548364400416034343698204186575808495617) (= |~one| 1) @@ -524,6 +1028,514 @@ (= (mod (* (+ (* |~one| 14651237294507013008273219182214280847718990358813499091232105186081237893121) (* |_0| 1) (* |_1| 21888242871839275222246405745257275088548364400416034343698204186575808495616)) (* |_258| 1)) |~prime|) (mod (* |_257| 1) |~prime|)) (= (mod (* (+ (* |~one| 1) (* |_257| 21888242871839275222246405745257275088548364400416034343698204186575808495616)) (+ (* |~one| 14651237294507013008273219182214280847718990358813499091232105186081237893121) (* |_0| 1) (* |_1| 21888242871839275222246405745257275088548364400416034343698204186575808495616))) |~prime|) (mod 0 |~prime|)) (= (mod (* (* |~one| 1) (* |~one| 1)) |~prime|) (mod (* |_257| 1) |~prime|)) -(= (mod (* (* |_2| 1) (+ (* |_0| 21888242871839275222246405745257275088548364400416034343698204186575808495616) (* |_1| 1))) |~prime|) (mod (* |_264| 1) |~prime|)) -(= (mod (* (* |~one| 1) (* |_264| 1)) |~prime|) (mod (* |~out_0| 1) |~prime|)) + +(= (mod (* (* |_259| 1) (* |_259| 1)) |~prime|) (mod (* |_259| 1) |~prime|)) +(= (mod (* (* |_260| 1) (* |_260| 1)) |~prime|) (mod (* |_260| 1) |~prime|)) +(= (mod (* (* |_261| 1) (* |_261| 1)) |~prime|) (mod (* |_261| 1) |~prime|)) +(= (mod (* (* |_262| 1) (* |_262| 1)) |~prime|) (mod (* |_262| 1) |~prime|)) +(= (mod (* (* |_263| 1) (* |_263| 1)) |~prime|) (mod (* |_263| 1) |~prime|)) +(= (mod (* (* |_264| 1) (* |_264| 1)) |~prime|) (mod (* |_264| 1) |~prime|)) +(= (mod (* (* |_265| 1) (* |_265| 1)) |~prime|) (mod (* |_265| 1) |~prime|)) +(= (mod (* (* |_266| 1) (* |_266| 1)) |~prime|) (mod (* |_266| 1) |~prime|)) +(= (mod (* (* |_267| 1) (* |_267| 1)) |~prime|) (mod (* |_267| 1) |~prime|)) +(= (mod (* (* |_268| 1) (* |_268| 1)) |~prime|) (mod (* |_268| 1) |~prime|)) +(= (mod (* (* |_269| 1) (* |_269| 1)) |~prime|) (mod (* |_269| 1) |~prime|)) +(= (mod (* (* |_270| 1) (* |_270| 1)) |~prime|) (mod (* |_270| 1) |~prime|)) +(= (mod (* (* |_271| 1) (* |_271| 1)) |~prime|) (mod (* |_271| 1) |~prime|)) +(= (mod (* (* |_272| 1) (* |_272| 1)) |~prime|) (mod (* |_272| 1) |~prime|)) +(= (mod (* (* |_273| 1) (* |_273| 1)) |~prime|) (mod (* |_273| 1) |~prime|)) +(= (mod (* (* |_274| 1) (* |_274| 1)) |~prime|) (mod (* |_274| 1) |~prime|)) +(= (mod (* (* |_275| 1) (* |_275| 1)) |~prime|) (mod (* |_275| 1) |~prime|)) +(= (mod (* (* |_276| 1) (* |_276| 1)) |~prime|) (mod (* |_276| 1) |~prime|)) +(= (mod (* (* |_277| 1) (* |_277| 1)) |~prime|) (mod (* |_277| 1) |~prime|)) +(= (mod (* (* |_278| 1) (* |_278| 1)) |~prime|) (mod (* |_278| 1) |~prime|)) +(= (mod (* (* |_279| 1) (* |_279| 1)) |~prime|) (mod (* |_279| 1) |~prime|)) +(= (mod (* (* |_280| 1) (* |_280| 1)) |~prime|) (mod (* |_280| 1) |~prime|)) +(= (mod (* (* |_281| 1) (* |_281| 1)) |~prime|) (mod (* |_281| 1) |~prime|)) +(= (mod (* (* |_282| 1) (* |_282| 1)) |~prime|) (mod (* |_282| 1) |~prime|)) +(= (mod (* (* |_283| 1) (* |_283| 1)) |~prime|) (mod (* |_283| 1) |~prime|)) +(= (mod (* (* |_284| 1) (* |_284| 1)) |~prime|) (mod (* |_284| 1) |~prime|)) +(= (mod (* (* |_285| 1) (* |_285| 1)) |~prime|) (mod (* |_285| 1) |~prime|)) +(= (mod (* (* |_286| 1) (* |_286| 1)) |~prime|) (mod (* |_286| 1) |~prime|)) +(= (mod (* (* |_287| 1) (* |_287| 1)) |~prime|) (mod (* |_287| 1) |~prime|)) +(= (mod (* (* |_288| 1) (* |_288| 1)) |~prime|) (mod (* |_288| 1) |~prime|)) +(= (mod (* (* |_289| 1) (* |_289| 1)) |~prime|) (mod (* |_289| 1) |~prime|)) +(= (mod (* (* |_290| 1) (* |_290| 1)) |~prime|) (mod (* |_290| 1) |~prime|)) +(= (mod (* (* |_291| 1) (* |_291| 1)) |~prime|) (mod (* |_291| 1) |~prime|)) +(= (mod (* (* |_292| 1) (* |_292| 1)) |~prime|) (mod (* |_292| 1) |~prime|)) +(= (mod (* (* |_293| 1) (* |_293| 1)) |~prime|) (mod (* |_293| 1) |~prime|)) +(= (mod (* (* |_294| 1) (* |_294| 1)) |~prime|) (mod (* |_294| 1) |~prime|)) +(= (mod (* (* |_295| 1) (* |_295| 1)) |~prime|) (mod (* |_295| 1) |~prime|)) +(= (mod (* (* |_296| 1) (* |_296| 1)) |~prime|) (mod (* |_296| 1) |~prime|)) +(= (mod (* (* |_297| 1) (* |_297| 1)) |~prime|) (mod (* |_297| 1) |~prime|)) +(= (mod (* (* |_298| 1) (* |_298| 1)) |~prime|) (mod (* |_298| 1) |~prime|)) +(= (mod (* (* |_299| 1) (* |_299| 1)) |~prime|) (mod (* |_299| 1) |~prime|)) +(= (mod (* (* |_300| 1) (* |_300| 1)) |~prime|) (mod (* |_300| 1) |~prime|)) +(= (mod (* (* |_301| 1) (* |_301| 1)) |~prime|) (mod (* |_301| 1) |~prime|)) +(= (mod (* (* |_302| 1) (* |_302| 1)) |~prime|) (mod (* |_302| 1) |~prime|)) +(= (mod (* (* |_303| 1) (* |_303| 1)) |~prime|) (mod (* |_303| 1) |~prime|)) +(= (mod (* (* |_304| 1) (* |_304| 1)) |~prime|) (mod (* |_304| 1) |~prime|)) +(= (mod (* (* |_305| 1) (* |_305| 1)) |~prime|) (mod (* |_305| 1) |~prime|)) +(= (mod (* (* |_306| 1) (* |_306| 1)) |~prime|) (mod (* |_306| 1) |~prime|)) +(= (mod (* (* |_307| 1) (* |_307| 1)) |~prime|) (mod (* |_307| 1) |~prime|)) +(= (mod (* (* |_308| 1) (* |_308| 1)) |~prime|) (mod (* |_308| 1) |~prime|)) +(= (mod (* (* |_309| 1) (* |_309| 1)) |~prime|) (mod (* |_309| 1) |~prime|)) +(= (mod (* (* |_310| 1) (* |_310| 1)) |~prime|) (mod (* |_310| 1) |~prime|)) +(= (mod (* (* |_311| 1) (* |_311| 1)) |~prime|) (mod (* |_311| 1) |~prime|)) +(= (mod (* (* |_312| 1) (* |_312| 1)) |~prime|) (mod (* |_312| 1) |~prime|)) +(= (mod (* (* |_313| 1) (* |_313| 1)) |~prime|) (mod (* |_313| 1) |~prime|)) +(= (mod (* (* |_314| 1) (* |_314| 1)) |~prime|) (mod (* |_314| 1) |~prime|)) +(= (mod (* (* |_315| 1) (* |_315| 1)) |~prime|) (mod (* |_315| 1) |~prime|)) +(= (mod (* (* |_316| 1) (* |_316| 1)) |~prime|) (mod (* |_316| 1) |~prime|)) +(= (mod (* (* |_317| 1) (* |_317| 1)) |~prime|) (mod (* |_317| 1) |~prime|)) +(= (mod (* (* |_318| 1) (* |_318| 1)) |~prime|) (mod (* |_318| 1) |~prime|)) +(= (mod (* (* |_319| 1) (* |_319| 1)) |~prime|) (mod (* |_319| 1) |~prime|)) +(= (mod (* (* |_320| 1) (* |_320| 1)) |~prime|) (mod (* |_320| 1) |~prime|)) +(= (mod (* (* |_321| 1) (* |_321| 1)) |~prime|) (mod (* |_321| 1) |~prime|)) +(= (mod (* (* |_322| 1) (* |_322| 1)) |~prime|) (mod (* |_322| 1) |~prime|)) +(= (mod (* (* |_323| 1) (* |_323| 1)) |~prime|) (mod (* |_323| 1) |~prime|)) +(= (mod (* (* |_324| 1) (* |_324| 1)) |~prime|) (mod (* |_324| 1) |~prime|)) +(= (mod (* (* |_325| 1) (* |_325| 1)) |~prime|) (mod (* |_325| 1) |~prime|)) +(= (mod (* (* |_326| 1) (* |_326| 1)) |~prime|) (mod (* |_326| 1) |~prime|)) +(= (mod (* (* |_327| 1) (* |_327| 1)) |~prime|) (mod (* |_327| 1) |~prime|)) +(= (mod (* (* |_328| 1) (* |_328| 1)) |~prime|) (mod (* |_328| 1) |~prime|)) +(= (mod (* (* |_329| 1) (* |_329| 1)) |~prime|) (mod (* |_329| 1) |~prime|)) +(= (mod (* (* |_330| 1) (* |_330| 1)) |~prime|) (mod (* |_330| 1) |~prime|)) +(= (mod (* (* |_331| 1) (* |_331| 1)) |~prime|) (mod (* |_331| 1) |~prime|)) +(= (mod (* (* |_332| 1) (* |_332| 1)) |~prime|) (mod (* |_332| 1) |~prime|)) +(= (mod (* (* |_333| 1) (* |_333| 1)) |~prime|) (mod (* |_333| 1) |~prime|)) +(= (mod (* (* |_334| 1) (* |_334| 1)) |~prime|) (mod (* |_334| 1) |~prime|)) +(= (mod (* (* |_335| 1) (* |_335| 1)) |~prime|) (mod (* |_335| 1) |~prime|)) +(= (mod (* (* |_336| 1) (* |_336| 1)) |~prime|) (mod (* |_336| 1) |~prime|)) +(= (mod (* (* |_337| 1) (* |_337| 1)) |~prime|) (mod (* |_337| 1) |~prime|)) +(= (mod (* (* |_338| 1) (* |_338| 1)) |~prime|) (mod (* |_338| 1) |~prime|)) +(= (mod (* (* |_339| 1) (* |_339| 1)) |~prime|) (mod (* |_339| 1) |~prime|)) +(= (mod (* (* |_340| 1) (* |_340| 1)) |~prime|) (mod (* |_340| 1) |~prime|)) +(= (mod (* (* |_341| 1) (* |_341| 1)) |~prime|) (mod (* |_341| 1) |~prime|)) +(= (mod (* (* |_342| 1) (* |_342| 1)) |~prime|) (mod (* |_342| 1) |~prime|)) +(= (mod (* (* |_343| 1) (* |_343| 1)) |~prime|) (mod (* |_343| 1) |~prime|)) +(= (mod (* (* |_344| 1) (* |_344| 1)) |~prime|) (mod (* |_344| 1) |~prime|)) +(= (mod (* (* |_345| 1) (* |_345| 1)) |~prime|) (mod (* |_345| 1) |~prime|)) +(= (mod (* (* |_346| 1) (* |_346| 1)) |~prime|) (mod (* |_346| 1) |~prime|)) +(= (mod (* (* |_347| 1) (* |_347| 1)) |~prime|) (mod (* |_347| 1) |~prime|)) +(= (mod (* (* |_348| 1) (* |_348| 1)) |~prime|) (mod (* |_348| 1) |~prime|)) +(= (mod (* (* |_349| 1) (* |_349| 1)) |~prime|) (mod (* |_349| 1) |~prime|)) +(= (mod (* (* |_350| 1) (* |_350| 1)) |~prime|) (mod (* |_350| 1) |~prime|)) +(= (mod (* (* |_351| 1) (* |_351| 1)) |~prime|) (mod (* |_351| 1) |~prime|)) +(= (mod (* (* |_352| 1) (* |_352| 1)) |~prime|) (mod (* |_352| 1) |~prime|)) +(= (mod (* (* |_353| 1) (* |_353| 1)) |~prime|) (mod (* |_353| 1) |~prime|)) +(= (mod (* (* |_354| 1) (* |_354| 1)) |~prime|) (mod (* |_354| 1) |~prime|)) +(= (mod (* (* |_355| 1) (* |_355| 1)) |~prime|) (mod (* |_355| 1) |~prime|)) +(= (mod (* (* |_356| 1) (* |_356| 1)) |~prime|) (mod (* |_356| 1) |~prime|)) +(= (mod (* (* |_357| 1) (* |_357| 1)) |~prime|) (mod (* |_357| 1) |~prime|)) +(= (mod (* (* |_358| 1) (* |_358| 1)) |~prime|) (mod (* |_358| 1) |~prime|)) +(= (mod (* (* |_359| 1) (* |_359| 1)) |~prime|) (mod (* |_359| 1) |~prime|)) +(= (mod (* (* |_360| 1) (* |_360| 1)) |~prime|) (mod (* |_360| 1) |~prime|)) +(= (mod (* (* |_361| 1) (* |_361| 1)) |~prime|) (mod (* |_361| 1) |~prime|)) +(= (mod (* (* |_362| 1) (* |_362| 1)) |~prime|) (mod (* |_362| 1) |~prime|)) +(= (mod (* (* |_363| 1) (* |_363| 1)) |~prime|) (mod (* |_363| 1) |~prime|)) +(= (mod (* (* |_364| 1) (* |_364| 1)) |~prime|) (mod (* |_364| 1) |~prime|)) +(= (mod (* (* |_365| 1) (* |_365| 1)) |~prime|) (mod (* |_365| 1) |~prime|)) +(= (mod (* (* |_366| 1) (* |_366| 1)) |~prime|) (mod (* |_366| 1) |~prime|)) +(= (mod (* (* |_367| 1) (* |_367| 1)) |~prime|) (mod (* |_367| 1) |~prime|)) +(= (mod (* (* |_368| 1) (* |_368| 1)) |~prime|) (mod (* |_368| 1) |~prime|)) +(= (mod (* (* |_369| 1) (* |_369| 1)) |~prime|) (mod (* |_369| 1) |~prime|)) +(= (mod (* (* |_370| 1) (* |_370| 1)) |~prime|) (mod (* |_370| 1) |~prime|)) +(= (mod (* (* |_371| 1) (* |_371| 1)) |~prime|) (mod (* |_371| 1) |~prime|)) +(= (mod (* (* |_372| 1) (* |_372| 1)) |~prime|) (mod (* |_372| 1) |~prime|)) +(= (mod (* (* |_373| 1) (* |_373| 1)) |~prime|) (mod (* |_373| 1) |~prime|)) +(= (mod (* (* |_374| 1) (* |_374| 1)) |~prime|) (mod (* |_374| 1) |~prime|)) +(= (mod (* (* |_375| 1) (* |_375| 1)) |~prime|) (mod (* |_375| 1) |~prime|)) +(= (mod (* (* |_376| 1) (* |_376| 1)) |~prime|) (mod (* |_376| 1) |~prime|)) +(= (mod (* (* |_377| 1) (* |_377| 1)) |~prime|) (mod (* |_377| 1) |~prime|)) +(= (mod (* (* |_378| 1) (* |_378| 1)) |~prime|) (mod (* |_378| 1) |~prime|)) +(= (mod (* (* |_379| 1) (* |_379| 1)) |~prime|) (mod (* |_379| 1) |~prime|)) +(= (mod (* (* |_380| 1) (* |_380| 1)) |~prime|) (mod (* |_380| 1) |~prime|)) +(= (mod (* (* |_381| 1) (* |_381| 1)) |~prime|) (mod (* |_381| 1) |~prime|)) +(= (mod (* (* |_382| 1) (* |_382| 1)) |~prime|) (mod (* |_382| 1) |~prime|)) +(= (mod (* (* |_383| 1) (* |_383| 1)) |~prime|) (mod (* |_383| 1) |~prime|)) +(= (mod (* (* |_384| 1) (* |_384| 1)) |~prime|) (mod (* |_384| 1) |~prime|)) +(= (mod (* (* |_385| 1) (* |_385| 1)) |~prime|) (mod (* |_385| 1) |~prime|)) +(= (mod (* (* |_386| 1) (* |_386| 1)) |~prime|) (mod (* |_386| 1) |~prime|)) +(= (mod (* (* |_387| 1) (* |_387| 1)) |~prime|) (mod (* |_387| 1) |~prime|)) +(= (mod (* (* |_388| 1) (* |_388| 1)) |~prime|) (mod (* |_388| 1) |~prime|)) +(= (mod (* (* |_389| 1) (* |_389| 1)) |~prime|) (mod (* |_389| 1) |~prime|)) +(= (mod (* (* |_390| 1) (* |_390| 1)) |~prime|) (mod (* |_390| 1) |~prime|)) +(= (mod (* (* |_391| 1) (* |_391| 1)) |~prime|) (mod (* |_391| 1) |~prime|)) +(= (mod (* (* |_392| 1) (* |_392| 1)) |~prime|) (mod (* |_392| 1) |~prime|)) +(= (mod (* (* |_393| 1) (* |_393| 1)) |~prime|) (mod (* |_393| 1) |~prime|)) +(= (mod (* (* |_394| 1) (* |_394| 1)) |~prime|) (mod (* |_394| 1) |~prime|)) +(= (mod (* (* |_395| 1) (* |_395| 1)) |~prime|) (mod (* |_395| 1) |~prime|)) +(= (mod (* (* |_396| 1) (* |_396| 1)) |~prime|) (mod (* |_396| 1) |~prime|)) +(= (mod (* (* |_397| 1) (* |_397| 1)) |~prime|) (mod (* |_397| 1) |~prime|)) +(= (mod (* (* |_398| 1) (* |_398| 1)) |~prime|) (mod (* |_398| 1) |~prime|)) +(= (mod (* (* |_399| 1) (* |_399| 1)) |~prime|) (mod (* |_399| 1) |~prime|)) +(= (mod (* (* |_400| 1) (* |_400| 1)) |~prime|) (mod (* |_400| 1) |~prime|)) +(= (mod (* (* |_401| 1) (* |_401| 1)) |~prime|) (mod (* |_401| 1) |~prime|)) +(= (mod (* (* |_402| 1) (* |_402| 1)) |~prime|) (mod (* |_402| 1) |~prime|)) +(= (mod (* (* |_403| 1) (* |_403| 1)) |~prime|) (mod (* |_403| 1) |~prime|)) +(= (mod (* (* |_404| 1) (* |_404| 1)) |~prime|) (mod (* |_404| 1) |~prime|)) +(= (mod (* (* |_405| 1) (* |_405| 1)) |~prime|) (mod (* |_405| 1) |~prime|)) +(= (mod (* (* |_406| 1) (* |_406| 1)) |~prime|) (mod (* |_406| 1) |~prime|)) +(= (mod (* (* |_407| 1) (* |_407| 1)) |~prime|) (mod (* |_407| 1) |~prime|)) +(= (mod (* (* |_408| 1) (* |_408| 1)) |~prime|) (mod (* |_408| 1) |~prime|)) +(= (mod (* (* |_409| 1) (* |_409| 1)) |~prime|) (mod (* |_409| 1) |~prime|)) +(= (mod (* (* |_410| 1) (* |_410| 1)) |~prime|) (mod (* |_410| 1) |~prime|)) +(= (mod (* (* |_411| 1) (* |_411| 1)) |~prime|) (mod (* |_411| 1) |~prime|)) +(= (mod (* (* |_412| 1) (* |_412| 1)) |~prime|) (mod (* |_412| 1) |~prime|)) +(= (mod (* (* |_413| 1) (* |_413| 1)) |~prime|) (mod (* |_413| 1) |~prime|)) +(= (mod (* (* |_414| 1) (* |_414| 1)) |~prime|) (mod (* |_414| 1) |~prime|)) +(= (mod (* (* |_415| 1) (* |_415| 1)) |~prime|) (mod (* |_415| 1) |~prime|)) +(= (mod (* (* |_416| 1) (* |_416| 1)) |~prime|) (mod (* |_416| 1) |~prime|)) +(= (mod (* (* |_417| 1) (* |_417| 1)) |~prime|) (mod (* |_417| 1) |~prime|)) +(= (mod (* (* |_418| 1) (* |_418| 1)) |~prime|) (mod (* |_418| 1) |~prime|)) +(= (mod (* (* |_419| 1) (* |_419| 1)) |~prime|) (mod (* |_419| 1) |~prime|)) +(= (mod (* (* |_420| 1) (* |_420| 1)) |~prime|) (mod (* |_420| 1) |~prime|)) +(= (mod (* (* |_421| 1) (* |_421| 1)) |~prime|) (mod (* |_421| 1) |~prime|)) +(= (mod (* (* |_422| 1) (* |_422| 1)) |~prime|) (mod (* |_422| 1) |~prime|)) +(= (mod (* (* |_423| 1) (* |_423| 1)) |~prime|) (mod (* |_423| 1) |~prime|)) +(= (mod (* (* |_424| 1) (* |_424| 1)) |~prime|) (mod (* |_424| 1) |~prime|)) +(= (mod (* (* |_425| 1) (* |_425| 1)) |~prime|) (mod (* |_425| 1) |~prime|)) +(= (mod (* (* |_426| 1) (* |_426| 1)) |~prime|) (mod (* |_426| 1) |~prime|)) +(= (mod (* (* |_427| 1) (* |_427| 1)) |~prime|) (mod (* |_427| 1) |~prime|)) +(= (mod (* (* |_428| 1) (* |_428| 1)) |~prime|) (mod (* |_428| 1) |~prime|)) +(= (mod (* (* |_429| 1) (* |_429| 1)) |~prime|) (mod (* |_429| 1) |~prime|)) +(= (mod (* (* |_430| 1) (* |_430| 1)) |~prime|) (mod (* |_430| 1) |~prime|)) +(= (mod (* (* |_431| 1) (* |_431| 1)) |~prime|) (mod (* |_431| 1) |~prime|)) +(= (mod (* (* |_432| 1) (* |_432| 1)) |~prime|) (mod (* |_432| 1) |~prime|)) +(= (mod (* (* |_433| 1) (* |_433| 1)) |~prime|) (mod (* |_433| 1) |~prime|)) +(= (mod (* (* |_434| 1) (* |_434| 1)) |~prime|) (mod (* |_434| 1) |~prime|)) +(= (mod (* (* |_435| 1) (* |_435| 1)) |~prime|) (mod (* |_435| 1) |~prime|)) +(= (mod (* (* |_436| 1) (* |_436| 1)) |~prime|) (mod (* |_436| 1) |~prime|)) +(= (mod (* (* |_437| 1) (* |_437| 1)) |~prime|) (mod (* |_437| 1) |~prime|)) +(= (mod (* (* |_438| 1) (* |_438| 1)) |~prime|) (mod (* |_438| 1) |~prime|)) +(= (mod (* (* |_439| 1) (* |_439| 1)) |~prime|) (mod (* |_439| 1) |~prime|)) +(= (mod (* (* |_440| 1) (* |_440| 1)) |~prime|) (mod (* |_440| 1) |~prime|)) +(= (mod (* (* |_441| 1) (* |_441| 1)) |~prime|) (mod (* |_441| 1) |~prime|)) +(= (mod (* (* |_442| 1) (* |_442| 1)) |~prime|) (mod (* |_442| 1) |~prime|)) +(= (mod (* (* |_443| 1) (* |_443| 1)) |~prime|) (mod (* |_443| 1) |~prime|)) +(= (mod (* (* |_444| 1) (* |_444| 1)) |~prime|) (mod (* |_444| 1) |~prime|)) +(= (mod (* (* |_445| 1) (* |_445| 1)) |~prime|) (mod (* |_445| 1) |~prime|)) +(= (mod (* (* |_446| 1) (* |_446| 1)) |~prime|) (mod (* |_446| 1) |~prime|)) +(= (mod (* (* |_447| 1) (* |_447| 1)) |~prime|) (mod (* |_447| 1) |~prime|)) +(= (mod (* (* |_448| 1) (* |_448| 1)) |~prime|) (mod (* |_448| 1) |~prime|)) +(= (mod (* (* |_449| 1) (* |_449| 1)) |~prime|) (mod (* |_449| 1) |~prime|)) +(= (mod (* (* |_450| 1) (* |_450| 1)) |~prime|) (mod (* |_450| 1) |~prime|)) +(= (mod (* (* |_451| 1) (* |_451| 1)) |~prime|) (mod (* |_451| 1) |~prime|)) +(= (mod (* (* |_452| 1) (* |_452| 1)) |~prime|) (mod (* |_452| 1) |~prime|)) +(= (mod (* (* |_453| 1) (* |_453| 1)) |~prime|) (mod (* |_453| 1) |~prime|)) +(= (mod (* (* |_454| 1) (* |_454| 1)) |~prime|) (mod (* |_454| 1) |~prime|)) +(= (mod (* (* |_455| 1) (* |_455| 1)) |~prime|) (mod (* |_455| 1) |~prime|)) +(= (mod (* (* |_456| 1) (* |_456| 1)) |~prime|) (mod (* |_456| 1) |~prime|)) +(= (mod (* (* |_457| 1) (* |_457| 1)) |~prime|) (mod (* |_457| 1) |~prime|)) +(= (mod (* (* |_458| 1) (* |_458| 1)) |~prime|) (mod (* |_458| 1) |~prime|)) +(= (mod (* (* |_459| 1) (* |_459| 1)) |~prime|) (mod (* |_459| 1) |~prime|)) +(= (mod (* (* |_460| 1) (* |_460| 1)) |~prime|) (mod (* |_460| 1) |~prime|)) +(= (mod (* (* |_461| 1) (* |_461| 1)) |~prime|) (mod (* |_461| 1) |~prime|)) +(= (mod (* (* |_462| 1) (* |_462| 1)) |~prime|) (mod (* |_462| 1) |~prime|)) +(= (mod (* (* |_463| 1) (* |_463| 1)) |~prime|) (mod (* |_463| 1) |~prime|)) +(= (mod (* (* |_464| 1) (* |_464| 1)) |~prime|) (mod (* |_464| 1) |~prime|)) +(= (mod (* (* |_465| 1) (* |_465| 1)) |~prime|) (mod (* |_465| 1) |~prime|)) +(= (mod (* (* |_466| 1) (* |_466| 1)) |~prime|) (mod (* |_466| 1) |~prime|)) +(= (mod (* (* |_467| 1) (* |_467| 1)) |~prime|) (mod (* |_467| 1) |~prime|)) +(= (mod (* (* |_468| 1) (* |_468| 1)) |~prime|) (mod (* |_468| 1) |~prime|)) +(= (mod (* (* |_469| 1) (* |_469| 1)) |~prime|) (mod (* |_469| 1) |~prime|)) +(= (mod (* (* |_470| 1) (* |_470| 1)) |~prime|) (mod (* |_470| 1) |~prime|)) +(= (mod (* (* |_471| 1) (* |_471| 1)) |~prime|) (mod (* |_471| 1) |~prime|)) +(= (mod (* (* |_472| 1) (* |_472| 1)) |~prime|) (mod (* |_472| 1) |~prime|)) +(= (mod (* (* |_473| 1) (* |_473| 1)) |~prime|) (mod (* |_473| 1) |~prime|)) +(= (mod (* (* |_474| 1) (* |_474| 1)) |~prime|) (mod (* |_474| 1) |~prime|)) +(= (mod (* (* |_475| 1) (* |_475| 1)) |~prime|) (mod (* |_475| 1) |~prime|)) +(= (mod (* (* |_476| 1) (* |_476| 1)) |~prime|) (mod (* |_476| 1) |~prime|)) +(= (mod (* (* |_477| 1) (* |_477| 1)) |~prime|) (mod (* |_477| 1) |~prime|)) +(= (mod (* (* |_478| 1) (* |_478| 1)) |~prime|) (mod (* |_478| 1) |~prime|)) +(= (mod (* (* |_479| 1) (* |_479| 1)) |~prime|) (mod (* |_479| 1) |~prime|)) +(= (mod (* (* |_480| 1) (* |_480| 1)) |~prime|) (mod (* |_480| 1) |~prime|)) +(= (mod (* (* |_481| 1) (* |_481| 1)) |~prime|) (mod (* |_481| 1) |~prime|)) +(= (mod (* (* |_482| 1) (* |_482| 1)) |~prime|) (mod (* |_482| 1) |~prime|)) +(= (mod (* (* |_483| 1) (* |_483| 1)) |~prime|) (mod (* |_483| 1) |~prime|)) +(= (mod (* (* |_484| 1) (* |_484| 1)) |~prime|) (mod (* |_484| 1) |~prime|)) +(= (mod (* (* |_485| 1) (* |_485| 1)) |~prime|) (mod (* |_485| 1) |~prime|)) +(= (mod (* (* |_486| 1) (* |_486| 1)) |~prime|) (mod (* |_486| 1) |~prime|)) +(= (mod (* (* |_487| 1) (* |_487| 1)) |~prime|) (mod (* |_487| 1) |~prime|)) +(= (mod (* (* |_488| 1) (* |_488| 1)) |~prime|) (mod (* |_488| 1) |~prime|)) +(= (mod (* (* |_489| 1) (* |_489| 1)) |~prime|) (mod (* |_489| 1) |~prime|)) +(= (mod (* (* |_490| 1) (* |_490| 1)) |~prime|) (mod (* |_490| 1) |~prime|)) +(= (mod (* (* |_491| 1) (* |_491| 1)) |~prime|) (mod (* |_491| 1) |~prime|)) +(= (mod (* (* |_492| 1) (* |_492| 1)) |~prime|) (mod (* |_492| 1) |~prime|)) +(= (mod (* (* |_493| 1) (* |_493| 1)) |~prime|) (mod (* |_493| 1) |~prime|)) +(= (mod (* (* |_494| 1) (* |_494| 1)) |~prime|) (mod (* |_494| 1) |~prime|)) +(= (mod (* (* |_495| 1) (* |_495| 1)) |~prime|) (mod (* |_495| 1) |~prime|)) +(= (mod (* (* |_496| 1) (* |_496| 1)) |~prime|) (mod (* |_496| 1) |~prime|)) +(= (mod (* (* |_497| 1) (* |_497| 1)) |~prime|) (mod (* |_497| 1) |~prime|)) +(= (mod (* (* |_498| 1) (* |_498| 1)) |~prime|) (mod (* |_498| 1) |~prime|)) +(= (mod (* (* |_499| 1) (* |_499| 1)) |~prime|) (mod (* |_499| 1) |~prime|)) +(= (mod (* (* |_500| 1) (* |_500| 1)) |~prime|) (mod (* |_500| 1) |~prime|)) +(= (mod (* (* |_501| 1) (* |_501| 1)) |~prime|) (mod (* |_501| 1) |~prime|)) +(= (mod (* (* |_502| 1) (* |_502| 1)) |~prime|) (mod (* |_502| 1) |~prime|)) +(= (mod (* (* |_503| 1) (* |_503| 1)) |~prime|) (mod (* |_503| 1) |~prime|)) +(= (mod (* (* |_504| 1) (* |_504| 1)) |~prime|) (mod (* |_504| 1) |~prime|)) +(= (mod (* (* |_505| 1) (* |_505| 1)) |~prime|) (mod (* |_505| 1) |~prime|)) +(= (mod (* (* |_506| 1) (* |_506| 1)) |~prime|) (mod (* |_506| 1) |~prime|)) +(= (mod (* (* |_507| 1) (* |_507| 1)) |~prime|) (mod (* |_507| 1) |~prime|)) +(= (mod (* (* |_508| 1) (* |_508| 1)) |~prime|) (mod (* |_508| 1) |~prime|)) +(= (mod (* (* |_509| 1) (* |_509| 1)) |~prime|) (mod (* |_509| 1) |~prime|)) +(= (mod (* (* |_510| 1) (* |_510| 1)) |~prime|) (mod (* |_510| 1) |~prime|)) +(= (mod (* (* |~one| 1) (+ (* |_259| 3618502788666131106986593281521497120414687020801267626233049500247285301248) (* |_260| 1809251394333065553493296640760748560207343510400633813116524750123642650624) (* |_261| 904625697166532776746648320380374280103671755200316906558262375061821325312) (* |_262| 452312848583266388373324160190187140051835877600158453279131187530910662656) (* |_263| 226156424291633194186662080095093570025917938800079226639565593765455331328) (* |_264| 113078212145816597093331040047546785012958969400039613319782796882727665664) (* |_265| 56539106072908298546665520023773392506479484700019806659891398441363832832) (* |_266| 28269553036454149273332760011886696253239742350009903329945699220681916416) (* |_267| 14134776518227074636666380005943348126619871175004951664972849610340958208) (* |_268| 7067388259113537318333190002971674063309935587502475832486424805170479104) (* |_269| 3533694129556768659166595001485837031654967793751237916243212402585239552) (* |_270| 1766847064778384329583297500742918515827483896875618958121606201292619776) (* |_271| 883423532389192164791648750371459257913741948437809479060803100646309888) (* |_272| 441711766194596082395824375185729628956870974218904739530401550323154944) (* |_273| 220855883097298041197912187592864814478435487109452369765200775161577472) (* |_274| 110427941548649020598956093796432407239217743554726184882600387580788736) (* |_275| 55213970774324510299478046898216203619608871777363092441300193790394368) (* |_276| 27606985387162255149739023449108101809804435888681546220650096895197184) (* |_277| 13803492693581127574869511724554050904902217944340773110325048447598592) (* |_278| 6901746346790563787434755862277025452451108972170386555162524223799296) (* |_279| 3450873173395281893717377931138512726225554486085193277581262111899648) (* |_280| 1725436586697640946858688965569256363112777243042596638790631055949824) (* |_281| 862718293348820473429344482784628181556388621521298319395315527974912) (* |_282| 431359146674410236714672241392314090778194310760649159697657763987456) (* |_283| 215679573337205118357336120696157045389097155380324579848828881993728) (* |_284| 107839786668602559178668060348078522694548577690162289924414440996864) (* |_285| 53919893334301279589334030174039261347274288845081144962207220498432) (* |_286| 26959946667150639794667015087019630673637144422540572481103610249216) (* |_287| 13479973333575319897333507543509815336818572211270286240551805124608) (* |_288| 6739986666787659948666753771754907668409286105635143120275902562304) (* |_289| 3369993333393829974333376885877453834204643052817571560137951281152) (* |_290| 1684996666696914987166688442938726917102321526408785780068975640576) (* |_291| 842498333348457493583344221469363458551160763204392890034487820288) (* |_292| 421249166674228746791672110734681729275580381602196445017243910144) (* |_293| 210624583337114373395836055367340864637790190801098222508621955072) (* |_294| 105312291668557186697918027683670432318895095400549111254310977536) (* |_295| 52656145834278593348959013841835216159447547700274555627155488768) (* |_296| 26328072917139296674479506920917608079723773850137277813577744384) (* |_297| 13164036458569648337239753460458804039861886925068638906788872192) (* |_298| 6582018229284824168619876730229402019930943462534319453394436096) (* |_299| 3291009114642412084309938365114701009965471731267159726697218048) (* |_300| 1645504557321206042154969182557350504982735865633579863348609024) (* |_301| 822752278660603021077484591278675252491367932816789931674304512) (* |_302| 411376139330301510538742295639337626245683966408394965837152256) (* |_303| 205688069665150755269371147819668813122841983204197482918576128) (* |_304| 102844034832575377634685573909834406561420991602098741459288064) (* |_305| 51422017416287688817342786954917203280710495801049370729644032) (* |_306| 25711008708143844408671393477458601640355247900524685364822016) (* |_307| 12855504354071922204335696738729300820177623950262342682411008) (* |_308| 6427752177035961102167848369364650410088811975131171341205504) (* |_309| 3213876088517980551083924184682325205044405987565585670602752) (* |_310| 1606938044258990275541962092341162602522202993782792835301376) (* |_311| 803469022129495137770981046170581301261101496891396417650688) (* |_312| 401734511064747568885490523085290650630550748445698208825344) (* |_313| 200867255532373784442745261542645325315275374222849104412672) (* |_314| 100433627766186892221372630771322662657637687111424552206336) (* |_315| 50216813883093446110686315385661331328818843555712276103168) (* |_316| 25108406941546723055343157692830665664409421777856138051584) (* |_317| 12554203470773361527671578846415332832204710888928069025792) (* |_318| 6277101735386680763835789423207666416102355444464034512896) (* |_319| 3138550867693340381917894711603833208051177722232017256448) (* |_320| 1569275433846670190958947355801916604025588861116008628224) (* |_321| 784637716923335095479473677900958302012794430558004314112) (* |_322| 392318858461667547739736838950479151006397215279002157056) (* |_323| 196159429230833773869868419475239575503198607639501078528) (* |_324| 98079714615416886934934209737619787751599303819750539264) (* |_325| 49039857307708443467467104868809893875799651909875269632) (* |_326| 24519928653854221733733552434404946937899825954937634816) (* |_327| 12259964326927110866866776217202473468949912977468817408) (* |_328| 6129982163463555433433388108601236734474956488734408704) (* |_329| 3064991081731777716716694054300618367237478244367204352) (* |_330| 1532495540865888858358347027150309183618739122183602176) (* |_331| 766247770432944429179173513575154591809369561091801088) (* |_332| 383123885216472214589586756787577295904684780545900544) (* |_333| 191561942608236107294793378393788647952342390272950272) (* |_334| 95780971304118053647396689196894323976171195136475136) (* |_335| 47890485652059026823698344598447161988085597568237568) (* |_336| 23945242826029513411849172299223580994042798784118784) (* |_337| 11972621413014756705924586149611790497021399392059392) (* |_338| 5986310706507378352962293074805895248510699696029696) (* |_339| 2993155353253689176481146537402947624255349848014848) (* |_340| 1496577676626844588240573268701473812127674924007424) (* |_341| 748288838313422294120286634350736906063837462003712) (* |_342| 374144419156711147060143317175368453031918731001856) (* |_343| 187072209578355573530071658587684226515959365500928) (* |_344| 93536104789177786765035829293842113257979682750464) (* |_345| 46768052394588893382517914646921056628989841375232) (* |_346| 23384026197294446691258957323460528314494920687616) (* |_347| 11692013098647223345629478661730264157247460343808) (* |_348| 5846006549323611672814739330865132078623730171904) (* |_349| 2923003274661805836407369665432566039311865085952) (* |_350| 1461501637330902918203684832716283019655932542976) (* |_351| 730750818665451459101842416358141509827966271488) (* |_352| 365375409332725729550921208179070754913983135744) (* |_353| 182687704666362864775460604089535377456991567872) (* |_354| 91343852333181432387730302044767688728495783936) (* |_355| 45671926166590716193865151022383844364247891968) (* |_356| 22835963083295358096932575511191922182123945984) (* |_357| 11417981541647679048466287755595961091061972992) (* |_358| 5708990770823839524233143877797980545530986496) (* |_359| 2854495385411919762116571938898990272765493248) (* |_360| 1427247692705959881058285969449495136382746624) (* |_361| 713623846352979940529142984724747568191373312) (* |_362| 356811923176489970264571492362373784095686656) (* |_363| 178405961588244985132285746181186892047843328) (* |_364| 89202980794122492566142873090593446023921664) (* |_365| 44601490397061246283071436545296723011960832) (* |_366| 22300745198530623141535718272648361505980416) (* |_367| 11150372599265311570767859136324180752990208) (* |_368| 5575186299632655785383929568162090376495104) (* |_369| 2787593149816327892691964784081045188247552) (* |_370| 1393796574908163946345982392040522594123776) (* |_371| 696898287454081973172991196020261297061888) (* |_372| 348449143727040986586495598010130648530944) (* |_373| 174224571863520493293247799005065324265472) (* |_374| 87112285931760246646623899502532662132736) (* |_375| 43556142965880123323311949751266331066368) (* |_376| 21778071482940061661655974875633165533184) (* |_377| 10889035741470030830827987437816582766592) (* |_378| 5444517870735015415413993718908291383296) (* |_379| 2722258935367507707706996859454145691648) (* |_380| 1361129467683753853853498429727072845824) (* |_381| 680564733841876926926749214863536422912) (* |_382| 340282366920938463463374607431768211456) (* |_383| 170141183460469231731687303715884105728) (* |_384| 85070591730234615865843651857942052864) (* |_385| 42535295865117307932921825928971026432) (* |_386| 21267647932558653966460912964485513216) (* |_387| 10633823966279326983230456482242756608) (* |_388| 5316911983139663491615228241121378304) (* |_389| 2658455991569831745807614120560689152) (* |_390| 1329227995784915872903807060280344576) (* |_391| 664613997892457936451903530140172288) (* |_392| 332306998946228968225951765070086144) (* |_393| 166153499473114484112975882535043072) (* |_394| 83076749736557242056487941267521536) (* |_395| 41538374868278621028243970633760768) (* |_396| 20769187434139310514121985316880384) (* |_397| 10384593717069655257060992658440192) (* |_398| 5192296858534827628530496329220096) (* |_399| 2596148429267413814265248164610048) (* |_400| 1298074214633706907132624082305024) (* |_401| 649037107316853453566312041152512) (* |_402| 324518553658426726783156020576256) (* |_403| 162259276829213363391578010288128) (* |_404| 81129638414606681695789005144064) (* |_405| 40564819207303340847894502572032) (* |_406| 20282409603651670423947251286016) (* |_407| 10141204801825835211973625643008) (* |_408| 5070602400912917605986812821504) (* |_409| 2535301200456458802993406410752) (* |_410| 1267650600228229401496703205376) (* |_411| 633825300114114700748351602688) (* |_412| 316912650057057350374175801344) (* |_413| 158456325028528675187087900672) (* |_414| 79228162514264337593543950336) (* |_415| 39614081257132168796771975168) (* |_416| 19807040628566084398385987584) (* |_417| 9903520314283042199192993792) (* |_418| 4951760157141521099596496896) (* |_419| 2475880078570760549798248448) (* |_420| 1237940039285380274899124224) (* |_421| 618970019642690137449562112) (* |_422| 309485009821345068724781056) (* |_423| 154742504910672534362390528) (* |_424| 77371252455336267181195264) (* |_425| 38685626227668133590597632) (* |_426| 19342813113834066795298816) (* |_427| 9671406556917033397649408) (* |_428| 4835703278458516698824704) (* |_429| 2417851639229258349412352) (* |_430| 1208925819614629174706176) (* |_431| 604462909807314587353088) (* |_432| 302231454903657293676544) (* |_433| 151115727451828646838272) (* |_434| 75557863725914323419136) (* |_435| 37778931862957161709568) (* |_436| 18889465931478580854784) (* |_437| 9444732965739290427392) (* |_438| 4722366482869645213696) (* |_439| 2361183241434822606848) (* |_440| 1180591620717411303424) (* |_441| 590295810358705651712) (* |_442| 295147905179352825856) (* |_443| 147573952589676412928) (* |_444| 73786976294838206464) (* |_445| 36893488147419103232) (* |_446| 18446744073709551616) (* |_447| 9223372036854775808) (* |_448| 4611686018427387904) (* |_449| 2305843009213693952) (* |_450| 1152921504606846976) (* |_451| 576460752303423488) (* |_452| 288230376151711744) (* |_453| 144115188075855872) (* |_454| 72057594037927936) (* |_455| 36028797018963968) (* |_456| 18014398509481984) (* |_457| 9007199254740992) (* |_458| 4503599627370496) (* |_459| 2251799813685248) (* |_460| 1125899906842624) (* |_461| 562949953421312) (* |_462| 281474976710656) (* |_463| 140737488355328) (* |_464| 70368744177664) (* |_465| 35184372088832) (* |_466| 17592186044416) (* |_467| 8796093022208) (* |_468| 4398046511104) (* |_469| 2199023255552) (* |_470| 1099511627776) (* |_471| 549755813888) (* |_472| 274877906944) (* |_473| 137438953472) (* |_474| 68719476736) (* |_475| 34359738368) (* |_476| 17179869184) (* |_477| 8589934592) (* |_478| 4294967296) (* |_479| 2147483648) (* |_480| 1073741824) (* |_481| 536870912) (* |_482| 268435456) (* |_483| 134217728) (* |_484| 67108864) (* |_485| 33554432) (* |_486| 16777216) (* |_487| 8388608) (* |_488| 4194304) (* |_489| 2097152) (* |_490| 1048576) (* |_491| 524288) (* |_492| 262144) (* |_493| 131072) (* |_494| 65536) (* |_495| 32768) (* |_496| 16384) (* |_497| 8192) (* |_498| 4096) (* |_499| 2048) (* |_500| 1024) (* |_501| 512) (* |_502| 256) (* |_503| 128) (* |_504| 64) (* |_505| 32) (* |_506| 16) (* |_507| 8) (* |_508| 4) (* |_509| 2) (* |_510| 1))) |~prime|) (mod (* |_1| 1) |~prime|)) + +(= (mod (* (* |_511| 1) (* |_511| 1)) |~prime|) (mod (* |_511| 1) |~prime|)) +(= (mod (* (* |_512| 1) (* |_512| 1)) |~prime|) (mod (* |_512| 1) |~prime|)) +(= (mod (* (* |_513| 1) (* |_513| 1)) |~prime|) (mod (* |_513| 1) |~prime|)) +(= (mod (* (* |_514| 1) (* |_514| 1)) |~prime|) (mod (* |_514| 1) |~prime|)) +(= (mod (* (* |_515| 1) (* |_515| 1)) |~prime|) (mod (* |_515| 1) |~prime|)) +(= (mod (* (* |_516| 1) (* |_516| 1)) |~prime|) (mod (* |_516| 1) |~prime|)) +(= (mod (* (* |_517| 1) (* |_517| 1)) |~prime|) (mod (* |_517| 1) |~prime|)) +(= (mod (* (* |_518| 1) (* |_518| 1)) |~prime|) (mod (* |_518| 1) |~prime|)) +(= (mod (* (* |_519| 1) (* |_519| 1)) |~prime|) (mod (* |_519| 1) |~prime|)) +(= (mod (* (* |_520| 1) (* |_520| 1)) |~prime|) (mod (* |_520| 1) |~prime|)) +(= (mod (* (* |_521| 1) (* |_521| 1)) |~prime|) (mod (* |_521| 1) |~prime|)) +(= (mod (* (* |_522| 1) (* |_522| 1)) |~prime|) (mod (* |_522| 1) |~prime|)) +(= (mod (* (* |_523| 1) (* |_523| 1)) |~prime|) (mod (* |_523| 1) |~prime|)) +(= (mod (* (* |_524| 1) (* |_524| 1)) |~prime|) (mod (* |_524| 1) |~prime|)) +(= (mod (* (* |_525| 1) (* |_525| 1)) |~prime|) (mod (* |_525| 1) |~prime|)) +(= (mod (* (* |_526| 1) (* |_526| 1)) |~prime|) (mod (* |_526| 1) |~prime|)) +(= (mod (* (* |_527| 1) (* |_527| 1)) |~prime|) (mod (* |_527| 1) |~prime|)) +(= (mod (* (* |_528| 1) (* |_528| 1)) |~prime|) (mod (* |_528| 1) |~prime|)) +(= (mod (* (* |_529| 1) (* |_529| 1)) |~prime|) (mod (* |_529| 1) |~prime|)) +(= (mod (* (* |_530| 1) (* |_530| 1)) |~prime|) (mod (* |_530| 1) |~prime|)) +(= (mod (* (* |_531| 1) (* |_531| 1)) |~prime|) (mod (* |_531| 1) |~prime|)) +(= (mod (* (* |_532| 1) (* |_532| 1)) |~prime|) (mod (* |_532| 1) |~prime|)) +(= (mod (* (* |_533| 1) (* |_533| 1)) |~prime|) (mod (* |_533| 1) |~prime|)) +(= (mod (* (* |_534| 1) (* |_534| 1)) |~prime|) (mod (* |_534| 1) |~prime|)) +(= (mod (* (* |_535| 1) (* |_535| 1)) |~prime|) (mod (* |_535| 1) |~prime|)) +(= (mod (* (* |_536| 1) (* |_536| 1)) |~prime|) (mod (* |_536| 1) |~prime|)) +(= (mod (* (* |_537| 1) (* |_537| 1)) |~prime|) (mod (* |_537| 1) |~prime|)) +(= (mod (* (* |_538| 1) (* |_538| 1)) |~prime|) (mod (* |_538| 1) |~prime|)) +(= (mod (* (* |_539| 1) (* |_539| 1)) |~prime|) (mod (* |_539| 1) |~prime|)) +(= (mod (* (* |_540| 1) (* |_540| 1)) |~prime|) (mod (* |_540| 1) |~prime|)) +(= (mod (* (* |_541| 1) (* |_541| 1)) |~prime|) (mod (* |_541| 1) |~prime|)) +(= (mod (* (* |_542| 1) (* |_542| 1)) |~prime|) (mod (* |_542| 1) |~prime|)) +(= (mod (* (* |_543| 1) (* |_543| 1)) |~prime|) (mod (* |_543| 1) |~prime|)) +(= (mod (* (* |_544| 1) (* |_544| 1)) |~prime|) (mod (* |_544| 1) |~prime|)) +(= (mod (* (* |_545| 1) (* |_545| 1)) |~prime|) (mod (* |_545| 1) |~prime|)) +(= (mod (* (* |_546| 1) (* |_546| 1)) |~prime|) (mod (* |_546| 1) |~prime|)) +(= (mod (* (* |_547| 1) (* |_547| 1)) |~prime|) (mod (* |_547| 1) |~prime|)) +(= (mod (* (* |_548| 1) (* |_548| 1)) |~prime|) (mod (* |_548| 1) |~prime|)) +(= (mod (* (* |_549| 1) (* |_549| 1)) |~prime|) (mod (* |_549| 1) |~prime|)) +(= (mod (* (* |_550| 1) (* |_550| 1)) |~prime|) (mod (* |_550| 1) |~prime|)) +(= (mod (* (* |_551| 1) (* |_551| 1)) |~prime|) (mod (* |_551| 1) |~prime|)) +(= (mod (* (* |_552| 1) (* |_552| 1)) |~prime|) (mod (* |_552| 1) |~prime|)) +(= (mod (* (* |_553| 1) (* |_553| 1)) |~prime|) (mod (* |_553| 1) |~prime|)) +(= (mod (* (* |_554| 1) (* |_554| 1)) |~prime|) (mod (* |_554| 1) |~prime|)) +(= (mod (* (* |_555| 1) (* |_555| 1)) |~prime|) (mod (* |_555| 1) |~prime|)) +(= (mod (* (* |_556| 1) (* |_556| 1)) |~prime|) (mod (* |_556| 1) |~prime|)) +(= (mod (* (* |_557| 1) (* |_557| 1)) |~prime|) (mod (* |_557| 1) |~prime|)) +(= (mod (* (* |_558| 1) (* |_558| 1)) |~prime|) (mod (* |_558| 1) |~prime|)) +(= (mod (* (* |_559| 1) (* |_559| 1)) |~prime|) (mod (* |_559| 1) |~prime|)) +(= (mod (* (* |_560| 1) (* |_560| 1)) |~prime|) (mod (* |_560| 1) |~prime|)) +(= (mod (* (* |_561| 1) (* |_561| 1)) |~prime|) (mod (* |_561| 1) |~prime|)) +(= (mod (* (* |_562| 1) (* |_562| 1)) |~prime|) (mod (* |_562| 1) |~prime|)) +(= (mod (* (* |_563| 1) (* |_563| 1)) |~prime|) (mod (* |_563| 1) |~prime|)) +(= (mod (* (* |_564| 1) (* |_564| 1)) |~prime|) (mod (* |_564| 1) |~prime|)) +(= (mod (* (* |_565| 1) (* |_565| 1)) |~prime|) (mod (* |_565| 1) |~prime|)) +(= (mod (* (* |_566| 1) (* |_566| 1)) |~prime|) (mod (* |_566| 1) |~prime|)) +(= (mod (* (* |_567| 1) (* |_567| 1)) |~prime|) (mod (* |_567| 1) |~prime|)) +(= (mod (* (* |_568| 1) (* |_568| 1)) |~prime|) (mod (* |_568| 1) |~prime|)) +(= (mod (* (* |_569| 1) (* |_569| 1)) |~prime|) (mod (* |_569| 1) |~prime|)) +(= (mod (* (* |_570| 1) (* |_570| 1)) |~prime|) (mod (* |_570| 1) |~prime|)) +(= (mod (* (* |_571| 1) (* |_571| 1)) |~prime|) (mod (* |_571| 1) |~prime|)) +(= (mod (* (* |_572| 1) (* |_572| 1)) |~prime|) (mod (* |_572| 1) |~prime|)) +(= (mod (* (* |_573| 1) (* |_573| 1)) |~prime|) (mod (* |_573| 1) |~prime|)) +(= (mod (* (* |_574| 1) (* |_574| 1)) |~prime|) (mod (* |_574| 1) |~prime|)) +(= (mod (* (* |_575| 1) (* |_575| 1)) |~prime|) (mod (* |_575| 1) |~prime|)) +(= (mod (* (* |_576| 1) (* |_576| 1)) |~prime|) (mod (* |_576| 1) |~prime|)) +(= (mod (* (* |_577| 1) (* |_577| 1)) |~prime|) (mod (* |_577| 1) |~prime|)) +(= (mod (* (* |_578| 1) (* |_578| 1)) |~prime|) (mod (* |_578| 1) |~prime|)) +(= (mod (* (* |_579| 1) (* |_579| 1)) |~prime|) (mod (* |_579| 1) |~prime|)) +(= (mod (* (* |_580| 1) (* |_580| 1)) |~prime|) (mod (* |_580| 1) |~prime|)) +(= (mod (* (* |_581| 1) (* |_581| 1)) |~prime|) (mod (* |_581| 1) |~prime|)) +(= (mod (* (* |_582| 1) (* |_582| 1)) |~prime|) (mod (* |_582| 1) |~prime|)) +(= (mod (* (* |_583| 1) (* |_583| 1)) |~prime|) (mod (* |_583| 1) |~prime|)) +(= (mod (* (* |_584| 1) (* |_584| 1)) |~prime|) (mod (* |_584| 1) |~prime|)) +(= (mod (* (* |_585| 1) (* |_585| 1)) |~prime|) (mod (* |_585| 1) |~prime|)) +(= (mod (* (* |_586| 1) (* |_586| 1)) |~prime|) (mod (* |_586| 1) |~prime|)) +(= (mod (* (* |_587| 1) (* |_587| 1)) |~prime|) (mod (* |_587| 1) |~prime|)) +(= (mod (* (* |_588| 1) (* |_588| 1)) |~prime|) (mod (* |_588| 1) |~prime|)) +(= (mod (* (* |_589| 1) (* |_589| 1)) |~prime|) (mod (* |_589| 1) |~prime|)) +(= (mod (* (* |_590| 1) (* |_590| 1)) |~prime|) (mod (* |_590| 1) |~prime|)) +(= (mod (* (* |_591| 1) (* |_591| 1)) |~prime|) (mod (* |_591| 1) |~prime|)) +(= (mod (* (* |_592| 1) (* |_592| 1)) |~prime|) (mod (* |_592| 1) |~prime|)) +(= (mod (* (* |_593| 1) (* |_593| 1)) |~prime|) (mod (* |_593| 1) |~prime|)) +(= (mod (* (* |_594| 1) (* |_594| 1)) |~prime|) (mod (* |_594| 1) |~prime|)) +(= (mod (* (* |_595| 1) (* |_595| 1)) |~prime|) (mod (* |_595| 1) |~prime|)) +(= (mod (* (* |_596| 1) (* |_596| 1)) |~prime|) (mod (* |_596| 1) |~prime|)) +(= (mod (* (* |_597| 1) (* |_597| 1)) |~prime|) (mod (* |_597| 1) |~prime|)) +(= (mod (* (* |_598| 1) (* |_598| 1)) |~prime|) (mod (* |_598| 1) |~prime|)) +(= (mod (* (* |_599| 1) (* |_599| 1)) |~prime|) (mod (* |_599| 1) |~prime|)) +(= (mod (* (* |_600| 1) (* |_600| 1)) |~prime|) (mod (* |_600| 1) |~prime|)) +(= (mod (* (* |_601| 1) (* |_601| 1)) |~prime|) (mod (* |_601| 1) |~prime|)) +(= (mod (* (* |_602| 1) (* |_602| 1)) |~prime|) (mod (* |_602| 1) |~prime|)) +(= (mod (* (* |_603| 1) (* |_603| 1)) |~prime|) (mod (* |_603| 1) |~prime|)) +(= (mod (* (* |_604| 1) (* |_604| 1)) |~prime|) (mod (* |_604| 1) |~prime|)) +(= (mod (* (* |_605| 1) (* |_605| 1)) |~prime|) (mod (* |_605| 1) |~prime|)) +(= (mod (* (* |_606| 1) (* |_606| 1)) |~prime|) (mod (* |_606| 1) |~prime|)) +(= (mod (* (* |_607| 1) (* |_607| 1)) |~prime|) (mod (* |_607| 1) |~prime|)) +(= (mod (* (* |_608| 1) (* |_608| 1)) |~prime|) (mod (* |_608| 1) |~prime|)) +(= (mod (* (* |_609| 1) (* |_609| 1)) |~prime|) (mod (* |_609| 1) |~prime|)) +(= (mod (* (* |_610| 1) (* |_610| 1)) |~prime|) (mod (* |_610| 1) |~prime|)) +(= (mod (* (* |_611| 1) (* |_611| 1)) |~prime|) (mod (* |_611| 1) |~prime|)) +(= (mod (* (* |_612| 1) (* |_612| 1)) |~prime|) (mod (* |_612| 1) |~prime|)) +(= (mod (* (* |_613| 1) (* |_613| 1)) |~prime|) (mod (* |_613| 1) |~prime|)) +(= (mod (* (* |_614| 1) (* |_614| 1)) |~prime|) (mod (* |_614| 1) |~prime|)) +(= (mod (* (* |_615| 1) (* |_615| 1)) |~prime|) (mod (* |_615| 1) |~prime|)) +(= (mod (* (* |_616| 1) (* |_616| 1)) |~prime|) (mod (* |_616| 1) |~prime|)) +(= (mod (* (* |_617| 1) (* |_617| 1)) |~prime|) (mod (* |_617| 1) |~prime|)) +(= (mod (* (* |_618| 1) (* |_618| 1)) |~prime|) (mod (* |_618| 1) |~prime|)) +(= (mod (* (* |_619| 1) (* |_619| 1)) |~prime|) (mod (* |_619| 1) |~prime|)) +(= (mod (* (* |_620| 1) (* |_620| 1)) |~prime|) (mod (* |_620| 1) |~prime|)) +(= (mod (* (* |_621| 1) (* |_621| 1)) |~prime|) (mod (* |_621| 1) |~prime|)) +(= (mod (* (* |_622| 1) (* |_622| 1)) |~prime|) (mod (* |_622| 1) |~prime|)) +(= (mod (* (* |_623| 1) (* |_623| 1)) |~prime|) (mod (* |_623| 1) |~prime|)) +(= (mod (* (* |_624| 1) (* |_624| 1)) |~prime|) (mod (* |_624| 1) |~prime|)) +(= (mod (* (* |_625| 1) (* |_625| 1)) |~prime|) (mod (* |_625| 1) |~prime|)) +(= (mod (* (* |_626| 1) (* |_626| 1)) |~prime|) (mod (* |_626| 1) |~prime|)) +(= (mod (* (* |_627| 1) (* |_627| 1)) |~prime|) (mod (* |_627| 1) |~prime|)) +(= (mod (* (* |_628| 1) (* |_628| 1)) |~prime|) (mod (* |_628| 1) |~prime|)) +(= (mod (* (* |_629| 1) (* |_629| 1)) |~prime|) (mod (* |_629| 1) |~prime|)) +(= (mod (* (* |_630| 1) (* |_630| 1)) |~prime|) (mod (* |_630| 1) |~prime|)) +(= (mod (* (* |_631| 1) (* |_631| 1)) |~prime|) (mod (* |_631| 1) |~prime|)) +(= (mod (* (* |_632| 1) (* |_632| 1)) |~prime|) (mod (* |_632| 1) |~prime|)) +(= (mod (* (* |_633| 1) (* |_633| 1)) |~prime|) (mod (* |_633| 1) |~prime|)) +(= (mod (* (* |_634| 1) (* |_634| 1)) |~prime|) (mod (* |_634| 1) |~prime|)) +(= (mod (* (* |_635| 1) (* |_635| 1)) |~prime|) (mod (* |_635| 1) |~prime|)) +(= (mod (* (* |_636| 1) (* |_636| 1)) |~prime|) (mod (* |_636| 1) |~prime|)) +(= (mod (* (* |_637| 1) (* |_637| 1)) |~prime|) (mod (* |_637| 1) |~prime|)) +(= (mod (* (* |_638| 1) (* |_638| 1)) |~prime|) (mod (* |_638| 1) |~prime|)) +(= (mod (* (* |_639| 1) (* |_639| 1)) |~prime|) (mod (* |_639| 1) |~prime|)) +(= (mod (* (* |_640| 1) (* |_640| 1)) |~prime|) (mod (* |_640| 1) |~prime|)) +(= (mod (* (* |_641| 1) (* |_641| 1)) |~prime|) (mod (* |_641| 1) |~prime|)) +(= (mod (* (* |_642| 1) (* |_642| 1)) |~prime|) (mod (* |_642| 1) |~prime|)) +(= (mod (* (* |_643| 1) (* |_643| 1)) |~prime|) (mod (* |_643| 1) |~prime|)) +(= (mod (* (* |_644| 1) (* |_644| 1)) |~prime|) (mod (* |_644| 1) |~prime|)) +(= (mod (* (* |_645| 1) (* |_645| 1)) |~prime|) (mod (* |_645| 1) |~prime|)) +(= (mod (* (* |_646| 1) (* |_646| 1)) |~prime|) (mod (* |_646| 1) |~prime|)) +(= (mod (* (* |_647| 1) (* |_647| 1)) |~prime|) (mod (* |_647| 1) |~prime|)) +(= (mod (* (* |_648| 1) (* |_648| 1)) |~prime|) (mod (* |_648| 1) |~prime|)) +(= (mod (* (* |_649| 1) (* |_649| 1)) |~prime|) (mod (* |_649| 1) |~prime|)) +(= (mod (* (* |_650| 1) (* |_650| 1)) |~prime|) (mod (* |_650| 1) |~prime|)) +(= (mod (* (* |_651| 1) (* |_651| 1)) |~prime|) (mod (* |_651| 1) |~prime|)) +(= (mod (* (* |_652| 1) (* |_652| 1)) |~prime|) (mod (* |_652| 1) |~prime|)) +(= (mod (* (* |_653| 1) (* |_653| 1)) |~prime|) (mod (* |_653| 1) |~prime|)) +(= (mod (* (* |_654| 1) (* |_654| 1)) |~prime|) (mod (* |_654| 1) |~prime|)) +(= (mod (* (* |_655| 1) (* |_655| 1)) |~prime|) (mod (* |_655| 1) |~prime|)) +(= (mod (* (* |_656| 1) (* |_656| 1)) |~prime|) (mod (* |_656| 1) |~prime|)) +(= (mod (* (* |_657| 1) (* |_657| 1)) |~prime|) (mod (* |_657| 1) |~prime|)) +(= (mod (* (* |_658| 1) (* |_658| 1)) |~prime|) (mod (* |_658| 1) |~prime|)) +(= (mod (* (* |_659| 1) (* |_659| 1)) |~prime|) (mod (* |_659| 1) |~prime|)) +(= (mod (* (* |_660| 1) (* |_660| 1)) |~prime|) (mod (* |_660| 1) |~prime|)) +(= (mod (* (* |_661| 1) (* |_661| 1)) |~prime|) (mod (* |_661| 1) |~prime|)) +(= (mod (* (* |_662| 1) (* |_662| 1)) |~prime|) (mod (* |_662| 1) |~prime|)) +(= (mod (* (* |_663| 1) (* |_663| 1)) |~prime|) (mod (* |_663| 1) |~prime|)) +(= (mod (* (* |_664| 1) (* |_664| 1)) |~prime|) (mod (* |_664| 1) |~prime|)) +(= (mod (* (* |_665| 1) (* |_665| 1)) |~prime|) (mod (* |_665| 1) |~prime|)) +(= (mod (* (* |_666| 1) (* |_666| 1)) |~prime|) (mod (* |_666| 1) |~prime|)) +(= (mod (* (* |_667| 1) (* |_667| 1)) |~prime|) (mod (* |_667| 1) |~prime|)) +(= (mod (* (* |_668| 1) (* |_668| 1)) |~prime|) (mod (* |_668| 1) |~prime|)) +(= (mod (* (* |_669| 1) (* |_669| 1)) |~prime|) (mod (* |_669| 1) |~prime|)) +(= (mod (* (* |_670| 1) (* |_670| 1)) |~prime|) (mod (* |_670| 1) |~prime|)) +(= (mod (* (* |_671| 1) (* |_671| 1)) |~prime|) (mod (* |_671| 1) |~prime|)) +(= (mod (* (* |_672| 1) (* |_672| 1)) |~prime|) (mod (* |_672| 1) |~prime|)) +(= (mod (* (* |_673| 1) (* |_673| 1)) |~prime|) (mod (* |_673| 1) |~prime|)) +(= (mod (* (* |_674| 1) (* |_674| 1)) |~prime|) (mod (* |_674| 1) |~prime|)) +(= (mod (* (* |_675| 1) (* |_675| 1)) |~prime|) (mod (* |_675| 1) |~prime|)) +(= (mod (* (* |_676| 1) (* |_676| 1)) |~prime|) (mod (* |_676| 1) |~prime|)) +(= (mod (* (* |_677| 1) (* |_677| 1)) |~prime|) (mod (* |_677| 1) |~prime|)) +(= (mod (* (* |_678| 1) (* |_678| 1)) |~prime|) (mod (* |_678| 1) |~prime|)) +(= (mod (* (* |_679| 1) (* |_679| 1)) |~prime|) (mod (* |_679| 1) |~prime|)) +(= (mod (* (* |_680| 1) (* |_680| 1)) |~prime|) (mod (* |_680| 1) |~prime|)) +(= (mod (* (* |_681| 1) (* |_681| 1)) |~prime|) (mod (* |_681| 1) |~prime|)) +(= (mod (* (* |_682| 1) (* |_682| 1)) |~prime|) (mod (* |_682| 1) |~prime|)) +(= (mod (* (* |_683| 1) (* |_683| 1)) |~prime|) (mod (* |_683| 1) |~prime|)) +(= (mod (* (* |_684| 1) (* |_684| 1)) |~prime|) (mod (* |_684| 1) |~prime|)) +(= (mod (* (* |_685| 1) (* |_685| 1)) |~prime|) (mod (* |_685| 1) |~prime|)) +(= (mod (* (* |_686| 1) (* |_686| 1)) |~prime|) (mod (* |_686| 1) |~prime|)) +(= (mod (* (* |_687| 1) (* |_687| 1)) |~prime|) (mod (* |_687| 1) |~prime|)) +(= (mod (* (* |_688| 1) (* |_688| 1)) |~prime|) (mod (* |_688| 1) |~prime|)) +(= (mod (* (* |_689| 1) (* |_689| 1)) |~prime|) (mod (* |_689| 1) |~prime|)) +(= (mod (* (* |_690| 1) (* |_690| 1)) |~prime|) (mod (* |_690| 1) |~prime|)) +(= (mod (* (* |_691| 1) (* |_691| 1)) |~prime|) (mod (* |_691| 1) |~prime|)) +(= (mod (* (* |_692| 1) (* |_692| 1)) |~prime|) (mod (* |_692| 1) |~prime|)) +(= (mod (* (* |_693| 1) (* |_693| 1)) |~prime|) (mod (* |_693| 1) |~prime|)) +(= (mod (* (* |_694| 1) (* |_694| 1)) |~prime|) (mod (* |_694| 1) |~prime|)) +(= (mod (* (* |_695| 1) (* |_695| 1)) |~prime|) (mod (* |_695| 1) |~prime|)) +(= (mod (* (* |_696| 1) (* |_696| 1)) |~prime|) (mod (* |_696| 1) |~prime|)) +(= (mod (* (* |_697| 1) (* |_697| 1)) |~prime|) (mod (* |_697| 1) |~prime|)) +(= (mod (* (* |_698| 1) (* |_698| 1)) |~prime|) (mod (* |_698| 1) |~prime|)) +(= (mod (* (* |_699| 1) (* |_699| 1)) |~prime|) (mod (* |_699| 1) |~prime|)) +(= (mod (* (* |_700| 1) (* |_700| 1)) |~prime|) (mod (* |_700| 1) |~prime|)) +(= (mod (* (* |_701| 1) (* |_701| 1)) |~prime|) (mod (* |_701| 1) |~prime|)) +(= (mod (* (* |_702| 1) (* |_702| 1)) |~prime|) (mod (* |_702| 1) |~prime|)) +(= (mod (* (* |_703| 1) (* |_703| 1)) |~prime|) (mod (* |_703| 1) |~prime|)) +(= (mod (* (* |_704| 1) (* |_704| 1)) |~prime|) (mod (* |_704| 1) |~prime|)) +(= (mod (* (* |_705| 1) (* |_705| 1)) |~prime|) (mod (* |_705| 1) |~prime|)) +(= (mod (* (* |_706| 1) (* |_706| 1)) |~prime|) (mod (* |_706| 1) |~prime|)) +(= (mod (* (* |_707| 1) (* |_707| 1)) |~prime|) (mod (* |_707| 1) |~prime|)) +(= (mod (* (* |_708| 1) (* |_708| 1)) |~prime|) (mod (* |_708| 1) |~prime|)) +(= (mod (* (* |_709| 1) (* |_709| 1)) |~prime|) (mod (* |_709| 1) |~prime|)) +(= (mod (* (* |_710| 1) (* |_710| 1)) |~prime|) (mod (* |_710| 1) |~prime|)) +(= (mod (* (* |_711| 1) (* |_711| 1)) |~prime|) (mod (* |_711| 1) |~prime|)) +(= (mod (* (* |_712| 1) (* |_712| 1)) |~prime|) (mod (* |_712| 1) |~prime|)) +(= (mod (* (* |_713| 1) (* |_713| 1)) |~prime|) (mod (* |_713| 1) |~prime|)) +(= (mod (* (* |_714| 1) (* |_714| 1)) |~prime|) (mod (* |_714| 1) |~prime|)) +(= (mod (* (* |_715| 1) (* |_715| 1)) |~prime|) (mod (* |_715| 1) |~prime|)) +(= (mod (* (* |_716| 1) (* |_716| 1)) |~prime|) (mod (* |_716| 1) |~prime|)) +(= (mod (* (* |_717| 1) (* |_717| 1)) |~prime|) (mod (* |_717| 1) |~prime|)) +(= (mod (* (* |_718| 1) (* |_718| 1)) |~prime|) (mod (* |_718| 1) |~prime|)) +(= (mod (* (* |_719| 1) (* |_719| 1)) |~prime|) (mod (* |_719| 1) |~prime|)) +(= (mod (* (* |_720| 1) (* |_720| 1)) |~prime|) (mod (* |_720| 1) |~prime|)) +(= (mod (* (* |_721| 1) (* |_721| 1)) |~prime|) (mod (* |_721| 1) |~prime|)) +(= (mod (* (* |_722| 1) (* |_722| 1)) |~prime|) (mod (* |_722| 1) |~prime|)) +(= (mod (* (* |_723| 1) (* |_723| 1)) |~prime|) (mod (* |_723| 1) |~prime|)) +(= (mod (* (* |_724| 1) (* |_724| 1)) |~prime|) (mod (* |_724| 1) |~prime|)) +(= (mod (* (* |_725| 1) (* |_725| 1)) |~prime|) (mod (* |_725| 1) |~prime|)) +(= (mod (* (* |_726| 1) (* |_726| 1)) |~prime|) (mod (* |_726| 1) |~prime|)) +(= (mod (* (* |_727| 1) (* |_727| 1)) |~prime|) (mod (* |_727| 1) |~prime|)) +(= (mod (* (* |_728| 1) (* |_728| 1)) |~prime|) (mod (* |_728| 1) |~prime|)) +(= (mod (* (* |_729| 1) (* |_729| 1)) |~prime|) (mod (* |_729| 1) |~prime|)) +(= (mod (* (* |_730| 1) (* |_730| 1)) |~prime|) (mod (* |_730| 1) |~prime|)) +(= (mod (* (* |_731| 1) (* |_731| 1)) |~prime|) (mod (* |_731| 1) |~prime|)) +(= (mod (* (* |_732| 1) (* |_732| 1)) |~prime|) (mod (* |_732| 1) |~prime|)) +(= (mod (* (* |_733| 1) (* |_733| 1)) |~prime|) (mod (* |_733| 1) |~prime|)) +(= (mod (* (* |_734| 1) (* |_734| 1)) |~prime|) (mod (* |_734| 1) |~prime|)) +(= (mod (* (* |_735| 1) (* |_735| 1)) |~prime|) (mod (* |_735| 1) |~prime|)) +(= (mod (* (* |_736| 1) (* |_736| 1)) |~prime|) (mod (* |_736| 1) |~prime|)) +(= (mod (* (* |_737| 1) (* |_737| 1)) |~prime|) (mod (* |_737| 1) |~prime|)) +(= (mod (* (* |_738| 1) (* |_738| 1)) |~prime|) (mod (* |_738| 1) |~prime|)) +(= (mod (* (* |_739| 1) (* |_739| 1)) |~prime|) (mod (* |_739| 1) |~prime|)) +(= (mod (* (* |_740| 1) (* |_740| 1)) |~prime|) (mod (* |_740| 1) |~prime|)) +(= (mod (* (* |_741| 1) (* |_741| 1)) |~prime|) (mod (* |_741| 1) |~prime|)) +(= (mod (* (* |_742| 1) (* |_742| 1)) |~prime|) (mod (* |_742| 1) |~prime|)) +(= (mod (* (* |_743| 1) (* |_743| 1)) |~prime|) (mod (* |_743| 1) |~prime|)) +(= (mod (* (* |_744| 1) (* |_744| 1)) |~prime|) (mod (* |_744| 1) |~prime|)) +(= (mod (* (* |_745| 1) (* |_745| 1)) |~prime|) (mod (* |_745| 1) |~prime|)) +(= (mod (* (* |_746| 1) (* |_746| 1)) |~prime|) (mod (* |_746| 1) |~prime|)) +(= (mod (* (* |_747| 1) (* |_747| 1)) |~prime|) (mod (* |_747| 1) |~prime|)) +(= (mod (* (* |_748| 1) (* |_748| 1)) |~prime|) (mod (* |_748| 1) |~prime|)) +(= (mod (* (* |_749| 1) (* |_749| 1)) |~prime|) (mod (* |_749| 1) |~prime|)) +(= (mod (* (* |_750| 1) (* |_750| 1)) |~prime|) (mod (* |_750| 1) |~prime|)) +(= (mod (* (* |_751| 1) (* |_751| 1)) |~prime|) (mod (* |_751| 1) |~prime|)) +(= (mod (* (* |_752| 1) (* |_752| 1)) |~prime|) (mod (* |_752| 1) |~prime|)) +(= (mod (* (* |_753| 1) (* |_753| 1)) |~prime|) (mod (* |_753| 1) |~prime|)) +(= (mod (* (* |_754| 1) (* |_754| 1)) |~prime|) (mod (* |_754| 1) |~prime|)) +(= (mod (* (* |_755| 1) (* |_755| 1)) |~prime|) (mod (* |_755| 1) |~prime|)) +(= (mod (* (* |_756| 1) (* |_756| 1)) |~prime|) (mod (* |_756| 1) |~prime|)) +(= (mod (* (* |_757| 1) (* |_757| 1)) |~prime|) (mod (* |_757| 1) |~prime|)) +(= (mod (* (* |_758| 1) (* |_758| 1)) |~prime|) (mod (* |_758| 1) |~prime|)) +(= (mod (* (* |_759| 1) (* |_759| 1)) |~prime|) (mod (* |_759| 1) |~prime|)) +(= (mod (* (* |_760| 1) (* |_760| 1)) |~prime|) (mod (* |_760| 1) |~prime|)) +(= (mod (* (* |_761| 1) (* |_761| 1)) |~prime|) (mod (* |_761| 1) |~prime|)) +(= (mod (* (* |_762| 1) (* |_762| 1)) |~prime|) (mod (* |_762| 1) |~prime|)) +(= (mod (* (* |~one| 1) (+ (* |_511| 3618502788666131106986593281521497120414687020801267626233049500247285301248) (* |_512| 1809251394333065553493296640760748560207343510400633813116524750123642650624) (* |_513| 904625697166532776746648320380374280103671755200316906558262375061821325312) (* |_514| 452312848583266388373324160190187140051835877600158453279131187530910662656) (* |_515| 226156424291633194186662080095093570025917938800079226639565593765455331328) (* |_516| 113078212145816597093331040047546785012958969400039613319782796882727665664) (* |_517| 56539106072908298546665520023773392506479484700019806659891398441363832832) (* |_518| 28269553036454149273332760011886696253239742350009903329945699220681916416) (* |_519| 14134776518227074636666380005943348126619871175004951664972849610340958208) (* |_520| 7067388259113537318333190002971674063309935587502475832486424805170479104) (* |_521| 3533694129556768659166595001485837031654967793751237916243212402585239552) (* |_522| 1766847064778384329583297500742918515827483896875618958121606201292619776) (* |_523| 883423532389192164791648750371459257913741948437809479060803100646309888) (* |_524| 441711766194596082395824375185729628956870974218904739530401550323154944) (* |_525| 220855883097298041197912187592864814478435487109452369765200775161577472) (* |_526| 110427941548649020598956093796432407239217743554726184882600387580788736) (* |_527| 55213970774324510299478046898216203619608871777363092441300193790394368) (* |_528| 27606985387162255149739023449108101809804435888681546220650096895197184) (* |_529| 13803492693581127574869511724554050904902217944340773110325048447598592) (* |_530| 6901746346790563787434755862277025452451108972170386555162524223799296) (* |_531| 3450873173395281893717377931138512726225554486085193277581262111899648) (* |_532| 1725436586697640946858688965569256363112777243042596638790631055949824) (* |_533| 862718293348820473429344482784628181556388621521298319395315527974912) (* |_534| 431359146674410236714672241392314090778194310760649159697657763987456) (* |_535| 215679573337205118357336120696157045389097155380324579848828881993728) (* |_536| 107839786668602559178668060348078522694548577690162289924414440996864) (* |_537| 53919893334301279589334030174039261347274288845081144962207220498432) (* |_538| 26959946667150639794667015087019630673637144422540572481103610249216) (* |_539| 13479973333575319897333507543509815336818572211270286240551805124608) (* |_540| 6739986666787659948666753771754907668409286105635143120275902562304) (* |_541| 3369993333393829974333376885877453834204643052817571560137951281152) (* |_542| 1684996666696914987166688442938726917102321526408785780068975640576) (* |_543| 842498333348457493583344221469363458551160763204392890034487820288) (* |_544| 421249166674228746791672110734681729275580381602196445017243910144) (* |_545| 210624583337114373395836055367340864637790190801098222508621955072) (* |_546| 105312291668557186697918027683670432318895095400549111254310977536) (* |_547| 52656145834278593348959013841835216159447547700274555627155488768) (* |_548| 26328072917139296674479506920917608079723773850137277813577744384) (* |_549| 13164036458569648337239753460458804039861886925068638906788872192) (* |_550| 6582018229284824168619876730229402019930943462534319453394436096) (* |_551| 3291009114642412084309938365114701009965471731267159726697218048) (* |_552| 1645504557321206042154969182557350504982735865633579863348609024) (* |_553| 822752278660603021077484591278675252491367932816789931674304512) (* |_554| 411376139330301510538742295639337626245683966408394965837152256) (* |_555| 205688069665150755269371147819668813122841983204197482918576128) (* |_556| 102844034832575377634685573909834406561420991602098741459288064) (* |_557| 51422017416287688817342786954917203280710495801049370729644032) (* |_558| 25711008708143844408671393477458601640355247900524685364822016) (* |_559| 12855504354071922204335696738729300820177623950262342682411008) (* |_560| 6427752177035961102167848369364650410088811975131171341205504) (* |_561| 3213876088517980551083924184682325205044405987565585670602752) (* |_562| 1606938044258990275541962092341162602522202993782792835301376) (* |_563| 803469022129495137770981046170581301261101496891396417650688) (* |_564| 401734511064747568885490523085290650630550748445698208825344) (* |_565| 200867255532373784442745261542645325315275374222849104412672) (* |_566| 100433627766186892221372630771322662657637687111424552206336) (* |_567| 50216813883093446110686315385661331328818843555712276103168) (* |_568| 25108406941546723055343157692830665664409421777856138051584) (* |_569| 12554203470773361527671578846415332832204710888928069025792) (* |_570| 6277101735386680763835789423207666416102355444464034512896) (* |_571| 3138550867693340381917894711603833208051177722232017256448) (* |_572| 1569275433846670190958947355801916604025588861116008628224) (* |_573| 784637716923335095479473677900958302012794430558004314112) (* |_574| 392318858461667547739736838950479151006397215279002157056) (* |_575| 196159429230833773869868419475239575503198607639501078528) (* |_576| 98079714615416886934934209737619787751599303819750539264) (* |_577| 49039857307708443467467104868809893875799651909875269632) (* |_578| 24519928653854221733733552434404946937899825954937634816) (* |_579| 12259964326927110866866776217202473468949912977468817408) (* |_580| 6129982163463555433433388108601236734474956488734408704) (* |_581| 3064991081731777716716694054300618367237478244367204352) (* |_582| 1532495540865888858358347027150309183618739122183602176) (* |_583| 766247770432944429179173513575154591809369561091801088) (* |_584| 383123885216472214589586756787577295904684780545900544) (* |_585| 191561942608236107294793378393788647952342390272950272) (* |_586| 95780971304118053647396689196894323976171195136475136) (* |_587| 47890485652059026823698344598447161988085597568237568) (* |_588| 23945242826029513411849172299223580994042798784118784) (* |_589| 11972621413014756705924586149611790497021399392059392) (* |_590| 5986310706507378352962293074805895248510699696029696) (* |_591| 2993155353253689176481146537402947624255349848014848) (* |_592| 1496577676626844588240573268701473812127674924007424) (* |_593| 748288838313422294120286634350736906063837462003712) (* |_594| 374144419156711147060143317175368453031918731001856) (* |_595| 187072209578355573530071658587684226515959365500928) (* |_596| 93536104789177786765035829293842113257979682750464) (* |_597| 46768052394588893382517914646921056628989841375232) (* |_598| 23384026197294446691258957323460528314494920687616) (* |_599| 11692013098647223345629478661730264157247460343808) (* |_600| 5846006549323611672814739330865132078623730171904) (* |_601| 2923003274661805836407369665432566039311865085952) (* |_602| 1461501637330902918203684832716283019655932542976) (* |_603| 730750818665451459101842416358141509827966271488) (* |_604| 365375409332725729550921208179070754913983135744) (* |_605| 182687704666362864775460604089535377456991567872) (* |_606| 91343852333181432387730302044767688728495783936) (* |_607| 45671926166590716193865151022383844364247891968) (* |_608| 22835963083295358096932575511191922182123945984) (* |_609| 11417981541647679048466287755595961091061972992) (* |_610| 5708990770823839524233143877797980545530986496) (* |_611| 2854495385411919762116571938898990272765493248) (* |_612| 1427247692705959881058285969449495136382746624) (* |_613| 713623846352979940529142984724747568191373312) (* |_614| 356811923176489970264571492362373784095686656) (* |_615| 178405961588244985132285746181186892047843328) (* |_616| 89202980794122492566142873090593446023921664) (* |_617| 44601490397061246283071436545296723011960832) (* |_618| 22300745198530623141535718272648361505980416) (* |_619| 11150372599265311570767859136324180752990208) (* |_620| 5575186299632655785383929568162090376495104) (* |_621| 2787593149816327892691964784081045188247552) (* |_622| 1393796574908163946345982392040522594123776) (* |_623| 696898287454081973172991196020261297061888) (* |_624| 348449143727040986586495598010130648530944) (* |_625| 174224571863520493293247799005065324265472) (* |_626| 87112285931760246646623899502532662132736) (* |_627| 43556142965880123323311949751266331066368) (* |_628| 21778071482940061661655974875633165533184) (* |_629| 10889035741470030830827987437816582766592) (* |_630| 5444517870735015415413993718908291383296) (* |_631| 2722258935367507707706996859454145691648) (* |_632| 1361129467683753853853498429727072845824) (* |_633| 680564733841876926926749214863536422912) (* |_634| 340282366920938463463374607431768211456) (* |_635| 170141183460469231731687303715884105728) (* |_636| 85070591730234615865843651857942052864) (* |_637| 42535295865117307932921825928971026432) (* |_638| 21267647932558653966460912964485513216) (* |_639| 10633823966279326983230456482242756608) (* |_640| 5316911983139663491615228241121378304) (* |_641| 2658455991569831745807614120560689152) (* |_642| 1329227995784915872903807060280344576) (* |_643| 664613997892457936451903530140172288) (* |_644| 332306998946228968225951765070086144) (* |_645| 166153499473114484112975882535043072) (* |_646| 83076749736557242056487941267521536) (* |_647| 41538374868278621028243970633760768) (* |_648| 20769187434139310514121985316880384) (* |_649| 10384593717069655257060992658440192) (* |_650| 5192296858534827628530496329220096) (* |_651| 2596148429267413814265248164610048) (* |_652| 1298074214633706907132624082305024) (* |_653| 649037107316853453566312041152512) (* |_654| 324518553658426726783156020576256) (* |_655| 162259276829213363391578010288128) (* |_656| 81129638414606681695789005144064) (* |_657| 40564819207303340847894502572032) (* |_658| 20282409603651670423947251286016) (* |_659| 10141204801825835211973625643008) (* |_660| 5070602400912917605986812821504) (* |_661| 2535301200456458802993406410752) (* |_662| 1267650600228229401496703205376) (* |_663| 633825300114114700748351602688) (* |_664| 316912650057057350374175801344) (* |_665| 158456325028528675187087900672) (* |_666| 79228162514264337593543950336) (* |_667| 39614081257132168796771975168) (* |_668| 19807040628566084398385987584) (* |_669| 9903520314283042199192993792) (* |_670| 4951760157141521099596496896) (* |_671| 2475880078570760549798248448) (* |_672| 1237940039285380274899124224) (* |_673| 618970019642690137449562112) (* |_674| 309485009821345068724781056) (* |_675| 154742504910672534362390528) (* |_676| 77371252455336267181195264) (* |_677| 38685626227668133590597632) (* |_678| 19342813113834066795298816) (* |_679| 9671406556917033397649408) (* |_680| 4835703278458516698824704) (* |_681| 2417851639229258349412352) (* |_682| 1208925819614629174706176) (* |_683| 604462909807314587353088) (* |_684| 302231454903657293676544) (* |_685| 151115727451828646838272) (* |_686| 75557863725914323419136) (* |_687| 37778931862957161709568) (* |_688| 18889465931478580854784) (* |_689| 9444732965739290427392) (* |_690| 4722366482869645213696) (* |_691| 2361183241434822606848) (* |_692| 1180591620717411303424) (* |_693| 590295810358705651712) (* |_694| 295147905179352825856) (* |_695| 147573952589676412928) (* |_696| 73786976294838206464) (* |_697| 36893488147419103232) (* |_698| 18446744073709551616) (* |_699| 9223372036854775808) (* |_700| 4611686018427387904) (* |_701| 2305843009213693952) (* |_702| 1152921504606846976) (* |_703| 576460752303423488) (* |_704| 288230376151711744) (* |_705| 144115188075855872) (* |_706| 72057594037927936) (* |_707| 36028797018963968) (* |_708| 18014398509481984) (* |_709| 9007199254740992) (* |_710| 4503599627370496) (* |_711| 2251799813685248) (* |_712| 1125899906842624) (* |_713| 562949953421312) (* |_714| 281474976710656) (* |_715| 140737488355328) (* |_716| 70368744177664) (* |_717| 35184372088832) (* |_718| 17592186044416) (* |_719| 8796093022208) (* |_720| 4398046511104) (* |_721| 2199023255552) (* |_722| 1099511627776) (* |_723| 549755813888) (* |_724| 274877906944) (* |_725| 137438953472) (* |_726| 68719476736) (* |_727| 34359738368) (* |_728| 17179869184) (* |_729| 8589934592) (* |_730| 4294967296) (* |_731| 2147483648) (* |_732| 1073741824) (* |_733| 536870912) (* |_734| 268435456) (* |_735| 134217728) (* |_736| 67108864) (* |_737| 33554432) (* |_738| 16777216) (* |_739| 8388608) (* |_740| 4194304) (* |_741| 2097152) (* |_742| 1048576) (* |_743| 524288) (* |_744| 262144) (* |_745| 131072) (* |_746| 65536) (* |_747| 32768) (* |_748| 16384) (* |_749| 8192) (* |_750| 4096) (* |_751| 2048) (* |_752| 1024) (* |_753| 512) (* |_754| 256) (* |_755| 128) (* |_756| 64) (* |_757| 32) (* |_758| 16) (* |_759| 8) (* |_760| 4) (* |_761| 2) (* |_762| 1))) |~prime|) (mod (* |_0| 1) |~prime|)) +(= (mod (* (* |_2| 1) (+ (* |_0| 21888242871839275222246405745257275088548364400416034343698204186575808495616) (* |_1| 1))) |~prime|) (mod (* |_768| 1) |~prime|)) +(= (mod (* (* |~one| 1) (* |_768| 1)) |~prime|) (mod (* |~out_0| 1) |~prime|)) )) \ No newline at end of file diff --git a/zokrates_codegen/Cargo.toml b/zokrates_codegen/Cargo.toml index 42fabe756..9560dcdec 100644 --- a/zokrates_codegen/Cargo.toml +++ b/zokrates_codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_codegen" -version = "0.1.3" +version = "0.1.4" edition = "2021" [features] diff --git a/zokrates_codegen/src/lib.rs b/zokrates_codegen/src/lib.rs index 46faf587e..9f6eea18d 100644 --- a/zokrates_codegen/src/lib.rs +++ b/zokrates_codegen/src/lib.rs @@ -33,7 +33,6 @@ use zokrates_ast::zir::{ BooleanExpression, Conditional, FieldElementExpression, Identifier, Parameter as ZirParameter, UExpression, UExpressionInner, Variable as ZirVariable, ZirExpression, ZirStatement, }; -use zokrates_common::CompileConfig; use zokrates_field::Field; /// A container for statements produced during code generation @@ -80,13 +79,10 @@ impl<'ast, T> IntoIterator for FlatStatements<'ast, T> { /// /// # Arguments /// * `funct` - `ZirFunction` that will be flattened -pub fn from_program_and_config( - prog: ZirProgram, - config: CompileConfig, -) -> FlattenerIterator { +pub fn from_program_and_config(prog: ZirProgram) -> FlattenerIterator { let funct = prog.main; - let mut flattener = Flattener::new(config); + let mut flattener = Flattener::default(); let mut statements_flattened = FlatStatements::default(); // push parameters let arguments_flattened = funct @@ -135,9 +131,8 @@ impl<'ast, T: Field> Iterator for FlattenerIteratorInner<'ast, T> { } /// Flattener, computes flattened program. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Flattener<'ast, T> { - config: CompileConfig, /// Index of the next introduced variable while processing the program. next_var_idx: usize, /// `Variable`s corresponding to each `Identifier` @@ -274,16 +269,6 @@ impl FlatUExpression { } impl<'ast, T: Field> Flattener<'ast, T> { - /// Returns a `Flattener` with fresh `layout`. - fn new(config: CompileConfig) -> Flattener<'ast, T> { - Flattener { - config, - next_var_idx: 0, - layout: HashMap::new(), - bits_cache: HashMap::new(), - } - } - /// Flattens a definition, trying to avoid creating redundant variables fn define( &mut self, @@ -571,68 +556,6 @@ impl<'ast, T: Field> Flattener<'ast, T> { } } - fn make_conditional( - &mut self, - statements: FlatStatements<'ast, T>, - condition: FlatExpression, - ) -> FlatStatements<'ast, T> { - statements - .into_iter() - .flat_map(|s| match s { - FlatStatement::Condition(s) => { - let span = s.get_span(); - - let mut output = FlatStatements::default(); - - output.set_span(span); - - // we transform (a == b) into (c => (a == b)) which is (!c || (a == b)) - - // let's introduce new variables to make sure everything is linear - let name_lin = self.define(s.lin, &mut output); - let name_quad = self.define(s.quad, &mut output); - - // let's introduce an expression which is 1 iff `a == b` - let y = FlatExpression::add( - FlatExpression::sub(name_lin.into(), name_quad.into()), - T::one().into(), - ); // let's introduce !c - let x = FlatExpression::sub(T::one().into(), condition.clone()); - assert!(x.is_linear() && y.is_linear()); - let name_x_or_y = self.use_sym(); - output.push_back(FlatStatement::directive( - vec![name_x_or_y], - Solver::Or, - vec![x.clone(), y.clone()], - )); - output.push_back(FlatStatement::condition( - FlatExpression::add( - x.clone(), - FlatExpression::sub(y.clone(), name_x_or_y.into()), - ), - FlatExpression::mul(x, y), - RuntimeError::BranchIsolation, - )); - output.push_back(FlatStatement::condition( - name_x_or_y.into(), - T::one().into(), - s.error, - )); - - output - } - s => { - let mut v = FlatStatements::default(); - v.push_back(s); - v - } - }) - .fold(FlatStatements::default(), |mut acc, s| { - acc.push_back(s); - acc - }) - } - /// Flatten an if/else expression /// /// # Arguments @@ -658,35 +581,8 @@ impl<'ast, T: Field> Flattener<'ast, T> { let condition_id = self.use_sym(); statements_flattened.push_back(FlatStatement::definition(condition_id, condition_flat)); - let (consequence, alternative) = if self.config.isolate_branches { - let mut consequence_statements = FlatStatements::default(); - - let consequence = consequence.flatten(self, &mut consequence_statements); - - let mut alternative_statements = FlatStatements::default(); - - let alternative = alternative.flatten(self, &mut alternative_statements); - - let consequence_statements = - self.make_conditional(consequence_statements, condition_id.into()); - let alternative_statements = self.make_conditional( - alternative_statements, - FlatExpression::sub(FlatExpression::value(T::one()), condition_id.into()), - ); - - statements_flattened.extend(consequence_statements); - statements_flattened.extend(alternative_statements); - - (consequence, alternative) - } else { - ( - consequence.flatten(self, statements_flattened), - alternative.flatten(self, statements_flattened), - ) - }; - - let consequence = consequence.flat(); - let alternative = alternative.flat(); + let consequence = consequence.flatten(self, statements_flattened).flat(); + let alternative = alternative.flatten(self, statements_flattened).flat(); let consequence_id = self.use_sym(); statements_flattened.push_back(FlatStatement::definition(consequence_id, consequence)); @@ -841,7 +737,7 @@ impl<'ast, T: Field> Flattener<'ast, T> { let lhs_id = self.define(lhs_flattened, statements_flattened); let rhs_id = self.define(rhs_flattened, statements_flattened); - // shifted_sub := 2**safe_width + lhs - rhs + // shifted_sub := 2**bit_width + lhs - rhs let shifted_sub = FlatExpression::add( FlatExpression::value(T::from(2).pow(bit_width)), FlatExpression::sub( @@ -857,7 +753,7 @@ impl<'ast, T: Field> Flattener<'ast, T> { sub_width, sub_width, statements_flattened, - RuntimeError::IncompleteDynamicRange, + RuntimeError::Sum, ); FlatExpression::sub( @@ -898,19 +794,42 @@ impl<'ast, T: Field> Flattener<'ast, T> { .flatten_select_expression(statements_flattened, e) .get_field_unchecked(), BooleanExpression::FieldLt(e) => { - // Get the bit width to know the size of the binary decompositions for this Field - let bit_width = T::get_required_bits(); - - let safe_width = bit_width - 2; // dynamic comparison is not complete, it only applies to field elements whose difference is strictly smaller than 2**(bitwidth - 2) - let lhs_flattened = self.flatten_field_expression(statements_flattened, *e.left); let rhs_flattened = self.flatten_field_expression(statements_flattened, *e.right); - self.lt_check( - statements_flattened, - lhs_flattened, - rhs_flattened, - safe_width, - ) + + match (lhs_flattened, rhs_flattened) { + (e, FlatExpression::Value(c)) => { + self.constant_lt_check(statements_flattened, e, c.value) + } + (FlatExpression::Value(c), e) => self.constant_lt_check( + statements_flattened, + FlatExpression::sub(T::max_value().into(), e), + T::max_value() - c.value, + ), + (lhs, rhs) => { + // Get the bit width to know the size of the binary decompositions for this Field + let bit_width = T::get_required_bits(); + let safe_width = bit_width - 2; // dynamic comparison is not complete, it only applies to field elements whose difference is strictly smaller than 2**(bitwidth - 2) + let safe_max = T::from(2).pow(safe_width); + + // enforce that lhs and rhs are in the correct range + self.enforce_constant_lt_check( + statements_flattened, + lhs.clone(), + safe_max, + RuntimeError::IncompleteDynamicRange, + ); + + self.enforce_constant_lt_check( + statements_flattened, + rhs.clone(), + safe_max, + RuntimeError::IncompleteDynamicRange, + ); + + self.lt_check(statements_flattened, lhs, rhs, safe_width) + } + } } BooleanExpression::BoolEq(e) => { // lhs and rhs are booleans, they flatten to 0 or 1 @@ -1314,7 +1233,7 @@ impl<'ast, T: Field> Flattener<'ast, T> { let xor: Vec> = left_bits .into_iter() - .zip(right_bits.into_iter()) + .zip(right_bits) .map(|(x, y)| match (x, y) { (FlatExpression::Value(n), e) | (e, FlatExpression::Value(n)) => { if n.value == T::from(0) { @@ -1686,8 +1605,8 @@ impl<'ast, T: Field> Flattener<'ast, T> { let res: Vec> = a_bits .into_iter() - .zip(b_bits.into_iter()) - .zip(c_bits.into_iter()) + .zip(b_bits) + .zip(c_bits) .map(|((a, b), c)| { // a(b - c) = ch - c @@ -1753,8 +1672,8 @@ impl<'ast, T: Field> Flattener<'ast, T> { let res: Vec> = a_bits .into_iter() - .zip(b_bits.into_iter()) - .zip(c_bits.into_iter()) + .zip(b_bits) + .zip(c_bits) .map(|((a, b), c)| { // (b) * (c) = (bc) // (2bc - b - c) * (a) = bc - maj @@ -1856,7 +1775,7 @@ impl<'ast, T: Field> Flattener<'ast, T> { let and: Vec<_> = left_bits .into_iter() - .zip(right_bits.into_iter()) + .zip(right_bits) .map(|(x, y)| match (x, y) { (FlatExpression::Value(n), e) | (e, FlatExpression::Value(n)) => { if n.value == T::from(0) { @@ -1890,7 +1809,7 @@ impl<'ast, T: Field> Flattener<'ast, T> { let or: Vec> = left_bits .into_iter() - .zip(right_bits.into_iter()) + .zip(right_bits) .map(|(x, y)| match (x, y) { (FlatExpression::Value(n), e) | (e, FlatExpression::Value(n)) => { if n.value == T::from(0) { @@ -1980,7 +1899,8 @@ impl<'ast, T: Field> Flattener<'ast, T> { /// /// # Notes /// * `from` and `to` must be smaller or equal to `T::get_required_bits()`, the bitwidth of the prime field - /// * the result is not checked to be in range. This is fine for `to < T::get_required_bits()`, but otherwise it is the caller's responsibility to add that check + /// * The result is not checked to be in range unless the bits of the expression were already decomposed with a higher bitwidth than `to` + /// * This is fine for `to < T::get_required_bits()`, but otherwise it is the caller's responsibility to add that check fn get_bits_unchecked( &mut self, e: &FlatUExpression, @@ -2015,19 +1935,30 @@ impl<'ast, T: Field> Flattener<'ast, T> { let from = std::cmp::max(from, to); let res = match self.bits_cache.entry(e.field.clone().unwrap()) { Entry::Occupied(entry) => { - let res: Vec<_> = entry.get().clone(); - // if we already know a decomposition, its number of elements has to be smaller or equal to `to` + let mut res: Vec<_> = entry.get().clone(); + + // only keep the last `to` values and return the sum of the others + let sum = res + .drain(0..res.len().saturating_sub(to)) + .fold(FlatExpression::from(T::zero()), |acc, e| { + FlatExpression::add(acc, e) + }); + + // force the sum to be 0 + statements_flattened.push_back(FlatStatement::condition( + FlatExpression::value(T::from(0)), + sum, + error, + )); + + // sanity check that we have at most `to` values assert!(res.len() <= to); - // we then pad it with zeroes on the left (big endian) to return `to` bits - if res.len() == to { - res - } else { - (0..to - res.len()) - .map(|_| FlatExpression::value(T::zero())) - .chain(res) - .collect() - } + // return the result left-padded to `to` values + std::iter::repeat(FlatExpression::value(T::zero())) + .take(to - res.len()) + .chain(res.clone()) + .collect() } Entry::Vacant(_) => { let bits = (0..from).map(|_| self.use_sym()).collect::>(); @@ -2448,34 +2379,12 @@ impl<'ast, T: Field> Flattener<'ast, T> { statements_flattened .push_back(FlatStatement::definition(condition_id, condition_flat)); - if self.config.isolate_branches { - let mut consequence_statements = FlatStatements::default(); - let mut alternative_statements = FlatStatements::default(); - - s.consequence - .into_iter() - .for_each(|s| self.flatten_statement(&mut consequence_statements, s)); - s.alternative - .into_iter() - .for_each(|s| self.flatten_statement(&mut alternative_statements, s)); - - let consequence_statements = - self.make_conditional(consequence_statements, condition_id.into()); - let alternative_statements = self.make_conditional( - alternative_statements, - FlatExpression::sub(FlatExpression::value(T::one()), condition_id.into()), - ); - - statements_flattened.extend(consequence_statements); - statements_flattened.extend(alternative_statements); - } else { - s.consequence - .into_iter() - .for_each(|s| self.flatten_statement(statements_flattened, s)); - s.alternative - .into_iter() - .for_each(|s| self.flatten_statement(statements_flattened, s)); - } + s.consequence + .into_iter() + .for_each(|s| self.flatten_statement(statements_flattened, s)); + s.alternative + .into_iter() + .for_each(|s| self.flatten_statement(statements_flattened, s)); } ZirStatement::Definition(s) => { // define n variables with n the number of primitive types for v_type @@ -2553,7 +2462,23 @@ impl<'ast, T: Field> Flattener<'ast, T> { ), (lhs, rhs) => { let bit_width = T::get_required_bits(); - let safe_width = bit_width - 2; // dynamic comparison is not complete + let safe_width = bit_width - 2; // dynamic comparison is not complete, it only applies to field elements whose difference is strictly smaller than 2**(bitwidth - 2) + let safe_max = T::from(2).pow(safe_width); + + self.enforce_constant_lt_check( + statements_flattened, + lhs.clone(), + safe_max, + RuntimeError::IncompleteDynamicRange, + ); + + self.enforce_constant_lt_check( + statements_flattened, + rhs.clone(), + safe_max, + RuntimeError::IncompleteDynamicRange, + ); + let e = self.lt_check(statements_flattened, lhs, rhs, safe_width); statements_flattened.push_back(FlatStatement::condition( e, @@ -2583,7 +2508,23 @@ impl<'ast, T: Field> Flattener<'ast, T> { ), (lhs, rhs) => { let bit_width = T::get_required_bits(); - let safe_width = bit_width - 2; // dynamic comparison is not complete + let safe_width = bit_width - 2; // dynamic comparison is not complete, it only applies to field elements whose difference is strictly smaller than 2**(bitwidth - 2) + + let safe_max = T::from(2).pow(safe_width); + self.enforce_constant_lt_check( + statements_flattened, + lhs.clone(), + safe_max, + RuntimeError::IncompleteDynamicRange, + ); + + self.enforce_constant_lt_check( + statements_flattened, + rhs.clone(), + safe_max, + RuntimeError::IncompleteDynamicRange, + ); + let e = self.le_check(statements_flattened, lhs, rhs, safe_width); statements_flattened.push_back(FlatStatement::condition( e, @@ -2593,32 +2534,72 @@ impl<'ast, T: Field> Flattener<'ast, T> { } } } - BooleanExpression::UintLe(e) => { + BooleanExpression::UintLt(e) => { + let bitwidth = e.left.bitwidth as usize; let lhs = self .flatten_uint_expression(statements_flattened, *e.left) .get_field_unchecked(); + let rhs = self .flatten_uint_expression(statements_flattened, *e.right) .get_field_unchecked(); match (lhs, rhs) { - (e, FlatExpression::Value(c)) => self.enforce_constant_le_check( + (e, FlatExpression::Value(c)) => self.enforce_constant_lt_check( statements_flattened, e, c.value, error.into(), ), - // c <= e <=> p - 1 - e <= p - 1 - c - (FlatExpression::Value(c), e) => self.enforce_constant_le_check( + // c < e <=> 2^bw - 1 - e < 2^bw - 1 - c + (FlatExpression::Value(c), e) => { + let max = T::from(2u32).pow(bitwidth) - T::one(); + self.enforce_constant_lt_check( + statements_flattened, + FlatExpression::sub(max.into(), e), + max - c.value, + error.into(), + ) + } + (lhs, rhs) => { + let e = self.lt_check(statements_flattened, lhs, rhs, bitwidth); + statements_flattened.push_back(FlatStatement::condition( + e, + FlatExpression::value(T::one()), + error.into(), + )); + } + } + } + BooleanExpression::UintLe(e) => { + let bitwidth = e.left.bitwidth as usize; + let lhs = self + .flatten_uint_expression(statements_flattened, *e.left) + .get_field_unchecked(); + + let rhs = self + .flatten_uint_expression(statements_flattened, *e.right) + .get_field_unchecked(); + + match (lhs, rhs) { + (e, FlatExpression::Value(c)) => self.enforce_constant_le_check( statements_flattened, - FlatExpression::sub(T::max_value().into(), e), - T::max_value() - c.value, + e, + c.value, error.into(), ), + // c <= e <=> 2^bw - 1 - e <= 2^bw - 1 - c + (FlatExpression::Value(c), e) => { + let max = T::from(2u32).pow(bitwidth) - T::one(); + self.enforce_constant_le_check( + statements_flattened, + FlatExpression::sub(max.into(), e), + max - c.value, + error.into(), + ) + } (lhs, rhs) => { - let bit_width = T::get_required_bits(); - let safe_width = bit_width - 2; // dynamic comparison is not complete - let e = self.le_check(statements_flattened, lhs, rhs, safe_width); + let e = self.le_check(statements_flattened, lhs, rhs, bitwidth); statements_flattened.push_back(FlatStatement::condition( e, FlatExpression::value(T::one()), @@ -2999,13 +2980,10 @@ mod tests { use zokrates_field::Bn128Field; fn flatten_function(f: ZirFunction) -> FlatProg { - from_program_and_config( - ZirProgram { - main: f, - module_map: Default::default(), - }, - CompileConfig::default(), - ) + from_program_and_config(ZirProgram { + main: f, + module_map: Default::default(), + }) .collect() } @@ -3801,7 +3779,6 @@ mod tests { #[test] fn if_else() { - let config = CompileConfig::default(); let expression = FieldElementExpression::conditional( BooleanExpression::field_eq( FieldElementExpression::value(Bn128Field::from(32)), @@ -3811,15 +3788,14 @@ mod tests { FieldElementExpression::value(Bn128Field::from(51)), ); - let mut flattener = Flattener::new(config); + let mut flattener = Flattener::default(); flattener.flatten_field_expression(&mut FlatStatements::default(), expression); } #[test] fn geq_leq() { - let config = CompileConfig::default(); - let mut flattener = Flattener::new(config); + let mut flattener = Flattener::default(); let expression_le = BooleanExpression::field_le( FieldElementExpression::value(Bn128Field::from(32)), FieldElementExpression::value(Bn128Field::from(4)), @@ -3829,8 +3805,7 @@ mod tests { #[test] fn bool_and() { - let config = CompileConfig::default(); - let mut flattener = Flattener::new(config); + let mut flattener = Flattener::default(); let expression = FieldElementExpression::conditional( BooleanExpression::bitand( @@ -3853,8 +3828,7 @@ mod tests { #[test] fn div() { // a = 5 / b / b - let config = CompileConfig::default(); - let mut flattener = Flattener::new(config); + let mut flattener = Flattener::default(); let mut statements_flattened = FlatStatements::default(); let definition = ZirStatement::definition( diff --git a/zokrates_common/Cargo.toml b/zokrates_common/Cargo.toml index 1a418c00c..162af953e 100644 --- a/zokrates_common/Cargo.toml +++ b/zokrates_common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_common" -version = "0.1.3" +version = "0.1.4" authors = ["dark64 "] edition = "2018" diff --git a/zokrates_common/src/lib.rs b/zokrates_common/src/lib.rs index a37d9112c..d1c6418ee 100644 --- a/zokrates_common/src/lib.rs +++ b/zokrates_common/src/lib.rs @@ -14,18 +14,11 @@ pub trait Resolver { #[derive(Debug, Default, Serialize, Deserialize, Clone, Copy)] pub struct CompileConfig { - #[serde(default)] - pub isolate_branches: bool, #[serde(default)] pub debug: bool, } impl CompileConfig { - pub fn isolate_branches(mut self, flag: bool) -> Self { - self.isolate_branches = flag; - self - } - pub fn debug(mut self, debug: bool) -> Self { self.debug = debug; self diff --git a/zokrates_core/Cargo.toml b/zokrates_core/Cargo.toml index 919677960..2f1de962e 100644 --- a/zokrates_core/Cargo.toml +++ b/zokrates_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_core" -version = "0.7.6" +version = "0.7.7" edition = "2021" authors = ["Jacob Eberhardt ", "Dennis Kuhnert "] repository = "https://github.com/Zokrates/ZoKrates" diff --git a/zokrates_core/src/compile.rs b/zokrates_core/src/compile.rs index 468c1b68b..3f9e32735 100644 --- a/zokrates_core/src/compile.rs +++ b/zokrates_core/src/compile.rs @@ -183,7 +183,7 @@ pub fn compile<'ast, T: Field, E: Into>( // flatten input program log::debug!("Flatten"); - let program_flattened = from_program_and_config(typed_ast, config); + let program_flattened = from_program_and_config(typed_ast); // convert to ir log::debug!("Convert to IR"); diff --git a/zokrates_core/src/optimizer/mod.rs b/zokrates_core/src/optimizer/mod.rs index 08a6c1b7d..6cd3628e9 100644 --- a/zokrates_core/src/optimizer/mod.rs +++ b/zokrates_core/src/optimizer/mod.rs @@ -27,9 +27,9 @@ pub fn optimize<'ast, T: Field, I: IntoIterator>>( // define all optimizer steps let mut redefinition_optimizer = RedefinitionOptimizer::init(&p); - let mut tautologies_optimizer = TautologyOptimizer::default(); + let mut tautologies_optimizer = TautologyOptimizer; let mut directive_optimizer = DirectiveOptimizer::default(); - let mut canonicalizer = Canonicalizer::default(); + let mut canonicalizer = Canonicalizer; let mut duplicate_optimizer = DuplicateOptimizer::default(); use zokrates_ast::ir::folder::Folder; diff --git a/zokrates_core/src/semantics.rs b/zokrates_core/src/semantics.rs index 5be636cbb..b1646e11c 100644 --- a/zokrates_core/src/semantics.rs +++ b/zokrates_core/src/semantics.rs @@ -1161,7 +1161,8 @@ impl<'ast, T: Field> Checker<'ast, T> { let decl_v = DeclarationVariable::new( self.id_in_this_scope(arg.id.value.id), decl_ty.clone(), - ); + ) + .with_span(arg.id.span().in_module(module_id)); let is_mutable = arg.id.value.is_mutable; @@ -1793,20 +1794,32 @@ impl<'ast, T: Field> Checker<'ast, T> { AssemblyStatement::Assignment(assignee, expression, constrained) => { let assignee = self.check_assignee(assignee, module_id, types)?; let e = self.check_expression(expression, module_id, types)?; - - let e = FieldElementExpression::try_from_typed(e).map_err(|e| ErrorInner { - span: Some(span), - message: format!( - "Expected right hand side of an assembly assignment to be of type field, found {}", - e.get_type(), - ), + let e = TypedExpression::align_to_type(e, &assignee.get_type()).map_err(|e| { + ErrorInner { + span: Some(span), + message: format!( + "Expected value of type `{}`, found `{}` of type `{}`", + e.1, + e.0, + e.0.get_type() + ), + } })?; match constrained { - true => { - let e = FieldElementExpression::block(vec![], e); - match assignee.get_type() { - Type::FieldElement => Ok(vec![ + true => match assignee.get_type() { + // in case of `lhs <== rhs` we expect lhs and rhs to be of type field + Type::FieldElement => { + let e = FieldElementExpression::try_from_typed(e).map_err(|e| ErrorInner { + span: Some(span), + message: format!( + "Expected right hand side of an assembly constrained assignment to be of type field, found {}", + e.get_type(), + ), + })?; + + let e = FieldElementExpression::block(vec![], e); + Ok(vec![ TypedAssemblyStatement::assignment( assignee.clone(), e.clone().into(), @@ -1818,18 +1831,28 @@ impl<'ast, T: Field> Checker<'ast, T> { SourceMetadata::new(module_id.display().to_string(), span.from), ) .with_span(span), - ]), - ty => Err(ErrorInner { - span: Some(span), - message: format!("Assignee must be of type field, found {}", ty), - }), + ]) } - } + ty => Err(ErrorInner { + span: Some(span), + message: format!("Assignee must be of type field, found {}", ty), + }), + }, false => { - let e = FieldElementExpression::block(vec![], e); - Ok(vec![ - TypedAssemblyStatement::assignment(assignee, e.into()).with_span(span) - ]) + // we can allow composite types in case of `<--` as no constraints are generated from this type of statement + // a composite type should only consist of field types + match e.get_type().is_composite_of_field() { + true => { + let e = TypedExpression::block(vec![], e); + Ok(vec![ + TypedAssemblyStatement::assignment(assignee, e).with_span(span) + ]) + }, + false => Err(ErrorInner { + span: Some(span), + message: "Assignee must be of type field or a composite type of field elements".to_string(), + }) + } } } } @@ -2140,10 +2163,9 @@ impl<'ast, T: Field> Checker<'ast, T> { span: Some(assignee.span().in_module(module_id)), message: format!("Assignment to an immutable variable `{}`", variable_name), }), - _ => Ok(TypedAssignee::Identifier(Variable::new( - info.id, - info.ty.clone(), - ))), + _ => Ok(TypedAssignee::Identifier( + Variable::new(info.id, info.ty.clone()).with_span(span), + )), }, None => Err(ErrorInner { span: Some(assignee.span().in_module(module_id)), diff --git a/zokrates_core_test/Cargo.toml b/zokrates_core_test/Cargo.toml index 3730edd67..bf79232ab 100644 --- a/zokrates_core_test/Cargo.toml +++ b/zokrates_core_test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_core_test" -version = "0.2.11" +version = "0.2.12" authors = ["schaeff "] edition = "2018" diff --git a/zokrates_core_test/tests/tests/assembly/assignment.json b/zokrates_core_test/tests/tests/assembly/assignment.json new file mode 100644 index 000000000..ca8f32f11 --- /dev/null +++ b/zokrates_core_test/tests/tests/assembly/assignment.json @@ -0,0 +1,16 @@ +{ + "curves": ["Bn128"], + "max_constraint_count": 4, + "tests": [ + { + "input": { + "values": ["1", "2"] + }, + "output": { + "Ok": { + "value": ["3", "2"] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/assembly/assignment.zok b/zokrates_core_test/tests/tests/assembly/assignment.zok new file mode 100644 index 000000000..8c9bb6dcb --- /dev/null +++ b/zokrates_core_test/tests/tests/assembly/assignment.zok @@ -0,0 +1,15 @@ +def foo(field a, field b) -> field[2] { + field c = a + b; + field d = a * b; + return [c, d]; +} + +def main(field a, field b) -> field[2] { + field[2] mut c = [0; 2]; + asm { + c <-- foo(a, b); + a + b === c[0]; + a * b === c[1]; + } + return c; +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/assembly/composite_assignment.json b/zokrates_core_test/tests/tests/assembly/composite_assignment.json new file mode 100644 index 000000000..7fce10f1a --- /dev/null +++ b/zokrates_core_test/tests/tests/assembly/composite_assignment.json @@ -0,0 +1,16 @@ +{ + "curves": ["Bn128"], + "max_constraint_count": 1, + "tests": [ + { + "input": { + "values": ["2", "2", "4"] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/assembly/composite_assignment.zok b/zokrates_core_test/tests/tests/assembly/composite_assignment.zok new file mode 100644 index 000000000..9bf3af9f8 --- /dev/null +++ b/zokrates_core_test/tests/tests/assembly/composite_assignment.zok @@ -0,0 +1,7 @@ +def main(field a, field b, field c) { + field[2] mut out = [0; 2]; + asm { + out <-- [a, b]; + out[0] * out[1] === c; + } +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/assembly/nested_assignment.json b/zokrates_core_test/tests/tests/assembly/nested_assignment.json new file mode 100644 index 000000000..7d72a99ff --- /dev/null +++ b/zokrates_core_test/tests/tests/assembly/nested_assignment.json @@ -0,0 +1,16 @@ +{ + "curves": ["Bn128"], + "max_constraint_count": 1, + "tests": [ + { + "input": { + "values": ["4"] + }, + "output": { + "Ok": { + "value": "32" + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/assembly/nested_assignment.zok b/zokrates_core_test/tests/tests/assembly/nested_assignment.zok new file mode 100644 index 000000000..0abf3c5e8 --- /dev/null +++ b/zokrates_core_test/tests/tests/assembly/nested_assignment.zok @@ -0,0 +1,20 @@ +def bar(field a) -> field { + field tmp = a * a; + field mut b = 0; + asm { + b <-- tmp * 2; + } + return b; +} + +def foo(field a) -> field { + field mut b = 0; + asm { + b <-- bar(a); + } + return b; +} + +def main(field a) -> field { + return foo(a); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/compare_min_to_max.json b/zokrates_core_test/tests/tests/compare_min_to_max.json deleted file mode 100644 index e1402336e..000000000 --- a/zokrates_core_test/tests/tests/compare_min_to_max.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "entry_point": "./tests/tests/compare_min_to_max.zok", - "curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"], - "tests": [ - { - "input": { - "values": ["0"] - }, - "output": { - "Ok": { - "value": false - } - } - } - ] -} diff --git a/zokrates_core_test/tests/tests/compare_min_to_max.zok b/zokrates_core_test/tests/tests/compare_min_to_max.zok deleted file mode 100644 index cd17242b0..000000000 --- a/zokrates_core_test/tests/tests/compare_min_to_max.zok +++ /dev/null @@ -1,10 +0,0 @@ -from "field" import FIELD_MAX; - -// /!\ should be called with a = 0 -// as `|a - FIELD_MAX| < 2**(N-2)` the comparison should succeed - -def main(field a) -> bool { - field p = FIELD_MAX + a; - // we added a = 0 to prevent the condition to be evaluated at compile time - return a < p; -} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/constant_condition.json b/zokrates_core_test/tests/tests/constant_condition.json new file mode 100644 index 000000000..08b8a0e94 --- /dev/null +++ b/zokrates_core_test/tests/tests/constant_condition.json @@ -0,0 +1,3 @@ +{ + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/constant_condition.zok b/zokrates_core_test/tests/tests/constant_condition.zok new file mode 100644 index 000000000..b42cd3b2c --- /dev/null +++ b/zokrates_core_test/tests/tests/constant_condition.zok @@ -0,0 +1,6 @@ +def main() { + field[2] a = [0; 2]; + for u32 i in 1..2 { + field b = (i == 1) ? 0 : a[i - 2]; + } +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/constants/propagate_embed.json b/zokrates_core_test/tests/tests/constants/propagate_embed.json new file mode 100644 index 000000000..3e1e26856 --- /dev/null +++ b/zokrates_core_test/tests/tests/constants/propagate_embed.json @@ -0,0 +1,5 @@ +{ + "entry_point": "./tests/tests/constants/propagate_embed.zok", + "max_constraint_count": 2, + "tests": [] +} diff --git a/zokrates_core_test/tests/tests/constants/propagate_embed.zok b/zokrates_core_test/tests/tests/constants/propagate_embed.zok new file mode 100644 index 000000000..6bafc7238 --- /dev/null +++ b/zokrates_core_test/tests/tests/constants/propagate_embed.zok @@ -0,0 +1,16 @@ +import "utils/casts/field_to_u32"; +from "EMBED" import unpack; + +def foo() -> field { + return 1; +} + +def main() -> field { + u32 N = field_to_u32(1); + for u32 i in 0..N { + log("{}", i); + } + bool[1] B = unpack(1); + u32 P = B[0] ? 1 : 0; + return foo::() + foo::

(); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/panics/conditional_bound_throw_no_isolation.json b/zokrates_core_test/tests/tests/panics/conditional_bound_throw.json similarity index 100% rename from zokrates_core_test/tests/tests/panics/conditional_bound_throw_no_isolation.json rename to zokrates_core_test/tests/tests/panics/conditional_bound_throw.json diff --git a/zokrates_core_test/tests/tests/panics/conditional_bound_throw.zok b/zokrates_core_test/tests/tests/panics/conditional_bound_throw.zok index 0d4fad916..829c7324e 100644 --- a/zokrates_core_test/tests/tests/panics/conditional_bound_throw.zok +++ b/zokrates_core_test/tests/tests/panics/conditional_bound_throw.zok @@ -4,7 +4,7 @@ def throwing_bound(u32 x) -> u32 { } // this compiles: the conditional, even though it can throw, has a constant compile-time value of `1` -// However, the assertions are still checked at runtime, which leads to panics without branch isolation. +// However, the assertions are still checked at runtime, which leads to panics def main(u32 x) { for u32 i in 0..x == 0 ? throwing_bound::<0>(x) : throwing_bound::<1>(x) {} return; diff --git a/zokrates_core_test/tests/tests/panics/conditional_panic.json b/zokrates_core_test/tests/tests/panics/conditional_panic.json new file mode 100644 index 000000000..20494a894 --- /dev/null +++ b/zokrates_core_test/tests/tests/panics/conditional_panic.json @@ -0,0 +1,50 @@ +{ + "entry_point": "./tests/tests/panics/conditional_panic.zok", + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": [true] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "1", + "right": "0", + "error": { + "SourceAssertion": { + "file": "./tests/tests/panics/conditional_panic.zok", + "position": { + "line": 7, + "col": 5 + } + } + } + } + } + } + }, + { + "input": { + "values": [false] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "1", + "right": "0", + "error": { + "SourceAssertion": { + "file": "./tests/tests/panics/conditional_panic.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/panics/conditional_panic.zok b/zokrates_core_test/tests/tests/panics/conditional_panic.zok new file mode 100644 index 000000000..982043f55 --- /dev/null +++ b/zokrates_core_test/tests/tests/panics/conditional_panic.zok @@ -0,0 +1,14 @@ +def yes(bool x) -> bool { + assert(x); + return x; +} + +def no(bool x) -> bool { + assert(!x); + return x; +} + +def main(bool condition) -> bool { + // this will always panic + return condition ? yes(condition) : no(condition); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/panics/deep_branch.json b/zokrates_core_test/tests/tests/panics/deep_branch.json index a9287c128..570291ec2 100644 --- a/zokrates_core_test/tests/tests/panics/deep_branch.json +++ b/zokrates_core_test/tests/tests/panics/deep_branch.json @@ -1,17 +1,48 @@ { "entry_point": "./tests/tests/panics/deep_branch.zok", "curves": ["Bn128"], - "config": { - "isolate_branches": true - }, "tests": [ + { + "input": { + "values": [[false, false, false]] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": { + "file": "./tests/tests/panics/deep_branch.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + }, { "input": { "values": [[true, true, true]] }, "output": { - "Ok": { - "value": [true, true, true] + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": { + "file": "./tests/tests/panics/deep_branch.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } } } }, @@ -20,8 +51,20 @@ "values": [[false, false, false]] }, "output": { - "Ok": { - "value": [false, false, false] + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": { + "file": "./tests/tests/panics/deep_branch.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } } } }, @@ -30,8 +73,20 @@ "values": [[false, true, false]] }, "output": { - "Ok": { - "value": [false, true, false] + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": { + "file": "./tests/tests/panics/deep_branch.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } } } }, @@ -40,8 +95,20 @@ "values": [[true, false, true]] }, "output": { - "Ok": { - "value": [true, false, true] + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": { + "SourceAssertion": { + "file": "./tests/tests/panics/deep_branch.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } } } } diff --git a/zokrates_core_test/tests/tests/panics/deep_branch_no_isolation.json b/zokrates_core_test/tests/tests/panics/deep_branch_no_isolation.json deleted file mode 100644 index 430a2c180..000000000 --- a/zokrates_core_test/tests/tests/panics/deep_branch_no_isolation.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "entry_point": "./tests/tests/panics/deep_branch.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [[false, false, false]] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "0", - "right": "1", - "error": { - "SourceAssertion": { - "file": "./tests/tests/panics/deep_branch.zok", - "position": { - "line": 2, - "col": 5 - } - } - } - } - } - } - } - ] -} diff --git a/zokrates_core_test/tests/tests/panics/internal_panic.json b/zokrates_core_test/tests/tests/panics/internal_panic.json index 6b5191253..c98e1cec2 100644 --- a/zokrates_core_test/tests/tests/panics/internal_panic.json +++ b/zokrates_core_test/tests/tests/panics/internal_panic.json @@ -1,9 +1,6 @@ { "entry_point": "./tests/tests/panics/internal_panic.zok", "curves": ["Bn128"], - "config": { - "isolate_branches": true - }, "tests": [ { "input": { @@ -20,8 +17,12 @@ "values": ["0"] }, "output": { - "Ok": { - "value": "0" + "Err": { + "UnsatisfiedConstraint": { + "left": "0", + "right": "1", + "error": "Inverse" + } } } } diff --git a/zokrates_core_test/tests/tests/panics/internal_panic_no_isolation.json b/zokrates_core_test/tests/tests/panics/internal_panic_no_isolation.json deleted file mode 100644 index c98e1cec2..000000000 --- a/zokrates_core_test/tests/tests/panics/internal_panic_no_isolation.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "entry_point": "./tests/tests/panics/internal_panic.zok", - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": ["1"] - }, - "output": { - "Ok": { - "value": "1" - } - } - }, - { - "input": { - "values": ["0"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "0", - "right": "1", - "error": "Inverse" - } - } - } - } - ] -} diff --git a/zokrates_core_test/tests/tests/panics/panic_isolation.json b/zokrates_core_test/tests/tests/panics/panic_isolation.json deleted file mode 100644 index b928bcd17..000000000 --- a/zokrates_core_test/tests/tests/panics/panic_isolation.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "entry_point": "./tests/tests/panics/panic_isolation.zok", - "config": { - "isolate_branches": true - }, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [true, ["42", "42"], "0"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "1", - "right": "21888242871839275222246405745257275088548364400416034343698204186575808495577", - "error": { - "SourceAssertion": { - "file": "./tests/tests/panics/panic_isolation.zok", - "position": { - "line": 22, - "col": 5 - } - } - } - } - } - } - }, - { - "input": { - "values": [true, ["1", "1"], "1"] - }, - "output": { - "Ok": { - "value": [true, ["1", "1"], "1"] - } - } - }, - { - "input": { - "values": [false, ["2", "2"], "0"] - }, - "output": { - "Ok": { - "value": [false, ["2", "2"], "0"] - } - } - } - ] -} diff --git a/zokrates_core_test/tests/tests/panics/panic_isolation.zok b/zokrates_core_test/tests/tests/panics/panic_isolation.zok deleted file mode 100644 index 276bcc58b..000000000 --- a/zokrates_core_test/tests/tests/panics/panic_isolation.zok +++ /dev/null @@ -1,38 +0,0 @@ -def zero(field x) -> field { - assert(x == 0); - return 0; -} - -def inverse(field x) -> field { - assert(x != 0); - return 1/x; -} - -def yes(bool x) -> bool { - assert(x); - return x; -} - -def no(bool x) -> bool { - assert(!x); - return x; -} - -def ones(field[2] a) -> field[2] { - assert(a == [1, 1]); - return a; -} - -def twos(field[2] a) -> field[2] { - assert(a == [2, 2]); - return a; -} - -def main(bool condition, field[2] a, field x) -> (bool, field[2], field) { - // first branch asserts that `condition` is true, second branch asserts that `condition` is false. This should never throw. - // first branch asserts that all elements in `a` are 1, 2 in the second branch. This should throw only if `a` is neither ones or zeroes - // first branch asserts that `x` is zero and returns it, second branch asserts that `x` isn't 0 and returns its inverse (which internally generates a failing assert if x is 0). This should never throw - return (condition ? yes(condition) : no(condition), \ - condition ? ones(a) : twos(a), \ - x == 0 ? zero(x) : inverse(x)); -} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/panics/panic_no_isolation.json b/zokrates_core_test/tests/tests/panics/panic_no_isolation.json deleted file mode 100644 index 107f79cd4..000000000 --- a/zokrates_core_test/tests/tests/panics/panic_no_isolation.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "entry_point": "./tests/tests/panics/panic_isolation.zok", - "config": { - "isolate_branches": false - }, - "curves": ["Bn128"], - "tests": [ - { - "input": { - "values": [true, ["1", "1"], "1"] - }, - "output": { - "Err": { - "UnsatisfiedConstraint": { - "left": "1", - "right": "0", - "error": { - "SourceAssertion": { - "file": "./tests/tests/panics/panic_isolation.zok", - "position": { - "line": 17, - "col": 5 - } - } - } - } - } - } - } - ] -} diff --git a/zokrates_core_test/tests/tests/range_check/assert_ge_big_constant.json b/zokrates_core_test/tests/tests/range_check/assert_ge_big_constant.json new file mode 100644 index 000000000..23198947f --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_ge_big_constant.json @@ -0,0 +1,73 @@ +{ + "entry_point": "./tests/tests/range_check/assert_ge_big_constant.zok", + "max_constraint_count": 2, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_ge_big_constant.zok", + "position": { + "line": 4, + "col": 5 + } + } + } + } + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495614" + ] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_ge_big_constant.zok", + "position": { + "line": 4, + "col": 5 + } + } + } + } + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495615" + ] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495616" + ] + }, + "output": { + "Ok": { + "value": [] + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/range_check/assert_ge_big_constant.zok b/zokrates_core_test/tests/tests/range_check/assert_ge_big_constant.zok new file mode 100644 index 000000000..5bf61eaeb --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_ge_big_constant.zok @@ -0,0 +1,5 @@ +from "field" import FIELD_MAX; + +def main(field x) { + assert(x >= FIELD_MAX - 1); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_ge.json b/zokrates_core_test/tests/tests/range_check/assert_ge_constant.json similarity index 82% rename from zokrates_core_test/tests/tests/range_check/assert_ge.json rename to zokrates_core_test/tests/tests/range_check/assert_ge_constant.json index 21f8219b0..feaae4e8b 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_ge.json +++ b/zokrates_core_test/tests/tests/range_check/assert_ge_constant.json @@ -1,5 +1,5 @@ { - "entry_point": "./tests/tests/range_check/assert_ge.zok", + "entry_point": "./tests/tests/range_check/assert_ge_constant.zok", "max_constraint_count": 509, "curves": ["Bn128"], "tests": [ @@ -12,7 +12,7 @@ "UnsatisfiedConstraint": { "error": { "SourceAssertion": { - "file": "./tests/tests/range_check/assert_ge.zok", + "file": "./tests/tests/range_check/assert_ge_constant.zok", "position": { "line": 2, "col": 5 @@ -32,7 +32,7 @@ "UnsatisfiedConstraint": { "error": { "SourceAssertion": { - "file": "./tests/tests/range_check/assert_ge.zok", + "file": "./tests/tests/range_check/assert_ge_constant.zok", "position": { "line": 2, "col": 5 diff --git a/zokrates_core_test/tests/tests/range_check/assert_ge.zok b/zokrates_core_test/tests/tests/range_check/assert_ge_constant.zok similarity index 77% rename from zokrates_core_test/tests/tests/range_check/assert_ge.zok rename to zokrates_core_test/tests/tests/range_check/assert_ge_constant.zok index db5af3ea3..93e8f4eed 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_ge.zok +++ b/zokrates_core_test/tests/tests/range_check/assert_ge_constant.zok @@ -1,4 +1,3 @@ def main(field x) { assert(x >= 2); - return; } \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_gt_big_constant.zok b/zokrates_core_test/tests/tests/range_check/assert_gt_big_constant.zok index c3c5a123c..1767bd87f 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_gt_big_constant.zok +++ b/zokrates_core_test/tests/tests/range_check/assert_gt_big_constant.zok @@ -2,5 +2,4 @@ from "field" import FIELD_MAX; def main(field x) { assert(x > FIELD_MAX - 1); - return; } \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_gt.json b/zokrates_core_test/tests/tests/range_check/assert_gt_constant.json similarity index 81% rename from zokrates_core_test/tests/tests/range_check/assert_gt.json rename to zokrates_core_test/tests/tests/range_check/assert_gt_constant.json index 7e800f8bb..aed5724f7 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_gt.json +++ b/zokrates_core_test/tests/tests/range_check/assert_gt_constant.json @@ -1,5 +1,5 @@ { - "entry_point": "./tests/tests/range_check/assert_gt.zok", + "entry_point": "./tests/tests/range_check/assert_gt_constant.zok", "max_constraint_count": 508, "curves": ["Bn128"], "tests": [ @@ -12,7 +12,7 @@ "UnsatisfiedConstraint": { "error": { "SourceAssertion": { - "file": "./tests/tests/range_check/assert_gt.zok", + "file": "./tests/tests/range_check/assert_gt_constant.zok", "position": { "line": 2, "col": 5 @@ -32,7 +32,7 @@ "UnsatisfiedConstraint": { "error": { "SourceAssertion": { - "file": "./tests/tests/range_check/assert_gt.zok", + "file": "./tests/tests/range_check/assert_gt_constant.zok", "position": { "line": 2, "col": 5 @@ -52,7 +52,7 @@ "UnsatisfiedConstraint": { "error": { "SourceAssertion": { - "file": "./tests/tests/range_check/assert_gt.zok", + "file": "./tests/tests/range_check/assert_gt_constant.zok", "position": { "line": 2, "col": 5 diff --git a/zokrates_core_test/tests/tests/range_check/assert_gt.zok b/zokrates_core_test/tests/tests/range_check/assert_gt_constant.zok similarity index 76% rename from zokrates_core_test/tests/tests/range_check/assert_gt.zok rename to zokrates_core_test/tests/tests/range_check/assert_gt_constant.zok index 0e4dfee82..fcf042b62 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_gt.zok +++ b/zokrates_core_test/tests/tests/range_check/assert_gt_constant.zok @@ -1,4 +1,3 @@ def main(field x) { assert(x > 2); - return; } \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_le.json b/zokrates_core_test/tests/tests/range_check/assert_le.json index 694379525..54cbda366 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_le.json +++ b/zokrates_core_test/tests/tests/range_check/assert_le.json @@ -1,11 +1,11 @@ { "entry_point": "./tests/tests/range_check/assert_le.zok", - "max_constraint_count": 5, + "max_constraint_count": 763, "curves": ["Bn128"], "tests": [ { "input": { - "values": ["1"] + "values": ["1", "2"] }, "output": { "Ok": { @@ -15,7 +15,7 @@ }, { "input": { - "values": ["2"] + "values": ["2", "2"] }, "output": { "Ok": { @@ -25,7 +25,23 @@ }, { "input": { - "values": ["3"] + "values": [ + "1", + "7237005577332262213973186563042994240829374041602535252466099000494570602495" + ] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": [ + "7237005577332262213973186563042994240829374041602535252466099000494570602495", + "1" + ] }, "output": { "Err": { @@ -45,20 +61,30 @@ }, { "input": { - "values": ["15"] + "values": [ + "1", + "7237005577332262213973186563042994240829374041602535252466099000494570602496" + ] }, "output": { "Err": { "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": { - "file": "./tests/tests/range_check/assert_le.zok", - "position": { - "line": 2, - "col": 5 - } - } - } + "error": "IncompleteDynamicRange" + } + } + } + }, + { + "input": { + "values": [ + "7237005577332262213973186563042994240829374041602535252466099000494570602496", + "1" + ] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": "IncompleteDynamicRange" } } } diff --git a/zokrates_core_test/tests/tests/range_check/assert_le.zok b/zokrates_core_test/tests/tests/range_check/assert_le.zok index c86524015..106ff4a0f 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_le.zok +++ b/zokrates_core_test/tests/tests/range_check/assert_le.zok @@ -1,4 +1,3 @@ -def main(field x) { - assert(x <= 2); - return; +def main(field a, field b) { + assert(a <= b); } \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_le_big_constant.json b/zokrates_core_test/tests/tests/range_check/assert_le_big_constant.json new file mode 100644 index 000000000..b4fef5d5d --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_le_big_constant.json @@ -0,0 +1,63 @@ +{ + "entry_point": "./tests/tests/range_check/assert_le_big_constant.zok", + "max_constraint_count": 508, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495614" + ] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495615" + ] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": [ + "21888242871839275222246405745257275088548364400416034343698204186575808495616" + ] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_le_big_constant.zok", + "position": { + "line": 4, + "col": 5 + } + } + } + } + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/range_check/assert_le_big_constant.zok b/zokrates_core_test/tests/tests/range_check/assert_le_big_constant.zok new file mode 100644 index 000000000..1ebbe6742 --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_le_big_constant.zok @@ -0,0 +1,5 @@ +from "field" import FIELD_MAX; + +def main(field x) { + assert(x <= FIELD_MAX - 1); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_le_constant.json b/zokrates_core_test/tests/tests/range_check/assert_le_constant.json new file mode 100644 index 000000000..485a7e08e --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_le_constant.json @@ -0,0 +1,67 @@ +{ + "entry_point": "./tests/tests/range_check/assert_le_constant.zok", + "max_constraint_count": 5, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["2"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["3"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_le_constant.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + }, + { + "input": { + "values": ["15"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_le_constant.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/range_check/assert_le_constant.zok b/zokrates_core_test/tests/tests/range_check/assert_le_constant.zok new file mode 100644 index 000000000..5046efe5a --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_le_constant.zok @@ -0,0 +1,3 @@ +def main(field x) { + assert(x <= 2); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_le_u8.json b/zokrates_core_test/tests/tests/range_check/assert_le_u8.json new file mode 100644 index 000000000..c4c746b06 --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_le_u8.json @@ -0,0 +1,47 @@ +{ + "entry_point": "./tests/tests/range_check/assert_le_u8.zok", + "max_constraint_count": 31, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0x01", "0x02"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["0x02", "0x02"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["0x04", "0x02"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_le_u8.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/range_check/assert_le_u8.zok b/zokrates_core_test/tests/tests/range_check/assert_le_u8.zok new file mode 100644 index 000000000..3f2edab47 --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_le_u8.zok @@ -0,0 +1,3 @@ +def main(u8 a, u8 b) { + assert(a <= b); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_le_u8_constant.json b/zokrates_core_test/tests/tests/range_check/assert_le_u8_constant.json new file mode 100644 index 000000000..74f8867d0 --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_le_u8_constant.json @@ -0,0 +1,57 @@ +{ + "entry_point": "./tests/tests/range_check/assert_le_u8_constant.zok", + "max_constraint_count": 12, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0x00"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["0x01"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["0x02"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["0x0f"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_le_u8_constant.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/range_check/assert_le_u8_constant.zok b/zokrates_core_test/tests/tests/range_check/assert_le_u8_constant.zok new file mode 100644 index 000000000..7c02e7214 --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_le_u8_constant.zok @@ -0,0 +1,3 @@ +def main(u8 x) { + assert(x <= 2); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt.json b/zokrates_core_test/tests/tests/range_check/assert_lt.json index 05c0e90eb..a788b6ee0 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_lt.json +++ b/zokrates_core_test/tests/tests/range_check/assert_lt.json @@ -1,11 +1,11 @@ { "entry_point": "./tests/tests/range_check/assert_lt.zok", - "max_constraint_count": 4, + "max_constraint_count": 764, "curves": ["Bn128"], "tests": [ { "input": { - "values": ["0"] + "values": ["1", "2"] }, "output": { "Ok": { @@ -15,7 +15,10 @@ }, { "input": { - "values": ["1"] + "values": [ + "1", + "7237005577332262213973186563042994240829374041602535252466099000494570602495" + ] }, "output": { "Ok": { @@ -25,7 +28,10 @@ }, { "input": { - "values": ["2"] + "values": [ + "7237005577332262213973186563042994240829374041602535252466099000494570602495", + "1" + ] }, "output": { "Err": { @@ -45,20 +51,30 @@ }, { "input": { - "values": ["15"] + "values": [ + "1", + "7237005577332262213973186563042994240829374041602535252466099000494570602496" + ] }, "output": { "Err": { "UnsatisfiedConstraint": { - "error": { - "SourceAssertion": { - "file": "./tests/tests/range_check/assert_lt.zok", - "position": { - "line": 2, - "col": 5 - } - } - } + "error": "IncompleteDynamicRange" + } + } + } + }, + { + "input": { + "values": [ + "7237005577332262213973186563042994240829374041602535252466099000494570602496", + "1" + ] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": "IncompleteDynamicRange" } } } diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt.zok b/zokrates_core_test/tests/tests/range_check/assert_lt.zok index cba29894b..cce1a6a7c 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_lt.zok +++ b/zokrates_core_test/tests/tests/range_check/assert_lt.zok @@ -1,4 +1,3 @@ -def main(field x) { - assert(x < 2); - return; +def main(field a, field b) { + assert(a < b); } \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt_big_constant.zok b/zokrates_core_test/tests/tests/range_check/assert_lt_big_constant.zok index 5e05a8c07..f8f804442 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_lt_big_constant.zok +++ b/zokrates_core_test/tests/tests/range_check/assert_lt_big_constant.zok @@ -2,5 +2,4 @@ from "field" import FIELD_MAX; def main(field x) { assert(x < FIELD_MAX - 1); - return; } \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt_constant.json b/zokrates_core_test/tests/tests/range_check/assert_lt_constant.json new file mode 100644 index 000000000..19b100024 --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_lt_constant.json @@ -0,0 +1,67 @@ +{ + "entry_point": "./tests/tests/range_check/assert_lt_constant.zok", + "max_constraint_count": 4, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["1"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["2"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_lt_constant.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + }, + { + "input": { + "values": ["15"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_lt_constant.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt_constant.zok b/zokrates_core_test/tests/tests/range_check/assert_lt_constant.zok new file mode 100644 index 000000000..bbbe9adf7 --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_lt_constant.zok @@ -0,0 +1,3 @@ +def main(field x) { + assert(x < 2); +} \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt_u8.json b/zokrates_core_test/tests/tests/range_check/assert_lt_u8.json index cad68703b..6126fe637 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_lt_u8.json +++ b/zokrates_core_test/tests/tests/range_check/assert_lt_u8.json @@ -1,11 +1,11 @@ { "entry_point": "./tests/tests/range_check/assert_lt_u8.zok", - "max_constraint_count": 9, + "max_constraint_count": 29, "curves": ["Bn128"], "tests": [ { "input": { - "values": ["0x00"] + "values": ["0x01", "0x02"] }, "output": { "Ok": { @@ -15,17 +15,7 @@ }, { "input": { - "values": ["0x01"] - }, - "output": { - "Ok": { - "value": [] - } - } - }, - { - "input": { - "values": ["0x02"] + "values": ["0x02", "0x02"] }, "output": { "Err": { @@ -45,7 +35,7 @@ }, { "input": { - "values": ["0x0f"] + "values": ["0x04", "0x02"] }, "output": { "Err": { diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt_u8.zok b/zokrates_core_test/tests/tests/range_check/assert_lt_u8.zok index cba29894b..f71b1b82e 100644 --- a/zokrates_core_test/tests/tests/range_check/assert_lt_u8.zok +++ b/zokrates_core_test/tests/tests/range_check/assert_lt_u8.zok @@ -1,4 +1,3 @@ -def main(field x) { - assert(x < 2); - return; +def main(u8 a, u8 b) { + assert(a < b); } \ No newline at end of file diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt_u8_constant.json b/zokrates_core_test/tests/tests/range_check/assert_lt_u8_constant.json new file mode 100644 index 000000000..c1f497ea9 --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_lt_u8_constant.json @@ -0,0 +1,67 @@ +{ + "entry_point": "./tests/tests/range_check/assert_lt_u8_constant.zok", + "max_constraint_count": 10, + "curves": ["Bn128"], + "tests": [ + { + "input": { + "values": ["0x00"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["0x01"] + }, + "output": { + "Ok": { + "value": [] + } + } + }, + { + "input": { + "values": ["0x02"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_lt_u8_constant.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + }, + { + "input": { + "values": ["0x0f"] + }, + "output": { + "Err": { + "UnsatisfiedConstraint": { + "error": { + "SourceAssertion": { + "file": "./tests/tests/range_check/assert_lt_u8_constant.zok", + "position": { + "line": 2, + "col": 5 + } + } + } + } + } + } + } + ] +} diff --git a/zokrates_core_test/tests/tests/range_check/assert_lt_u8_constant.zok b/zokrates_core_test/tests/tests/range_check/assert_lt_u8_constant.zok new file mode 100644 index 000000000..7b52a6dee --- /dev/null +++ b/zokrates_core_test/tests/tests/range_check/assert_lt_u8_constant.zok @@ -0,0 +1,3 @@ +def main(u8 x) { + assert(x < 2); +} \ No newline at end of file diff --git a/zokrates_embed/Cargo.toml b/zokrates_embed/Cargo.toml index fcff9510e..58efe2304 100644 --- a/zokrates_embed/Cargo.toml +++ b/zokrates_embed/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_embed" -version = "0.1.10" +version = "0.1.11" authors = ["schaeff "] edition = "2018" diff --git a/zokrates_embed/src/ark.rs b/zokrates_embed/src/ark.rs index fa8544962..4097e34ad 100644 --- a/zokrates_embed/src/ark.rs +++ b/zokrates_embed/src/ark.rs @@ -163,8 +163,8 @@ pub fn generate_verify_constraints( let constraints: Vec> = matrices .a .into_iter() - .zip(matrices.b.into_iter()) - .zip(matrices.c.into_iter()) + .zip(matrices.b) + .zip(matrices.c) .map(|((a, b), c)| Constraint { a, b, c }) .collect(); diff --git a/zokrates_field/Cargo.toml b/zokrates_field/Cargo.toml index dfe4d0736..47cff7200 100644 --- a/zokrates_field/Cargo.toml +++ b/zokrates_field/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_field" -version = "0.5.5" +version = "0.5.6" authors = ["Thibaut Schaeffer ", "Guillaume Ballet "] edition = "2021" @@ -24,11 +24,11 @@ num-integer = { version = "0.1", default-features = false } bellman_ce = { version = "^0.3", default-features = false, optional = true } # bellperson -bellperson = { version = "0.24", default-features = false, optional = true } +bellperson = { version = "0.25", default-features = false, optional = true } pairing = { version = "0.22", default-features = false, optional = true } -ff = { version = "0.12.0", default-features = false, optional = true } -pasta_curves = { version = "0.5.2", features = ["repr-c", "serde"], package = "fil_pasta_curves", optional = true } -nova-snark = { version = "0.20.3", optional = true } +ff = { version = "0.13.0", default-features = false, optional = true } +pasta_curves = { version = "0.5", features = ["repr-c", "serde"], optional = true } +nova-snark = { version = "0.21.0", optional = true } # ark ark-ff = { version = "^0.3.0", default-features = false } diff --git a/zokrates_interpreter/Cargo.toml b/zokrates_interpreter/Cargo.toml index 756ccd6a4..c8707853d 100644 --- a/zokrates_interpreter/Cargo.toml +++ b/zokrates_interpreter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_interpreter" -version = "0.1.5" +version = "0.1.6" edition = "2021" [features] diff --git a/zokrates_interpreter/src/lib.rs b/zokrates_interpreter/src/lib.rs index 3f3a086e2..46d1b8526 100644 --- a/zokrates_interpreter/src/lib.rs +++ b/zokrates_interpreter/src/lib.rs @@ -318,8 +318,8 @@ impl Interpreter { let s = x.to_dec_string(); ::Fr::from_str(&s).unwrap() }; - let i: Vec<_> = i.iter().map(|x| to_fr(x)).collect(); - let h: Vec<_> = h.iter().map(|x| to_fr(x)).collect(); + let i: Vec<_> = i.iter().map(to_fr).collect(); + let h: Vec<_> = h.iter().map(to_fr).collect(); assert_eq!(h.len(), 256); generate_sha256_round_witness::(&i, &h) .into_iter() @@ -434,7 +434,7 @@ mod tests { #[test] fn execute() { let cond_eq = Solver::ConditionEq; - let inputs = vec![0]; + let inputs = [0]; let r = Interpreter::execute_solver( &cond_eq, &inputs @@ -444,14 +444,14 @@ mod tests { &[], ) .unwrap(); - let res: Vec = vec![0, 1].iter().map(|&i| Bn128Field::from(i)).collect(); + let res: Vec = [0, 1].iter().map(|&i| Bn128Field::from(i)).collect(); assert_eq!(r, &res[..]); } #[test] fn execute_non_eq() { let cond_eq = Solver::ConditionEq; - let inputs = vec![1]; + let inputs = [1]; let r = Interpreter::execute_solver( &cond_eq, &inputs @@ -461,7 +461,7 @@ mod tests { &[], ) .unwrap(); - let res: Vec = vec![1, 1].iter().map(|&i| Bn128Field::from(i)).collect(); + let res: Vec = [1, 1].iter().map(|&i| Bn128Field::from(i)).collect(); assert_eq!(r, &res[..]); } } @@ -523,7 +523,7 @@ mod tests { let id = IdentifierExpression::new(Identifier::internal(0usize)); // (field i0) -> i0 * i0 - let solvers = vec![Solver::Zir(ZirFunction { + let solver = Solver::Zir(ZirFunction { arguments: vec![Parameter::new(Variable::field_element(id.id.clone()), true)], statements: vec![ZirStatement::ret(vec![FieldElementExpression::mul( FieldElementExpression::Identifier(id.clone()), @@ -533,13 +533,16 @@ mod tests { signature: Signature::new() .inputs(vec![Type::FieldElement]) .outputs(vec![Type::FieldElement]), - })]; + }); + + let signature = solver.get_signature(); + let solvers = vec![solver]; let inputs = vec![Bn128Field::from(2)]; let res = Interpreter::execute_solver( &Solver::Ref(RefCall { index: 0, - argument_count: 1, + signature, }), &inputs, &solvers, diff --git a/zokrates_js/Cargo.toml b/zokrates_js/Cargo.toml index 2ff4f49e0..dcecfd105 100644 --- a/zokrates_js/Cargo.toml +++ b/zokrates_js/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_js" -version = "1.1.8" +version = "1.1.9" authors = ["Darko Macesic"] edition = "2018" diff --git a/zokrates_js/index-node.js b/zokrates_js/index-node.js index 566a24632..9045fe1fa 100644 --- a/zokrates_js/index-node.js +++ b/zokrates_js/index-node.js @@ -1,5 +1,7 @@ // https://docs.rs/getrandom/0.2.8/getrandom/index.html#nodejs-es-module-support import { webcrypto } from "node:crypto"; -globalThis.crypto = webcrypto; +if (typeof globalThis.crypto === "undefined") { + globalThis.crypto = webcrypto; +} export * from "./index.js"; diff --git a/zokrates_js/index.d.ts b/zokrates_js/index.d.ts index ff7cba246..8ec0b2ddb 100644 --- a/zokrates_js/index.d.ts +++ b/zokrates_js/index.d.ts @@ -8,11 +8,10 @@ declare module "zokrates-js" { export type ResolveCallback = ( location: string, - path: string + path: string, ) => ResolverResult; export interface CompileConfig { - isolate_branches?: boolean; debug?: boolean; } @@ -78,12 +77,12 @@ declare module "zokrates-js" { withOptions(options: Options): ZoKratesProvider; compile( source: string, - compileOptions?: CompileOptions + compileOptions?: CompileOptions, ): CompilationArtifacts; computeWitness( input: CompilationArtifacts | Uint8Array, args: any[], - options?: ComputeOptions + options?: ComputeOptions, ): ComputationResult; setup(program: Uint8Array, entropy?: string): SetupKeypair; universalSetup(size: number, entropy?: string): Uint8Array; @@ -92,7 +91,7 @@ declare module "zokrates-js" { program: Uint8Array, witness: Uint8Array, provingKey: Uint8Array, - entropy?: string + entropy?: string, ): Proof; verify(verificationKey: VerificationKey, proof: Proof): boolean; exportSolidityVerifier(verificationKey: VerificationKey): string; diff --git a/zokrates_js/index.js b/zokrates_js/index.js index 55a7dbda6..f0ef0a393 100644 --- a/zokrates_js/index.js +++ b/zokrates_js/index.js @@ -22,7 +22,7 @@ const initialize = async () => { location, resolveCallback, config, - curve + curve, ); const result = Object.assign( { @@ -30,7 +30,7 @@ const initialize = async () => { abi: ptr.abi(), constraintCount: ptr.constraint_count(), }, - snarkjs ? { snarkjs: { program: ptr.snarkjs_program() } } : {} + snarkjs ? { snarkjs: { program: ptr.snarkjs_program() } } : {}, ); ptr.free(); return result; @@ -47,7 +47,7 @@ const initialize = async () => { { snarkjs: snarkjs, }, - logCallback + logCallback, ); const result = Object.assign( @@ -61,7 +61,7 @@ const initialize = async () => { witness: ptr.snarkjs_witness(), }, } - : {} + : {}, ); ptr.free(); @@ -94,7 +94,7 @@ const initialize = async () => { witness, provingKey, entropy, - options + options, ); }, verify: (vk, proof, options) => { @@ -132,7 +132,7 @@ const initialize = async () => { witness, provingKey, entropy, - options + options, ), verify: (vk, proof) => defaultProvider.verify(vk, proof, options), exportSolidityVerifier: (vk) => diff --git a/zokrates_js/package-lock.json b/zokrates_js/package-lock.json index 4c3f24745..2d687d21f 100644 --- a/zokrates_js/package-lock.json +++ b/zokrates_js/package-lock.json @@ -1,12 +1,12 @@ { "name": "zokrates-js", - "version": "1.1.5", + "version": "1.1.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "zokrates-js", - "version": "1.1.5", + "version": "1.1.8", "license": "GPLv3", "dependencies": { "pako": "^2.1.0" diff --git a/zokrates_js/package.json b/zokrates_js/package.json index ddb900a58..5eec9eeb5 100644 --- a/zokrates_js/package.json +++ b/zokrates_js/package.json @@ -1,6 +1,6 @@ { "name": "zokrates-js", - "version": "1.1.8", + "version": "1.1.9", "module": "index.js", "main": "index-node.js", "description": "JavaScript bindings for ZoKrates", diff --git a/zokrates_js/patch.js b/zokrates_js/patch.js index 4f4c19aa7..72bffba57 100644 --- a/zokrates_js/patch.js +++ b/zokrates_js/patch.js @@ -5,7 +5,7 @@ import pako from "pako"; (async function () { const packageObject = JSON.parse( - await fs.readFile("pkg/package.json", { encoding: "utf-8" }) + await fs.readFile("pkg/package.json", { encoding: "utf-8" }), ); const wasmPath = packageObject.files.find((file) => file.endsWith(".wasm")); const wasm = await fs.readFile(`pkg/${wasmPath}`); diff --git a/zokrates_js/src/lib.rs b/zokrates_js/src/lib.rs index b39d0169c..d70e145bb 100644 --- a/zokrates_js/src/lib.rs +++ b/zokrates_js/src/lib.rs @@ -276,13 +276,7 @@ mod internal { &arena, ) .map_err(|ce| { - JsValue::from_str( - &ce.0 - .iter() - .map(|e| fmt_error(e)) - .collect::>() - .join("\n"), - ) + JsValue::from_str(&ce.0.iter().map(fmt_error).collect::>().join("\n")) })?; let abi = artifacts.abi().clone(); diff --git a/zokrates_js/tests/tests.js b/zokrates_js/tests/tests.js index ad43c5dbd..3c6149e74 100644 --- a/zokrates_js/tests/tests.js +++ b/zokrates_js/tests/tests.js @@ -39,7 +39,7 @@ describe("tests", () => { describe("compilation", () => { it("should compile", () => { const artifacts = zokratesProvider.compile( - "def main() -> field { return 42; }" + "def main() -> field { return 42; }", ); assert.ok(artifacts); assert.ok(artifacts.snarkjs === undefined); @@ -49,7 +49,7 @@ describe("tests", () => { it("should compile with snarkjs output", () => { const artifacts = zokratesProvider.compile( "def main() -> field { return 42; }", - { snarkjs: true } + { snarkjs: true }, ); assert.ok(artifacts); assert.ok(artifacts.snarkjs.program !== undefined); @@ -167,7 +167,7 @@ describe("tests", () => { ["337", "113569"], { snarkjs: true, - } + }, ); }); @@ -214,7 +214,7 @@ describe("tests", () => { return snarkjs.zKey.newZKey( r1csPath, "./tests/powersOfTau5_0000.ptau", - zkeyPath + zkeyPath, ); }); }); @@ -231,7 +231,7 @@ describe("tests", () => { proof = provider.generateProof( artifacts.program, computationResult.witness, - keypair.pk + keypair.pk, ); assert.ok(proof !== undefined); assert.equal(proof.inputs.length, 2); @@ -240,7 +240,7 @@ describe("tests", () => { let proof2 = provider.generateProof( artifacts.program, computationResult.witness, - keypair.pk + keypair.pk, ); assert.notDeepEqual(proof, proof2); }); @@ -251,7 +251,7 @@ describe("tests", () => { artifacts.program, computationResult.witness, keypair.pk, - entropy + entropy, ); assert.ok(proof !== undefined); assert.equal(proof.inputs.length, 2); @@ -261,7 +261,7 @@ describe("tests", () => { artifacts.program, computationResult.witness, keypair.pk, - entropy + entropy, ); assert.deepEqual(proof, proof2); }); @@ -333,7 +333,7 @@ describe("tests", () => { const fileSystemResolver = (from, to) => { let parsedPath = path.parse( - path.resolve(path.dirname(path.resolve(from)), to) + path.resolve(path.dirname(path.resolve(from)), to), ); const location = path.format({ ...parsedPath, @@ -368,7 +368,7 @@ describe("tests", () => { try { const result = specializedProvider.computeWitness( input, - t.input.values + t.input.values, ); const value = JSON.parse(result.output); assert.deepEqual({ Ok: { value } }, t.output); diff --git a/zokrates_js/tests/umd/tests.js b/zokrates_js/tests/umd/tests.js index 4bda5f8a6..2f61a60cb 100644 --- a/zokrates_js/tests/umd/tests.js +++ b/zokrates_js/tests/umd/tests.js @@ -11,7 +11,7 @@ describe("umd web tests", () => { const page = await browser.newPage(); let response = await page.goto( - path.dirname(import.meta.url) + "/index.html" + path.dirname(import.meta.url) + "/index.html", ); assert(response.ok()); diff --git a/zokrates_pest_ast/Cargo.toml b/zokrates_pest_ast/Cargo.toml index 08a976b59..92c621586 100644 --- a/zokrates_pest_ast/Cargo.toml +++ b/zokrates_pest_ast/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "zokrates_pest_ast" -version = "0.3.3" +version = "0.3.4" authors = ["schaeff "] edition = "2018" [dependencies] zokrates_parser = { version = "0.3.0", path = "../zokrates_parser" } pest = "=2.3" -pest-ast = "0.3.3" +pest-ast = "=0.3.3" from-pest = "0.3.1" lazy_static = "1.3.0" diff --git a/zokrates_proof_systems/Cargo.toml b/zokrates_proof_systems/Cargo.toml index aef2f9e6e..bee3cf24f 100644 --- a/zokrates_proof_systems/Cargo.toml +++ b/zokrates_proof_systems/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_proof_systems" -version = "0.1.3" +version = "0.1.4" edition = "2021" [dependencies] diff --git a/zokrates_proof_systems/src/scheme/gm17.rs b/zokrates_proof_systems/src/scheme/gm17.rs index 97d1099c1..1b55e82b6 100644 --- a/zokrates_proof_systems/src/scheme/gm17.rs +++ b/zokrates_proof_systems/src/scheme/gm17.rs @@ -136,7 +136,7 @@ impl SolidityCompatibleScheme for GM17 { } } -const CONTRACT_TEMPLATE: &str = r#" +const CONTRACT_TEMPLATE: &str = r" contract Verifier { using Pairing for *; struct VerifyingKey { @@ -196,4 +196,4 @@ contract Verifier { } } } -"#; +"; diff --git a/zokrates_stdlib/Cargo.toml b/zokrates_stdlib/Cargo.toml index 24763e3f2..d687ccdd7 100644 --- a/zokrates_stdlib/Cargo.toml +++ b/zokrates_stdlib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zokrates_stdlib" -version = "0.3.3" +version = "0.3.4" authors = ["Stefan Deml ", "schaeff "] edition = "2018" diff --git a/zokrates_stdlib/stdlib/hashes/mimc7/mimc7.zok b/zokrates_stdlib/stdlib/hashes/mimc7/mimc7.zok index dd7cbded7..f9ea58904 100644 --- a/zokrates_stdlib/stdlib/hashes/mimc7/mimc7.zok +++ b/zokrates_stdlib/stdlib/hashes/mimc7/mimc7.zok @@ -89,7 +89,7 @@ const field[91] C = [ 4212716923652881254737947578600828255798948993302968210248673545442808456151, 7594017890037021425366623750593200398174488805473151513558919864633711506220, 18979889247746272055963929241596362599320706910852082477600815822482192194401, - 1360213922981323134938688511315690179366171918090039581890971975815045550053 + 13602139229813231349386885113156901793661719180900395818909719758150455500533 ]; def main(field x_in, field k) -> field { @@ -109,4 +109,4 @@ def main(field x_in, field k) -> field { } return t6[R - 1] * t + k; -} \ No newline at end of file +}