From 62642fd8044c78f606d810e0fbf29c118b6bf4a1 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 21 Jun 2021 13:38:43 +0100 Subject: [PATCH] Add `Bundle::verify_proof` API --- src/bundle.rs | 16 +++++++++++++++- src/circuit.rs | 2 ++ src/lib.rs | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/bundle.rs b/src/bundle.rs index 38e8fc9d..3018b847 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -3,7 +3,7 @@ use nonempty::NonEmpty; use crate::{ - circuit::{Instance, Proof}, + circuit::{Instance, Proof, VerifyingKey}, note::{ExtractedNoteCommitment, Nullifier, TransmittedNoteCiphertext}, primitives::redpallas::{self, Binding, SpendAuth}, tree::Anchor, @@ -298,6 +298,13 @@ impl Bundle { authorization: step(context, authorization)?, }) } + + pub(crate) fn to_instances(&self) -> Vec { + self.actions + .iter() + .map(|a| a.to_instance(self.flags, self.anchor)) + .collect() + } } impl> Bundle { @@ -354,6 +361,13 @@ impl Bundle { pub fn authorizing_commitment(&self) -> BundleAuthorizingCommitment { todo!() } + + /// Verifies the proof for this bundle. + pub fn verify_proof(&self, vk: &VerifyingKey) -> Result<(), halo2::plonk::Error> { + self.authorization() + .proof() + .verify(vk, &self.to_instances()) + } } /// A commitment to a bundle of actions. diff --git a/src/circuit.rs b/src/circuit.rs index 69bddf91..c3631dfe 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -1,3 +1,5 @@ +//! The Orchard Action circuit implementation. + use group::Curve; use halo2::{ plonk, diff --git a/src/lib.rs b/src/lib.rs index de60a20f..3b46ae84 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ mod address; pub mod builder; pub mod bundle; -mod circuit; +pub mod circuit; mod constants; pub mod keys; pub mod note;