Add nullifiers(), and note_commitments() to ShieldedData

This commit is contained in:
Deirdre Connolly 2020-09-26 04:53:45 -04:00 committed by Deirdre Connolly
parent 97b6ba10cc
commit 5a78bbb6c9
1 changed files with 12 additions and 1 deletions

View File

@ -2,7 +2,7 @@ use futures::future::Either;
use crate::{
primitives::redjubjub::{Binding, Signature},
sapling::{Output, Spend},
sapling::{Nullifier, Output, Spend},
serialization::serde_helpers,
};
@ -61,6 +61,17 @@ impl ShieldedData {
.into_iter()
.chain(self.rest_outputs.iter())
}
/// Collect the [`Nullifier`]s for this transaction, if it contains
/// [`Spend`]s.
pub fn nullifiers(&self) -> Vec<Nullifier> {
self.spends().map(|spend| spend.nullifier).collect()
}
/// Collect the cm_u's for this transaction, if it contains [`Output`]s.
pub fn note_commitments(&self) -> Vec<jubjub::Fq> {
self.outputs().map(|output| output.cm_u).collect()
}
}
// Technically, it's possible to construct two equivalent representations