Skip to content
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

Verify Halo2 proofs as part of V5 transaction verification #3039

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions zebra-consensus/src/primitives/halo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ impl BatchVerifier {

// === END TEMPORARY BATCH HALO2 SUBSTITUTE ===

impl From<zebra_chain::orchard::ShieldedData> for Item {
fn from(shielded_data: zebra_chain::orchard::ShieldedData) -> Item {
impl From<&zebra_chain::orchard::ShieldedData> for Item {
fn from(shielded_data: &zebra_chain::orchard::ShieldedData) -> Item {
use orchard::{circuit, note, primitives::redpallas, tree, value};

let anchor = tree::Anchor::from_bytes(shielded_data.shared_anchor.into()).unwrap();
Expand Down Expand Up @@ -108,7 +108,7 @@ impl From<zebra_chain::orchard::ShieldedData> for Item {

Item {
instances,
proof: orchard::circuit::Proof::new(shielded_data.proof.0),
proof: orchard::circuit::Proof::new(shielded_data.proof.0.clone()),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions zebra-consensus/src/primitives/halo2/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ where
for sd in shielded_data {
tracing::trace!(?sd);

let rsp = verifier.ready().await?.call(Item::from(sd));
let rsp = verifier.ready().await?.call(Item::from(&sd));

async_checks.push(rsp);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ where

tracing::trace!(?sd);

let rsp = verifier.ready().await?.call(Item::from(sd));
let rsp = verifier.ready().await?.call(Item::from(&sd));

async_checks.push(rsp);
}
Expand Down
16 changes: 16 additions & 0 deletions zebra-consensus/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,22 @@ where
if let Some(orchard_shielded_data) = orchard_shielded_data {
for authorized_action in orchard_shielded_data.actions.iter().cloned() {
let (action, spend_auth_sig) = authorized_action.into_parts();

// Consensus rule: The proof 𝜋 MUST be valid given a primary
// input (cv, rtOrchard, nf, rk, cm𝑥, 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)),
);

teor2345 marked this conversation as resolved.
Show resolved Hide resolved
// Consensus rule: The spend authorization signature
// MUST be a valid SpendAuthSig signature over
// SigHash using rk as the validating key.
Expand Down