diff --git a/src/bundle.rs b/src/bundle.rs index e5c758c7..f55b1c2b 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -7,7 +7,7 @@ use crate::{ note::{ExtractedNoteCommitment, Nullifier, TransmittedNoteCiphertext}, primitives::redpallas::{self, Binding, SpendAuth}, tree::Anchor, - value::ValueCommitment, + value::{ValueCommitTrapdoor, ValueCommitment, ValueSum}, }; /// An action applied to the global ledger. @@ -300,6 +300,22 @@ impl Bundle { } } +impl> Bundle { + /// Returns the transaction binding validating key for this bundle. + /// + /// This can be used to validate the [`Authorized::binding_signature`] returned from + /// [`Bundle::authorization`]. + pub fn binding_validating_key(&self) -> redpallas::VerificationKey { + (self + .actions + .iter() + .map(|a| a.cv_net()) + .sum::() + - ValueCommitment::derive(self.value_balance.into(), ValueCommitTrapdoor::zero())) + .into_bvk() + } +} + /// Authorizing data for a bundle of actions, ready to be committed to the ledger. #[derive(Debug, Clone)] pub struct Authorized {