Skip to main content

A Python wrapper for RISC Zero prover

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Python wrapper for RISC Zero prover

many military tanks rolling in parallel on the desert

When people talk about accelerating zero-knowledge proofs, there are usually two approaches:

  • hardware acceleration
  • distributed computation

After years of exploration, many in the industry (including Supranational, Ingonyama) would agree that Nvidia GPU and Apple Metal GPU seems to be doing pretty well for hardware acceleration. FPGA and ASIC are still too early to compete, and evidence in chip design suggests that FPGA/ASIC are unlikely to beat GPU eventually—any idea that can challenge this assertion is most welcomed. In fact, Omer Shlomovits from Ingonyama and I have a bounty for breakthrough ideas in hardware acceleration.

This leaves distributed computing.

The idea is that, if we have a zero-knowledge proof task, we want to distribute it to multiple machines and then aggregate their work together. This would require a zero-knowledge proof system that is distributed-computation-friendly.

  • the different machines involving in the process are laconic and taciturn, i.e., they have minimalistic communication between each other.
  • the individual proof work can be merged in an efficient way without severely sacrificing the overall proof generation time

This idea has, however, been systematically studied.

  • zkBridge (ACM CCS 2022), which leads to our portfolio company Polyhedra, discovers that an algebraic holographic proof protocol, Goldwasser-Kalai-Rothblum (GKR), can be made distributed-computation-friendly by having each machine handle part of the multilinear extensions.
    • However, committing the input polynomials (through FRI) still has to be done in a federated manner, which is only suitable for circuits with small inputs.
  • Pianist (IEEE S&P 2024) shows that, by using bivariate KZG commitment, one can make polynomial commitment distributed-computation-friendly, coupled with Plonk (or its variants), which are distributed-computation-friendly, one can create fully distributed-computation-friendly proof systems.
    • However, it requires homomorphic polynomial commitments, for which KZG is but not FRI. But KZG is usually slower.
  • all SNARK protocols can be made distributed-computation-friendly through recursive composition. This would incur additional overhead and latency in composing proofs together, but it is a very general approach that applies to, technically, any SNARK.

RISC Zero takes the third approach. The problem with the first two approaches is the same—not working well with FRI, which still has a prevailing advantage in terms of performance, and the benefit declines if subsequent recursive composition is not avoidable. For RISC Zero, it is desirable, for Bonsai, to merge proofs from different transactions to lower the on-chain verification costs, which means that all proofs would eventually go through recursion, which discourages KZG-based approach.

The third approach reduces the entire acceleration task into a simple step: coordinate enough machines to work together. Tools for this purpose have been extensively studied in machine learning, and we here focus on the Dask framework.

We have experimented with the Ray, but the fact that it uses fork() appears to require a lot of care when handling with the CUDA connections.

Background in Dask, a distributed computing framework

Dask is another distributed computing framework with wide adoption. It can be done in a similar manner.

import l2_r0prover
from dask.distributed import Client, LocalCluster

if __name__ == '__main__':
  cluster = LocalCluster()
  client = Client(cluster)
  
  elf_handle = open("elf", mode="rb")
  elf = elf_handle.read()
  image = l2_r0prover.load_image_from_elf(elf)
  input = bytes([33, 0, 0, 0, ...]) # omit the detail input
  segments, info = l2_r0prover.execute_with_input(image, input)
  
  # distribute the task using `client.submit(func, args)`
  future_1 = client.submit(l2_r0prover.prove_segment, segments[0])
  future_2 = client.submit(l2_r0prover.prove_segment, segments[1])
  
  # obtain the results using `future.result()`
  receipt_1 = future_1.result()
  receipt_2 = future_2.result()

Supported versions

Currently, the library is compiled with CUDA 12.3. There is a risk that it would not work with other versions of CUDA and would require compilation from the source.

License

As mentioned in pyproject.toml, this Python module, listed on PyPI, is under MIT and Apache 2 licenses.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

