-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plonky2 proofs verification #4393
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just 2 things:
- Do
bls12_381
changes belong to this PR? - I think
gr_permute
is not very descriptive, maybegr_poseidon_permute
will be better
use plonky2::plonk::verifier::verify; | ||
|
||
#[gstd::async_main] | ||
async fn main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you measured how much gas will it take for a recursive proof verification? It's interesting to know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provided the benchmarks of the syscall/hostcall combo are correct, a recursive proof verification would take slightly above 100 bln gas. Or roughly ~15% of a block gas allowance.
d6390a0
to
d79aefa
Compare
d79aefa
to
018068e
Compare
b3dc57b
to
0abd6eb
Compare
…ackable impl for Goldilocks field
Plonky2 proofs onchain verification.
The change implements a framework for zk-related apps. Specifically, it allows to verify Plonky2 proofs for arbitrary circuits.
A general flow might look like so:
Application contract
is supposed to store circuit-specific data, and prepend with it a proof it wants verified.The
Verifier contract
imports the original plonky2 code for verification; however, the underlying primitives (Goldilocks field and Poseidon hasher) are custom-implemented in such a way that heavy operations are offloaded to host (through a dedicated syscall).Specifically, the change includes:
Goldilocks
field implementation to plug into the out-of-the-boxplonky2
verifier;Goldilocks
field arithmetic andPoseidon
hashing primitives to back up the Poseidon permutation host call.Note: To make
plonky2
compile for wasm target we need to use our fork with a different feature enabled for thegetrandom
crate.Hardware acceleration of field arithmetics and hashing
plonky2
provides specialisations for the field ops and Poseidon hashing over the Goldilocks field. However, currently SIMD parallelisation of Poseidon only works on theaarch64
architecture; it has been disabled forx86_64
after the MDS matrix constants update in plonky2 and haven't been aligned with those changes ever since.x86_64
allows SIMD withavx2
oravx512
target features enabled. Theavx512
has been completely removed in our implementation because it requires unstable language features to compile. As for theavx2
support, it is there but, as mentioned, not used in Poseidon. We keep it in the codebase though in case we want to benefit from polynomials evaluation on the host some day.That being said, on an
x86_u64
machine we won't have any parallelisation yet. Nevertheless, even as is it gives about 4.5-5x speed-up on Poseidon permute operation with respect to fully wasm-based solution.