Rename tree::*NoteTreeRootHash to tree::Root
This commit is contained in:
parent
31d98248ab
commit
b467a75e08
|
@ -1,7 +1,7 @@
|
|||
//! The LightClientRootHash enum, used for the corresponding block header field.
|
||||
|
||||
use crate::parameters::{Network, NetworkUpgrade, NetworkUpgrade::*};
|
||||
use crate::sapling::tree::SaplingNoteTreeRootHash;
|
||||
use crate::sapling::tree::Root;
|
||||
|
||||
use super::Height;
|
||||
|
||||
|
@ -21,7 +21,7 @@ pub enum RootHash {
|
|||
///
|
||||
/// The root LEBS2OSP256(rt) of the Sapling note commitment tree
|
||||
/// corresponding to the final Sapling treestate of this block.
|
||||
FinalSaplingRoot(SaplingNoteTreeRootHash),
|
||||
FinalSaplingRoot(Root),
|
||||
|
||||
/// [Heartwood activation block] Reserved field.
|
||||
///
|
||||
|
@ -51,7 +51,7 @@ impl RootHash {
|
|||
|
||||
match NetworkUpgrade::current(network, height) {
|
||||
Genesis | BeforeOverwinter | Overwinter => PreSaplingReserved(bytes),
|
||||
Sapling | Blossom => FinalSaplingRoot(SaplingNoteTreeRootHash(bytes)),
|
||||
Sapling | Blossom => FinalSaplingRoot(Root(bytes)),
|
||||
Heartwood if Some(height) == Heartwood.activation_height(network) => {
|
||||
ChainHistoryActivationReserved(bytes)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ pub struct Spend {
|
|||
/// A value commitment to the value of the input note.
|
||||
pub cv: commitment::ValueCommitment,
|
||||
/// A root of the Sapling note commitment tree at some block height in the past.
|
||||
pub anchor: tree::SaplingNoteTreeRootHash,
|
||||
pub anchor: tree::Root,
|
||||
/// The nullifier of the input note.
|
||||
pub nullifier: note::Nullifier,
|
||||
/// The randomized public key for `spend_auth_sig`.
|
||||
|
@ -45,12 +45,10 @@ impl ZcashSerialize for Spend {
|
|||
|
||||
impl ZcashDeserialize for Spend {
|
||||
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
|
||||
use crate::sapling::{
|
||||
commitment::ValueCommitment, note::Nullifier, tree::SaplingNoteTreeRootHash,
|
||||
};
|
||||
use crate::sapling::{commitment::ValueCommitment, note::Nullifier};
|
||||
Ok(Spend {
|
||||
cv: ValueCommitment::zcash_deserialize(&mut reader)?,
|
||||
anchor: SaplingNoteTreeRootHash(reader.read_32_bytes()?),
|
||||
anchor: tree::Root(reader.read_32_bytes()?),
|
||||
nullifier: Nullifier::from(reader.read_32_bytes()?),
|
||||
rk: reader.read_32_bytes()?.into(),
|
||||
zkproof: Groth16Proof::zcash_deserialize(&mut reader)?,
|
||||
|
|
|
@ -9,7 +9,7 @@ impl Arbitrary for Spend {
|
|||
|
||||
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
|
||||
(
|
||||
any::<tree::SaplingNoteTreeRootHash>(),
|
||||
any::<tree::Root>(),
|
||||
any::<commitment::ValueCommitment>(),
|
||||
any::<note::Nullifier>(),
|
||||
array::uniform32(any::<u8>()),
|
||||
|
|
|
@ -64,17 +64,15 @@ pub struct SaplingNoteCommitmentTree;
|
|||
/// each treestate.
|
||||
#[derive(Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(test, derive(Arbitrary))]
|
||||
pub struct SaplingNoteTreeRootHash(pub [u8; 32]);
|
||||
pub struct Root(pub [u8; 32]);
|
||||
|
||||
impl fmt::Debug for SaplingNoteTreeRootHash {
|
||||
impl fmt::Debug for Root {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple("SaplingNoteTreeRootHash")
|
||||
.field(&hex::encode(&self.0))
|
||||
.finish()
|
||||
f.debug_tuple("Root").field(&hex::encode(&self.0)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SaplingNoteCommitmentTree> for SaplingNoteTreeRootHash {
|
||||
impl From<SaplingNoteCommitmentTree> for Root {
|
||||
fn from(_tree: SaplingNoteCommitmentTree) -> Self {
|
||||
// TODO: The Sapling note commitment tree requires a Pedersen
|
||||
// hash function, not SHA256.
|
||||
|
|
|
@ -28,7 +28,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.
|
||||
pub anchor: tree::NoteTreeRootHash,
|
||||
pub anchor: tree::Root,
|
||||
/// A nullifier for the input notes.
|
||||
pub nullifiers: [note::Nullifier; 2],
|
||||
/// A note commitment for this output note.
|
||||
|
@ -93,7 +93,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: tree::NoteTreeRootHash::from(reader.read_32_bytes()?),
|
||||
anchor: tree::Root::from(reader.read_32_bytes()?),
|
||||
nullifiers: [
|
||||
reader.read_32_bytes()?.into(),
|
||||
reader.read_32_bytes()?.into(),
|
||||
|
|
|
@ -14,7 +14,7 @@ impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplit<P> {
|
|||
(
|
||||
any::<Amount<NonNegative>>(),
|
||||
any::<Amount<NonNegative>>(),
|
||||
any::<tree::NoteTreeRootHash>(),
|
||||
any::<tree::Root>(),
|
||||
array::uniform2(any::<note::Nullifier>()),
|
||||
array::uniform2(any::<commitment::NoteCommitment>()),
|
||||
array::uniform32(any::<u8>()),
|
||||
|
|
|
@ -24,24 +24,22 @@ use proptest_derive::Arbitrary;
|
|||
/// each treestate.
|
||||
#[derive(Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(test, derive(Arbitrary))]
|
||||
pub struct NoteTreeRootHash([u8; 32]);
|
||||
pub struct Root([u8; 32]);
|
||||
|
||||
impl fmt::Debug for NoteTreeRootHash {
|
||||
impl fmt::Debug for Root {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple("SproutNoteTreeRootHash")
|
||||
.field(&hex::encode(&self.0))
|
||||
.finish()
|
||||
f.debug_tuple("Root").field(&hex::encode(&self.0)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<[u8; 32]> for NoteTreeRootHash {
|
||||
fn from(bytes: [u8; 32]) -> NoteTreeRootHash {
|
||||
impl From<[u8; 32]> for Root {
|
||||
fn from(bytes: [u8; 32]) -> Root {
|
||||
Self(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NoteTreeRootHash> for [u8; 32] {
|
||||
fn from(rt: NoteTreeRootHash) -> [u8; 32] {
|
||||
impl From<Root> for [u8; 32] {
|
||||
fn from(rt: Root) -> [u8; 32] {
|
||||
rt.0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue