dalek-cryptography / bulletproofs

A pure-Rust implementation of Bulletproofs using Ristretto.
MIT License
1.03k stars 217 forks source link

Non-`'static` second phase #323

Open rubdos opened 4 years ago

rubdos commented 4 years ago

Continuation of a discussion at #276: the second phase challenges can only use FnOnce + 'static since #276.

This effectively breaks the API (and apparently, rightfully, annoys @oleganza)! We have to pass a generic lifetime to the RandomizableConstraintSystem trait in order to constrain the lifetime to the container in Prover and Verifier. I don't think there's another way, except maybe with GATs (which would bring different API breaks anyhow).

Example of breaking API in Spacesuit

How about upgrading from Fn to FnOnce in this PR, but keeping the 'static requirement, and then separately explore if moving to generic lifetime bound is worth it? Right now i have to propagate 'a in a ton of places in ZkVM, because where I had a vm::Verifier, now I have vm::Verifier<'a>, and it leaks to PrecomputedTx that wraps it, etc. I could probably slap 'static at some point inside ZkVM/Spacesuit, but that would push the burden of justification on my codebase and I'm just... ugh... not ready for it right now :-P


Depends on #244/#276 (I'll rebase on develop when #276 is merged, too much conflicts to handle otherwise)