Refine JoinSplit::anchor to be a sprout::NoteTreeRootHash type
This commit is contained in:
parent
5a5882700c
commit
437f40d3c8
|
@ -4,6 +4,7 @@ use crate::{
|
||||||
ed25519_zebra,
|
ed25519_zebra,
|
||||||
notes::sprout,
|
notes::sprout,
|
||||||
proofs::ZkSnarkProof,
|
proofs::ZkSnarkProof,
|
||||||
|
treestate,
|
||||||
types::amount::{Amount, NonNegative},
|
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
|
/// 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
|
/// past, or the root produced by a previous JoinSplit transfer in this
|
||||||
/// transaction.
|
/// transaction.
|
||||||
///
|
pub anchor: treestate::sprout::NoteTreeRootHash,
|
||||||
/// XXX refine type
|
|
||||||
pub anchor: [u8; 32],
|
|
||||||
/// A nullifier for the input notes.
|
/// A nullifier for the input notes.
|
||||||
pub nullifiers: [crate::notes::sprout::Nullifier; 2],
|
pub nullifiers: [crate::notes::sprout::Nullifier; 2],
|
||||||
/// A note commitment for this output note.
|
/// A note commitment for this output note.
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::{
|
||||||
serialization::{
|
serialization::{
|
||||||
ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize, ZcashSerialize,
|
ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize, ZcashSerialize,
|
||||||
},
|
},
|
||||||
types,
|
treestate, types,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
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> {
|
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_old.into())?;
|
||||||
writer.write_u64::<LittleEndian>(self.vpub_new.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[0].into())?;
|
||||||
writer.write_32_bytes(&self.nullifiers[1].into())?;
|
writer.write_32_bytes(&self.nullifiers[1].into())?;
|
||||||
writer.write_32_bytes(&self.commitments[0].into())?;
|
writer.write_32_bytes(&self.commitments[0].into())?;
|
||||||
|
@ -262,7 +262,7 @@ impl<P: ZkSnarkProof> ZcashDeserialize for JoinSplit<P> {
|
||||||
Ok(JoinSplit::<P> {
|
Ok(JoinSplit::<P> {
|
||||||
vpub_old: reader.read_u64::<LittleEndian>()?.try_into()?,
|
vpub_old: reader.read_u64::<LittleEndian>()?.try_into()?,
|
||||||
vpub_new: 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: [
|
nullifiers: [
|
||||||
reader.read_32_bytes()?.into(),
|
reader.read_32_bytes()?.into(),
|
||||||
reader.read_32_bytes()?.into(),
|
reader.read_32_bytes()?.into(),
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
CoinbaseData, JoinSplit, JoinSplitData, OutPoint, Output, ShieldedData, Spend, Transaction,
|
CoinbaseData, JoinSplit, JoinSplitData, OutPoint, Output, ShieldedData, Spend, Transaction,
|
||||||
TransparentInput,
|
TransparentInput,
|
||||||
},
|
},
|
||||||
treestate::note_commitment_tree::SaplingNoteTreeRootHash,
|
treestate::{self, note_commitment_tree::SaplingNoteTreeRootHash},
|
||||||
types::{
|
types::{
|
||||||
amount::{Amount, NonNegative},
|
amount::{Amount, NonNegative},
|
||||||
BlockHeight, Script,
|
BlockHeight, Script,
|
||||||
|
@ -22,7 +22,7 @@ impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplit<P> {
|
||||||
(
|
(
|
||||||
any::<Amount<NonNegative>>(),
|
any::<Amount<NonNegative>>(),
|
||||||
any::<Amount<NonNegative>>(),
|
any::<Amount<NonNegative>>(),
|
||||||
array::uniform32(any::<u8>()),
|
any::<treestate::sprout::NoteTreeRootHash>(),
|
||||||
array::uniform2(any::<sprout::Nullifier>()),
|
array::uniform2(any::<sprout::Nullifier>()),
|
||||||
array::uniform2(any::<commitments::sprout::NoteCommitment>()),
|
array::uniform2(any::<commitments::sprout::NoteCommitment>()),
|
||||||
array::uniform32(any::<u8>()),
|
array::uniform32(any::<u8>()),
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
|
|
||||||
pub mod note_commitment_tree;
|
pub mod note_commitment_tree;
|
||||||
// mod nullifier_set;
|
// mod nullifier_set;
|
||||||
|
pub mod sprout;
|
||||||
|
|
Loading…
Reference in New Issue