Compare commits

...

5 Commits

Author SHA1 Message Date
github-actions[bot]
3f494f6758 ci: update version string in docs 2026-01-17 15:10:36 +00:00
dante
5da444ee72 chore: update docs, deps, and ci (#1019) 2026-01-17 10:10:20 -05:00
dante
5144991b21 fix: update decompose base type 2025-10-26 14:34:36 -04:00
dante
64acb1d9d6 fix: bump decomp base to integerrep (#1016) 2025-10-25 23:22:12 -04:00
dante
8cf28456b3 refactor: remove IPA (#1014) 2025-10-14 09:32:28 -04:00
38 changed files with 2325 additions and 2161 deletions

View File

@@ -15,7 +15,7 @@ jobs:
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: nanoGPT Mock

View File

@@ -24,12 +24,12 @@ jobs:
matrix:
target: [x86_64, universal2-apple-darwin]
env:
RELEASE_TAG: ${{ github.ref_name }}
RELEASE_TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
with:
persist-credentials: false
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
with:
python-version: 3.12
architecture: x64
@@ -48,22 +48,22 @@ jobs:
mv Cargo.lock Cargo.lock.orig
sed "s/0\\.0\\.0/${RELEASE_TAG//v}/" Cargo.lock.orig >Cargo.lock
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
cache: false
- name: Build wheels
if: matrix.target == 'universal2-apple-darwin'
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
with:
target: ${{ matrix.target }}
args: --release --out dist --features python-bindings
- name: Build wheels
if: matrix.target == 'x86_64'
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
with:
target: ${{ matrix.target }}
args: --release --out dist --features python-bindings
@@ -74,7 +74,7 @@ jobs:
python -c "import ezkl"
- name: Upload wheels
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0
with:
name: dist-macos-${{ matrix.target }}
path: dist
@@ -88,10 +88,10 @@ jobs:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
with:
persist-credentials: false
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
with:
python-version: 3.12
architecture: ${{ matrix.target }}
@@ -114,15 +114,15 @@ jobs:
mv Cargo.lock Cargo.lock.orig
sed "s/0\\.0\\.0/${RELEASE_TAG//v}/" Cargo.lock.orig >Cargo.lock
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
cache: false
- name: Build wheels
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
with:
target: ${{ matrix.target }}
args: --release --out dist --features python-bindings
@@ -132,7 +132,7 @@ jobs:
python -c "import ezkl"
- name: Upload wheels
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0 #v4.6.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0 #v4.6.0
with:
name: dist-windows-${{ matrix.target }}
path: dist
@@ -146,10 +146,10 @@ jobs:
matrix:
target: [x86_64]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
with:
persist-credentials: false
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
with:
python-version: 3.12
architecture: x64
@@ -178,7 +178,7 @@ jobs:
sudo apt-get update && sudo apt-get install -y openssl pkg-config libssl-dev
- name: Build wheels
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
with:
target: ${{ matrix.target }}
manylinux: auto
@@ -205,7 +205,7 @@ jobs:
python -c "import ezkl"
- name: Upload wheels
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0
with:
name: dist-linux-${{ matrix.target }}
path: dist
@@ -220,10 +220,10 @@ jobs:
target:
- x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
with:
persist-credentials: false
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
with:
python-version: 3.12
architecture: x64
@@ -252,7 +252,7 @@ jobs:
sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
- name: Build wheels
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
with:
target: ${{ matrix.target }}
manylinux: musllinux_1_2
@@ -273,7 +273,7 @@ jobs:
python3 -c "import ezkl"
- name: Upload wheels
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0
with:
name: dist-musllinux-${{ matrix.target }}
path: dist
@@ -289,10 +289,10 @@ jobs:
- target: aarch64-unknown-linux-musl
arch: aarch64
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
with:
persist-credentials: false
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa #v4.8.0
with:
python-version: 3.12
@@ -315,13 +315,13 @@ jobs:
sed "s/0\\.0\\.0/${RELEASE_TAG//v}/" Cargo.lock.orig >Cargo.lock
- name: Build wheels
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
uses: PyO3/maturin-action@5f8a1b3b0aad13193f46c9131f9b9e663def8ce5 #v1.46.0
with:
target: ${{ matrix.platform.target }}
manylinux: musllinux_1_2
args: --release --out dist --features python-bindings
- uses: uraimo/run-on-arch-action@5397f9e30a9b62422f302092631c99ae1effcd9e #v2.8.1
- uses: uraimo/run-on-arch-action@5397f9e30a9b62422f302092631c99ae1effcd9e #v2.8.1
name: Install built wheel
with:
arch: ${{ matrix.platform.arch }}
@@ -336,7 +336,7 @@ jobs:
python3 -c "import ezkl"
- name: Upload wheels
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0
with:
name: dist-musllinux-${{ matrix.platform.target }}
path: dist
@@ -349,7 +349,7 @@ jobs:
if: "startsWith(github.ref, 'refs/tags/')"
needs: [macos, windows, linux, musllinux, musllinux-cross]
steps:
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 #v4.1.8
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 #v4.1.8
with:
pattern: dist-*
merge-multiple: true
@@ -366,11 +366,10 @@ jobs:
# publishes to PyPI
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc #v1.12.4
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc #v1.12.4
with:
packages-dir: ./wheels
doc-publish:
permissions:
contents: read
@@ -378,7 +377,7 @@ jobs:
runs-on: ubuntu-latest
needs: pypi-publish
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
with:
persist-credentials: false
- name: Trigger RTDs build
@@ -386,4 +385,4 @@ jobs:
with:
webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }}
webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }}
commit_ref: ${{ github.ref_name }}
commit_ref: ${{ github.ref_name }}

View File

@@ -52,7 +52,7 @@ jobs:
steps:
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
cache: false
@@ -98,14 +98,11 @@ jobs:
echo "ASSET=build-artifacts/ezkl-linux-gpu.tar.gz" >> $GITHUB_ENV
- name: Upload release archive
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 #v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda #v2.2.1
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
token: ${{ secrets.RELEASE_TOKEN }}
tag_name: ${{ env.EZKL_VERSION }}
files: ${{ env.ASSET }}
build-release:
permissions:
@@ -127,27 +124,27 @@ jobs:
include:
- build: windows-msvc
os: windows-latest
rust: nightly-2025-05-01
rust: nightly-2025-12-01
target: x86_64-pc-windows-msvc
- build: macos
os: macos-13
rust: nightly-2025-05-01
rust: nightly-2025-12-01
target: x86_64-apple-darwin
- build: macos-aarch64
os: macos-13
rust: nightly-2025-05-01
rust: nightly-2025-12-01
target: aarch64-apple-darwin
- build: linux-musl
os: ubuntu-22.04
rust: nightly-2025-05-01
rust: nightly-2025-12-01
target: x86_64-unknown-linux-musl
- build: linux-gnu
os: ubuntu-22.04
rust: nightly-2025-05-01
rust: nightly-2025-12-01
target: x86_64-unknown-linux-gnu
- build: linux-aarch64
os: ubuntu-22.04
rust: nightly-2025-05-01
rust: nightly-2025-12-01
target: aarch64-unknown-linux-gnu
steps:
@@ -240,11 +237,8 @@ jobs:
echo "ASSET=build-artifacts/ezkl-win.zip" >> $GITHUB_ENV
- name: Upload release archive
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 #v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda #v2.2.1
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
token: ${{ secrets.RELEASE_TOKEN }}
tag_name: ${{ env.EZKL_VERSION }}
files: ${{ env.ASSET }}

View File

@@ -33,7 +33,7 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- uses: baptiste0928/cargo-install@91c5da15570085bcde6f4d7aed98cb82d6769fd3
@@ -58,7 +58,7 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: install libc6
@@ -82,7 +82,7 @@ jobs:
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: install libc6
@@ -106,7 +106,7 @@ jobs:
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: install libc6
@@ -140,7 +140,7 @@ jobs:
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- uses: baptiste0928/cargo-install@91c5da15570085bcde6f4d7aed98cb82d6769fd3 #v3.3.0
@@ -185,7 +185,7 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: install libc6
@@ -223,7 +223,7 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: install libc6
@@ -256,7 +256,7 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- uses: baptiste0928/cargo-install@91c5da15570085bcde6f4d7aed98cb82d6769fd3 #v3.3.0
@@ -331,7 +331,7 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- uses: baptiste0928/cargo-install@91c5da15570085bcde6f4d7aed98cb82d6769fd3 #v3.3.0
@@ -344,11 +344,11 @@ jobs:
with:
persist-credentials: false
- name: "Add rust-src"
run: rustup component add rust-src --toolchain nightly-2025-05-01-x86_64-unknown-linux-gnu
run: rustup component add rust-src --toolchain nightly-2025-12-01-x86_64-unknown-linux-gnu
# - name: Install solc
# run: (hash svm 2>/dev/null || cargo install svm-rs) && svm install 0.8.20 && solc --version
- name: Install Anvil
run: cargo install --git https://github.com/foundry-rs/foundry --rev 56b806a3ba7866a3b061093bebd0fa2ace97f1fc --locked anvil --force
run: cargo install --git https://github.com/foundry-rs/foundry --rev c11315be56183bcbc13235475045670542d542ba --locked anvil --force
- name: KZG prove and verify tests (EVM)
run: cargo nextest run --verbose "tests_evm::kzg_evm_prove_and_verify_::" --test-threads 1
# - name: KZG prove and verify tests (EVM + reusable verifier + col-overflow)
@@ -380,11 +380,11 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: Add rust-src
run: rustup component add rust-src --toolchain nightly-2025-05-01-x86_64-unknown-linux-gnu
run: rustup component add rust-src --toolchain nightly-2025-12-01-x86_64-unknown-linux-gnu
- name: Force rebuild icicle dependencies
run: cargo clean -p icicle-runtime -p icicle-core -p icicle-hash -p icicle-bn254
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
@@ -437,11 +437,11 @@ jobs:
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: Add rust-src
run: rustup component add rust-src --toolchain nightly-2025-05-01-x86_64-unknown-linux-gnu
run: rustup component add rust-src --toolchain nightly-2025-12-01-x86_64-unknown-linux-gnu
- uses: baptiste0928/cargo-install@91c5da15570085bcde6f4d7aed98cb82d6769fd3 #v3.3.0
with:
crate: cargo-nextest
@@ -486,7 +486,7 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: install libc6
@@ -520,7 +520,7 @@ jobs:
python-version: "3.12"
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- name: Install cmake
@@ -530,7 +530,7 @@ jobs:
- name: Setup Virtual Env and Install python dependencies
run: python -m venv .env --clear; source .env/bin/activate; pip install -r requirements.txt;
- name: Install Anvil
run: cargo install --git https://github.com/foundry-rs/foundry --rev 56b806a3ba7866a3b061093bebd0fa2ace97f1fc --locked anvil --force
run: cargo install --git https://github.com/foundry-rs/foundry --rev c11315be56183bcbc13235475045670542d542ba --locked anvil --force
- name: Build python ezkl
run: source .env/bin/activate; unset CONDA_PREFIX; maturin develop --features python-bindings,reusable-verifier --profile=test-runs
- name: Run pytest
@@ -554,7 +554,7 @@ jobs:
python-version: "3.12"
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- uses: baptiste0928/cargo-install@91c5da15570085bcde6f4d7aed98cb82d6769fd3 #v3.3.0
@@ -592,7 +592,7 @@ jobs:
python-version: "3.11"
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy
- uses: baptiste0928/cargo-install@91c5da15570085bcde6f4d7aed98cb82d6769fd3 #v3.3.0
@@ -602,7 +602,7 @@ jobs:
# - name: Install solc
# run: (hash svm 2>/dev/null || cargo install svm-rs) && svm install 0.8.20 && solc --version
- name: Install Anvil
run: cargo install --git https://github.com/foundry-rs/foundry --rev 56b806a3ba7866a3b061093bebd0fa2ace97f1fc --locked anvil --force
run: cargo install --git https://github.com/foundry-rs/foundry --rev c11315be56183bcbc13235475045670542d542ba --locked anvil --force
- name: Install pip
run: python -m ensurepip --upgrade
- name: Setup Virtual Env and Install python dependencies

