redpallas: Expose batch validation API

This commit is contained in:
Jack Grigg 2021-06-13 22:25:37 +01:00
parent eec17a9174
commit e90a5972f1
1 changed files with 22 additions and 0 deletions

View File

@ -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<SpendAuth> {
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<M: AsRef<[u8]>>(
&self,
sig: Signature<SpendAuth>,
msg: &M,
) -> batch::Item<SpendAuth, Binding> {
batch::Item::from_spendauth(self.0.into(), sig.0, msg)
}
}
impl VerificationKey<Binding> {
/// Creates a batch validation item from a `Binding` signature.
pub fn create_batch_item<M: AsRef<[u8]>>(
&self,
sig: Signature<Binding>,
msg: &M,
) -> batch::Item<SpendAuth, Binding> {
batch::Item::from_binding(self.0.into(), sig.0, msg)
}
}
/// A RedPallas signature.