Add a `Bundle::binding_validating_key` method

This derives the `bvk` for validating `Authorized::binding_signature`.
This commit is contained in:
Jack Grigg 2021-06-13 20:55:39 +01:00
parent ee26116fcf
commit eec17a9174
1 changed files with 17 additions and 1 deletions

View File

@ -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<T: Authorization, V> Bundle<T, V> {
}
}
impl<T: Authorization, V: Copy + Into<ValueSum>> Bundle<T, V> {
/// 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<Binding> {
(self
.actions
.iter()
.map(|a| a.cv_net())
.sum::<ValueCommitment>()
- 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 {