View File

@@ -17,7 +17,7 @@ jobs:
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 #v1.0.6
with:
toolchain: nightly-2025-05-01
toolchain: nightly-2025-12-01
override: true
components: rustfmt, clippy

3370
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -51,17 +51,16 @@ semver = { version = "1.0.22", optional = true }
# evm related deps
serde_json = { version = "1.0.97", features = ["float_roundtrip", "raw_value"] }
alloy = { git = "https://github.com/alloy-rs/alloy", version = "0.1.0", rev = "5fbf57bac99edef9d8475190109a7ea9fb7e5e83", features = [
alloy = { version = "1.0", features = [
"provider-http",
"signers",
"contract",
"rpc-types-eth",
"signer-wallet",
"signer-local",
"node-bindings",
], optional = true }
foundry-compilers = { version = "0.4.1", features = [
foundry-compilers = { version = "0.19.1", features = [
"svm-solc",
], optional = true }
ethabi = { version = "18", optional = true }
@@ -80,16 +79,16 @@ tokio = { version = "1.35.0", default-features = false, features = [
"macros",
"rt-multi-thread",
], optional = true }
pyo3 = { version = "0.24.2", features = [
pyo3 = { version = "0.27.2", features = [
"extension-module",
"abi3-py37",
"macros",
], default-features = false, optional = true }
pyo3-async-runtimes = { git = "https://github.com/PyO3/pyo3-async-runtimes", version = "0.24.0", features = [
pyo3-async-runtimes = { git = "https://github.com/PyO3/pyo3-async-runtimes", version = "0.27.0", features = [
"attributes",
"tokio-runtime",
], default-features = false, optional = true }
pyo3-log = { version = "0.12.0", default-features = false, optional = true }
pyo3-log = { version = "0.13.2", default-features = false, optional = true }
tract-onnx = { git = "https://github.com/sonos/tract/", rev = "37132e0397d0a73e5bd3a8615d932dabe44f6736", default-features = false, optional = true }
tabled = { version = "0.12.0", optional = true }
objc = { version = "0.2.4", optional = true }

View File

@@ -155,5 +155,5 @@ Check out `docs/advanced_security` for more advanced information on potential th
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2025 Zkonduit Inc.
Copyright (c) 2026 Zkonduit Inc.

View File

@@ -152,7 +152,6 @@ fn runcnvrl(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -119,7 +119,6 @@ fn rundot(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -174,7 +174,6 @@ fn runmatmul(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -154,7 +154,6 @@ fn runmatmul(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -157,7 +157,6 @@ fn runmatmul(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -116,7 +116,6 @@ fn runsum(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -131,7 +131,6 @@ fn runsumpool(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -118,7 +118,6 @@ fn runadd(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -117,7 +117,6 @@ fn runpow(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -104,7 +104,6 @@ fn runposeidon(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -130,7 +130,6 @@ fn runrelu(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -124,7 +124,6 @@ fn runrelu(c: &mut Criterion) {
&params,
&pk,
CheckMode::UNSAFE,
ezkl::Commitments::KZG,
None,
None,
);

View File

@@ -1,7 +1,7 @@
import ezkl
project = 'ezkl'
release = '0.0.0'
release = '23.0.4'
version = release

View File

@@ -54,7 +54,7 @@
" gip_run_args.param_scale = 19\n",
" gip_run_args.logrows = 8\n",
" run_args = ezkl.gen_settings(py_run_args=gip_run_args)\n",
" await ezkl.get_srs(commitment=ezkl.PyCommitments.KZG)\n",
" await ezkl.get_srs()\n",
" ezkl.compile_circuit()\n",
" res = ezkl.gen_witness()\n",
" print(res)\n",
@@ -127,4 +127,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}

View File

@@ -301,7 +301,7 @@
"run_args.param_scale = 0\n",
"run_args.logrows = 18\n",
"\n",
"ezkl.get_srs(logrows=run_args.logrows, commitment=ezkl.PyCommitments.KZG)\n"
"ezkl.get_srs(logrows=run_args.logrows, )\n"
]
},
{

View File

@@ -234,7 +234,7 @@
"run_args.input_scale = 2\n",
"run_args.logrows = 15\n",
"\n",
"ezkl.get_srs(logrows=run_args.logrows, commitment=ezkl.PyCommitments.KZG)"
"ezkl.get_srs(logrows=run_args.logrows, )"
]
},
{

View File

@@ -31,14 +31,6 @@ class PyRunArgs:
...
class PyCommitments(Enum):
r"""
pyclass representing an enum, denoting the type of commitment
"""
KZG = auto()
IPA = auto()
class PyInputType(Enum):
Bool = auto()
F16 = auto()
@@ -421,7 +413,6 @@ def get_srs(
settings_path: typing.Optional[str | os.PathLike | pathlib.Path],
logrows: typing.Optional[int],
srs_path: typing.Optional[str | os.PathLike | pathlib.Path],
commitment: typing.Optional[PyCommitments],
) -> typing.Any:
r"""
Gets a public srs
@@ -437,44 +428,12 @@ def get_srs(
srs_path: str
Path to the create the SRS file
commitment: str
Specify the commitment used ("kzg", "ipa")
Returns
-------
bool
"""
...
def ipa_commit(
message: typing.Sequence[str],
vk_path: str | os.PathLike | pathlib.Path,
settings_path: str | os.PathLike | pathlib.Path,
srs_path: typing.Optional[str | os.PathLike | pathlib.Path],
) -> list[PyG1Affine]:
r"""
Generate an ipa commitment.
Arguments
-------
message: list[str]
List of field elements represnted as strings
vk_path: str
Path to the verification key
settings_path: str
Path to the settings file
srs_path: str
Path to the Structure Reference String (SRS) file
Returns
-------
list[PyG1Affine]
"""
...
def kzg_commit(
message: typing.Sequence[str],
vk_path: str | os.PathLike | pathlib.Path,

View File

@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2025-05-01"
channel = "nightly-2025-12-01"
components = ["rustfmt", "clippy"]

View File

@@ -15,9 +15,7 @@ use crate::graph::{
use crate::pfsys::{
load_pk, load_vk, save_params, save_vk, srs::gen_srs as ezkl_gen_srs, srs::load_srs_prover,
};
use crate::Commitments;
use crate::RunArgs;
use halo2_proofs::poly::ipa::commitment::IPACommitmentScheme;
use halo2_proofs::poly::kzg::commitment::KZGCommitmentScheme;
use halo2curves::bn256::{Bn256, Fq, Fr, G1Affine, G1};
use pyo3::exceptions::{PyIOError, PyRuntimeError};
@@ -171,9 +169,6 @@ struct PyRunArgs {
#[pyo3(get, set)]
/// str: check mode, accepts `safe`, `unsafe`
pub check_mode: CheckMode,
#[pyo3(get, set)]
/// str: commitment type, accepts `kzg`, `ipa`
pub commitment: PyCommitments,
/// int: The base used for decomposition
#[pyo3(get, set)]
pub decomp_base: usize,
@@ -221,7 +216,6 @@ impl From<PyRunArgs> for RunArgs {
variables: py_run_args.variables,
rebase_frac_zero_constants: py_run_args.rebase_frac_zero_constants,
check_mode: py_run_args.check_mode,
commitment: Some(py_run_args.commitment.into()),
decomp_base: py_run_args.decomp_base,
decomp_legs: py_run_args.decomp_legs,
ignore_range_check_inputs_outputs: py_run_args.ignore_range_check_inputs_outputs,
@@ -249,7 +243,6 @@ impl Into<PyRunArgs> for RunArgs {
variables: self.variables,
rebase_frac_zero_constants: self.rebase_frac_zero_constants,
check_mode: self.check_mode,
commitment: self.commitment.into(),
decomp_base: self.decomp_base,
decomp_legs: self.decomp_legs,
ignore_range_check_inputs_outputs: self.ignore_range_check_inputs_outputs,
@@ -259,56 +252,6 @@ impl Into<PyRunArgs> for RunArgs {
}
}
#[pyclass]
#[derive(Debug, Clone)]
#[gen_stub_pyclass_enum]
/// pyclass representing an enum, denoting the type of commitment
pub enum PyCommitments {
/// KZG commitment
KZG,
/// IPA commitment
IPA,
}
impl From<Option<Commitments>> for PyCommitments {
fn from(commitment: Option<Commitments>) -> Self {
match commitment {
Some(Commitments::KZG) => PyCommitments::KZG,
Some(Commitments::IPA) => PyCommitments::IPA,
None => PyCommitments::KZG,
}
}
}
impl From<PyCommitments> for Commitments {
fn from(py_commitments: PyCommitments) -> Self {
match py_commitments {
PyCommitments::KZG => Commitments::KZG,
PyCommitments::IPA => Commitments::IPA,
}
}
}
impl Into<PyCommitments> for Commitments {
fn into(self) -> PyCommitments {
match self {
Commitments::KZG => PyCommitments::KZG,
Commitments::IPA => PyCommitments::IPA,
}
}
}
impl FromStr for PyCommitments {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"kzg" => Ok(PyCommitments::KZG),
"ipa" => Ok(PyCommitments::IPA),
_ => Err("Invalid value for Commitments".to_string()),
}
}
}
#[pyclass]
#[derive(Debug, Clone)]
#[gen_stub_pyclass_enum]
@@ -621,8 +564,7 @@ fn kzg_commit(
let settings = GraphSettings::load(&settings_path)
.map_err(|_| PyIOError::new_err("Failed to load circuit settings"))?;
let srs_path =
crate::execute::get_srs_path(settings.run_args.logrows, srs_path, Commitments::KZG);
let srs_path = crate::execute::get_srs_path(settings.run_args.logrows, srs_path);
let srs = load_srs_prover::<KZGCommitmentScheme<Bn256>>(srs_path)
.map_err(|_| PyIOError::new_err("Failed to load srs"))?;
@@ -639,65 +581,6 @@ fn kzg_commit(
Ok(output.iter().map(|x| (*x).into()).collect::<Vec<_>>())
}
/// Generate an ipa commitment.
///
/// Arguments
/// -------
/// message: list[str]
/// List of field elements represented as strings
///
/// vk_path: str
/// Path to the verification key
///
/// settings_path: str
/// Path to the settings file
///
/// srs_path: str
/// Path to the Structure Reference String (SRS) file
///
/// Returns
/// -------
/// list[PyG1Affine]
///
#[pyfunction(signature = (
message,
vk_path=PathBuf::from(DEFAULT_VK),
settings_path=PathBuf::from(DEFAULT_SETTINGS),
srs_path=None
))]
#[gen_stub_pyfunction]
fn ipa_commit(
message: Vec<PyFelt>,
vk_path: PathBuf,
settings_path: PathBuf,
srs_path: Option<PathBuf>,
) -> PyResult<Vec<PyG1Affine>> {
let message: Vec<Fr> = message
.iter()
.map(crate::pfsys::string_to_field::<Fr>)
.collect::<Vec<_>>();
let settings = GraphSettings::load(&settings_path)
.map_err(|_| PyIOError::new_err("Failed to load circuit settings"))?;
let srs_path =
crate::execute::get_srs_path(settings.run_args.logrows, srs_path, Commitments::IPA);
let srs = load_srs_prover::<IPACommitmentScheme<G1Affine>>(srs_path)
.map_err(|_| PyIOError::new_err("Failed to load srs"))?;
let vk = load_vk::<IPACommitmentScheme<G1Affine>, GraphCircuit>(vk_path, settings)
.map_err(|_| PyIOError::new_err("Failed to load vk"))?;
let output = PolyCommitChip::commit::<IPACommitmentScheme<G1Affine>>(
message,
(vk.cs().blinding_factors() + 1) as u32,
&srs,
);
Ok(output.iter().map(|x| (*x).into()).collect::<Vec<_>>())
}
/// Swap the commitments in a proof
///
/// Arguments
@@ -825,8 +708,6 @@ fn gen_srs(srs_path: PathBuf, logrows: usize) -> PyResult<()> {
/// srs_path: str
/// Path to the create the SRS file
///
/// commitment: str
/// Specify the commitment used ("kzg", "ipa")
///
/// Returns
/// -------
@@ -836,7 +717,6 @@ fn gen_srs(srs_path: PathBuf, logrows: usize) -> PyResult<()> {
settings_path=PathBuf::from(DEFAULT_SETTINGS),
logrows=None,
srs_path=None,
commitment=None,
))]
#[gen_stub_pyfunction]
fn get_srs(
@@ -844,15 +724,9 @@ fn get_srs(
settings_path: Option<PathBuf>,
logrows: Option<u32>,
srs_path: Option<PathBuf>,
commitment: Option<PyCommitments>,
) -> PyResult<Bound<'_, PyAny>> {
let commitment: Option<Commitments> = match commitment {
Some(c) => Some(c.into()),
None => None,
};
pyo3_async_runtimes::tokio::future_into_py(py, async move {
crate::execute::get_srs_cmd(srs_path, settings_path, logrows, commitment)
crate::execute::get_srs_cmd(srs_path, settings_path, logrows)
.await
.map_err(|e| {
let err_str = format!("Failed to get srs: {}", e);
@@ -1046,18 +920,19 @@ fn calibrate_settings(
))]
#[gen_stub_pyfunction]
fn gen_witness(
py: Python<'_>,
data: String,
model: PathBuf,
output: Option<PathBuf>,
vk_path: Option<PathBuf>,
srs_path: Option<PathBuf>,
) -> PyResult<PyObject> {
) -> PyResult<Py<PyAny>> {
let output =
crate::execute::gen_witness(model, data, output, vk_path, srs_path).map_err(|e| {
let err_str = format!("Failed to generate witness: {}", e);
PyRuntimeError::new_err(err_str)
})?;
Python::with_gil(|py| Ok(output.into_pyobject(py).unwrap().into()))
Ok(output.into_pyobject(py).unwrap().unbind())
}
/// Mocks the prover
@@ -1179,12 +1054,13 @@ fn setup(
))]
#[gen_stub_pyfunction]
fn prove(
py: Python<'_>,
witness: PathBuf,
model: PathBuf,
pk_path: PathBuf,
proof_path: Option<PathBuf>,
srs_path: Option<PathBuf>,
) -> PyResult<PyObject> {
) -> PyResult<Py<PyAny>> {
let snark = crate::execute::prove(
witness,
model,
@@ -1198,7 +1074,7 @@ fn prove(
PyRuntimeError::new_err(err_str)
})?;
Python::with_gil(|py| Ok(snark.into_pyobject(py).unwrap().into()))
Ok(snark.into_pyobject(py).unwrap().unbind())
}
/// Verifies a given proof
@@ -1602,14 +1478,12 @@ fn ezkl(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<PyG1Affine>()?;
m.add_class::<PyG1>()?;
m.add_class::<PyTestDataSource>()?;
m.add_class::<PyCommitments>()?;
m.add_class::<PyInputType>()?;
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
m.add_function(wrap_pyfunction!(felt_to_big_endian, m)?)?;
m.add_function(wrap_pyfunction!(felt_to_int, m)?)?;
m.add_function(wrap_pyfunction!(felt_to_float, m)?)?;
m.add_function(wrap_pyfunction!(kzg_commit, m)?)?;
m.add_function(wrap_pyfunction!(ipa_commit, m)?)?;
m.add_function(wrap_pyfunction!(swap_proof_commitments, m)?)?;
m.add_function(wrap_pyfunction!(poseidon_hash, m)?)?;
m.add_function(wrap_pyfunction!(float_to_felt, m)?)?;

View File

@@ -102,9 +102,11 @@ impl<'py> IntoPyObject<'py> for CheckMode {
#[cfg(feature = "python-bindings")]
/// Obtains CheckMode from PyObject (Required for CheckMode to be compatible with Python)
impl<'source> FromPyObject<'source> for CheckMode {
fn extract_bound(ob: &pyo3::Bound<'source, pyo3::PyAny>) -> PyResult<Self> {
let trystr = String::extract_bound(ob)?;
impl<'py> FromPyObject<'_, 'py> for CheckMode {
type Error = pyo3::PyErr;
fn extract(ob: pyo3::Borrowed<'_, 'py, pyo3::PyAny>) -> Result<Self, Self::Error> {
let trystr = String::extract(ob)?;
match trystr.to_lowercase().as_str() {
"safe" => Ok(CheckMode::SAFE),
"unsafe" => Ok(CheckMode::UNSAFE),

View File

@@ -6229,9 +6229,9 @@ pub(crate) fn recompose<F: PrimeField + TensorType + PartialOrd + std::hash::Has
(0..num_first_dims)
.flat_map(|_| {
(0..n).rev().map(|x| {
let base = (*base).checked_pow(x as u32);
let base = (*base as IntegerRep).checked_pow(x as u32);
if let Some(base) = base {
Ok(ValType::Constant(integer_rep_to_felt(base as IntegerRep)))
Ok(ValType::Constant(integer_rep_to_felt(base)))
} else {
Err(CircuitError::DecompositionBaseOverflow)
}
@@ -6341,9 +6341,9 @@ pub(crate) fn decompose<F: PrimeField + TensorType + PartialOrd + std::hash::Has
(0..input.len())
.flat_map(|_| {
(0..*n).rev().map(|x| {
let base = (*base).checked_pow(x as u32);
let base = (*base as IntegerRep).checked_pow(x as u32);
if let Some(base) = base {
Ok(ValType::Constant(integer_rep_to_felt(base as IntegerRep)))
Ok(ValType::Constant(integer_rep_to_felt(base)))
} else {
Err(CircuitError::DecompositionBaseOverflow)
}

View File

@@ -359,7 +359,6 @@ mod matmul_col_ultra_overflow_double_col {
&pk,
// use safe mode to verify that the proof is correct
CheckMode::SAFE,
crate::Commitments::KZG,
None,
None,
);
@@ -479,7 +478,6 @@ mod matmul_col_ultra_overflow {
&pk,
// use safe mode to verify that the proof is correct
CheckMode::SAFE,
crate::Commitments::KZG,
None,
None,
);
@@ -1296,7 +1294,6 @@ mod conv_col_ultra_overflow {
&pk,
// use safe mode to verify that the proof is correct
CheckMode::SAFE,
crate::Commitments::KZG,
None,
None,
);
@@ -1464,7 +1461,6 @@ mod conv_relu_col_ultra_overflow {
&params,
&pk,
CheckMode::SAFE,
crate::Commitments::KZG,
// use safe mode to verify that the proof is correct
None,
None,
@@ -2639,7 +2635,6 @@ mod lookup_ultra_overflow {
&pk,
// use safe mode to verify that the proof is correct
CheckMode::SAFE,
crate::Commitments::KZG,
None,
None,
);

View File

@@ -9,7 +9,7 @@ use std::path::PathBuf;
use std::str::FromStr;
use tosubcommand::{ToFlags, ToSubcommand};
use crate::{Commitments, RunArgs};
use crate::RunArgs;
use crate::circuit::CheckMode;
@@ -238,9 +238,11 @@ impl<'py> IntoPyObject<'py> for CalibrationTarget {
#[cfg(feature = "python-bindings")]
/// Obtains CalibrationTarget from PyObject (Required for CalibrationTarget to be compatible with Python)
impl<'source> FromPyObject<'source> for CalibrationTarget {
fn extract_bound(ob: &pyo3::Bound<'source, pyo3::PyAny>) -> PyResult<Self> {
let strval = String::extract_bound(ob)?;
impl<'py> FromPyObject<'_, 'py> for CalibrationTarget {
type Error = pyo3::PyErr;
fn extract(ob: pyo3::Borrowed<'_, 'py, pyo3::PyAny>) -> Result<Self, Self::Error> {
let strval = String::extract(ob)?;
match strval.to_lowercase().as_str() {
"resources" => Ok(CalibrationTarget::Resources {
col_overflow: false,
@@ -270,9 +272,11 @@ impl<'py> IntoPyObject<'py> for ContractType {
#[cfg(feature = "python-bindings")]
/// Obtains ContractType from PyObject (Required for ContractType to be compatible with Python)
impl<'source> FromPyObject<'source> for ContractType {
fn extract_bound(ob: &pyo3::Bound<'source, pyo3::PyAny>) -> PyResult<Self> {
let strval = String::extract_bound(ob)?;
impl<'py> FromPyObject<'_, 'py> for ContractType {
type Error = pyo3::PyErr;
fn extract(ob: pyo3::Borrowed<'_, 'py, pyo3::PyAny>) -> Result<Self, Self::Error> {
let strval = String::extract(ob)?;
match strval.to_lowercase().as_str() {
"verifier" => Ok(ContractType::Verifier { reusable: false }),
"verifier/reusable" => Ok(ContractType::Verifier { reusable: true }),
@@ -492,9 +496,6 @@ pub enum Commands {
/// number of logrows to use for srs
#[arg(long, value_hint = clap::ValueHint::Other)]
logrows: usize,
/// commitment used
#[arg(long, default_value = DEFAULT_COMMITMENT, value_hint = clap::ValueHint::Other)]
commitment: Option<Commitments>,
},
/// Gets an SRS from a circuit settings file.
@@ -509,9 +510,6 @@ pub enum Commands {
/// Number of logrows to use for srs. Overrides settings_path if specified.
#[arg(long, default_value = None, value_hint = clap::ValueHint::Other)]
logrows: Option<u32>,
/// Commitment used
#[arg(long, default_value = None, value_hint = clap::ValueHint::Other)]
commitment: Option<Commitments>,
},
/// Loads model and input and runs mock prover (for testing)
Mock {

View File

@@ -4,31 +4,26 @@ use alloy::core::primitives::Address as H160;
use alloy::core::primitives::Bytes;
use alloy::core::primitives::I256;
use alloy::dyn_abi::abi::TokenSeq;
// use alloy::providers::Middleware;
use alloy::json_abi::JsonAbi;
use alloy::network::{Ethereum, EthereumWallet};
use alloy::primitives::ruint::ParseError;
use alloy::primitives::ParseSignedError;
use alloy::providers::fillers::{
ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, SignerFiller,
};
use alloy::providers::network::{Ethereum, EthereumSigner};
use alloy::providers::ProviderBuilder;
use alloy::providers::{Identity, Provider, RootProvider};
use alloy::rpc::types::eth::TransactionInput;
use alloy::rpc::types::eth::TransactionRequest;
use alloy::providers::Provider;
use alloy::rpc::types::TransactionInput;
use alloy::rpc::types::TransactionRequest;
use alloy::signers::k256::ecdsa;
use alloy::signers::wallet::{LocalWallet, WalletError};
use alloy::signers::local::{PrivateKeySigner, LocalSignerError};
use alloy::transports::http::Http;
use alloy::transports::{RpcError, TransportErrorKind};
use foundry_compilers::artifacts::Settings as SolcSettings;
use foundry_compilers::error::{SolcError, SolcIoError};
use foundry_compilers::Solc;
use foundry_compilers::solc::Solc;
use halo2_solidity_verifier::encode_register_vk_calldata;
use halo2curves::bn256::{Fr, G1Affine};
use log::{debug, info, warn};
use reqwest::Client;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
const ANVIL_DEFAULT_PRIVATE_KEY: &str =
@@ -52,8 +47,10 @@ pub enum EthError {
Transport(#[from] RpcError<TransportErrorKind>),
#[error("a contract error occurred: {0}")]
Contract(#[from] alloy::contract::Error),
#[error("a pending transaction error occurred: {0}")]
PendingTransaction(#[from] alloy::providers::PendingTransactionError),
#[error("a wallet error occurred: {0}")]
Wallet(#[from] WalletError),
Wallet(#[from] LocalSignerError),
#[error("failed to parse url {0}")]
UrlParse(String),
#[error("Private key must be in hex format, 64 chars, without 0x prefix")]
@@ -102,49 +99,57 @@ pub enum EthError {
}
pub type EthersClient = Arc<
FillProvider<
JoinFill<
JoinFill<JoinFill<JoinFill<Identity, GasFiller>, NonceFiller>, ChainIdFiller>,
SignerFiller<EthereumSigner>,
alloy::providers::fillers::FillProvider<
alloy::providers::fillers::JoinFill<
alloy::providers::fillers::JoinFill<
alloy::providers::fillers::JoinFill<
alloy::providers::fillers::JoinFill<
alloy::providers::Identity,
alloy::providers::fillers::GasFiller,
>,
alloy::providers::fillers::NonceFiller,
>,
alloy::providers::fillers::ChainIdFiller,
>,
alloy::providers::fillers::WalletFiller<EthereumWallet>,
>,
RootProvider<Http<Client>>,
alloy::providers::RootProvider<Http<Client>>,
Http<Client>,
Ethereum,
>,
>;
pub type ContractFactory<M> = CallBuilder<Http<Client>, Arc<M>, ()>;
pub type ContractFactory<M> = CallBuilder<Arc<M>, (), Ethereum>;
/// Return an instance of Anvil and a client for the given RPC URL. If none is provided, a local client is used.
pub async fn setup_eth_backend(
rpc_url: &str,
private_key: Option<&str>,
) -> Result<(EthersClient, alloy::primitives::Address), EthError> {
) -> Result<(Arc<impl Provider + Clone>, alloy::primitives::Address), EthError> {
// Launch anvil
let endpoint = rpc_url.to_string();
// Instantiate the wallet
let wallet: LocalWallet;
let signer: PrivateKeySigner;
if let Some(private_key) = private_key {
debug!("using private key {}", private_key);
if private_key.len() != 64 {
return Err(EthError::PrivateKeyFormat);
}
let private_key_buffer = hex::decode(private_key)?;
wallet = LocalWallet::from_slice(&private_key_buffer)?;
signer = PrivateKeySigner::from_slice(&private_key_buffer)?;
} else {
wallet = LocalWallet::from_str(ANVIL_DEFAULT_PRIVATE_KEY)?;
signer = ANVIL_DEFAULT_PRIVATE_KEY.parse()?;
}
let wallet_address = wallet.address();
let wallet_address = signer.address();
let wallet = EthereumWallet::from(signer);
// Connect to the network
let client = Arc::new(
ProviderBuilder::new()
.with_recommended_fillers()
.signer(EthereumSigner::from(wallet))
.on_http(endpoint.parse().map_err(|_| EthError::UrlParse(endpoint))?),
.wallet(wallet)
.connect_http(endpoint.parse().map_err(|_| EthError::UrlParse(endpoint))?),
);
let chain_id = client.get_chain_id().await?;
@@ -194,7 +199,7 @@ pub async fn register_vka_via_rv(
let tx = TransactionRequest::default().to(rv_address).input(input);
debug!("transaction {:#?}", tx);
let result = client.call(&tx).await;
let result = client.call(tx.clone()).await;
if let Err(e) = result {
return Err(EthError::EvmVerificationError(e.to_string()).into());
@@ -204,7 +209,7 @@ pub async fn register_vka_via_rv(
// decode return bytes value into uint8
let output = result.to_vec();
let gas = client.estimate_gas(&tx).await?;
let gas = client.estimate_gas(tx.clone()).await?;
info!("estimated vka registration cost: {:#?}", gas);
@@ -215,11 +220,11 @@ pub async fn register_vka_via_rv(
result.watch().await?;
// if gas is greater than 30 million warn the user that the gas cost is above ethereum's 30 million block gas limit
if gas > 30_000_000_u128 {
if gas > 30_000_000_u64 {
warn!(
"Gas cost of verify transaction is greater than 30 million block gas limit. It will fail on mainnet."
);
} else if gas > 15_000_000_u128 {
} else if gas > 15_000_000_u64 {
warn!(
"Gas cost of verify transaction is greater than 15 million, the target block size for ethereum"
);
@@ -266,7 +271,7 @@ pub async fn verify_proof_via_solidity(
let tx = TransactionRequest::default().to(addr).input(input);
debug!("transaction {:#?}", tx);
let result = client.call(&tx).await;
let result = client.call(tx.clone()).await;
if let Err(e) = result {
return Err(EthError::EvmVerificationError(e.to_string()).into());
@@ -291,7 +296,7 @@ pub async fn verify_proof_via_solidity(
if !scaled_matches(inst, exp) {
return Err(EthError::RescaleCheckError(RescaleCheckError::Mismatch {
idx,
expected: exp.clone(),
expected: exp.to_string(),
got: to_decimal_18(inst),
}));
}
@@ -308,16 +313,16 @@ pub async fn verify_proof_via_solidity(
return Err(EthError::EvmVerificationError("Invalid proof".into()));
}
let gas = client.estimate_gas(&tx).await?;
let gas = client.estimate_gas(tx.clone()).await?;
info!("estimated verify gas cost: {:#?}", gas);
// if gas is greater than 30 million warn the user that the gas cost is above ethereum's 30 million block gas limit
if gas > 30_000_000_u128 {
if gas > 30_000_000_u64 {
warn!(
"Gas cost of verify transaction is greater than 30 million block gas limit. It will fail on mainnet."
);
} else if gas > 15_000_000_u128 {
} else if gas > 15_000_000_u64 {
warn!(
"Gas cost of verify transaction is greater than 15 million, the target block size for ethereum"
);
@@ -327,7 +332,7 @@ pub async fn verify_proof_via_solidity(
}
/// Generates the contract factory for a solidity verifier. The factory is used to deploy the contract
fn get_sol_contract_factory<'a, M: 'static + Provider<Http<Client>, Ethereum>, T: TokenSeq<'a>>(
fn get_sol_contract_factory<'a, M: 'static + Provider, T: TokenSeq<'a>>(
abi: JsonAbi,
bytecode: Bytes,
runtime_bytecode: Bytes,
@@ -365,7 +370,7 @@ fn get_sol_contract_factory<'a, M: 'static + Provider<Http<Client>, Ethereum>, T
}
};
Ok(CallBuilder::new_raw_deploy(client, data))
Ok(CallBuilder::<_, _, Ethereum>::new_raw_deploy(client, data))
}
/// Compiles a solidity verifier contract and returns the abi, bytecode, and runtime bytecode
@@ -374,11 +379,12 @@ pub async fn get_contract_artifacts(
contract_name: &str,
runs: usize,
) -> Result<(JsonAbi, Bytes, Bytes), EthError> {
use foundry_compilers::{
artifacts::{output_selection::OutputSelection, Optimizer},
compilers::CompilerInput,
SolcInput, SHANGHAI_SOLC,
use foundry_compilers::artifacts::{
output_selection::OutputSelection, Optimizer, SolcInput, SolcLanguage,
};
use semver::Version;
const SHANGHAI_SOLC: Version = Version::new(0, 8, 20);
if !sol_code_path.exists() {
return Err(EthError::ContractNotFound(
@@ -396,16 +402,14 @@ pub async fn get_contract_artifacts(
..Default::default()
};
let input = SolcInput::build(
std::collections::BTreeMap::from([(
sol_code_path.clone(),
foundry_compilers::artifacts::Source::read(sol_code_path)?,
)]),
settings,
&SHANGHAI_SOLC,
);
let sources = foundry_compilers::artifacts::Sources::from([(
sol_code_path.clone(),
foundry_compilers::artifacts::Source::read(&sol_code_path)?,
)]);
let solc_opt = Solc::find_svm_installed_version(SHANGHAI_SOLC.to_string())?;
let input = SolcInput::new(SolcLanguage::Solidity, sources, settings).sanitized(&SHANGHAI_SOLC);
let solc_opt = Solc::find_svm_installed_version(&SHANGHAI_SOLC)?;
let solc = match solc_opt {
Some(solc) => solc,
None => {
@@ -416,7 +420,7 @@ pub async fn get_contract_artifacts(
}
};
let compiled: foundry_compilers::CompilerOutput = solc.compile(&input[0])?;
let compiled = solc.compile(&input)?;
let (abi, bytecode, runtime_bytecode) = match compiled.find(contract_name) {
Some(c) => c.into_parts_or_default(),

View File

@@ -10,15 +10,15 @@ use crate::eth::register_vka_via_rv;
use crate::eth::{get_contract_artifacts, verify_proof_via_solidity};
use crate::graph::input::GraphData;
use crate::graph::{GraphCircuit, GraphSettings, GraphWitness, Model};
use crate::pfsys::{create_keys, load_pk, load_vk, save_params, save_pk, Snark};
use crate::pfsys::{
create_proof_circuit, swap_proof_commitments_polycommit, verify_proof_circuit, ProofSplitCommit,
create_keys, load_pk, load_vk, save_params, save_pk, swap_proof_commitments, Snark,
};
use crate::pfsys::{create_proof_circuit, verify_proof_circuit, ProofSplitCommit};
use crate::pfsys::{encode_calldata, save_vk, srs::*};
use crate::tensor::TensorError;
use crate::RunArgs;
use crate::EZKL_BUF_CAPACITY;
use crate::{commands::*, EZKLError};
use crate::{Commitments, RunArgs};
use colored::Colorize;
#[cfg(unix)]
use gag::Gag;
@@ -28,9 +28,7 @@ use halo2_proofs::icicle::try_load_and_set_backend_device;
use halo2_proofs::plonk::{self, Circuit};
use halo2_proofs::poly::commitment::Verifier;
use halo2_proofs::poly::commitment::{CommitmentScheme, Params};
use halo2_proofs::poly::ipa::commitment::{IPACommitmentScheme, ParamsIPA};
use halo2_proofs::poly::ipa::multiopen::{ProverIPA, VerifierIPA};
use halo2_proofs::poly::ipa::strategy::SingleStrategy as IPASingleStrategy;
use halo2_proofs::poly::kzg::commitment::KZGCommitmentScheme;
use halo2_proofs::poly::kzg::multiopen::{ProverSHPLONK, VerifierSHPLONK};
use halo2_proofs::poly::kzg::{
@@ -62,7 +60,6 @@ use std::io::Cursor;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use std::str::FromStr;
use std::time::Duration;
use tabled::Tabled;
use thiserror::Error;
@@ -128,21 +125,12 @@ pub async fn run(command: Commands) -> Result<String, EZKLError> {
match command {
#[cfg(feature = "empty-cmd")]
Commands::Empty => Ok(String::new()),
Commands::GenSrs {
srs_path,
logrows,
commitment,
} => gen_srs_cmd(
srs_path,
logrows as u32,
commitment.unwrap_or_else(|| Commitments::from_str(DEFAULT_COMMITMENT).unwrap()),
),
Commands::GenSrs { srs_path, logrows } => gen_srs_cmd(srs_path, logrows as u32),
Commands::GetSrs {
srs_path,
settings_path,
logrows,
commitment,
} => get_srs_cmd(srs_path, settings_path, logrows, commitment).await,
} => get_srs_cmd(srs_path, settings_path, logrows).await,
Commands::Table { model, args } => table(model.unwrap_or(DEFAULT_MODEL.into()), args),
Commands::GenSettings {
model,
@@ -448,39 +436,24 @@ fn update_ezkl_binary(version: &Option<String>) -> Result<String, EZKLError> {
}
/// Get the srs path
pub fn get_srs_path(logrows: u32, srs_path: Option<PathBuf>, commitment: Commitments) -> PathBuf {
pub fn get_srs_path(logrows: u32, srs_path: Option<PathBuf>) -> PathBuf {
if let Some(srs_path) = srs_path {
srs_path
} else {
if !Path::new(&*EZKL_SRS_REPO_PATH).exists() {
std::fs::create_dir_all(&*EZKL_SRS_REPO_PATH).unwrap();
}
match commitment {
Commitments::KZG => Path::new(&*EZKL_SRS_REPO_PATH).join(format!("kzg{}.srs", logrows)),
Commitments::IPA => Path::new(&*EZKL_SRS_REPO_PATH).join(format!("ipa{}.srs", logrows)),
}
Path::new(&*EZKL_SRS_REPO_PATH).join(format!("kzg{}.srs", logrows))
}
}
fn srs_exists_check(logrows: u32, srs_path: Option<PathBuf>, commitment: Commitments) -> bool {
Path::new(&get_srs_path(logrows, srs_path, commitment)).exists()
fn srs_exists_check(logrows: u32, srs_path: Option<PathBuf>) -> bool {
Path::new(&get_srs_path(logrows, srs_path)).exists()
}
pub(crate) fn gen_srs_cmd(
srs_path: PathBuf,
logrows: u32,
commitment: Commitments,
) -> Result<String, EZKLError> {
match commitment {
Commitments::KZG => {
let params = gen_srs::<KZGCommitmentScheme<Bn256>>(logrows);
save_params::<KZGCommitmentScheme<Bn256>>(&srs_path, &params)?;
}
Commitments::IPA => {
let params = gen_srs::<IPACommitmentScheme<G1Affine>>(logrows);
save_params::<IPACommitmentScheme<G1Affine>>(&srs_path, &params)?;
}
}
pub(crate) fn gen_srs_cmd(srs_path: PathBuf, logrows: u32) -> Result<String, EZKLError> {
let params = gen_srs::<KZGCommitmentScheme<Bn256>>(logrows);
save_params::<KZGCommitmentScheme<Bn256>>(&srs_path, &params)?;
Ok(String::new())
}
@@ -521,12 +494,8 @@ pub(crate) fn get_file_hash(path: &PathBuf) -> Result<String, EZKLError> {
Ok(hash)
}
fn check_srs_hash(
logrows: u32,
srs_path: Option<PathBuf>,
commitment: Commitments,
) -> Result<String, EZKLError> {
let path = get_srs_path(logrows, srs_path, commitment);
fn check_srs_hash(logrows: u32, srs_path: Option<PathBuf>) -> Result<String, EZKLError> {
let path = get_srs_path(logrows, srs_path);
let hash = get_file_hash(&path)?;
let predefined_hash = match crate::srs_sha::PUBLIC_SRS_SHA256_HASHES.get(&logrows) {
@@ -550,7 +519,6 @@ pub(crate) async fn get_srs_cmd(
srs_path: Option<PathBuf>,
settings_path: Option<PathBuf>,
logrows: Option<u32>,
commitment: Option<Commitments>,
) -> Result<String, EZKLError> {
// logrows overrides settings
@@ -569,53 +537,33 @@ pub(crate) async fn get_srs_cmd(
return Err(err_string.into());
};
let commitment = if let Some(c) = commitment {
c
} else if let Some(settings_p) = settings_path {
if settings_p.exists() {
let settings = GraphSettings::load(&settings_p)?;
settings.run_args.commitment.into()
} else {
return Err(err_string.into());
}
} else {
return Err(err_string.into());
};
if !srs_exists_check(k, srs_path.clone()) {
info!("SRS does not exist, downloading...");
let srs_uri = format!("{}{}", PUBLIC_SRS_URL, k);
let mut reader = Cursor::new(fetch_srs(&srs_uri).await?);
// check the SRS
let pb = init_spinner();
pb.set_message("Validating SRS (this may take a while) ...");
let params = ParamsKZG::<Bn256>::read(&mut reader)?;
pb.finish_with_message("SRS validated.");
if !srs_exists_check(k, srs_path.clone(), commitment) {
if matches!(commitment, Commitments::KZG) {
info!("SRS does not exist, downloading...");
let srs_uri = format!("{}{}", PUBLIC_SRS_URL, k);
let mut reader = Cursor::new(fetch_srs(&srs_uri).await?);
// check the SRS
let pb = init_spinner();
pb.set_message("Validating SRS (this may take a while) ...");
let params = ParamsKZG::<Bn256>::read(&mut reader)?;
pb.finish_with_message("SRS validated.");
info!("Saving SRS to disk...");
let computed_srs_path = get_srs_path(k, srs_path.clone());
let mut file = std::fs::File::create(&computed_srs_path)?;
let mut buffer = BufWriter::with_capacity(*EZKL_BUF_CAPACITY, &mut file);
params.write(&mut buffer)?;
info!("Saving SRS to disk...");
let computed_srs_path = get_srs_path(k, srs_path.clone(), commitment);
let mut file = std::fs::File::create(&computed_srs_path)?;
let mut buffer = BufWriter::with_capacity(*EZKL_BUF_CAPACITY, &mut file);
params.write(&mut buffer)?;
info!(
"Saved SRS to {}.",
computed_srs_path.as_os_str().to_str().unwrap_or("disk")
);
info!(
"Saved SRS to {}.",
computed_srs_path.as_os_str().to_str().unwrap_or("disk")
);
info!("SRS downloaded");
} else {
let path = get_srs_path(k, srs_path.clone(), commitment);
gen_srs_cmd(path, k, commitment)?;
}
info!("SRS downloaded");
} else {
info!("SRS already exists at that path");
};
// check the hash
if matches!(commitment, Commitments::KZG) {
check_srs_hash(k, srs_path.clone(), commitment)?;
}
check_srs_hash(k, srs_path.clone())?;
Ok(String::new())
}
@@ -654,43 +602,22 @@ pub(crate) fn gen_witness(
// if any of the settings have kzg visibility then we need to load the srs
let commitment: Commitments = settings.run_args.commitment.into();
let region_settings =
RegionSettings::all_true(settings.run_args.decomp_base, settings.run_args.decomp_legs);
let start_time = Instant::now();
let witness = if settings.module_requires_polycommit() {
if get_srs_path(settings.run_args.logrows, srs_path.clone(), commitment).exists() {
match Commitments::from(settings.run_args.commitment) {
Commitments::KZG => {
let srs: ParamsKZG<Bn256> = load_params_prover::<KZGCommitmentScheme<Bn256>>(
srs_path.clone(),
settings.run_args.logrows,
commitment,
)?;
circuit.forward::<KZGCommitmentScheme<_>>(
&mut input,
vk.as_ref(),
Some(&srs),
region_settings,
)?
}
Commitments::IPA => {
let srs: ParamsIPA<G1Affine> =
load_params_prover::<IPACommitmentScheme<G1Affine>>(
srs_path.clone(),
settings.run_args.logrows,
commitment,
)?;
circuit.forward::<IPACommitmentScheme<_>>(
&mut input,
vk.as_ref(),
Some(&srs),
region_settings,
)?
}
}
if get_srs_path(settings.run_args.logrows, srs_path.clone()).exists() {
let srs: ParamsKZG<Bn256> = load_params_prover::<KZGCommitmentScheme<Bn256>>(
srs_path.clone(),
settings.run_args.logrows,
)?;
circuit.forward::<KZGCommitmentScheme<_>>(
&mut input,
vk.as_ref(),
Some(&srs),
region_settings,
)?
} else {
warn!("SRS for poly commit does not exist (will be ignored)");
circuit.forward::<KZGCommitmentScheme<Bn256>>(
@@ -1386,12 +1313,8 @@ pub(crate) async fn create_evm_verifier(
reusable: bool,
) -> Result<String, EZKLError> {
let settings = GraphSettings::load(&settings_path)?;
let commitment: Commitments = settings.run_args.commitment.into();
let params = load_params_verifier::<KZGCommitmentScheme<Bn256>>(
srs_path,
settings.run_args.logrows,
commitment,
)?;
let params =
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, settings.run_args.logrows)?;
let num_instance = settings.total_instances();
// create a scales array that is the same length as the number of instances, all populated with 0
@@ -1436,12 +1359,8 @@ pub(crate) async fn create_evm_vka(
) -> Result<String, EZKLError> {
log::warn!("Reusable verifier support is experimental and may change in the future. Use at your own risk.");
let settings = GraphSettings::load(&settings_path)?;
let commitment: Commitments = settings.run_args.commitment.into();
let params = load_params_verifier::<KZGCommitmentScheme<Bn256>>(
srs_path,
settings.run_args.logrows,
commitment,
)?;
let params =
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, settings.run_args.logrows)?;
let num_poseidon_instance = settings.module_sizes.num_instances().iter().sum::<usize>();
let num_fixed_point_instance = settings
@@ -1554,7 +1473,7 @@ pub(crate) fn encode_evm_calldata(
calldata_path: PathBuf,
vka_path: Option<PathBuf>,
) -> Result<Vec<u8>, EZKLError> {
let snark = Snark::load::<IPACommitmentScheme<G1Affine>>(&proof_path)?;
let snark = Snark::load::<KZGCommitmentScheme<Bn256>>(&proof_path)?;
let flattened_instances = snark.instances.into_iter().flatten();
@@ -1639,34 +1558,14 @@ pub(crate) fn setup(
}
let logrows = circuit.settings().run_args.logrows;
let commitment: Commitments = circuit.settings().run_args.commitment.into();
let pk = match commitment {
Commitments::KZG => {
let params = load_params_prover::<KZGCommitmentScheme<Bn256>>(
srs_path,
logrows,
Commitments::KZG,
)?;
create_keys::<KZGCommitmentScheme<Bn256>, GraphCircuit>(
&circuit,
&params,
disable_selector_compression,
)?
}
Commitments::IPA => {
let params = load_params_prover::<IPACommitmentScheme<G1Affine>>(
srs_path,
logrows,
Commitments::IPA,
)?;
create_keys::<IPACommitmentScheme<G1Affine>, GraphCircuit>(
&circuit,
&params,
disable_selector_compression,
)?
}
};
let params = load_params_prover::<KZGCommitmentScheme<Bn256>>(srs_path, logrows)?;
let pk = create_keys::<KZGCommitmentScheme<Bn256>, GraphCircuit>(
&circuit,
&params,
disable_selector_compression,
)?;
save_vk::<G1Affine>(&vk_path, pk.get_vk())?;
save_pk::<G1Affine>(&pk_path, &pk)?;
Ok(String::new())
@@ -1693,69 +1592,30 @@ pub(crate) fn prove(
let proof_split_commits: Option<ProofSplitCommit> = data.into();
let commitment = circuit_settings.run_args.commitment.into();
let logrows = circuit_settings.run_args.logrows;
// creates and verifies the proof
let mut snark = match commitment {
Commitments::KZG => {
let pk =
load_pk::<KZGCommitmentScheme<Bn256>, GraphCircuit>(pk_path, circuit.params())?;
let params = load_params_prover::<KZGCommitmentScheme<Bn256>>(
srs_path,
logrows,
Commitments::KZG,
)?;
create_proof_circuit::<
KZGCommitmentScheme<Bn256>,
_,
ProverSHPLONK<_>,
VerifierSHPLONK<_>,
KZGSingleStrategy<_>,
_,
EvmTranscript<_, _, _, _>,
EvmTranscript<_, _, _, _>,
>(
circuit,
vec![public_inputs],
&params,
&pk,
check_mode,
commitment,
proof_split_commits,
None,
)
}
Commitments::IPA => {
let pk =
load_pk::<IPACommitmentScheme<G1Affine>, GraphCircuit>(pk_path, circuit.params())?;
let pk = load_pk::<KZGCommitmentScheme<Bn256>, GraphCircuit>(pk_path, circuit.params())?;
let params = load_params_prover::<IPACommitmentScheme<G1Affine>>(
srs_path,
circuit_settings.run_args.logrows,
Commitments::IPA,
)?;
create_proof_circuit::<
IPACommitmentScheme<G1Affine>,
_,
ProverIPA<_>,
VerifierIPA<_>,
IPASingleStrategy<_>,
_,
EvmTranscript<_, _, _, _>,
EvmTranscript<_, _, _, _>,
>(
circuit,
vec![public_inputs],
&params,
&pk,
check_mode,
commitment,
proof_split_commits,
None,
)
}
}?;
let params = load_params_prover::<KZGCommitmentScheme<Bn256>>(srs_path, logrows)?;
let mut snark = create_proof_circuit::<
KZGCommitmentScheme<Bn256>,
_,
ProverSHPLONK<_>,
VerifierSHPLONK<_>,
KZGSingleStrategy<_>,
_,
EvmTranscript<_, _, _, _>,
EvmTranscript<_, _, _, _>,
>(
circuit,
vec![public_inputs],
&params,
&pk,
check_mode,
proof_split_commits,
None,
)?;
snark.pretty_public_inputs = pretty_public_inputs;
@@ -1774,7 +1634,11 @@ pub(crate) fn swap_proof_commitments_cmd(
let witness = GraphWitness::from_path(witness)?;
let commitments = witness.get_polycommitments();
let snark_new = swap_proof_commitments_polycommit(&snark, &commitments)?;
let snark_new = swap_proof_commitments::<
KZGCommitmentScheme<Bn256>,
_,
EvmTranscript<G1Affine, _, _, _>,
>(&snark, &commitments)?;
if snark_new.proof != *snark.proof {
log::warn!("swap proof has created a different proof");
@@ -1794,51 +1658,23 @@ pub(crate) fn verify(
let circuit_settings = GraphSettings::load(&settings_path)?;
let logrows = circuit_settings.run_args.logrows;
let commitment = circuit_settings.run_args.commitment.into();
match commitment {
Commitments::KZG => {
let params: ParamsKZG<Bn256> = if reduced_srs {
// only need G_0 for the verification with shplonk
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, 1, Commitments::KZG)?
} else {
load_params_verifier::<KZGCommitmentScheme<Bn256>>(
srs_path,
logrows,
Commitments::KZG,
)?
};
{
verify_commitment::<
KZGCommitmentScheme<Bn256>,
VerifierSHPLONK<'_, Bn256>,
_,
KZGSingleStrategy<_>,
EvmTranscript<G1Affine, _, _, _>,
GraphCircuit,
_,
>(proof_path, circuit_settings, vk_path, &params, logrows)
}
}
Commitments::IPA => {
let params: ParamsIPA<_> = load_params_verifier::<IPACommitmentScheme<G1Affine>>(
srs_path,
logrows,
Commitments::IPA,
)?;
{
verify_commitment::<
IPACommitmentScheme<G1Affine>,
VerifierIPA<_>,
_,
IPASingleStrategy<_>,
EvmTranscript<G1Affine, _, _, _>,
GraphCircuit,
_,
>(proof_path, circuit_settings, vk_path, &params, logrows)
}
}
}
let params: ParamsKZG<Bn256> = if reduced_srs {
// only need G_0 for the verification with shplonk
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, 1)?
} else {
load_params_verifier::<KZGCommitmentScheme<Bn256>>(srs_path, logrows)?
};
verify_commitment::<
KZGCommitmentScheme<Bn256>,
VerifierSHPLONK<'_, Bn256>,
_,
KZGSingleStrategy<_>,
EvmTranscript<G1Affine, _, _, _>,
GraphCircuit,
_,
>(proof_path, circuit_settings, vk_path, &params, logrows)
}
fn verify_commitment<
@@ -1889,9 +1725,8 @@ where
pub(crate) fn load_params_verifier<Scheme: CommitmentScheme>(
srs_path: Option<PathBuf>,
logrows: u32,
commitment: Commitments,
) -> Result<Scheme::ParamsVerifier, EZKLError> {
let srs_path = get_srs_path(logrows, srs_path, commitment);
let srs_path = get_srs_path(logrows, srs_path);
let mut params = load_srs_verifier::<Scheme>(srs_path)?;
if logrows < params.k() {
info!("downsizing params to {} logrows", logrows);
@@ -1904,9 +1739,8 @@ pub(crate) fn load_params_verifier<Scheme: CommitmentScheme>(
pub(crate) fn load_params_prover<Scheme: CommitmentScheme>(
srs_path: Option<PathBuf>,
logrows: u32,
commitment: Commitments,
) -> Result<Scheme::ParamsProver, EZKLError> {
let srs_path = get_srs_path(logrows, srs_path, commitment);
let srs_path = get_srs_path(logrows, srs_path);
let mut params = load_srs_prover::<Scheme>(srs_path)?;
if logrows < params.k() {
info!("downsizing params to {} logrows", logrows);

View File

@@ -8,7 +8,7 @@ use halo2curves::ff::PrimeField;
use itertools::Itertools;
use log::debug;
#[cfg(feature = "python-bindings")]
use pyo3::{exceptions::PyValueError, FromPyObject, IntoPyObject, PyResult, Python};
use pyo3::{exceptions::PyValueError, FromPyObject, IntoPyObject, Python};
use serde::{Deserialize, Serialize};
#[cfg(all(feature = "ezkl", not(target_arch = "wasm32")))]
use tosubcommand::ToFlags;
@@ -78,7 +78,7 @@ impl<'a> From<&'a str> for Visibility {
let outlets = outlets
.trim_start_matches('/')
.split(',')
.map(|s| s.parse::<usize>().unwrap())
.map(|s: &str| s.parse::<usize>().unwrap())
.collect_vec();
return Visibility::Hashed {
@@ -139,10 +139,12 @@ impl<'py> IntoPyObject<'py> for Visibility {
}
#[cfg(feature = "python-bindings")]
impl<'source> FromPyObject<'source> for Visibility {
impl<'py> FromPyObject<'_, 'py> for Visibility {
type Error = pyo3::PyErr;
/// Extracts Visibility from Python object
fn extract_bound(ob: &pyo3::Bound<'source, pyo3::PyAny>) -> PyResult<Self> {
let strval = String::extract_bound(ob)?;
fn extract(ob: pyo3::Borrowed<'_, 'py, pyo3::PyAny>) -> Result<Self, Self::Error> {
let strval = String::extract(ob)?;
let strval = strval.as_str();
if strval.contains("hashed/private") {
@@ -150,7 +152,7 @@ impl<'source> FromPyObject<'source> for Visibility {
let outlets = outlets
.trim_start_matches('/')
.split(',')
.map(|s| s.parse::<usize>().unwrap())
.map(|s: &str| s.parse::<usize>().unwrap())
.collect_vec();
return Ok(Visibility::Hashed {

View File

@@ -98,18 +98,11 @@ impl From<String> for EZKLError {
EZKLError::UncategorizedError(s)
}
}
use std::str::FromStr;
use circuit::{table::Range, CheckMode};
#[cfg(all(feature = "ezkl", not(target_arch = "wasm32")))]
use clap::Args;
use fieldutils::IntegerRep;
use graph::{Visibility, MAX_PUBLIC_SRS};
use halo2_proofs::poly::{
ipa::commitment::IPACommitmentScheme, kzg::commitment::KZGCommitmentScheme,
};
use halo2curves::bn256::{Bn256, G1Affine};
use serde::{Deserialize, Serialize};
#[cfg(all(feature = "ezkl", not(target_arch = "wasm32")))]
use tosubcommand::ToFlags;
@@ -193,78 +186,6 @@ const EZKL_KEY_FORMAT: &str = "raw-bytes";
#[cfg(any(not(feature = "ezkl"), target_arch = "wasm32"))]
const EZKL_BUF_CAPACITY: &usize = &8000;
#[derive(
Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize, Default, Copy,
)]
/// Commitment scheme
pub enum Commitments {
#[default]
/// KZG
KZG,
/// IPA
IPA,
}
impl From<Option<Commitments>> for Commitments {
fn from(value: Option<Commitments>) -> Self {
value.unwrap_or(Commitments::KZG)
}
}
impl FromStr for Commitments {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"kzg" => Ok(Commitments::KZG),
"ipa" => Ok(Commitments::IPA),
_ => Err("Invalid value for Commitments".to_string()),
}
}
}
impl From<KZGCommitmentScheme<Bn256>> for Commitments {
fn from(_value: KZGCommitmentScheme<Bn256>) -> Self {
Commitments::KZG
}
}
impl From<IPACommitmentScheme<G1Affine>> for Commitments {
fn from(_value: IPACommitmentScheme<G1Affine>) -> Self {
Commitments::IPA
}
}
impl std::fmt::Display for Commitments {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Commitments::KZG => write!(f, "kzg"),
Commitments::IPA => write!(f, "ipa"),
}
}
}
#[cfg(all(feature = "ezkl", not(target_arch = "wasm32")))]
impl ToFlags for Commitments {
/// Convert the struct to a subcommand string
fn to_flags(&self) -> Vec<String> {
vec![format!("{}", self)]
}
}
impl From<String> for Commitments {
fn from(value: String) -> Self {
match value.to_lowercase().as_str() {
"kzg" => Commitments::KZG,
"ipa" => Commitments::IPA,
_ => {
log::error!("Invalid value for Commitments");
log::warn!("defaulting to KZG");
Commitments::KZG
}
}
}
}
/// Parameters specific to a proving run
///
/// RunArgs contains all configuration parameters needed to control the proving process,
@@ -331,10 +252,6 @@ pub struct RunArgs {
/// Controls level of constraint verification
#[cfg_attr(all(feature = "ezkl", not(target_arch = "wasm32")), arg(long, default_value = "unsafe", value_hint = clap::ValueHint::Other))]
pub check_mode: CheckMode,
/// Commitment scheme for circuit proving
/// Affects proof size and verification time
#[cfg_attr(all(feature = "ezkl", not(target_arch = "wasm32")), arg(long, default_value = "kzg", value_hint = clap::ValueHint::Other))]
pub commitment: Option<Commitments>,
/// Base for number decomposition
/// Must be a power of 2
#[cfg_attr(all(feature = "ezkl", not(target_arch = "wasm32")), arg(long, default_value = "16384", value_hint = clap::ValueHint::Other))]
@@ -395,7 +312,6 @@ impl Default for RunArgs {
param_visibility: Visibility::Fixed,
rebase_frac_zero_constants: false,
check_mode: CheckMode::UNSAFE,
commitment: None,
decomp_base: 16384,
decomp_legs: 2,
ignore_range_check_inputs_outputs: false,

View File

@@ -10,13 +10,11 @@ use std::borrow::Borrow;
use crate::circuit::CheckMode;
use crate::graph::GraphWitness;
use crate::{Commitments, EZKL_BUF_CAPACITY, EZKL_KEY_FORMAT};
use crate::{EZKL_BUF_CAPACITY, EZKL_KEY_FORMAT};
use halo2_proofs::plonk::{
create_proof, keygen_pk, keygen_vk_custom, verify_proof, Circuit, ProvingKey, VerifyingKey,
};
use halo2_proofs::poly::commitment::{CommitmentScheme, Params, ParamsProver, Prover, Verifier};
use halo2_proofs::poly::ipa::commitment::IPACommitmentScheme;
use halo2_proofs::poly::kzg::commitment::KZGCommitmentScheme;
use halo2_proofs::poly::VerificationStrategy;
use halo2_proofs::transcript::{EncodedChallenge, TranscriptReadBuffer, TranscriptWriterBuffer};
use halo2curves::ff::{FromUniformBytes, PrimeField, WithSmallOrderMulGroup};
@@ -30,7 +28,6 @@ use rand::rngs::OsRng;
use rand::rngs::StdRng;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use snark_verifier::system::halo2::transcript::evm::EvmTranscript;
use snark_verifier::verifier::plonk::PlonkProtocol;
use std::fs::File;
use std::io::{self, BufReader, BufWriter, Cursor, Write};
@@ -41,8 +38,6 @@ use thiserror::Error as thisError;
#[cfg(feature = "python-bindings")]
use pyo3::types::PyDictMethods;
use halo2curves::bn256::{Bn256, Fr, G1Affine};
/// Converts a string to a `SerdeFormat`.
/// # Panics
/// Panics if the provided `s` is not a valid `SerdeFormat` (i.e. not one of "processed", "raw-bytes-unchecked", or "raw-bytes").
@@ -138,6 +133,9 @@ pub enum PfSysError {
PackingExponent,
}
#[cfg(feature = "python-bindings")]
use halo2curves::bn256::G1Affine;
#[cfg(feature = "python-bindings")]
///
pub fn g1affine_to_pydict(g1affine_dict: &pyo3::Bound<'_, PyDict>, g1affine: &G1Affine) {
@@ -216,8 +214,6 @@ where
pub pretty_public_inputs: Option<PrettyElements>,
/// timestamp
pub timestamp: Option<u128>,
/// commitment
pub commitment: Option<Commitments>,
/// (optional) version of ezkl used to generate the proof
version: Option<String>,
}
@@ -266,7 +262,6 @@ where
hex_proof: Option<String>,
split: Option<ProofSplitCommit>,
pretty_public_inputs: Option<PrettyElements>,
commitment: Option<Commitments>,
) -> Self {
Self {
protocol,
@@ -282,7 +277,6 @@ where
.unwrap()
.as_millis(),
),
commitment,
version: Some(crate::version().to_string()),
}
}
@@ -423,7 +417,6 @@ pub fn create_proof_circuit<
params: &'params Scheme::ParamsProver,
pk: &ProvingKey<Scheme::Curve>,
check_mode: CheckMode,
commitment: Commitments,
split: Option<ProofSplitCommit>,
protocol: Option<PlonkProtocol<Scheme::Curve>>,
) -> Result<Snark<Scheme::Scalar, Scheme::Curve>, PfsysError>
@@ -471,15 +464,7 @@ where
let proof = transcript.finalize();
let hex_proof = format!("0x{}", hex::encode(&proof));
let checkable_pf = Snark::new(
protocol,
instances,
proof,
Some(hex_proof),
split,
None,
Some(commitment),
);
let checkable_pf = Snark::new(protocol, instances, proof, Some(hex_proof), split, None);
// sanity check that the generated proof is valid
if check_mode == CheckMode::SAFE {
@@ -568,30 +553,6 @@ where
Ok(proof_first_bytes)
}
/// Swap the proof commitments to a new set in the proof for KZG
pub fn swap_proof_commitments_polycommit(
snark: &Snark<Fr, G1Affine>,
commitments: &[G1Affine],
) -> Result<Snark<Fr, G1Affine>, PfsysError> {
let proof = match snark.commitment {
Some(Commitments::KZG) => swap_proof_commitments::<
KZGCommitmentScheme<Bn256>,
_,
EvmTranscript<G1Affine, _, _, _>,
>(snark, commitments)?,
Some(Commitments::IPA) => swap_proof_commitments::<
IPACommitmentScheme<G1Affine>,
_,
EvmTranscript<G1Affine, _, _, _>,
>(snark, commitments)?,
None => {
return Err(PfsysError::InvalidCommitmentScheme);
}
};
Ok(proof)
}
/// A wrapper around halo2's verify_proof
pub fn verify_proof_circuit<
'params,
@@ -753,7 +714,6 @@ mod tests {
split: None,
pretty_public_inputs: None,
timestamp: None,
commitment: None,
version: None,
};

View File

@@ -6,7 +6,6 @@ mod native_tests {
use ezkl::graph::input::GraphData;
use ezkl::graph::GraphSettings;
use ezkl::pfsys::Snark;
use ezkl::Commitments;
use halo2_proofs::poly::kzg::commitment::KZGCommitmentScheme;
use halo2curves::bn256::Bn256;
use lazy_static::lazy_static;
@@ -92,16 +91,10 @@ mod native_tests {
});
}
fn download_srs(logrows: u32, commitment: Commitments) {
fn download_srs(logrows: u32) {
// if does not exist, download it
let status = Command::new(format!("{}/{}", *CARGO_TARGET_DIR, TEST_BINARY))
.args([
"get-srs",
"--logrows",
&format!("{}", logrows),
"--commitment",
&commitment.to_string(),
])
.args(["get-srs", "--logrows", &format!("{}", logrows)])
.status()
.expect("failed to execute process");
assert!(status.success());
@@ -116,7 +109,7 @@ mod native_tests {
let settings: GraphSettings = serde_json::from_str(&settings).unwrap();
let logrows = settings.run_args.logrows;
download_srs(logrows, settings.run_args.commitment.into());
download_srs(logrows);
}
fn mv_test_(test_dir: &str, test: &str) {
@@ -346,7 +339,6 @@ mod native_tests {
use crate::native_tests::model_serialization_different_binaries;
use tempdir::TempDir;
use ezkl::Commitments;
#[test]
fn model_serialization_different_binaries_() {
@@ -625,7 +617,7 @@ mod native_tests {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, 2);
test_dir.close().unwrap();
}
@@ -634,7 +626,7 @@ mod native_tests {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 3, None, false, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 3, None, false, 2);
test_dir.close().unwrap();
}
@@ -643,7 +635,7 @@ mod native_tests {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 4, None, false, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 4, None, false, 2);
test_dir.close().unwrap();
}
@@ -652,7 +644,7 @@ mod native_tests {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 8, None, false, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 8, None, false, 2);
test_dir.close().unwrap();
}
@@ -661,7 +653,7 @@ mod native_tests {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, 2);
test_dir.close().unwrap();
}
@@ -672,25 +664,17 @@ mod native_tests {
let path = test_dir.into_path();
let path = path.to_str().unwrap();
crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, Commitments::KZG, 1);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, 1);
// test_dir.close().unwrap();
}
#(#[test_case(TESTS[N])])*
fn ipa_prove_and_verify_(test: &str) {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, false, Commitments::IPA, 2);
test_dir.close().unwrap();
}
#(#[test_case(TESTS[N])])*
fn kzg_prove_and_verify_public_input_(test: &str) {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "public", "private", "public", 1, None, false, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "public", "private", "public", 1, None, false, 2);
test_dir.close().unwrap();
}
@@ -699,7 +683,7 @@ mod native_tests {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "fixed", "public", 1, None, false, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "fixed", "public", 1, None, false, 2);
test_dir.close().unwrap();
}
@@ -708,7 +692,7 @@ mod native_tests {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "hashed", 1, None, false, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "hashed", 1, None, false, 2);
test_dir.close().unwrap();
}
@@ -717,16 +701,7 @@ mod native_tests {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "polycommit", 1, None, false, Commitments::KZG, 2);
test_dir.close().unwrap();
}
#(#[test_case(TESTS[N])])*
fn ipa_prove_and_verify_ipa_output(test: &str) {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "polycommit", 1, None, false, Commitments::IPA, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "polycommit", 1, None, false, 2);
test_dir.close().unwrap();
}
@@ -740,7 +715,7 @@ mod native_tests {
let test_dir = TempDir::new(test).unwrap();
env_logger::init();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, true, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "private", "public", 1, None, true, 2);
test_dir.close().unwrap();
}
@@ -750,7 +725,7 @@ mod native_tests {
let test_dir = TempDir::new(test).unwrap();
env_logger::init();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "hashed", "private", "public", 1, None, true, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "hashed", "private", "public", 1, None, true, 2);
test_dir.close().unwrap();
}
@@ -760,7 +735,7 @@ mod native_tests {
let test_dir = TempDir::new(test).unwrap();
env_logger::init();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "safe", "private", "fixed", "public", 1, None, true, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "safe", "private", "fixed", "public", 1, None, true, 2);
test_dir.close().unwrap();
}
@@ -774,7 +749,7 @@ mod native_tests {
crate::native_tests::init_binary();
let test_dir = TempDir::new(test).unwrap();
let path = test_dir.path().to_str().unwrap(); crate::native_tests::mv_test_(path, test);
prove_and_verify(path, test.to_string(), "unsafe", "private", "fixed", "public", 1, None, false, Commitments::KZG, 2);
prove_and_verify(path, test.to_string(), "unsafe", "private", "fixed", "public", 1, None, false, 2);
test_dir.close().unwrap();
}
@@ -1146,7 +1121,6 @@ mod native_tests {
cal_target,
scales_to_use,
2,
Commitments::KZG,
2,
bounded_lookup_log,
decomp_base,
@@ -1177,7 +1151,6 @@ mod native_tests {
cal_target: &str,
scales_to_use: Option<Vec<u32>>,
num_inner_columns: usize,
commitment: Commitments,
lookup_safety_margin: usize,
bounded_lookup_log: bool,
decomp_base: Option<usize>,
@@ -1199,7 +1172,6 @@ mod native_tests {
format!("--param-visibility={}", param_visibility),
format!("--output-visibility={}", output_visibility),
format!("--num-inner-cols={}", num_inner_columns),
format!("--commitment={}", commitment),
format!("--logrows={}", 22),
];
@@ -1310,7 +1282,6 @@ mod native_tests {
cal_target,
None,
2,
Commitments::KZG,
2,
false,
None,
@@ -1349,7 +1320,7 @@ mod native_tests {
num_inner_columns: usize,
scales_to_use: Option<Vec<u32>>,
overflow: bool,
commitment: Commitments,
lookup_safety_margin: usize,
) {
let target_str = if overflow {
@@ -1368,7 +1339,6 @@ mod native_tests {
target_str,
scales_to_use,
num_inner_columns,
commitment,
lookup_safety_margin,
false,
None,
@@ -1436,15 +1406,8 @@ mod native_tests {
.expect("failed to execute process");
assert!(status.success());
// load settings file
let settings =
std::fs::read_to_string(settings_path.clone()).expect("failed to read settings file");
let graph_settings = serde_json::from_str::<GraphSettings>(&settings)
.expect("failed to parse settings file");
// get_srs for the graph_settings_num_instances
download_srs(1, graph_settings.run_args.commitment.into());
download_srs(1);
let status = Command::new(format!("{}/{}", *CARGO_TARGET_DIR, TEST_BINARY))
.args([
@@ -1482,7 +1445,6 @@ mod native_tests {
num_inner_columns,
None,
false,
Commitments::KZG,
2,
);
@@ -1608,7 +1570,6 @@ mod native_tests {
num_inner_columns,
None,
overflow,
Commitments::KZG,
2,
);

View File

@@ -199,7 +199,8 @@ async def test_get_srs():
another_srs_path = os.path.join(folder_path, "kzg_test_k8.params")
res = await ezkl.get_srs(
logrows=8, srs_path=another_srs_path, commitment=ezkl.PyCommitments.KZG
logrows=8,
srs_path=another_srs_path,
)
assert os.path.isfile(another_srs_path)