From 95584ac7a41782747bbf3439316e97a7ad688988 Mon Sep 17 00:00:00 2001 From: Alex Xiong Date: Sun, 27 Oct 2024 11:50:39 +0800 Subject: [PATCH] update CHANGELOG, better Debug for MTNode --- merkle_tree/CHANGELOG.md | 1 + merkle_tree/Cargo.toml | 1 + merkle_tree/src/prelude.rs | 12 ++++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/merkle_tree/CHANGELOG.md b/merkle_tree/CHANGELOG.md index ef5e898fa..606dc8795 100644 --- a/merkle_tree/CHANGELOG.md +++ b/merkle_tree/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Merkle proof verification proof APIs now takes `MerkleCommitment` instead of simply a root digest value. It can now be called without instantiating an actual Merkle tree struct. - Deprecate namespace Merkle tree for now because it's no longer in use. +- [#685](https://github.com/EspressoSystems/jellyfish/pull/685) Include a keccak256 Merkle trees in prelude ## 0.1.0 diff --git a/merkle_tree/Cargo.toml b/merkle_tree/Cargo.toml index 0f39ae5ad..7679ce5b1 100644 --- a/merkle_tree/Cargo.toml +++ b/merkle_tree/Cargo.toml @@ -22,6 +22,7 @@ derivative = { workspace = true } digest = { workspace = true } displaydoc = { workspace = true } hashbrown = { workspace = true } +hex = "0.4.3" itertools = { workspace = true, features = ["use_alloc"] } jf-relation = { version = "0.4.4", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", optional = true, default-features = false } jf-rescue = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", default-features = false } diff --git a/merkle_tree/src/prelude.rs b/merkle_tree/src/prelude.rs index f65b4bd20..495c38f33 100644 --- a/merkle_tree/src/prelude.rs +++ b/merkle_tree/src/prelude.rs @@ -22,7 +22,7 @@ use ark_serialize::{ CanonicalDeserialize, CanonicalSerialize, Compress, Read, SerializationError, Valid, Validate, Write, }; -use ark_std::{marker::PhantomData, vec::Vec}; +use ark_std::{fmt, marker::PhantomData, vec::Vec}; use jf_rescue::{crhf::RescueCRHF, RescueParameter}; use sha3::{Digest, Keccak256, Sha3_256}; @@ -63,9 +63,17 @@ pub type RescueSparseMerkleTree = UniversalMerkleTree, I, macro_rules! impl_mt_hash_256 { ($hasher:ident, $node_name:ident, $digest_name:ident) => { /// Internal node for merkle tree - #[derive(Default, Eq, PartialEq, Clone, Copy, Debug, Ord, PartialOrd, Hash)] + #[derive(Default, Eq, PartialEq, Clone, Copy, Ord, PartialOrd, Hash)] pub struct $node_name(pub(crate) [u8; 32]); + impl fmt::Debug for $node_name { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple(&stringify!($node_name)) + .field(&hex::encode(self.0)) + .finish() + } + } + impl AsRef<[u8]> for $node_name { fn as_ref(&self) -> &[u8] { &self.0