diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 609abfc..0f3cfea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: ${{ runner.os }}-cargo-build- - name: Run tests - run: cargo test --verbose + run: cargo test -rv verify-proof: runs-on: ubuntu-latest @@ -52,6 +52,11 @@ jobs: "starknet", "starknet_with_keccak", ] + + env: + PROOFS_DIR: ${{ github.workspace }}/examples/proofs + WORKING_DIR: ${{ github.workspace }}/cli + steps: - name: Checkout repository uses: actions/checkout@v3 @@ -78,27 +83,55 @@ jobs: ${{ runner.os }}-cargo-build- - name: Run verification - run: cargo run --release --bin swiftness --features std,${{ matrix.layout }},keccak --no-default-features -- --proof examples/proofs/${{ matrix.layout }}/cairo0_example_proof.json - - # no-std-build: - # name: Test no_std support - # runs-on: ubuntu-latest - # strategy: - # fail-fast: false - # matrix: - # layout: - # [ - # "dex", - # "recursive", - # "recursive_with_poseidon", - # "small", - # "starknet", - # "starknet_with_keccak", - # ] - # steps: - # - uses: actions/checkout@v3 - # - name: Check wasm compatibility - # run: |- - # cd examples/no_std_build - # rustup show - # cargo build -r --features ${{ matrix.layout }},keccak --no-default-features + run: cargo run -r --bin swiftness --features std,${{ matrix.layout }},keccak --no-default-features -- --proof ${{ env.PROOFS_DIR }}/${{ matrix.layout }}/cairo0_example_proof.json + working-directory: ${{ env.WORKING_DIR }} + + no-std-build: + runs-on: ubuntu-latest + needs: verify-proof + strategy: + fail-fast: false + matrix: + layout: ["dex", "recursive", "recursive_with_poseidon", "small", "starknet", "starknet_with_keccak"] + hash: ["blake2s", "keccak"] + target: ["armebv7r-none-eabi", "riscv64imac-unknown-none-elf"] + + env: + WORKING_DIR: ${{ github.workspace }}/examples/no_std_build + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Cache Cargo registry + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry- + + - name: Cache Cargo build + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-build- + + - name: Show rustup + run: rustup show + working-directory: ${{ env.WORKING_DIR }} + + - name: Build project + run: cargo build -r --features ${{ matrix.layout }},${{ matrix.hash }} --no-default-features --target ${{ matrix.target }} + working-directory: ${{ env.WORKING_DIR }} + + - name: Print binary metadata + run: file target/${{ matrix.target }}/release/no_std_build + working-directory: ${{ env.WORKING_DIR }} diff --git a/.github/workflows/npm_publish.yaml b/.github/workflows/npm_publish.yaml index 5ef0c33..24c095a 100644 --- a/.github/workflows/npm_publish.yaml +++ b/.github/workflows/npm_publish.yaml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest env: - WORKING_DIR: wasm_bindings # define the working directory here + WORKING_DIR: ${{ github.workspace }}/wasm_bindings strategy: fail-fast: false @@ -51,7 +51,7 @@ jobs: run: cargo install wasm-pack - name: Build package - run: wasm-pack build --out-dir pkg --target web --workspace --features ${{ matrix.layout }},${{ matrix.hash }} --no-default-features + run: wasm-pack build --out-dir pkg --target web --features std,${{ matrix.layout }},${{ matrix.hash }} --no-default-features working-directory: ${{ env.WORKING_DIR }} - name: Rename package diff --git a/Cargo.lock b/Cargo.lock index 6173ddb..77126ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,97 +8,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[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.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" - -[[package]] -name = "anstyle-parse" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "anyhow" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" - [[package]] name = "autocfg" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "bail-out" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa66d6fe2058f811faa3e6a16e6504d92b23eff948d766c132425d1dc3d51f5c" - [[package]] name = "base64" version = "0.13.1" @@ -129,18 +44,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "cc" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" - [[package]] name = "cfg-if" version = "1.0.0" @@ -153,65 +56,10 @@ version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ - "android-tzdata", - "iana-time-zone", "num-traits", "serde", - "windows-targets", -] - -[[package]] -name = "clap" -version = "4.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.72", ] -[[package]] -name = "clap_lex" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" - -[[package]] -name = "colorchoice" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -237,7 +85,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core", "subtle", "zeroize", ] @@ -294,7 +141,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", - "serde", ] [[package]] @@ -334,31 +180,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi", - "wasm-bindgen", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[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" @@ -374,67 +195,18 @@ dependencies = [ "digest", ] -[[package]] -name = "iana-time-zone" -version = "0.1.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" -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 = "ident_case" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown", - "serde", -] - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" - [[package]] name = "itoa" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "keccak" version = "0.1.5" @@ -472,18 +244,6 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - [[package]] name = "miniz_oxide" version = "0.7.4" @@ -501,7 +261,6 @@ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", - "serde", ] [[package]] @@ -528,12 +287,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - [[package]] name = "powerfmt" version = "0.2.0" @@ -558,44 +311,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "regex" -version = "1.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - [[package]] name = "rfc6979" version = "0.4.0" @@ -663,13 +378,23 @@ dependencies = [ "base64 0.13.1", "chrono", "hex", - "indexmap", "serde", "serde_json", - "serde_with_macros", + "serde_with_macros 2.3.3", "time", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros 3.9.0", +] + [[package]] name = "serde_with_macros" version = "2.3.3" @@ -682,6 +407,18 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "sha2" version = "0.10.8" @@ -716,7 +453,7 @@ dependencies = [ "serde", "serde_json", "serde_json_pythonic", - "serde_with", + "serde_with 2.3.3", "sha3", "starknet-crypto", "starknet-types-core", @@ -788,24 +525,12 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "swiftness" -version = "0.0.5" -dependencies = [ - "clap", - "starknet-crypto", - "swiftness_air", - "swiftness_proof_parser", - "swiftness_stark", -] - [[package]] name = "swiftness_air" version = "0.0.5" dependencies = [ - "bail-out", "serde", - "serde_with", + "serde_with 3.9.0", "starknet-core", "starknet-crypto", "swiftness_commitment", @@ -819,9 +544,8 @@ name = "swiftness_commitment" version = "0.0.5" dependencies = [ "blake2", - "crypto-bigint", "serde", - "serde_with", + "serde_with 3.9.0", "sha3", "starknet-core", "starknet-crypto", @@ -836,7 +560,7 @@ name = "swiftness_fri" version = "0.0.5" dependencies = [ "serde", - "serde_with", + "serde_with 3.9.0", "sha3", "starknet-core", "starknet-crypto", @@ -850,7 +574,6 @@ dependencies = [ name = "swiftness_pow" version = "0.0.5" dependencies = [ - "bail-out", "blake2", "serde", "sha3", @@ -861,32 +584,12 @@ dependencies = [ "thiserror-no-std", ] -[[package]] -name = "swiftness_proof_parser" -version = "0.0.5" -dependencies = [ - "anyhow", - "clap", - "num-bigint", - "regex", - "serde", - "serde_json", - "starknet-types-core", - "swiftness_air", - "swiftness_commitment", - "swiftness_fri", - "swiftness_pow", - "swiftness_stark", - "thiserror", -] - [[package]] name = "swiftness_stark" version = "0.0.5" dependencies = [ - "bail-out", "serde", - "serde_with", + "serde_with 3.9.0", "starknet-core", "starknet-crypto", "swiftness_air", @@ -896,7 +599,6 @@ dependencies = [ "swiftness_transcript", "thiserror", "thiserror-no-std", - "wasm-bindgen", ] [[package]] @@ -906,18 +608,6 @@ dependencies = [ "starknet-crypto", ] -[[package]] -name = "swiftness_wasm" -version = "0.0.5" -dependencies = [ - "getrandom", - "serde_json", - "swiftness_air", - "swiftness_proof_parser", - "swiftness_stark", - "wasm-bindgen", -] - [[package]] name = "syn" version = "1.0.109" @@ -987,12 +677,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", - "itoa", "num-conv", "powerfmt", "serde", "time-core", - "time-macros", ] [[package]] @@ -1001,16 +689,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" -[[package]] -name = "time-macros" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "typenum" version = "1.17.0" @@ -1023,160 +701,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[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.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "wasi" -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.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.72", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" - -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[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.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[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.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[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.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - [[package]] name = "zeroize" version = "1.8.1" diff --git a/Cargo.toml b/Cargo.toml index 2532f99..47076ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,13 +10,12 @@ members = [ "crates/fri", "crates/pow", "crates/stark", - "proof_parser", - "cli", - "wasm_bindings", ] exclude = [ + "cli", + "proof_parser", + "wasm_bindings", "examples/no_std_build", - "examples/arm_build", ] [workspace.package] @@ -28,20 +27,16 @@ repository = "https://github.com/iosis-tech/swiftness" version = "0.0.5" [workspace.dependencies] -bail-out = "0.2.0" -serde_json = "1.0.114" -serde = { version = "1.0", features = ["derive"] } -serde_with = "2.3.2" -sha3 = "0.10.8" +blake2 = { version = "0.10.6", default-features = false } +serde = { version = "1.0", default-features = false, features = ["derive"] } +serde_json = { version = "1.0.114", default-features = false } +serde_with = { version = "3.8.3", default-features = false, features = ["macros"] } +sha3 = { version = "0.10.8", default-features = false } starknet-core = { version = "0.11.1", default-features = false } starknet-crypto = { version = "0.7.1", default-features = false } starknet-types-core = { version = "0.1.5", default-features = false } -crypto-bigint = "0.5.5" -thiserror-no-std = "=2.0.2" thiserror = "1.0.61" -num-bigint = { version = "0.4.4", features = ["serde"] } -blake2 = "0.10.6" -wasm-bindgen = "0.2" +thiserror-no-std = "2.0.2" swiftness_air = { path = "crates/air", default-features = false, version = "0.0.5" } swiftness_commitment = { path = "crates/commitment", default-features = false, version = "0.0.5" } @@ -49,4 +44,3 @@ swiftness_fri = { path = "crates/fri", default-features = false, version = "0.0. swiftness_pow = { path = "crates/pow", default-features = false, version = "0.0.5" } swiftness_stark = { path = "crates/stark", default-features = false, version = "0.0.5" } swiftness_transcript = { path = "crates/transcript", default-features = false, version = "0.0.5" } -swiftness_proof_parser = { path = "proof_parser", default-features = false, version = "0.0.5" } diff --git a/README.md b/README.md index 2b1cc65..01b69a6 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ cargo install wasm-pack ### Build WASM: ```sh -cd wasm-binding && wasm-pack build --target web --workspace --features std,starknet_with_keccak,blake2s --no-default-features +cd wasm-binding && wasm-pack build --target web --features std,starknet_with_keccak,blake2s --no-default-features ``` ## Features diff --git a/examples/no_std_build/Cargo.lock b/cli/Cargo.lock similarity index 78% rename from examples/no_std_build/Cargo.lock rename to cli/Cargo.lock index be0e72d..ab1dfd8 100644 --- a/examples/no_std_build/Cargo.lock +++ b/cli/Cargo.lock @@ -3,31 +3,80 @@ version = 3 [[package]] -name = "android-tzdata" -version = "0.1.1" +name = "adler" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] -name = "android_system_properties" -version = "0.1.5" +name = "aho-corasick" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ - "libc", + "memchr", ] [[package]] -name = "autocfg" -version = "1.3.0" +name = "anstream" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] [[package]] -name = "bail-out" -version = "0.2.0" +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa66d6fe2058f811faa3e6a16e6504d92b23eff948d766c132425d1dc3d51f5c" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "base64" @@ -59,18 +108,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "cc" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" - [[package]] name = "cfg-if" version = "1.0.0" @@ -83,18 +120,55 @@ version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ - "android-tzdata", - "iana-time-zone", "num-traits", "serde", - "windows-targets", ] [[package]] -name = "core-foundation-sys" -version = "0.8.6" +name = "clap" +version = "4.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "clap_lex" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" + +[[package]] +name = "colorchoice" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "cpufeatures" @@ -105,6 +179,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -112,7 +195,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core", "subtle", "zeroize", ] @@ -169,7 +251,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", - "serde", ] [[package]] @@ -183,6 +264,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "flate2" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -200,23 +291,10 @@ dependencies = [ ] [[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi", - "wasm-bindgen", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" +name = "heck" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hex" @@ -233,29 +311,6 @@ dependencies = [ "digest", ] -[[package]] -name = "iana-time-zone" -version = "0.1.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" -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 = "ident_case" version = "1.0.1" @@ -263,15 +318,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] -name = "indexmap" -version = "1.9.3" +name = "is_terminal_polyfill" +version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown", - "serde", -] +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" [[package]] name = "itoa" @@ -280,21 +330,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] -name = "js-sys" -version = "0.3.69" +name = "keccak" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ - "wasm-bindgen", + "cpufeatures", ] [[package]] -name = "keccak" -version = "0.1.5" +name = "lambdaworks-crypto" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +checksum = "7fb5d4f22241504f7c7b8d2c3a7d7835d7c07117f10bff2a7d96a9ef6ef217c3" dependencies = [ - "cpufeatures", + "lambdaworks-math", + "serde", + "sha2", + "sha3", ] [[package]] @@ -302,6 +355,10 @@ name = "lambdaworks-math" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "358e172628e713b80a530a59654154bfc45783a6ed70ea284839800cebdf8f97" +dependencies = [ + "serde", + "serde_json", +] [[package]] name = "libc" @@ -310,22 +367,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] -name = "log" -version = "0.4.22" +name = "memchr" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "no_std_build" -version = "0.1.0" +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ - "getrandom", - "swiftness_air", - "swiftness_commitment", - "swiftness_fri", - "swiftness_pow", - "swiftness_stark", - "swiftness_transcript", + "adler", ] [[package]] @@ -336,6 +389,7 @@ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", + "serde", ] [[package]] @@ -362,12 +416,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - [[package]] name = "powerfmt" version = "0.2.0" @@ -393,14 +441,34 @@ dependencies = [ ] [[package]] -name = "rand_core" -version = "0.6.4" +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ - "getrandom", + "aho-corasick", + "memchr", + "regex-syntax", ] +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + [[package]] name = "rfc6979" version = "0.4.0" @@ -468,13 +536,23 @@ dependencies = [ "base64 0.13.1", "chrono", "hex", - "indexmap", "serde", "serde_json", - "serde_with_macros", + "serde_with_macros 2.3.3", "time", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros 3.9.0", +] + [[package]] name = "serde_with_macros" version = "2.3.3" @@ -487,6 +565,18 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "sha2" version = "0.10.8" @@ -516,11 +606,12 @@ checksum = "d506e02a4083290d13b427dfe437fd95aa8b56315c455bb2f9cdeca76620d457" dependencies = [ "base64 0.21.7", "crypto-bigint", + "flate2", "hex", "serde", "serde_json", "serde_json_pythonic", - "serde_with", + "serde_with 2.3.3", "sha3", "starknet-crypto", "starknet-types-core", @@ -572,6 +663,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6bacf0ba19bc721e518bc4bf389ff13daa8a7c5db5fd320600473b8aa9fcbd" dependencies = [ + "lambdaworks-crypto", "lambdaworks-math", "num-bigint", "num-integer", @@ -591,17 +683,27 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "swiftness" +version = "0.0.5" +dependencies = [ + "clap", + "swiftness_air", + "swiftness_proof_parser", + "swiftness_stark", +] + [[package]] name = "swiftness_air" version = "0.0.5" dependencies = [ - "bail-out", "serde", - "serde_with", + "serde_with 3.9.0", "starknet-core", "starknet-crypto", "swiftness_commitment", "swiftness_transcript", + "thiserror", "thiserror-no-std", ] @@ -610,14 +712,14 @@ name = "swiftness_commitment" version = "0.0.5" dependencies = [ "blake2", - "crypto-bigint", "serde", - "serde_with", + "serde_with 3.9.0", "sha3", "starknet-core", "starknet-crypto", "starknet-types-core", "swiftness_transcript", + "thiserror", "thiserror-no-std", ] @@ -626,12 +728,13 @@ name = "swiftness_fri" version = "0.0.5" dependencies = [ "serde", - "serde_with", + "serde_with 3.9.0", "sha3", "starknet-core", "starknet-crypto", "swiftness_commitment", "swiftness_transcript", + "thiserror", "thiserror-no-std", ] @@ -639,23 +742,42 @@ dependencies = [ name = "swiftness_pow" version = "0.0.5" dependencies = [ - "bail-out", "blake2", "serde", "sha3", "starknet-crypto", "starknet-types-core", "swiftness_transcript", + "thiserror", "thiserror-no-std", ] +[[package]] +name = "swiftness_proof_parser" +version = "0.0.5" +dependencies = [ + "anyhow", + "clap", + "num-bigint", + "regex", + "serde", + "serde_json", + "starknet-types-core", + "swiftness_air", + "swiftness_commitment", + "swiftness_fri", + "swiftness_pow", + "swiftness_stark", + "swiftness_transcript", + "thiserror", +] + [[package]] name = "swiftness_stark" version = "0.0.5" dependencies = [ - "bail-out", "serde", - "serde_with", + "serde_with 3.9.0", "starknet-core", "starknet-crypto", "swiftness_air", @@ -663,8 +785,8 @@ dependencies = [ "swiftness_fri", "swiftness_pow", "swiftness_transcript", + "thiserror", "thiserror-no-std", - "wasm-bindgen", ] [[package]] @@ -696,6 +818,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "thiserror" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "thiserror-impl-no-std" version = "2.0.2" @@ -723,12 +865,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", - "itoa", "num-conv", "powerfmt", "serde", "time-core", - "time-macros", ] [[package]] @@ -737,16 +877,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" -[[package]] -name = "time-macros" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "typenum" version = "1.17.0" @@ -760,76 +890,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "version_check" -version = "0.9.4" +name = "utf8parse" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] -name = "wasi" -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.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.72", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" +name = "version_check" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] -name = "windows-core" +name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index d6eae70..14546a9 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,19 +1,18 @@ [package] name = "swiftness" -description.workspace = true -edition.workspace = true -license-file.workspace = true -readme.workspace = true -repository.workspace = true -version.workspace = true +description = "Swiftness - Rust CairoVM Verifier implementation" +edition = "2021" +license-file = "LICENSE" +readme = "README.md" +repository = "https://github.com/iosis-tech/swiftness" +version = "0.0.5" [dependencies] clap = { version = "4.4.4", features = ["derive"] } -starknet-crypto.workspace = true -swiftness_air = { workspace = true } -swiftness_stark = { workspace = true } -swiftness_proof_parser = { workspace = true } +swiftness_air = { path = "../crates/air", default-features = false, version = "0.0.5" } +swiftness_stark = { path = "../crates/stark", default-features = false, version = "0.0.5" } +swiftness_proof_parser = { path = "../proof_parser", default-features = false, version = "0.0.5" } [features] default = ["std", "recursive", "keccak"] diff --git a/cli/LICENSE b/cli/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/cli/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/crates/air/Cargo.toml b/crates/air/Cargo.toml index cdfde66..98a9053 100644 --- a/crates/air/Cargo.toml +++ b/crates/air/Cargo.toml @@ -30,7 +30,6 @@ blake2s = [ ] [dependencies] -bail-out.workspace = true serde_with.workspace = true serde.workspace = true starknet-core.workspace = true diff --git a/crates/air/src/layout/dex/global_values.rs b/crates/air/src/layout/dex/global_values.rs index 2716518..f8aa21a 100644 --- a/crates/air/src/layout/dex/global_values.rs +++ b/crates/air/src/layout/dex/global_values.rs @@ -1,24 +1,35 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; use swiftness_transcript::transcript::Transcript; #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcPoint { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub y: Felt, } #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcdsaSigConfig { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub alpha: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub beta: Felt, pub shift_point: EcPoint, } @@ -28,53 +39,116 @@ pub struct EcdsaSigConfig { #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct GlobalValues { // Public input. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub trace_length: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pedersen_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_range_check_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ecdsa_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_min: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_max: Felt, // Constants. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub offset_size: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub half_offset_size: Felt, pub pedersen_shift_point: EcPoint, pub ecdsa_sig_config: EcdsaSigConfig, // Periodic columns. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_y: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub ecdsa_generator_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub ecdsa_generator_points_y: Felt, // Interaction elements. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, // Permutation products. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_public_memory_prod: Felt, } @@ -83,11 +157,20 @@ pub struct GlobalValues { #[serde_as] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct InteractionElements { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, } diff --git a/crates/air/src/layout/dex/mod.rs b/crates/air/src/layout/dex/mod.rs index d4a8568..24d110d 100644 --- a/crates/air/src/layout/dex/mod.rs +++ b/crates/air/src/layout/dex/mod.rs @@ -8,11 +8,11 @@ use crate::{ }; use alloc::vec; use alloc::vec::Vec; -use bail_out::ensure; use global_values::{EcPoint, EcdsaSigConfig, GlobalValues, InteractionElements}; use starknet_core::types::NonZeroFelt; use starknet_crypto::{poseidon_hash_many, Felt}; use swiftness_commitment::table::{commit::table_commit, decommit::table_decommit}; +use swiftness_transcript::ensure; use super::{CompositionPolyEvalError, LayoutTrait, PublicInputError}; diff --git a/crates/air/src/layout/recursive/global_values.rs b/crates/air/src/layout/recursive/global_values.rs index e15c969..ad835d7 100644 --- a/crates/air/src/layout/recursive/global_values.rs +++ b/crates/air/src/layout/recursive/global_values.rs @@ -1,15 +1,20 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; use swiftness_transcript::transcript::Transcript; #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcPoint { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub y: Felt, } @@ -18,60 +23,135 @@ pub struct EcPoint { #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct GlobalValues { // Public input. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub trace_length: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pedersen_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_range_check_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_bitwise_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_min: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_max: Felt, // Constants. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub offset_size: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub half_offset_size: Felt, pub pedersen_shift_point: EcPoint, // Periodic columns. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_y: Felt, // Interaction elements. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_z: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_alpha: Felt, // Permutation products. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_first_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_final_cum_val: Felt, } @@ -80,17 +160,35 @@ pub struct GlobalValues { #[serde_as] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct InteractionElements { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_z: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_alpha: Felt, } diff --git a/crates/air/src/layout/recursive/mod.rs b/crates/air/src/layout/recursive/mod.rs index 8982c5e..f812586 100644 --- a/crates/air/src/layout/recursive/mod.rs +++ b/crates/air/src/layout/recursive/mod.rs @@ -8,11 +8,11 @@ use crate::{ }; use alloc::vec; use alloc::vec::Vec; -use bail_out::ensure; use global_values::{EcPoint, GlobalValues, InteractionElements}; use starknet_core::types::NonZeroFelt; use starknet_crypto::{poseidon_hash_many, Felt}; use swiftness_commitment::table::{commit::table_commit, decommit::table_decommit}; +use swiftness_transcript::ensure; use super::{CompositionPolyEvalError, LayoutTrait, PublicInputError}; diff --git a/crates/air/src/layout/recursive_with_poseidon/global_values.rs b/crates/air/src/layout/recursive_with_poseidon/global_values.rs index 9b07ff5..795bcde 100644 --- a/crates/air/src/layout/recursive_with_poseidon/global_values.rs +++ b/crates/air/src/layout/recursive_with_poseidon/global_values.rs @@ -1,15 +1,20 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; use swiftness_transcript::transcript::Transcript; #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcPoint { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub y: Felt, } @@ -18,72 +23,165 @@ pub struct EcPoint { #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct GlobalValues { // Public input. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub trace_length: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pedersen_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_range_check_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_bitwise_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_poseidon_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_min: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_max: Felt, // Constants. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub offset_size: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub half_offset_size: Felt, pub pedersen_shift_point: EcPoint, // Periodic columns. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_y: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_full_round_key0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_full_round_key1: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_full_round_key2: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_partial_round_key0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_partial_round_key1: Felt, // Interaction elements. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_z: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_alpha: Felt, // Permutation products. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_first_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_final_cum_val: Felt, } @@ -92,17 +190,35 @@ pub struct GlobalValues { #[serde_as] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct InteractionElements { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_z: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_alpha: Felt, } diff --git a/crates/air/src/layout/recursive_with_poseidon/mod.rs b/crates/air/src/layout/recursive_with_poseidon/mod.rs index 6ce3c28..32e502c 100644 --- a/crates/air/src/layout/recursive_with_poseidon/mod.rs +++ b/crates/air/src/layout/recursive_with_poseidon/mod.rs @@ -12,11 +12,11 @@ use crate::{ }; use alloc::vec; use alloc::vec::Vec; -use bail_out::ensure; use global_values::{EcPoint, GlobalValues, InteractionElements}; use starknet_core::types::NonZeroFelt; use starknet_crypto::{poseidon_hash_many, Felt}; use swiftness_commitment::table::{commit::table_commit, decommit::table_decommit}; +use swiftness_transcript::ensure; use super::{CompositionPolyEvalError, LayoutTrait, PublicInputError}; diff --git a/crates/air/src/layout/small/global_values.rs b/crates/air/src/layout/small/global_values.rs index 2716518..f8aa21a 100644 --- a/crates/air/src/layout/small/global_values.rs +++ b/crates/air/src/layout/small/global_values.rs @@ -1,24 +1,35 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; use swiftness_transcript::transcript::Transcript; #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcPoint { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub y: Felt, } #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcdsaSigConfig { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub alpha: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub beta: Felt, pub shift_point: EcPoint, } @@ -28,53 +39,116 @@ pub struct EcdsaSigConfig { #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct GlobalValues { // Public input. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub trace_length: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pedersen_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_range_check_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ecdsa_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_min: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_max: Felt, // Constants. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub offset_size: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub half_offset_size: Felt, pub pedersen_shift_point: EcPoint, pub ecdsa_sig_config: EcdsaSigConfig, // Periodic columns. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_y: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub ecdsa_generator_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub ecdsa_generator_points_y: Felt, // Interaction elements. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, // Permutation products. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_public_memory_prod: Felt, } @@ -83,11 +157,20 @@ pub struct GlobalValues { #[serde_as] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct InteractionElements { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, } diff --git a/crates/air/src/layout/small/mod.rs b/crates/air/src/layout/small/mod.rs index e2ed95e..b3de58b 100644 --- a/crates/air/src/layout/small/mod.rs +++ b/crates/air/src/layout/small/mod.rs @@ -8,11 +8,11 @@ use crate::{ }; use alloc::vec; use alloc::vec::Vec; -use bail_out::ensure; use global_values::{EcPoint, EcdsaSigConfig, GlobalValues, InteractionElements}; use starknet_core::types::NonZeroFelt; use starknet_crypto::{poseidon_hash_many, Felt}; use swiftness_commitment::table::{commit::table_commit, decommit::table_decommit}; +use swiftness_transcript::ensure; use super::{CompositionPolyEvalError, LayoutTrait, PublicInputError}; diff --git a/crates/air/src/layout/starknet/global_values.rs b/crates/air/src/layout/starknet/global_values.rs index a58d0e5..4dbd28e 100644 --- a/crates/air/src/layout/starknet/global_values.rs +++ b/crates/air/src/layout/starknet/global_values.rs @@ -1,33 +1,50 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; use swiftness_transcript::transcript::Transcript; #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcPoint { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub y: Felt, } #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct CurveConfig { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub alpha: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub beta: Felt, } #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcdsaSigConfig { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub alpha: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub beta: Felt, pub shift_point: EcPoint, } @@ -37,82 +54,187 @@ pub struct EcdsaSigConfig { #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct GlobalValues { // Public input. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub trace_length: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pedersen_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_range_check_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ecdsa_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_bitwise_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ec_op_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_poseidon_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_min: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_max: Felt, // Constants. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub offset_size: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub half_offset_size: Felt, pub pedersen_shift_point: EcPoint, pub ecdsa_sig_config: EcdsaSigConfig, pub ec_op_curve_config: CurveConfig, // Periodic columns. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_y: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub ecdsa_generator_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub ecdsa_generator_points_y: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_full_round_key0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_full_round_key1: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_full_round_key2: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_partial_round_key0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_partial_round_key1: Felt, // Interaction elements. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_z: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_alpha: Felt, // Permutation products. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_first_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_final_cum_val: Felt, } @@ -121,17 +243,35 @@ pub struct GlobalValues { #[serde_as] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct InteractionElements { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_z: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_alpha: Felt, } diff --git a/crates/air/src/layout/starknet/mod.rs b/crates/air/src/layout/starknet/mod.rs index 041a0ab..23dca9e 100644 --- a/crates/air/src/layout/starknet/mod.rs +++ b/crates/air/src/layout/starknet/mod.rs @@ -14,11 +14,11 @@ use crate::{ }; use alloc::vec; use alloc::vec::Vec; -use bail_out::ensure; use global_values::{CurveConfig, EcPoint, EcdsaSigConfig, GlobalValues, InteractionElements}; use starknet_core::types::NonZeroFelt; use starknet_crypto::{poseidon_hash_many, Felt}; use swiftness_commitment::table::{commit::table_commit, decommit::table_decommit}; +use swiftness_transcript::ensure; use super::{CompositionPolyEvalError, LayoutTrait, PublicInputError}; diff --git a/crates/air/src/layout/starknet_with_keccak/global_values.rs b/crates/air/src/layout/starknet_with_keccak/global_values.rs index e8f792b..882ece9 100644 --- a/crates/air/src/layout/starknet_with_keccak/global_values.rs +++ b/crates/air/src/layout/starknet_with_keccak/global_values.rs @@ -1,33 +1,50 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; use swiftness_transcript::transcript::Transcript; #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcPoint { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub y: Felt, } #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct CurveConfig { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub alpha: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub beta: Felt, } #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct EcdsaSigConfig { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub alpha: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub beta: Felt, pub shift_point: EcPoint, } @@ -37,98 +54,227 @@ pub struct EcdsaSigConfig { #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct GlobalValues { // Public input. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub trace_length: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_pc: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub final_ap: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_pedersen_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_range_check_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ecdsa_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_bitwise_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_ec_op_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_keccak_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub initial_poseidon_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_min: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_max: Felt, // Constants. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub offset_size: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub half_offset_size: Felt, pub pedersen_shift_point: EcPoint, pub ecdsa_sig_config: EcdsaSigConfig, pub ec_op_curve_config: CurveConfig, // Periodic columns. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub pedersen_points_y: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub ecdsa_generator_points_x: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub ecdsa_generator_points_y: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub keccak_keccak_keccak_round_key0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub keccak_keccak_keccak_round_key1: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub keccak_keccak_keccak_round_key3: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub keccak_keccak_keccak_round_key7: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub keccak_keccak_keccak_round_key15: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub keccak_keccak_keccak_round_key31: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub keccak_keccak_keccak_round_key63: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_full_round_key0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_full_round_key1: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_full_round_key2: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_partial_round_key0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub poseidon_poseidon_partial_round_key1: Felt, // Interaction elements. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_z: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_alpha: Felt, // Permutation products. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_first_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_public_memory_prod: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_final_cum_val: Felt, } @@ -137,17 +283,35 @@ pub struct GlobalValues { #[serde_as] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct InteractionElements { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub memory_multi_column_perm_hash_interaction_elm0: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check16_perm_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_permutation_interaction_elm: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_z: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub diluted_check_interaction_alpha: Felt, } diff --git a/crates/air/src/layout/starknet_with_keccak/mod.rs b/crates/air/src/layout/starknet_with_keccak/mod.rs index cf76234..93538a9 100644 --- a/crates/air/src/layout/starknet_with_keccak/mod.rs +++ b/crates/air/src/layout/starknet_with_keccak/mod.rs @@ -16,11 +16,11 @@ use crate::{ }; use alloc::vec; use alloc::vec::Vec; -use bail_out::ensure; use global_values::{CurveConfig, EcPoint, EcdsaSigConfig, GlobalValues, InteractionElements}; use starknet_core::types::NonZeroFelt; use starknet_crypto::{poseidon_hash_many, Felt}; use swiftness_commitment::table::{commit::table_commit, decommit::table_decommit}; +use swiftness_transcript::ensure; use super::{CompositionPolyEvalError, LayoutTrait, PublicInputError}; diff --git a/crates/air/src/public_memory.rs b/crates/air/src/public_memory.rs index f12ac1e..99963af 100644 --- a/crates/air/src/public_memory.rs +++ b/crates/air/src/public_memory.rs @@ -3,7 +3,7 @@ use alloc::vec; use alloc::vec::Vec; use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::{serde::unsigned_field_element::UfeHex, types::NonZeroFelt}; +use starknet_core::types::NonZeroFelt; use starknet_crypto::{pedersen_hash, poseidon_hash_many, Felt}; pub const MAX_LOG_N_STEPS: Felt = Felt::from_hex_unchecked("50"); @@ -14,20 +14,41 @@ pub const INITIAL_PC: Felt = Felt::from_hex_unchecked("0x1"); #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct PublicInput { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub log_n_steps: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_min: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub range_check_max: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub layout: Felt, - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub dynamic_params: Vec, pub segments: Vec, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub padding_addr: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub padding_value: Felt, pub main_page: Page, pub continuous_page_headers: Vec, diff --git a/crates/air/src/trace/mod.rs b/crates/air/src/trace/mod.rs index bbaa610..3feaa86 100644 --- a/crates/air/src/trace/mod.rs +++ b/crates/air/src/trace/mod.rs @@ -3,7 +3,6 @@ pub mod decommit; use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; // Commitment values for the Traces component. Used to generate a commitment by "reading" these @@ -11,9 +10,15 @@ use starknet_crypto::Felt; #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct UnsentCommitment { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub original: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub interaction: Felt, } diff --git a/crates/air/src/types.rs b/crates/air/src/types.rs index 44d7ecc..403cd3e 100644 --- a/crates/air/src/types.rs +++ b/crates/air/src/types.rs @@ -2,26 +2,37 @@ use alloc::vec::Vec; use core::ops::Deref; use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct SegmentInfo { // Start address of the memory segment. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub begin_addr: Felt, // Stop pointer of the segment - not necessarily the end of the segment. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub stop_ptr: Felt, } #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct AddrValue { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub address: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub value: Felt, } @@ -65,15 +76,27 @@ impl Page { #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct ContinuousPageHeader { // Start address. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub start_address: Felt, // Size of the page. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub size: Felt, // Hash of the page. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub hash: Felt, // Cumulative product of the page. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub prod: Felt, } diff --git a/crates/commitment/Cargo.toml b/crates/commitment/Cargo.toml index a2a4977..480a2d8 100644 --- a/crates/commitment/Cargo.toml +++ b/crates/commitment/Cargo.toml @@ -26,7 +26,6 @@ starknet-types-core.workspace = true starknet-crypto.workspace = true thiserror = { optional = true, workspace = true } thiserror-no-std.workspace = true -crypto-bigint.workspace = true blake2.workspace = true swiftness_transcript.workspace = true diff --git a/crates/commitment/src/table/config.rs b/crates/commitment/src/table/config.rs index d9131d7..5ebab03 100644 --- a/crates/commitment/src/table/config.rs +++ b/crates/commitment/src/table/config.rs @@ -1,13 +1,15 @@ use crate::vector; use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; #[serde_as] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Config { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub n_columns: Felt, pub vector: vector::config::Config, } diff --git a/crates/commitment/src/table/types.rs b/crates/commitment/src/table/types.rs index 1d8b0e0..b6e3798 100644 --- a/crates/commitment/src/table/types.rs +++ b/crates/commitment/src/table/types.rs @@ -3,7 +3,6 @@ use crate::vector; use alloc::vec::Vec; use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; // Commitment for a table (n_rows x n_columns) of field elements in montgomery form. @@ -19,7 +18,10 @@ pub struct Commitment { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Decommitment { // n_columns * n_queries values to decommit. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub values: Vec, } diff --git a/crates/commitment/src/vector/config.rs b/crates/commitment/src/vector/config.rs index ff46b42..6120ca2 100644 --- a/crates/commitment/src/vector/config.rs +++ b/crates/commitment/src/vector/config.rs @@ -1,14 +1,19 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; #[serde_as] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Config { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub height: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub n_verifier_friendly_commitment_layers: Felt, } diff --git a/crates/commitment/src/vector/types.rs b/crates/commitment/src/vector/types.rs index ea2a575..8066f66 100644 --- a/crates/commitment/src/vector/types.rs +++ b/crates/commitment/src/vector/types.rs @@ -2,7 +2,6 @@ use super::config::Config; use alloc::vec::Vec; use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; // Commitment for a vector of field elements. @@ -10,7 +9,10 @@ use starknet_crypto::Felt; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Commitment { pub config: Config, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub commitment_hash: Felt, } @@ -18,9 +20,15 @@ pub struct Commitment { #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Query { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub index: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub value: Felt, } @@ -28,11 +36,20 @@ pub struct Query { #[serde_as] #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct QueryWithDepth { - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub index: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub value: Felt, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub depth: Felt, } @@ -42,6 +59,9 @@ pub struct QueryWithDepth { pub struct Witness { // The authentication values: all the siblings of the subtree generated by the queried indices, // bottom layer up, left to right. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub authentications: Vec, } diff --git a/crates/fri/src/config.rs b/crates/fri/src/config.rs index 2277e8e..47f0e54 100644 --- a/crates/fri/src/config.rs +++ b/crates/fri/src/config.rs @@ -1,7 +1,6 @@ use alloc::vec::Vec; use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; const MAX_LAST_LAYER_LOG_DEGREE_BOUND: u64 = 15; @@ -14,19 +13,31 @@ const MIN_FRI_STEP: u64 = 1; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Config { // Log2 of the size of the input layer to FRI. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub log_input_size: Felt, // Number of layers in the FRI. Inner + last layer. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub n_layers: Felt, // Array of size n_layers - 1, each entry is a configuration of a table commitment for the // corresponding inner layer. pub inner_layers: Vec, // Array of size n_layers, each entry represents the FRI step size, // i.e. the number of FRI-foldings between layer i and i+1. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub fri_step_sizes: Vec, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub log_last_layer_degree_bound: Felt, } diff --git a/crates/fri/src/types.rs b/crates/fri/src/types.rs index 7c7cd8a..c629b68 100644 --- a/crates/fri/src/types.rs +++ b/crates/fri/src/types.rs @@ -2,7 +2,6 @@ use crate::config::Config; use alloc::vec::Vec; use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; // Commitment values for FRI. Used to generate a commitment by "reading" these values @@ -11,11 +10,17 @@ use starknet_crypto::Felt; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct UnsentCommitment { // Array of size n_layers - 1 containing unsent table commitments for each inner layer. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub inner_layers: Vec, // Array of size 2**log_last_layer_degree_bound containing coefficients for the last layer // polynomial. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub last_layer_coefficients: Vec, } @@ -26,11 +31,17 @@ pub struct Commitment { // Array of size n_layers - 1 containing table commitments for each inner layer. pub inner_layers: Vec, // Array of size n_layers, of one evaluation point for each layer. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub eval_points: Vec, // Array of size 2**log_last_layer_degree_bound containing coefficients for the last layer // polynomial. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub last_layer_coefficients: Vec, } @@ -38,11 +49,17 @@ pub struct Commitment { #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Decommitment { // Array of size n_values, containing the values of the input layer at query indices. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub values: Vec, // Array of size n_values, containing the field elements that correspond to the query indices // (See queries_to_points). - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub points: Vec, } @@ -59,7 +76,10 @@ pub struct Witness { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct LayerWitness { // Values for the sibling leaves required for decommitment. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub leaves: Vec, // Table commitment witnesses for decommiting all the leaves. pub table_witness: swiftness_commitment::table::types::Witness, diff --git a/crates/pow/Cargo.toml b/crates/pow/Cargo.toml index dded926..07b9eac 100644 --- a/crates/pow/Cargo.toml +++ b/crates/pow/Cargo.toml @@ -18,7 +18,6 @@ keccak = [] blake2s = [] [dependencies] -bail-out.workspace = true serde.workspace = true sha3.workspace = true starknet-crypto.workspace = true diff --git a/crates/pow/src/pow.rs b/crates/pow/src/pow.rs index 754da4c..c056d83 100644 --- a/crates/pow/src/pow.rs +++ b/crates/pow/src/pow.rs @@ -8,10 +8,9 @@ use sha3::Digest; #[cfg(feature = "keccak")] use sha3::Keccak256; -use bail_out::assure; use serde::{Deserialize, Serialize}; use starknet_crypto::Felt; -use swiftness_transcript::transcript::Transcript; +use swiftness_transcript::{assure, transcript::Transcript}; use crate::config::Config; diff --git a/crates/stark/Cargo.toml b/crates/stark/Cargo.toml index ec5abb1..ec82da5 100644 --- a/crates/stark/Cargo.toml +++ b/crates/stark/Cargo.toml @@ -31,21 +31,21 @@ starknet_with_keccak = [ "swiftness_air/starknet_with_keccak", ] keccak = [ + "swiftness_pow/keccak", "swiftness_commitment/keccak", ] blake2s = [ + "swiftness_pow/blake2s", "swiftness_commitment/blake2s", ] [dependencies] -bail-out.workspace = true serde_with.workspace = true serde.workspace = true starknet-core.workspace = true starknet-crypto.workspace = true thiserror = { optional = true, workspace = true } thiserror-no-std.workspace = true -wasm-bindgen.workspace = true swiftness_air.workspace = true swiftness_commitment.workspace = true diff --git a/crates/stark/src/config.rs b/crates/stark/src/config.rs index 13dda79..0d87ecf 100644 --- a/crates/stark/src/config.rs +++ b/crates/stark/src/config.rs @@ -1,6 +1,5 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; #[serde_as] @@ -11,17 +10,29 @@ pub struct StarkConfig { pub fri: swiftness_fri::config::Config, pub proof_of_work: swiftness_pow::config::Config, // Log2 of the trace domain size. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub log_trace_domain_size: Felt, // Number of queries to the last component, FRI. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub n_queries: Felt, // Log2 of the number of cosets composing the evaluation domain, where the coset size is the // trace length. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub log_n_cosets: Felt, // Number of layers that use a verifier friendly hash in each commitment. - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub n_verifier_friendly_commitment_layers: Felt, } diff --git a/crates/stark/src/oods.rs b/crates/stark/src/oods.rs index 5ec7d2d..5a70254 100644 --- a/crates/stark/src/oods.rs +++ b/crates/stark/src/oods.rs @@ -1,5 +1,4 @@ use alloc::vec::Vec; -use bail_out::assure; use starknet_crypto::Felt; #[cfg(feature = "dex")] use swiftness_air::layout::dex::CONSTRAINT_DEGREE; @@ -60,6 +59,7 @@ pub fn verify_oods( ) } +use swiftness_transcript::assure; #[cfg(feature = "std")] use thiserror::Error; diff --git a/crates/stark/src/types.rs b/crates/stark/src/types.rs index 5bc31eb..e5fc5a9 100644 --- a/crates/stark/src/types.rs +++ b/crates/stark/src/types.rs @@ -1,7 +1,6 @@ use alloc::vec::Vec; use serde::{Deserialize, Serialize}; use serde_with::serde_as; -use starknet_core::serde::unsigned_field_element::UfeHex; use starknet_crypto::Felt; use crate::config; @@ -18,12 +17,18 @@ pub struct StarkProof { #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct StarkUnsentCommitment { pub traces: swiftness_air::trace::UnsentCommitment, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub composition: Felt, // n_oods_values elements. The i-th value is the evaluation of the i-th mask item polynomial at // the OODS point, where the mask item polynomial is the interpolation polynomial of the // corresponding column shifted by the corresponding row_offset. - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub oods_values: Vec, pub fri: swiftness_fri::types::UnsentCommitment, pub proof_of_work: swiftness_pow::pow::UnsentCommitment, @@ -34,11 +39,20 @@ pub struct StarkUnsentCommitment { pub struct StarkCommitment { pub traces: swiftness_air::trace::Commitment, pub composition: swiftness_commitment::table::types::Commitment, - #[serde_as(as = "UfeHex")] + #[cfg_attr( + feature = "std", + serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex") + )] pub interaction_after_composition: Felt, - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub oods_values: Vec, - #[serde_as(as = "Vec")] + #[cfg_attr( + feature = "std", + serde_as(as = "Vec") + )] pub interaction_after_oods: Vec, pub fri: swiftness_fri::types::Commitment, } diff --git a/crates/transcript/src/lib.rs b/crates/transcript/src/lib.rs index df9dc1b..9ed0638 100644 --- a/crates/transcript/src/lib.rs +++ b/crates/transcript/src/lib.rs @@ -6,3 +6,23 @@ pub mod transcript; #[cfg(test)] pub mod tests; + +#[macro_export] +macro_rules! ensure { + ($condition:expr, $err:expr) => { + if !$condition { + return Err($err); + } + }; +} + +#[macro_export] +macro_rules! assure { + ($condition:expr, $err:expr) => { + if !$condition { + Err($err) + } else { + Ok(()) + } + }; +} diff --git a/examples/no_std_build/.cargo/config.toml b/examples/no_std_build/.cargo/config.toml deleted file mode 100644 index a7b19c9..0000000 --- a/examples/no_std_build/.cargo/config.toml +++ /dev/null @@ -1 +0,0 @@ -[build] diff --git a/examples/no_std_build/Cargo.toml b/examples/no_std_build/Cargo.toml index c80aa53..543a11f 100644 --- a/examples/no_std_build/Cargo.toml +++ b/examples/no_std_build/Cargo.toml @@ -10,12 +10,10 @@ swiftness_commitment = { path = "../../crates/commitment", default-features = fa swiftness_pow = { path = "../../crates/pow", default-features = false } swiftness_fri = { path = "../../crates/fri", default-features = false } swiftness_transcript = { path = "../../crates/transcript", default-features = false } - -[target.'cfg(target_arch = "wasm32")'.dependencies] -getrandom = { version = "0.2.15", features = ["js"] } +embedded-alloc = "0.5.1" [features] -default = ["recursive", "keccak"] +default = ["recursive", "blake2s"] dex = ["swiftness_air/dex", "swiftness_stark/dex"] recursive = [ "swiftness_air/recursive", diff --git a/examples/no_std_build/rust-toolchain.toml b/examples/no_std_build/rust-toolchain.toml index 16d70f4..854480a 100644 --- a/examples/no_std_build/rust-toolchain.toml +++ b/examples/no_std_build/rust-toolchain.toml @@ -1,6 +1,10 @@ [toolchain] channel = "1.79.0" components = ["rustfmt", "clippy"] +targets = [ + "armebv7r-none-eabi", + "riscv64imac-unknown-none-elf" +] profile = "minimal" [profile.dev] diff --git a/examples/no_std_build/src/main.rs b/examples/no_std_build/src/main.rs index 816aff8..74fe8e4 100644 --- a/examples/no_std_build/src/main.rs +++ b/examples/no_std_build/src/main.rs @@ -2,6 +2,7 @@ #![no_main] use core::panic::PanicInfo; +use embedded_alloc::Heap; /// This function is called on panic. #[panic_handler] @@ -14,6 +15,9 @@ pub extern "C" fn _start() -> ! { loop {} } +#[global_allocator] +static HEAP: Heap = Heap::empty(); + #[allow(unused_imports)] use swiftness_air; #[allow(unused_imports)] diff --git a/proof_parser/Cargo.toml b/proof_parser/Cargo.toml index cd2c178..d63f233 100644 --- a/proof_parser/Cargo.toml +++ b/proof_parser/Cargo.toml @@ -1,14 +1,22 @@ [package] name = "swiftness_proof_parser" -description.workspace = true -edition.workspace = true -license-file.workspace = true +description = "Swiftness - Rust CairoVM Verifier implementation" +edition = "2021" +license-file = "LICENSE" readme = "README.md" -repository.workspace = true -version.workspace = true +repository = "https://github.com/iosis-tech/swiftness" +version = "0.0.5" [features] -default = ["keccak", "recursive"] +default = ["std", "keccak", "recursive"] +std = [ + "swiftness_air/std", + "swiftness_commitment/std", + "swiftness_fri/std", + "swiftness_pow/std", + "swiftness_stark/std", + "swiftness_transcript/std", +] dex = [] recursive = [] recursive_with_poseidon = [] @@ -20,17 +28,18 @@ blake2s = [] [dependencies] -serde.workspace = true -thiserror.workspace = true -starknet-types-core.workspace = true -num-bigint.workspace = true +serde = "1.0" +thiserror = "1.0.61" +starknet-types-core = "0.1.5" +num-bigint = { version = "0.4.4", features = ["serde"] } anyhow = "1.0.80" clap = { version = "4.5.1", features = ["derive"] } regex = "1.10.3" serde_json = "1.0.114" -swiftness_stark.workspace = true -swiftness_commitment.workspace = true -swiftness_fri.workspace = true -swiftness_air.workspace = true -swiftness_pow.workspace = true +swiftness_air = { path = "../crates/air", default-features = false, version = "0.0.5" } +swiftness_commitment = { path = "../crates/commitment", default-features = false, version = "0.0.5" } +swiftness_fri = { path = "../crates/fri", default-features = false, version = "0.0.5" } +swiftness_pow = { path = "../crates/pow", default-features = false, version = "0.0.5" } +swiftness_stark = { path = "../crates/stark", default-features = false, version = "0.0.5" } +swiftness_transcript = { path = "../crates/transcript", default-features = false, version = "0.0.5" } diff --git a/proof_parser/LICENSE b/proof_parser/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/proof_parser/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/wasm_bindings/.gitignore b/wasm_bindings/.gitignore index 86c3eac..b2bcbe8 100644 --- a/wasm_bindings/.gitignore +++ b/wasm_bindings/.gitignore @@ -1,2 +1 @@ -pkg/ -LICENSE \ No newline at end of file +pkg/ \ No newline at end of file diff --git a/wasm_bindings/Cargo.lock b/wasm_bindings/Cargo.lock new file mode 100644 index 0000000..21b3e9b --- /dev/null +++ b/wasm_bindings/Cargo.lock @@ -0,0 +1,1083 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "cfg-if" +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 = [ + "num-traits", + "serde", +] + +[[package]] +name = "clap" +version = "4.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "clap_lex" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" + +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.72", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "flate2" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[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 = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lambdaworks-crypto" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb5d4f22241504f7c7b8d2c3a7d7835d7c07117f10bff2a7d96a9ef6ef217c3" +dependencies = [ + "lambdaworks-math", + "serde", + "sha2", + "sha3", +] + +[[package]] +name = "lambdaworks-math" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "358e172628e713b80a530a59654154bfc45783a6ed70ea284839800cebdf8f97" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_json_pythonic" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62212da9872ca2a0cad0093191ee33753eddff9266cbbc1b4a602d13a3a768db" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" +dependencies = [ + "base64 0.13.1", + "chrono", + "hex", + "serde", + "serde_json", + "serde_with_macros 2.3.3", + "time", +] + +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros 3.9.0", +] + +[[package]] +name = "serde_with_macros" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "starknet-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d506e02a4083290d13b427dfe437fd95aa8b56315c455bb2f9cdeca76620d457" +dependencies = [ + "base64 0.21.7", + "crypto-bigint", + "flate2", + "hex", + "serde", + "serde_json", + "serde_json_pythonic", + "serde_with 2.3.3", + "sha3", + "starknet-crypto", + "starknet-types-core", +] + +[[package]] +name = "starknet-crypto" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2a821ad8d98c6c3e4d0e5097f3fe6e2ed120ada9d32be87cd1330c7923a2f0" +dependencies = [ + "crypto-bigint", + "hex", + "hmac", + "num-bigint", + "num-integer", + "num-traits", + "rfc6979", + "sha2", + "starknet-crypto-codegen", + "starknet-curve", + "starknet-types-core", + "zeroize", +] + +[[package]] +name = "starknet-crypto-codegen" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e179dedc3fa6da064e56811d3e05d446aa2f7459e4eb0e3e49378a337235437" +dependencies = [ + "starknet-curve", + "starknet-types-core", + "syn 2.0.72", +] + +[[package]] +name = "starknet-curve" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56935b306dcf0b8f14bb2a1257164b8478bb8be4801dfae0923f5b266d1b457c" +dependencies = [ + "starknet-types-core", +] + +[[package]] +name = "starknet-types-core" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6bacf0ba19bc721e518bc4bf389ff13daa8a7c5db5fd320600473b8aa9fcbd" +dependencies = [ + "lambdaworks-crypto", + "lambdaworks-math", + "num-bigint", + "num-integer", + "num-traits", + "serde", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "swiftness_air" +version = "0.0.5" +dependencies = [ + "serde", + "serde_with 3.9.0", + "starknet-core", + "starknet-crypto", + "swiftness_commitment", + "swiftness_transcript", + "thiserror", + "thiserror-no-std", +] + +[[package]] +name = "swiftness_commitment" +version = "0.0.5" +dependencies = [ + "blake2", + "serde", + "serde_with 3.9.0", + "sha3", + "starknet-core", + "starknet-crypto", + "starknet-types-core", + "swiftness_transcript", + "thiserror", + "thiserror-no-std", +] + +[[package]] +name = "swiftness_fri" +version = "0.0.5" +dependencies = [ + "serde", + "serde_with 3.9.0", + "sha3", + "starknet-core", + "starknet-crypto", + "swiftness_commitment", + "swiftness_transcript", + "thiserror", + "thiserror-no-std", +] + +[[package]] +name = "swiftness_pow" +version = "0.0.5" +dependencies = [ + "blake2", + "serde", + "sha3", + "starknet-crypto", + "starknet-types-core", + "swiftness_transcript", + "thiserror", + "thiserror-no-std", +] + +[[package]] +name = "swiftness_proof_parser" +version = "0.0.5" +dependencies = [ + "anyhow", + "clap", + "num-bigint", + "regex", + "serde", + "serde_json", + "starknet-types-core", + "swiftness_air", + "swiftness_commitment", + "swiftness_fri", + "swiftness_pow", + "swiftness_stark", + "swiftness_transcript", + "thiserror", +] + +[[package]] +name = "swiftness_stark" +version = "0.0.5" +dependencies = [ + "serde", + "serde_with 3.9.0", + "starknet-core", + "starknet-crypto", + "swiftness_air", + "swiftness_commitment", + "swiftness_fri", + "swiftness_pow", + "swiftness_transcript", + "thiserror", + "thiserror-no-std", +] + +[[package]] +name = "swiftness_transcript" +version = "0.0.5" +dependencies = [ + "starknet-crypto", +] + +[[package]] +name = "swiftness_wasm" +version = "0.0.5" +dependencies = [ + "getrandom", + "serde_json", + "swiftness_air", + "swiftness_proof_parser", + "swiftness_stark", + "wasm-bindgen", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "thiserror-impl-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "thiserror-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" +dependencies = [ + "thiserror-impl-no-std", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +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.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.72", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[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.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[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.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[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.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/wasm_bindings/Cargo.toml b/wasm_bindings/Cargo.toml index 4dd4f17..ae04328 100644 --- a/wasm_bindings/Cargo.toml +++ b/wasm_bindings/Cargo.toml @@ -1,19 +1,19 @@ [package] name = "swiftness_wasm" description = "Swiftness CairoVM Verifier | swiftness-{layout}-{commitment hash}" -edition.workspace = true -license-file.workspace = true +edition = "2021" +license-file = "LICENSE" readme = "README.md" -repository.workspace = true -version.workspace = true +repository = "https://github.com/iosis-tech/swiftness" +version = "0.0.5" [dependencies] -serde_json.workspace = true -wasm-bindgen.workspace = true +wasm-bindgen = "0.2" +serde_json = "1.0.114" -swiftness_air = { workspace = true } -swiftness_stark = { workspace = true } -swiftness_proof_parser = { workspace = true } +swiftness_air = { path = "../crates/air", default-features = false, version = "0.0.5" } +swiftness_stark = { path = "../crates/stark", default-features = false, version = "0.0.5" } +swiftness_proof_parser = { path = "../proof_parser", default-features = false, version = "0.0.5" } [lib] crate-type = ["cdylib", "rlib"] diff --git a/wasm_bindings/LICENSE b/wasm_bindings/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/wasm_bindings/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License.