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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: l2_r0prover-0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 de5b9ef0be154a687398083626a5efc921a6ee8b1160b63b874dd9b9a0cf1034
MD5 5d871d9c1f25ac37ccd18ae772ace634
BLAKE2b-256 f253a060d2bbaa442f41f10dba81e3b6e5ee661024e257f5e9d26f46b0c11912

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18134b8c92742552de4d414ca1e62621c7c0aa0e069eac1ddc44a16d26f6f675
MD5 6bf8a9cfdc66cc529bf7337368c3ec86
BLAKE2b-256 eca0ea526899fc31110c7cdfb56c3202938899c65c5e71d1c3870ea71828b77f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a63402c2ce163d1849c846c5be478e6d22894b1a62f79fa34f930bd8d414067d
MD5 e014690eec613f17148b3cbc6e5ca256
BLAKE2b-256 2baabf720b4f177f8116d26579da05931640a408bdeffc79f69e5de80a2a75d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 097561467a1757598cd8cd5b4634751a3a0f047d4f845243dc7f0e20df313b3a
MD5 4448467762b759f34a72ed91e28b1140
BLAKE2b-256 db745a2d647157dbdd4ba1d763bc1852ef48f908ffafc2bfb92c2667d5b23c6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ea9a00c43cc4930661307b174261a27fa13b0c2433014462b3ccc42d5b5a2a7
MD5 75c715cfe5ce30273b02f46c66638ea6
BLAKE2b-256 6b3401fe36c363237c4650195ac46785d24c0bfdc51592eabb77cc0660c68c14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33bb83a7336b244e00a5979a878436566fe0fc16d129578fb7c6a6753b0090e4
MD5 1c7bc1ea70a2e7cf96c25489b7a8ed61
BLAKE2b-256 6d668d3a9eb2ec855a1c6841ec1d4da7ecaa2a1ecff59b47a11c375e6826600f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6f129dadf92894dd664b4d5e9ea6a2f7d5d264c1350ea1d16c0ba3c412e344e
MD5 589b4684171f531bb0a217a5ef35800a
BLAKE2b-256 f35f68642139a9578a480957213d7e113b5c39169aa1baf6f30ddc9416840d32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 73dd026a5d18f546fe72c20dedbafb6978dea8069c0fcf0c5b22fa49a1a22a3f
MD5 ef1e048d3f7dd9f7e66e74f8dccbcebb
BLAKE2b-256 bb49ca6cae7d14771cc668b418b206e4efed9fe8fc03a585a023a8315c459960

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4282466379934b834b63d48025cfb89ed29cc2e15c04bc7a41b6a5950387ed42
MD5 e8d3f53bd5080b4df0272ffb1387ce06
BLAKE2b-256 2a42bdfc8dbd5ed64d547329a44bad3a0a856006f3b9d8a7821c0f8579e50c88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 008ab8e8791dbc3c9c728a30bb3757270fc2ec67b0affeaded7b1faefa370520
MD5 b31c5d259557dd0f13872c05fe4d352d
BLAKE2b-256 16338463c313e972b0cb4a8583ba37609d95cb3bbff4e84248f3e91207b23025

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bbcc38f1b26064d1442adb070d3bacec31e37d58918648a64ab0877998d02c5e
MD5 4c4c1cfed507d3ab41def1c7f58ff947
BLAKE2b-256 bd8adb898a8f448d01f2632d8e5dae4f395abb7563999a65d7c58f3945dcc7d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 089ffa7dbdba1f29caf91a534e6c09d6979f27923e662f373ce4ab9be503abfc
MD5 16893fe9c26c80bcc03ae1d10ef95d3c
BLAKE2b-256 0c43c8154c39f099cb258cb1ec7b16c70ffc476a690d056c0731e51f8d816256

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 36be99db0548a74385864eaa6a1ee87e06badb93c07fe3de012869e2e17e6d47
MD5 df235bf0cadeb2bd72440847e77eeefc
BLAKE2b-256 14571fd34335431e5e71f7cd4b956ae0f353b8af4d5d82138d2ce4932298456e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for l2_r0prover-0.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d8180a3eb2b9e7c3b2a8615a5f2ac6b030a4fb3fdf9c3c018c974c6051ae6921
MD5 89baa226204a567774fbb52e11d37c47
BLAKE2b-256 53905a7c6685795be6cedfe7275cc732797f15dc52605ee9266c04a3534273e5

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