Refine JoinSplit::anchor to be a sprout::NoteTreeRootHash type

This commit is contained in:
Deirdre Connolly 2020-08-12 02:15:57 -04:00 committed by Deirdre Connolly
parent 5a5882700c
commit 437f40d3c8
4 changed files with 8 additions and 8 deletions

View File

@ -4,6 +4,7 @@ use crate::{
ed25519_zebra,
notes::sprout,
proofs::ZkSnarkProof,
treestate,
types::amount::{Amount, NonNegative},
};
@ -22,9 +23,7 @@ pub struct JoinSplit<P: ZkSnarkProof> {
/// A root of the Sprout note commitment tree at some block height in the
/// past, or the root produced by a previous JoinSplit transfer in this
/// transaction.
///
/// XXX refine type
pub anchor: [u8; 32],
pub anchor: treestate::sprout::NoteTreeRootHash,
/// A nullifier for the input notes.
pub nullifiers: [crate::notes::sprout::Nullifier; 2],
/// A note commitment for this output note.

View File

@ -14,7 +14,7 @@ use crate::{
serialization::{
ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize, ZcashSerialize,
},
types,
treestate, types,
};
use super::*;
@ -241,7 +241,7 @@ impl<P: ZkSnarkProof> ZcashSerialize for JoinSplit<P> {
fn zcash_serialize<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> {
writer.write_u64::<LittleEndian>(self.vpub_old.into())?;
writer.write_u64::<LittleEndian>(self.vpub_new.into())?;
writer.write_all(&self.anchor[..])?;
writer.write_32_bytes(&self.anchor.into())?;
writer.write_32_bytes(&self.nullifiers[0].into())?;
writer.write_32_bytes(&self.nullifiers[1].into())?;
writer.write_32_bytes(&self.commitments[0].into())?;
@ -262,7 +262,7 @@ impl<P: ZkSnarkProof> ZcashDeserialize for JoinSplit<P> {
Ok(JoinSplit::<P> {
vpub_old: reader.read_u64::<LittleEndian>()?.try_into()?,
vpub_new: reader.read_u64::<LittleEndian>()?.try_into()?,
anchor: reader.read_32_bytes()?,
anchor: treestate::sprout::NoteTreeRootHash::from(reader.read_32_bytes()?),
nullifiers: [
reader.read_32_bytes()?.into(),
reader.read_32_bytes()?.into(),

View File

@ -6,7 +6,7 @@ use crate::{
CoinbaseData, JoinSplit, JoinSplitData, OutPoint, Output, ShieldedData, Spend, Transaction,
TransparentInput,
},
treestate::note_commitment_tree::SaplingNoteTreeRootHash,
treestate::{self, note_commitment_tree::SaplingNoteTreeRootHash},
types::{
amount::{Amount, NonNegative},
BlockHeight, Script,
@ -22,7 +22,7 @@ impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplit<P> {
(
any::<Amount<NonNegative>>(),
any::<Amount<NonNegative>>(),
array::uniform32(any::<u8>()),
any::<treestate::sprout::NoteTreeRootHash>(),
array::uniform2(any::<sprout::Nullifier>()),
array::uniform2(any::<commitments::sprout::NoteCommitment>()),
array::uniform32(any::<u8>()),

View File

@ -2,3 +2,4 @@
pub mod note_commitment_tree;
// mod nullifier_set;
pub mod sprout;