foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.31k stars 1.75k forks source link

Support for Zero Knowledge Proof generation from external source, like Javascript/WASM #3963

Closed shekohex closed 7 months ago

shekohex commented 1 year ago

Component

Forge

Describe the feature you would like

The title say it all, currently, what stops us at @webb-tools from switching to use foundry for our contract tests (which by the way, from GitHub Actions, it takes up to 56m to complete) is that our protocol is based on Zero Knowledge proof generation/verification, our code for generating these proofs are currently written in Javascript, which wraps some other WASM code from Circom.

So back to the original question, how we can do such thing like Generating ZKP inside solidity? Do we have to write it in say Rust, and expose that as FFI? what the workflow would look like?

Additional context

joshieDo commented 1 year ago

56m to complete

ouch

for generating these proofs are currently written in Javascript, which wraps some other WASM code from Circom.

You can indeed use ffi to call the proof generation script, and then either "consume" it as hex or json, up to you. I don't see why it wouldn't work. Feel free to tag me on the tg channel and I'd be more than happy to help.

rkrasiuk commented 1 year ago

@shekohex did you have any luck using ffi for proof generation?

shekohex commented 1 year ago

@shekohex did you have any luck using ffi for proof generation?

Not yet, we are like in the research phase in that area! also, right now we are trying to use ark-circom more, so that we can write our FFI in rust too.

wagmiwiz commented 1 year ago

Does anyone have some examples of using Foundry toolbelt for managing/testing ZK based projects (using Circom)? Specifically interested in how to generate proofs for use in tests etc.

krisgrm commented 1 year ago

Any updates on this ?

DaniPopes commented 7 months ago

This feels very out of scope. You should just use vm.ffi and CLI wrappers for these kinds of things.