-
Notifications
You must be signed in to change notification settings - Fork 252
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
bellman: Batch verification API #253
Comments
I agree with using an IUF-style API, and it fits nicely with how I plan to use the batch API from 1️⃣ Taking ownership will work fine for 5️⃣ I personally think that refactoring from |
Having an additional |
I created #254 for (5) to do the error change separately. |
One issue with this design is that it's not possible to batch together proofs created with different verification keys, even though there's no (theoretical) obstacle to doing so. I tried to think of some alternatives that would allow this but they all run into problems related to how to specify which pvk is associated with each item. Maybe there is some solution involving accumulating items into distinct batch accumulators, and then combining batch accumulators with each other. But this seems very complicated, in comparison to the simpler API above. |
Closed by zkcrypto/bellman#59. |
We'd like there to be a batch verification API in
bellman
that provides batch verification of Groth16 proofs, as described in §B.2 of the protocol spec. Forbellman
, it makes sense for the batch verification API to be synchronous, but we'd like the API to be compatible with an asynchronous wrapper usingtower-batch
, which we designed for this use-case. Based on our experience with writing asynchronous wrappers for Ed25519 and Redjubjub verification, I think that an IUF-style API would work well.Here is a more concrete proposal. Inside
bellman::verifier
, add amod batch
with the following contents:Some design choices made here:
We take ownership of the public inputs in the
Item
struct. This ensures thatItem: 'static
, which is important because it means that we can send verification items between threads or tasks without having to manage lifetime bounds.The
PreparedVerifyingKey
is passed in as a parameter toverify
, so that we don't need to prove relationships about the lifetime of theVerifier
and thepvk
.Because
queue
takesimpl Into<Item<E>>
, it can be called asverifier.queue((proof, inputs))
. However, because theItem
is a single type, it's easy to work with in a generic context (like Tower).The
Item
exposes averify_single
method that allows unbatched verification. In combination with theClone
impl, this allows implementing fallback logic for handling batch failures.Unlike the existing
verify_proof
function, the verification functions returnResult<(), Error>
(error type tbd) rather thanResult<bool, SynthesisError>
. I don't think that the current return type is good, because it mixes failure modes across theOk/Err
variants. Checkingverify_proof.is_ok()
, for instance, will happily typecheck and be subtly wrong. Instead I think thatverify_proof
should returnOk(())
on successful verification andErr(SomeError)
on failure. I would be happy to make this change together with or separate from batch verification.The text was updated successfully, but these errors were encountered: