From f486615ddb5578c1b74031183072185f02fd0397 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 6 Jul 2022 07:05:57 +1000 Subject: [PATCH 1/3] Only verify halo2 proofs once per transaction (rather than once per action) --- zebra-consensus/src/transaction.rs | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/zebra-consensus/src/transaction.rs b/zebra-consensus/src/transaction.rs index c13b9e66516..8bbe70e8bab 100644 --- a/zebra-consensus/src/transaction.rs +++ b/zebra-consensus/src/transaction.rs @@ -909,26 +909,26 @@ where let mut async_checks = AsyncChecks::new(); if let Some(orchard_shielded_data) = orchard_shielded_data { + // # Consensus + // + // > The proof 𝜋 MUST be valid given a primary input (cv, rt^{Orchard}, + // > nf, rk, cm_x, enableSpends, enableOutputs) + // + // https://zips.z.cash/protocol/protocol.pdf#actiondesc + // + // Queue the verification of the Halo2 proof for each Action + // description while adding the resulting future to our + // collection of async checks that (at a minimum) must pass for + // the transaction to verify. + async_checks.push( + primitives::halo2::VERIFIER + .clone() + .oneshot(primitives::halo2::Item::from(orchard_shielded_data)), + ); + for authorized_action in orchard_shielded_data.actions.iter().cloned() { let (action, spend_auth_sig) = authorized_action.into_parts(); - // # Consensus - // - // > The proof 𝜋 MUST be valid given a primary input (cv, rt^{Orchard}, - // > nf, rk, cm_x, enableSpends, enableOutputs) - // - // https://zips.z.cash/protocol/protocol.pdf#actiondesc - // - // Queue the verification of the Halo2 proof for each Action - // description while adding the resulting future to our - // collection of async checks that (at a minimum) must pass for - // the transaction to verify. - async_checks.push( - primitives::halo2::VERIFIER - .clone() - .oneshot(primitives::halo2::Item::from(orchard_shielded_data)), - ); - // # Consensus // // > - Let SigHash be the SIGHASH transaction hash of this transaction, not From 180337d6bd4512b1e53b00d4d3560e1567bd083e Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Tue, 5 Jul 2022 18:22:10 -0400 Subject: [PATCH 2/3] Update comments on how there is one aggregate Halo2 proof instead of one per Action Co-authored-by: Marek --- zebra-consensus/src/transaction.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zebra-consensus/src/transaction.rs b/zebra-consensus/src/transaction.rs index 8bbe70e8bab..9476fca0f87 100644 --- a/zebra-consensus/src/transaction.rs +++ b/zebra-consensus/src/transaction.rs @@ -916,10 +916,10 @@ where // // https://zips.z.cash/protocol/protocol.pdf#actiondesc // - // Queue the verification of the Halo2 proof for each Action - // description while adding the resulting future to our - // collection of async checks that (at a minimum) must pass for - // the transaction to verify. + // Unlike Sapling, Orchard shielded transactions have a single + // aggregated Halo2 proof per transaction, even with multiple + // Actions in one transaction. So we queue it for verification + // only once instead of queuing it up for every Action description. async_checks.push( primitives::halo2::VERIFIER .clone() From 63e087702ea31605c0ed3199cb2418ff289bfdd1 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 6 Jul 2022 09:06:09 +1000 Subject: [PATCH 3/3] cargo +stable fmt --all --- zebra-consensus/src/transaction.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zebra-consensus/src/transaction.rs b/zebra-consensus/src/transaction.rs index 9476fca0f87..c9bf3030e94 100644 --- a/zebra-consensus/src/transaction.rs +++ b/zebra-consensus/src/transaction.rs @@ -916,9 +916,9 @@ where // // https://zips.z.cash/protocol/protocol.pdf#actiondesc // - // Unlike Sapling, Orchard shielded transactions have a single - // aggregated Halo2 proof per transaction, even with multiple - // Actions in one transaction. So we queue it for verification + // Unlike Sapling, Orchard shielded transactions have a single + // aggregated Halo2 proof per transaction, even with multiple + // Actions in one transaction. So we queue it for verification // only once instead of queuing it up for every Action description. async_checks.push( primitives::halo2::VERIFIER