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 can use two widely adopted frameworks, Ray and Dask, here.

Background in Ray and Dask, two distributed computing frameworks

Ray (USENIX OSDI 2018) is a distributed computing framework that enables simple remote computation, starting as a UC Berkeley research project. To let two remote clusters to each prove a segment, this can be done with the following code.

import l2_r0prover, ray

ray.init()

# define a Ray remote function
@ray.remote
def async_prove_segment(_segment):
    return l2_r0prover.prove_segment(_segment)

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 `func.remote(args)`
future_1 = async_prove_segment.remote(segments[0])
future_2 = async_prove_segment.remote(segments[1])

# obtain the results using `ray.get(future)`
receipt_1 = ray.get(future_1)
receipt_2 = ray.get(future_2)

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()

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.1.tar.gz (568.0 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.1-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.1-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.1-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.1-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.1-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.1-cp312-cp312-macosx_11_0_arm64.whl (28.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

l2_r0prover-0.1-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.1-cp311-cp311-macosx_11_0_arm64.whl (28.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

l2_r0prover-0.1-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.1-cp310-cp310-macosx_11_0_arm64.whl (28.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

l2_r0prover-0.1-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.1-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.1-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.1.tar.gz.

File metadata

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

File hashes

Hashes for l2_r0prover-0.1.tar.gz
Algorithm Hash digest
SHA256 22818ee5bdabd546109547da2260856b32ba4be34519e3dffb5684bae91e5e92
MD5 e1b65bbee3f447761589635740ab87bb
BLAKE2b-256 57fed93260bb369371751940177c535353011e0d4fa20713499946448ae13392

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 55c7dc903104c7aaaafd60f03aa62631b6d4875757ad01d1e6b2ac505960d9db
MD5 fdbe38857e244bb74d242a62f3217485
BLAKE2b-256 6e5e0b71d395e2fb0225e49b25ff2582da9da8fa408cb564a3e57215b52eeb77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 edd4dc463a22dc639c64468f818cfce57695e0f2653a2e1612feb3be0dd7dbf3
MD5 57eeae57e5a6127ce3e671244b53cd38
BLAKE2b-256 8dcc4b176c7ff21ec37f1dfaa000b23dae883e18ac5f3595cd967b91937ea65b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 feeaa23b0aaef24db3a51b6f4e0257f45b8e9b6e018e2b132c9c6073b2bd7fe6
MD5 74a7d38153c2f1950084bbe487a448f9
BLAKE2b-256 44e2c71eb5dc2b3442ceb8f8ca00589e685849475f8902de5ada0aff80a35022

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ae2c6283076a489faaa5a86aa9fbbcd1f8d1295199b4022fdbc960a875b26fc1
MD5 4a40590e0d880d60250615c11690eadf
BLAKE2b-256 06da9576691ef638fa7fb04ee528717cc2a2e0698f50cf516287dc0787225640

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7fc708c25a73659c2cdf1bde31ce366da1094d2bcf907150a48a089af714398f
MD5 77f6a9d718cdb3b01605b980a624b5d8
BLAKE2b-256 6ba9e45e9c2db4f4a63ed1feee53267e4f283080b68818e72c127e5f4e8ad7f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1f35ab8c135c8897f346eb86d0922c6bf09523aff23c458f3719c798dab69b9e
MD5 fd92c545fd890f9a3f30c03033814938
BLAKE2b-256 f7113770638763253c2c9a294d0a96d3a99ed707a853cada6a0bd335469c658c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 95264f16c1e82046ea0113a396c0e9339977c6c96c55ba80aab64bd327572227
MD5 417aeb226a9583f2a1ee02aa18024bc2
BLAKE2b-256 b4bc8cedd230b2e55faeeb0522dcb3685ea76ff0d0024205bbe555a3a3b372d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d379169003a2c8d975965307259a5c196aa8dac639d29d23b93093f8f59b4af2
MD5 81c31a9087894341d577abbc3575b414
BLAKE2b-256 c2308a609295ca8229bcfd1cc1f862f3627df3ed4a31939aa9c4bd2a810e1c36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5c307707dd56b5b99d4b64d9cf729ca8ccb67c1c7c1fe8075d65e490943c058
MD5 ec638c5863b93c7181521e4d79655955
BLAKE2b-256 124534577b71e57c6e73a22ee086f98b6f0c54e85749321066975f76c9d97f9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e1bde4e625579a55197c0f249b3b9ca4d835b7b73696bb056b0ee392ba684b5
MD5 9f4f9e97c4534a8d55618e61145e5a22
BLAKE2b-256 2008f9cbb61792a11219f3cf107ac497b700f86576cf305ca75fa32d4b929f64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e2af7bb6f2ffd32443c782dad7756a85c93670e2cd22a20e412c656ba5fb2a30
MD5 99ee7feb628ce6969d88afa388d6ae6e
BLAKE2b-256 154363d0f653ceccc7431bcd23894b9dc8da56c8079affca159c0212a54c3214

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1da3415a1c7d02afc611621f85e12ba78b4f14e7602b09f32e05aa519abdf561
MD5 38878c49824e4d57efb2130a9c341725
BLAKE2b-256 2f43e676897d27a81259417216c002f14eaea16937fcfeff4547408a61371881

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9be369033bbb7ad885282f951ae78b38c557571c7e0324f27b46555f7cb358d4
MD5 493b6f99fe7a9b61d0acbca2f93c4f78
BLAKE2b-256 332fcc00230956547d9786653516262c15d50571fa8344df353f3f50449e4b7e

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