-
Notifications
You must be signed in to change notification settings - Fork 61
zkvm: encapsulate bulletproofs dependencies #223
Conversation
@@ -79,10 +79,11 @@ impl<'a, 'b> Delegate<r1cs::Verifier<'a, 'b>> for Verifier<'a, 'b> { | |||
impl<'a, 'b> Verifier<'a, 'b> { | |||
/// Verifies the `Tx` object by executing the VM and returns the `VerifiedTx`. | |||
/// Returns an error if the program is malformed or any of the proofs are not valid. | |||
pub fn verify_tx<'g>(tx: Tx, bp_gens: &'g BulletproofGens) -> Result<VerifiedTx, VMError> { | |||
pub fn verify_tx(tx: Tx) -> Result<VerifiedTx, VMError> { | |||
let bp_gens = BulletproofGens::new(256, 1); |
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.
We cannot hardcode this for two reasons:
- Bigger txs will have larger circuits and more than 256 multipliers, failing the verification if 256 is hardcoded.
- Computing generators is expensive. Validator would want to precompute them and use over its whole lifetime to validate arbitrary amount of transactions, so we need to pass it in.
Note: each rangeproof is 64 multipliers, each "lane" of Cloak is roughly 8+64=72 multipliers (8 for shuffles and mixes, 64 for output rangeproof). So the 10-input/output tx would use ≈720 multipliers. Plus custom contracts may allocate a few here and there.
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.
Got it, so on the prover we'd want to calculate the capacity that we need?
If the verifier might want to precompute generators, would we need to keep bp_gens
as a parameter on verify_tx
?
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.
Yeah, that's why this discussion was prompted: https://dalek-cryptography.slack.com/archives/CBKMRC8DN/p1552425846018800
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.
As of exposing BP API, we could re-export only BulletproofGens
in the lib.rs to allow user precompute them and pass into verifier. This way if they don't care about other parts of R1CS, they can avoid explicitly linking with bulletproofs
crate.
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.
got it, that makes sense! reading slack thread now :)
We should probably simply do |
Fixes #210 - uses capacity of 256 for bulletprooofs generator.