From cc0b2d2544df8be5e96f40e38c7bf295c6864e13 Mon Sep 17 00:00:00 2001 From: vimwitch Date: Wed, 16 Oct 2024 11:41:00 -0700 Subject: [PATCH] refactor: use ring instances from ashlang package, add example r1cs with usage --- Cargo.lock | 441 ++++++++++++++++++++++++++++++++++++- Cargo.toml | 3 + src/constraints.rs | 55 +++-- test-vectors/example.ar1cs | 293 ++++++++++++++++++++++++ 4 files changed, 759 insertions(+), 33 deletions(-) create mode 100644 test-vectors/example.ar1cs diff --git a/Cargo.lock b/Cargo.lock index 5b4d5d4..4683812 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,70 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.89" @@ -164,6 +228,24 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "ashlang" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d7c53d5f9bd154ea4d9c0539fe7ec3f0c58360659cef9ca1052254ec1faafed" +dependencies = [ + "anyhow", + "camino", + "chrono", + "clap", + "colored", + "lazy_static", + "pest", + "pest_derive", + "ring-math", + "scalarff", +] + [[package]] name = "attribute-derive" version = "0.6.1" @@ -243,12 +325,24 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" + [[package]] name = "cc" version = "1.1.28" @@ -264,12 +358,72 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.52.6", +] + +[[package]] +name = "clap" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + [[package]] name = "collection_literals" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "186dce98367766de751c42c4f03970fc60fc012296e706ccbb9d5df9b6c1e271" +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + [[package]] name = "colored" version = "2.1.0" @@ -277,7 +431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" dependencies = [ "lazy_static", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -286,6 +440,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.14" @@ -501,18 +661,53 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "interpolator" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71dd52191aae121e8611f1e8dc3e324dd0dd1dee1e6dd91d10ee07a3cfb4d9d8" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -537,6 +732,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "keccak" version = "0.1.5" @@ -550,6 +754,8 @@ dependencies = [ name = "labrador" version = "0.0.0" dependencies = [ + "anyhow", + "ashlang", "rand", "ring-math", "scalarff", @@ -573,6 +779,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + [[package]] name = "memchr" version = "2.7.4" @@ -621,6 +833,51 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pest" +version = "2.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "pest_meta" +version = "2.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + [[package]] name = "phf" version = "0.11.2" @@ -905,6 +1162,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha3" version = "0.10.8" @@ -933,6 +1201,12 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.6.1" @@ -1021,12 +1295,24 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "unicode-ident" version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "version_check" version = "0.9.5" @@ -1039,13 +1325,86 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.79", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -1054,13 +1413,29 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -1069,42 +1444,90 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 7ee2c4e..40ffb18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,9 @@ license = "MIT OR Apache-2.0" rand = "0.8.5" ring-math = "0.1.0" scalarff = "0.5.1" +ashlang = { version = "0.1.2", default-features = false } +#ashlang = { path = "../ashlang/ashlang", default-features = false } +anyhow = "1.0.89" #ring-math = { path = "../ashlang/ring-math" } #scalarff = { path = "../scalarff" } diff --git a/src/constraints.rs b/src/constraints.rs index 255f8c1..b209fb7 100644 --- a/src/constraints.rs +++ b/src/constraints.rs @@ -1,31 +1,38 @@ -use ring_math::polynomial_ring; -use ring_math::Polynomial; -use ring_math::PolynomialRingElement; -use scalarff::scalar_ring; -use scalarff::FieldElement; - -// creates a scalar ring struct DilithiumRingElement -scalar_ring!(DilithiumRingElement, 8380417, "dilithium_23_bit"); - -// creates a polynomial ring struct -polynomial_ring!( - DilithiumPolynomialRingElement, - DilithiumRingElement, - { - // creating the ring modulus polynomial - // here we use x^64 + 1 - let mut p = Polynomial::identity(); - p.term(&DilithiumRingElement::one(), 64); - p - }, - "dilithium_x64+1" -); - #[cfg(test)] mod test { + use ashlang::r1cs::parser::R1csParser; + use ashlang::rings::DilithiumPolynomialRingElement; + use ashlang::rings::DilithiumRingElement; use ring_math::Matrix2D; + use ring_math::PolynomialRingElement; + use scalarff::FieldElement; - use super::*; + #[test] + fn transform_r1cs() -> anyhow::Result<()> { + let ar1cs_src = std::fs::read_to_string("./test-vectors/example.ar1cs")?; + let r1cs_parser: R1csParser = R1csParser::new(&ar1cs_src)?; + let _constraints = r1cs_parser.constraints; + + // TODO: transform constraints into dot product form + + // generate a witness just for fun 🤩 + let input = 55; + let witness = ashlang::r1cs::witness::build( + &ar1cs_src, + vec![DilithiumPolynomialRingElement::from(input)], + )?; + println!("Calculated witness for input: {input}"); + println!( + "{}", + witness + .variables + .iter() + .map(|v| v.to_string()) + .collect::>() + .join("\n") + ); + Ok(()) + } #[test] fn conj_automorphism() { diff --git a/test-vectors/example.ar1cs b/test-vectors/example.ar1cs new file mode 100644 index 0000000..a817198 --- /dev/null +++ b/test-vectors/example.ar1cs @@ -0,0 +1,293 @@ +# r1cs_test +# Compiled at 2024-10-16T18:36:22.846Z +# Compiled for dilithium x^64+1 polynomial ring +# +# This script tests various mathematical operators +# view the source below +# +# https://github.com/chancehudson/ashlang/blob/main/ashlang/test-vectors/r1cs_test.ash +# +x1 = (1*one) * (0*one) # scalar literal (0) to signal index 0 (member of vector) +x2 = (1*one) * (100*one) # scalar literal (100) to signal index 0 (member of vector) +x3 = (100*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x4 = (1*one) * (99*one) # scalar literal (99) to signal index 0 (member of vector) +x5 = (99*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x6 = (1*one) * (98*one) # scalar literal (98) to signal index 0 (member of vector) +x7 = (98*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x8 = (1*one) * (99*one) # scalar literal (99) to signal index 0 (member of vector) +x9 = (100*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x10 = (100*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x11 = (99*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x12 = (99*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x13 = (98*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x14 = (98*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x15 = (99*one) * (1*x2) # re-assign _ +x16 = (9900*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x17 = (1*x2 + 8380318*one) * (1*one) # re-assign _ +x18 = (1*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x19 = (99*one + 8380416*x2) * (1*one) # re-assign _ +x20 = (99*one + 8380416*x2) * (1*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x21 = (99*one + 1*x2) * (1*one) # re-assign _ +x22 = (199*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x23 = (5502294*x2) * (1*one) # re-assign _ +x25 = (1*one) / (1*x2) # re-assign _ +x24 = (99*x25) * (1*one) # re-assign _ +x26 = (1*x2 + 1*x4) * (1*one) # re-assign _ +x27 = (199*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x28 = (1*x2 + 8380416*x4) * (1*one) # re-assign _ +x29 = (1*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x30 = (1*x2) * (1*x4) # re-assign _ +x31 = (9900*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x32 = (1*one) / (1*x4) # re-assign _ +x33 = (1*x2) * (1*x32) # re-assign _ +x34 = (1*x2) * (1*x2) # let v2 +x35 = (1*x34) * (1*x34) # let v4 +x36 = (1*x35) * (1*x2) # return call in ./ashlang/stdlib/pow5.ash +x37 = (10000000000*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x38 = (32*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x39 = (32*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x40 = (1*one) * (32*one) # scalar literal (32) to signal index 0 (member of vector) +x41 = (9*one) + (0*one) # sqrt() (./ashlang/stdlib/sqrt.ar1cs) +x42 = (2*one) radix (1*x41) # b is the square root of a +x43 = (3*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x44 = (1*one) * (0*one) # scalar literal (0) to signal index 0 (member of vector) +x45 = (1*one) * (2*one) # scalar literal (2) to signal index 0 (member of vector) +x46 = (1*one + 1*x44) * (1*one) # re-assign lll +x47 = (1*x45) * (1*x45) # let v2 +x48 = (1*x47) * (1*x47) # let v4 +x49 = (1*x48) * (1*x45) # return call in ./ashlang/stdlib/pow5.ash +x50 = (1*x45) * (1*x45) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x51 = (1*x50) * (1*x45) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x52 = (1*x51) * (1*x45) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x53 = (1*x52) * (1*x45) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x54 = (1*one + 1*x46) * (1*one) # re-assign lll +x55 = (1*x49) * (1*x49) # let v2 +x56 = (1*x55) * (1*x55) # let v4 +x57 = (1*x56) * (1*x49) # return call in ./ashlang/stdlib/pow5.ash +x58 = (1*x49) * (1*x49) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x59 = (1*x58) * (1*x49) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x60 = (1*x59) * (1*x49) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x61 = (1*x60) * (1*x49) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x62 = (1*one + 1*x54) * (1*one) # re-assign lll +x63 = (1*x57) * (1*x57) # let v2 +x64 = (1*x63) * (1*x63) # let v4 +x65 = (1*x64) * (1*x57) # return call in ./ashlang/stdlib/pow5.ash +x66 = (1*x57) * (1*x57) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x67 = (1*x66) * (1*x57) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x68 = (1*x67) * (1*x57) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x69 = (1*x68) * (1*x57) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x70 = (1*one + 1*x62) * (1*one) # re-assign lll +x71 = (1*x65) * (1*x65) # let v2 +x72 = (1*x71) * (1*x71) # let v4 +x73 = (1*x72) * (1*x65) # return call in ./ashlang/stdlib/pow5.ash +x74 = (1*x65) * (1*x65) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x75 = (1*x74) * (1*x65) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x76 = (1*x75) * (1*x65) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x77 = (1*x76) * (1*x65) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x78 = (1*one + 1*x70) * (1*one) # re-assign lll +x79 = (1*x73) * (1*x73) # let v2 +x80 = (1*x79) * (1*x79) # let v4 +x81 = (1*x80) * (1*x73) # return call in ./ashlang/stdlib/pow5.ash +x82 = (1*x73) * (1*x73) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x83 = (1*x82) * (1*x73) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x84 = (1*x83) * (1*x73) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x85 = (1*x84) * (1*x73) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x86 = (1*one + 1*x78) * (1*one) # re-assign lll +x87 = (1*x81) * (1*x81) # let v2 +x88 = (1*x87) * (1*x87) # let v4 +x89 = (1*x88) * (1*x81) # return call in ./ashlang/stdlib/pow5.ash +x90 = (1*x81) * (1*x81) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x91 = (1*x90) * (1*x81) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x92 = (1*x91) * (1*x81) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x93 = (1*x92) * (1*x81) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x94 = (1*one + 1*x86) * (1*one) # re-assign lll +x95 = (1*x89) * (1*x89) # let v2 +x96 = (1*x95) * (1*x95) # let v4 +x97 = (1*x96) * (1*x89) # return call in ./ashlang/stdlib/pow5.ash +x98 = (1*x89) * (1*x89) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x99 = (1*x98) * (1*x89) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x100 = (1*x99) * (1*x89) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x101 = (1*x100) * (1*x89) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x102 = (1*one + 1*x94) * (1*one) # re-assign lll +x103 = (1*x97) * (1*x97) # let v2 +x104 = (1*x103) * (1*x103) # let v4 +x105 = (1*x104) * (1*x97) # return call in ./ashlang/stdlib/pow5.ash +x106 = (1*x97) * (1*x97) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x107 = (1*x106) * (1*x97) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x108 = (1*x107) * (1*x97) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x109 = (1*x108) * (1*x97) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x110 = (1*one + 1*x102) * (1*one) # re-assign lll +x111 = (1*x105) * (1*x105) # let v2 +x112 = (1*x111) * (1*x111) # let v4 +x113 = (1*x112) * (1*x105) # return call in ./ashlang/stdlib/pow5.ash +x114 = (1*x105) * (1*x105) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x115 = (1*x114) * (1*x105) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x116 = (1*x115) * (1*x105) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x117 = (1*x116) * (1*x105) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x118 = (1*one + 1*x110) * (1*one) # re-assign lll +x119 = (1*x113) * (1*x113) # let v2 +x120 = (1*x119) * (1*x119) # let v4 +x121 = (1*x120) * (1*x113) # return call in ./ashlang/stdlib/pow5.ash +x122 = (1*x113) * (1*x113) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x123 = (1*x122) * (1*x113) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x124 = (1*x123) * (1*x113) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x125 = (1*x124) * (1*x113) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x126 = (10*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +x127 = (1*one) input (1*one) # +x128 = (55*one) + (0*one) # assert_eq() (./ashlang/stdlib/assert_eq.ar1cs) +0 = (8380416*one) * (8380416*one) - (1*one) # field safety constraint +0 = (1*x1) * (1*one) - (0*one) # scalar literal (0) to signal index (0) (member of vector) +0 = (1*x2) * (1*one) - (100*one) # scalar literal (100) to signal index (0) (member of vector) +0 = (1*x3) * (1*one) - (100*one) # assigning literal (100) to signal 3 +0 = (1*x2 + 0*one) * (1*one) - (1*x3) # assert equality +0 = (1*x4) * (1*one) - (99*one) # scalar literal (99) to signal index (0) (member of vector) +0 = (1*x5) * (1*one) - (99*one) # assigning literal (99) to signal 5 +0 = (1*x4 + 0*one) * (1*one) - (1*x5) # assert equality +0 = (1*x6) * (1*one) - (98*one) # scalar literal (98) to signal index (0) (member of vector) +0 = (1*x7) * (1*one) - (98*one) # assigning literal (98) to signal 7 +0 = (1*x6 + 0*one) * (1*one) - (1*x7) # assert equality +0 = (1*x8) * (1*one) - (99*one) # scalar literal (99) to signal index (0) (member of vector) +0 = (1*x9) * (1*one) - (100*one) # assigning literal (100) to signal 9 +0 = (1*x10) * (1*one) - (100*one) # assigning literal (100) to signal 10 +0 = (1*x9 + 0*one) * (1*one) - (1*x10) # assert equality +0 = (1*x11) * (1*one) - (99*one) # assigning literal (99) to signal 11 +0 = (1*x12) * (1*one) - (99*one) # assigning literal (99) to signal 12 +0 = (1*x11 + 0*one) * (1*one) - (1*x12) # assert equality +0 = (1*x13) * (1*one) - (98*one) # assigning literal (98) to signal 13 +0 = (1*x14) * (1*one) - (98*one) # assigning literal (98) to signal 14 +0 = (1*x13 + 0*one) * (1*one) - (1*x14) # assert equality +0 = (99*one) * (1*x2) - (1*x15) # multiplication between (99) and 2 into 15 +0 = (1*x16) * (1*one) - (9900*one) # assigning literal (9900) to signal 16 +0 = (1*x15 + 0*one) * (1*one) - (1*x16) # assert equality +0 = (99*one + 1*x17) * (1*one) - (1*x2) # subtraction between 2 and (99) into 17 +0 = (1*x18) * (1*one) - (1*one) # assigning literal (1) to signal 18 +0 = (1*x17 + 0*one) * (1*one) - (1*x18) # assert equality +0 = (1*x2 + 1*x19) * (1*one) - (99*one) # subtraction between (99) and 2 into 19 +0 = (1*x2 + 1*x20) * (1*one) - (99*one) # subtraction between (99) and 2 into 20 +0 = (1*x19 + 0*one) * (1*one) - (1*x20) # assert equality +0 = (99*one + 1*x2) * (1*one) - (1*x21) # addition between (99) and 2 into 21 +0 = (1*x22) * (1*one) - (199*one) # assigning literal (199) to signal 22 +0 = (1*x21 + 0*one) * (1*one) - (1*x22) # assert equality +0 = (5502294*x2) * (1*one) - (1*x23) # modinv between 2 and (99) into 23 +0 = (1*x2) * (1*x25) - (1*one) # modinv 2 into 25 +0 = (99*x25) * (1*one) - (1*x24) # multiply 25 and (99) into 24 +0 = (1*x2 + 1*x4) * (1*one) - (1*x26) # addition between 2 and 4 into 26 +0 = (1*x27) * (1*one) - (199*one) # assigning literal (199) to signal 27 +0 = (1*x26 + 0*one) * (1*one) - (1*x27) # assert equality +0 = (1*x2 + 8380416*x4) * (1*one) - (1*x28) # subtraction between 2 and 4 into 28 +0 = (1*x29) * (1*one) - (1*one) # assigning literal (1) to signal 29 +0 = (1*x28 + 0*one) * (1*one) - (1*x29) # assert equality +0 = (1*x2) * (1*x4) - (1*x30) # multiplication between 2 and 4 into 30 +0 = (1*x31) * (1*one) - (9900*one) # assigning literal (9900) to signal 31 +0 = (1*x30 + 0*one) * (1*one) - (1*x31) # assert equality +0 = (1*x4) * (1*x32) - (1*one) # inversion of 4 into 32 (1/2) +0 = (1*x2) * (1*x32) - (1*x33) # multiplication of 2 and 32 into 33 (2/2) +0 = (1*x2) * (1*x2) - (1*x34) # multiplication between 2 and 2 into 34 +0 = (1*x34) * (1*x34) - (1*x35) # multiplication between 34 and 34 into 35 +0 = (1*x35) * (1*x2) - (1*x36) # multiplication between 35 and 2 into 36 +0 = (1*x37) * (1*one) - (10000000000*one) # assigning literal (10000000000) to signal 37 +0 = (1*x36 + 0*one) * (1*one) - (1*x37) # assert equality +0 = (1*x38) * (1*one) - (32*one) # assigning literal (32) to signal 38 +0 = (1*x39) * (1*one) - (32*one) # assigning literal (32) to signal 39 +0 = (1*x38 + 0*one) * (1*one) - (1*x39) # assert equality +0 = (1*x40) * (1*one) - (32*one) # scalar literal (32) to signal index (0) (member of vector) +0 = (1*x41) * (1*one) - (9*one) # assigning literal (9) to signal 41 +0 = (1*x42) * (1*x42) - (1*x41) # assert that a = b*b +0 = (1*x43) * (1*one) - (3*one) # assigning literal (3) to signal 43 +0 = (1*x42 + 0*one) * (1*one) - (1*x43) # assert equality +0 = (1*x44) * (1*one) - (0*one) # scalar literal (0) to signal index (0) (member of vector) +0 = (1*x45) * (1*one) - (2*one) # scalar literal (2) to signal index (0) (member of vector) +0 = (1*one + 1*x44) * (1*one) - (1*x46) # addition between (1) and 44 into 46 +0 = (1*x45) * (1*x45) - (1*x47) # multiplication between 45 and 45 into 47 +0 = (1*x47) * (1*x47) - (1*x48) # multiplication between 47 and 47 into 48 +0 = (1*x48) * (1*x45) - (1*x49) # multiplication between 48 and 45 into 49 +0 = (1*x45) * (1*x45) - (1*x50) # multiplication between 45 and 45 into 50 +0 = (1*x50) * (1*x45) - (1*x51) # multiplication between 50 and 45 into 51 +0 = (1*x51) * (1*x45) - (1*x52) # multiplication between 51 and 45 into 52 +0 = (1*x52) * (1*x45) - (1*x53) # multiplication between 52 and 45 into 53 +0 = (1*x49 + 0*one) * (1*one) - (1*x53) # assert equality +0 = (1*one + 1*x46) * (1*one) - (1*x54) # addition between (1) and 46 into 54 +0 = (1*x49) * (1*x49) - (1*x55) # multiplication between 49 and 49 into 55 +0 = (1*x55) * (1*x55) - (1*x56) # multiplication between 55 and 55 into 56 +0 = (1*x56) * (1*x49) - (1*x57) # multiplication between 56 and 49 into 57 +0 = (1*x49) * (1*x49) - (1*x58) # multiplication between 49 and 49 into 58 +0 = (1*x58) * (1*x49) - (1*x59) # multiplication between 58 and 49 into 59 +0 = (1*x59) * (1*x49) - (1*x60) # multiplication between 59 and 49 into 60 +0 = (1*x60) * (1*x49) - (1*x61) # multiplication between 60 and 49 into 61 +0 = (1*x57 + 0*one) * (1*one) - (1*x61) # assert equality +0 = (1*one + 1*x54) * (1*one) - (1*x62) # addition between (1) and 54 into 62 +0 = (1*x57) * (1*x57) - (1*x63) # multiplication between 57 and 57 into 63 +0 = (1*x63) * (1*x63) - (1*x64) # multiplication between 63 and 63 into 64 +0 = (1*x64) * (1*x57) - (1*x65) # multiplication between 64 and 57 into 65 +0 = (1*x57) * (1*x57) - (1*x66) # multiplication between 57 and 57 into 66 +0 = (1*x66) * (1*x57) - (1*x67) # multiplication between 66 and 57 into 67 +0 = (1*x67) * (1*x57) - (1*x68) # multiplication between 67 and 57 into 68 +0 = (1*x68) * (1*x57) - (1*x69) # multiplication between 68 and 57 into 69 +0 = (1*x65 + 0*one) * (1*one) - (1*x69) # assert equality +0 = (1*one + 1*x62) * (1*one) - (1*x70) # addition between (1) and 62 into 70 +0 = (1*x65) * (1*x65) - (1*x71) # multiplication between 65 and 65 into 71 +0 = (1*x71) * (1*x71) - (1*x72) # multiplication between 71 and 71 into 72 +0 = (1*x72) * (1*x65) - (1*x73) # multiplication between 72 and 65 into 73 +0 = (1*x65) * (1*x65) - (1*x74) # multiplication between 65 and 65 into 74 +0 = (1*x74) * (1*x65) - (1*x75) # multiplication between 74 and 65 into 75 +0 = (1*x75) * (1*x65) - (1*x76) # multiplication between 75 and 65 into 76 +0 = (1*x76) * (1*x65) - (1*x77) # multiplication between 76 and 65 into 77 +0 = (1*x73 + 0*one) * (1*one) - (1*x77) # assert equality +0 = (1*one + 1*x70) * (1*one) - (1*x78) # addition between (1) and 70 into 78 +0 = (1*x73) * (1*x73) - (1*x79) # multiplication between 73 and 73 into 79 +0 = (1*x79) * (1*x79) - (1*x80) # multiplication between 79 and 79 into 80 +0 = (1*x80) * (1*x73) - (1*x81) # multiplication between 80 and 73 into 81 +0 = (1*x73) * (1*x73) - (1*x82) # multiplication between 73 and 73 into 82 +0 = (1*x82) * (1*x73) - (1*x83) # multiplication between 82 and 73 into 83 +0 = (1*x83) * (1*x73) - (1*x84) # multiplication between 83 and 73 into 84 +0 = (1*x84) * (1*x73) - (1*x85) # multiplication between 84 and 73 into 85 +0 = (1*x81 + 0*one) * (1*one) - (1*x85) # assert equality +0 = (1*one + 1*x78) * (1*one) - (1*x86) # addition between (1) and 78 into 86 +0 = (1*x81) * (1*x81) - (1*x87) # multiplication between 81 and 81 into 87 +0 = (1*x87) * (1*x87) - (1*x88) # multiplication between 87 and 87 into 88 +0 = (1*x88) * (1*x81) - (1*x89) # multiplication between 88 and 81 into 89 +0 = (1*x81) * (1*x81) - (1*x90) # multiplication between 81 and 81 into 90 +0 = (1*x90) * (1*x81) - (1*x91) # multiplication between 90 and 81 into 91 +0 = (1*x91) * (1*x81) - (1*x92) # multiplication between 91 and 81 into 92 +0 = (1*x92) * (1*x81) - (1*x93) # multiplication between 92 and 81 into 93 +0 = (1*x89 + 0*one) * (1*one) - (1*x93) # assert equality +0 = (1*one + 1*x86) * (1*one) - (1*x94) # addition between (1) and 86 into 94 +0 = (1*x89) * (1*x89) - (1*x95) # multiplication between 89 and 89 into 95 +0 = (1*x95) * (1*x95) - (1*x96) # multiplication between 95 and 95 into 96 +0 = (1*x96) * (1*x89) - (1*x97) # multiplication between 96 and 89 into 97 +0 = (1*x89) * (1*x89) - (1*x98) # multiplication between 89 and 89 into 98 +0 = (1*x98) * (1*x89) - (1*x99) # multiplication between 98 and 89 into 99 +0 = (1*x99) * (1*x89) - (1*x100) # multiplication between 99 and 89 into 100 +0 = (1*x100) * (1*x89) - (1*x101) # multiplication between 100 and 89 into 101 +0 = (1*x97 + 0*one) * (1*one) - (1*x101) # assert equality +0 = (1*one + 1*x94) * (1*one) - (1*x102) # addition between (1) and 94 into 102 +0 = (1*x97) * (1*x97) - (1*x103) # multiplication between 97 and 97 into 103 +0 = (1*x103) * (1*x103) - (1*x104) # multiplication between 103 and 103 into 104 +0 = (1*x104) * (1*x97) - (1*x105) # multiplication between 104 and 97 into 105 +0 = (1*x97) * (1*x97) - (1*x106) # multiplication between 97 and 97 into 106 +0 = (1*x106) * (1*x97) - (1*x107) # multiplication between 106 and 97 into 107 +0 = (1*x107) * (1*x97) - (1*x108) # multiplication between 107 and 97 into 108 +0 = (1*x108) * (1*x97) - (1*x109) # multiplication between 108 and 97 into 109 +0 = (1*x105 + 0*one) * (1*one) - (1*x109) # assert equality +0 = (1*one + 1*x102) * (1*one) - (1*x110) # addition between (1) and 102 into 110 +0 = (1*x105) * (1*x105) - (1*x111) # multiplication between 105 and 105 into 111 +0 = (1*x111) * (1*x111) - (1*x112) # multiplication between 111 and 111 into 112 +0 = (1*x112) * (1*x105) - (1*x113) # multiplication between 112 and 105 into 113 +0 = (1*x105) * (1*x105) - (1*x114) # multiplication between 105 and 105 into 114 +0 = (1*x114) * (1*x105) - (1*x115) # multiplication between 114 and 105 into 115 +0 = (1*x115) * (1*x105) - (1*x116) # multiplication between 115 and 105 into 116 +0 = (1*x116) * (1*x105) - (1*x117) # multiplication between 116 and 105 into 117 +0 = (1*x113 + 0*one) * (1*one) - (1*x117) # assert equality +0 = (1*one + 1*x110) * (1*one) - (1*x118) # addition between (1) and 110 into 118 +0 = (1*x113) * (1*x113) - (1*x119) # multiplication between 113 and 113 into 119 +0 = (1*x119) * (1*x119) - (1*x120) # multiplication between 119 and 119 into 120 +0 = (1*x120) * (1*x113) - (1*x121) # multiplication between 120 and 113 into 121 +0 = (1*x113) * (1*x113) - (1*x122) # multiplication between 113 and 113 into 122 +0 = (1*x122) * (1*x113) - (1*x123) # multiplication between 122 and 113 into 123 +0 = (1*x123) * (1*x113) - (1*x124) # multiplication between 123 and 113 into 124 +0 = (1*x124) * (1*x113) - (1*x125) # multiplication between 124 and 113 into 125 +0 = (1*x121 + 0*one) * (1*one) - (1*x125) # assert equality +0 = (1*x126) * (1*one) - (10*one) # assigning literal (10) to signal 126 +0 = (1*x118 + 0*one) * (1*one) - (1*x126) # assert equality +0 = (1*x128) * (1*one) - (55*one) # assigning literal (55) to signal 128 +0 = (1*x127 + 0*one) * (1*one) - (1*x128) # assert equality