l2_r0prover-0.2.0.tar.gz (566.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

l2_r0prover-0.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

l2_r0prover-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

l2_r0prover-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

l2_r0prover-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

l2_r0prover-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

l2_r0prover-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (28.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

l2_r0prover-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

l2_r0prover-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (28.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

l2_r0prover-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

l2_r0prover-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (28.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

l2_r0prover-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

l2_r0prover-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

l2_r0prover-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

File details

Details for the file l2_r0prover-0.2.0.tar.gz.

File metadata

  • Download URL: l2_r0prover-0.2.0.tar.gz
  • Upload date:
  • Size: 566.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.4.0

File hashes

Hashes for l2_r0prover-0.2.0.tar.gz
Algorithm Hash digest
SHA256 137c672245ba50650181d3339c1620e032504030742ae7c826c927b7c2ec0afe
MD5 dd5c9ca57d9ebe27292146ffb924746b
BLAKE2b-256 8fbf326071ceabf709352fca3eeaac36de55cf94ea9c674b6d9f629d1060cec9

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d8d832f38aa0623993d028519e855c7455a5b11a8c67014f17dbdf1b0a866cc1
MD5 cc609bf8fecbe81c88e1026f3aceb273
BLAKE2b-256 c74f61c8d1f83270c689aa0dbc109529d23e717dfa551e8cfea6bddd96be4a36

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 affb1acbab5d3a0aee209e7ff56708fb767440812cbfb60dd8e452b4ea392f38
MD5 5f8ef08473a6c9f82cd59286c1a2af34
BLAKE2b-256 a26d9a6f62006ecbb371d9e37489b90c59d837cf3564a8224c4db49b64a59ca0

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9fa4a569b8b8b320659c0a1a5687c38a45dacba28f9c37a4a77ccc92b2ba624
MD5 8f9c1044f3aab596203390eee1ed4f28
BLAKE2b-256 09ebde302b365025b082273f7e9a7e6a95959bcf5ac40657a65cc75286b2b32c

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 608b682a999a6f7b80e2b1db1df986b1f4438de02fbfd0d347d3030825651914
MD5 d4be4e81f96e46bb026a18798f6fc839
BLAKE2b-256 86abfe2190e05dc407fb5a12d583376325e8c02bacbae6caf6a9f8600c6ad176

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a0c1bbbd59c74a4d03ae4494b4762d303e02376b9e5a4a78290f9ac2c44ac0b8
MD5 22f3b8ab07a4d1eb4ee1a95053def012
BLAKE2b-256 f04aa9edcf2d5d179ab07b89b7b6c1d61aba3e194670d5df1bb168e98f12587b

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99179e15494ae5835d4e0c8d89262e678167ebadfd9dde6bbe75f9227fc2ff41
MD5 94e72434b912854ce6f5fd866d86e09a
BLAKE2b-256 4ad0bf29d239a2014f5825e9d548086b7aae34532ca2e67cdbb5d5399ac60fee

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de1ebd2c6c558820726e6d102527ac848da82be1b2da652aba4b94be3f6e34ce
MD5 f1abd208316d1f65046e0e31bf966dcf
BLAKE2b-256 eb31608b36049c5c6444dcfc99eed475051d28ca0f81aa91f7c3ec41165da499

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8173254fd6c89b4892c158ad26554256c6c080c43cab8cfe8012728c6ea82ec8
MD5 2a97e73bcdf493742048673d9b6c5011
BLAKE2b-256 9a80a3172f87c49c02cbea8d500fae7dfe6c389383166b84141d91496f891e2b

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0be6ecdb91c91f45b70cce1e8246ded07914e297f4c488b0522bae21b737beb2
MD5 63fe904202f9ba45777aa598c2fd80e8
BLAKE2b-256 464c429538ed3e80311ca7f8dd0b76ba31041cfce93e99c6795dc03be9f3774b

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 75f3c951c791886c696eb84d45f2d5d59dce6969c07e441ff829ac06858e8fad
MD5 e5d30ae33ff315450948cb9aa9e93eec
BLAKE2b-256 57059bbd81a0db4dc8d6e99ac1f83e369669094aaf6dd46cd2424e31f70fabea

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a619f1c533cc3362d8186c9004cbb4148d35f290f679d079ede7c7ee1a0c3bd9
MD5 c357d6bed3dc1365df95ade62de9e9ea
BLAKE2b-256 c66dd165c85def8692161366f117f4864125862f9debcff5f4a6934adf4866cd

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cf50c16d28d265c839c8c3cf89abe73dc8b5ff7fc96118bd93ff51a334c5f070
MD5 6ae138d88cbc6e25f45bcee0357b1c37
BLAKE2b-256 9f20a2d3404a7fcb40b6d864075c9c8fc5f20aa5b817f52052c60ecf34250f99

See more details on using hashes here.

File details

Details for the file l2_r0prover-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for l2_r0prover-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 44c80d646a4a54c893c91cebbbcf847cd2199193ce7cfb5951ca27d55e4dd010
MD5 5859a539dcceef372a6e50d061877c6d
BLAKE2b-256 7aa18e0f7cf541a0eff94f6c4f29be5189ecd153ca6b86aabf146e563d3d0a35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page