From e90a5972f1b824b4494f04b00efec66ea79be66b Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 13 Jun 2021 22:25:37 +0100 Subject: [PATCH] redpallas: Expose batch validation API --- src/primitives/redpallas.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/primitives/redpallas.rs b/src/primitives/redpallas.rs index 5b2c2611..f367c0b8 100644 --- a/src/primitives/redpallas.rs +++ b/src/primitives/redpallas.rs @@ -5,6 +5,8 @@ use std::convert::{TryFrom, TryInto}; use pasta_curves::pallas; use rand::{CryptoRng, RngCore}; +pub use reddsa::batch; + #[cfg(test)] use rand::rngs::OsRng; @@ -108,6 +110,26 @@ impl VerificationKey { pub fn randomize(&self, randomizer: &pallas::Scalar) -> Self { VerificationKey(self.0.randomize(randomizer)) } + + /// Creates a batch validation item from a `SpendAuth` signature. + pub fn create_batch_item>( + &self, + sig: Signature, + msg: &M, + ) -> batch::Item { + batch::Item::from_spendauth(self.0.into(), sig.0, msg) + } +} + +impl VerificationKey { + /// Creates a batch validation item from a `Binding` signature. + pub fn create_batch_item>( + &self, + sig: Signature, + msg: &M, + ) -> batch::Item { + batch::Item::from_binding(self.0.into(), sig.0, msg) + } } /// A RedPallas signature.