Add accessors necessary for zip-225 write.

This commit is contained in:
Kris Nuttycombe 2021-04-21 14:32:54 -06:00
parent e743198a50
commit a5c9fb953b
6 changed files with 37 additions and 0 deletions

View File

@ -195,6 +195,16 @@ impl Authorized {
binding_signature,
}
}
/// Return the proof component of the authorizing data.
pub fn proof(&self) -> &Proof {
&self.proof
}
/// Return the binding signature.
pub fn binding_signature(&self) -> &redpallas::Signature<Binding> {
&self.binding_signature
}
}
impl Authorization for Authorized {

View File

@ -120,6 +120,12 @@ impl Instance {
#[derive(Debug)]
pub struct Proof(Vec<u8>);
impl<'a> From<&'a Proof> for &'a Vec<u8> {
fn from(proof: &'a Proof) -> &'a Vec<u8> {
&proof.0
}
}
impl Proof {
/// Creates a proof for the given circuits and instances.
pub fn create(

View File

@ -64,6 +64,11 @@ impl ExtractedNoteCommitment {
pub fn from_bytes(bytes: &[u8; 32]) -> CtOption<Self> {
pallas::Base::from_bytes(bytes).map(ExtractedNoteCommitment)
}
/// Serialize the value commitment to its canonical byte representation.
pub fn to_bytes(&self) -> [u8; 32] {
self.0.to_bytes()
}
}
impl From<NoteCommitment> for ExtractedNoteCommitment {

View File

@ -36,6 +36,11 @@ impl Nullifier {
pallas::Base::from_bytes(bytes).map(Nullifier)
}
/// Serialize the nullifier to its canonical byte representation.
pub fn to_bytes(&self) -> [u8; 32] {
self.0.to_bytes()
}
/// $DeriveNullifier$.
///
/// Defined in [Zcash Protocol Spec § 4.16: Note Commitments and Nullifiers][commitmentsandnullifiers].

View File

@ -102,6 +102,12 @@ impl<T: SigType> From<[u8; 64]> for Signature<T> {
}
}
impl<T: SigType> From<&Signature<T>> for [u8; 64] {
fn from(sig: &Signature<T>) -> Self {
sig.0.into()
}
}
pub(crate) mod private {
use super::{Binding, SpendAuth};

View File

@ -266,4 +266,9 @@ mod tests {
assert_eq!(redpallas::VerificationKey::from(&bsk), bvk);
}
}
/// Serialize the value commitment to its canonical byte representation.
pub fn to_bytes(&self) -> [u8; 32] {
self.0.to_bytes()
}
}