Skip to content

Commit 419faa8

Browse files
committed
Format Sprout and Sapling nullifiers as hex when debugging
1 parent 6f3eebe commit 419faa8

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

zebra-chain/src/sapling/note/nullifiers.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
//! Sapling nullifiers.
22
3+
use crate::fmt::HexDebug;
4+
35
/// A Nullifier for Sapling transactions
46
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
57
#[cfg_attr(
68
any(test, feature = "proptest-impl"),
79
derive(proptest_derive::Arbitrary)
810
)]
9-
pub struct Nullifier(pub [u8; 32]);
11+
pub struct Nullifier(pub HexDebug<[u8; 32]>);
1012

1113
impl From<[u8; 32]> for Nullifier {
1214
fn from(buf: [u8; 32]) -> Self {
13-
Self(buf)
15+
Self(buf.into())
1416
}
1517
}
1618

1719
impl From<Nullifier> for [u8; 32] {
1820
fn from(n: Nullifier) -> Self {
19-
n.0
21+
*n.0
2022
}
2123
}
2224

zebra-chain/src/sprout/note/nullifiers.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
33
use serde::{Deserialize, Serialize};
44

5+
use crate::fmt::HexDebug;
6+
57
/// Nullifier seed, named rho in the [spec][ps].
68
///
79
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
@@ -11,23 +13,23 @@ use serde::{Deserialize, Serialize};
1113
any(test, feature = "proptest-impl"),
1214
derive(proptest_derive::Arbitrary)
1315
)]
14-
pub struct NullifierSeed(pub(crate) [u8; 32]);
16+
pub struct NullifierSeed(pub(crate) HexDebug<[u8; 32]>);
1517

1618
impl AsRef<[u8]> for NullifierSeed {
1719
fn as_ref(&self) -> &[u8] {
18-
&self.0
20+
self.0.as_ref()
1921
}
2022
}
2123

2224
impl From<[u8; 32]> for NullifierSeed {
2325
fn from(bytes: [u8; 32]) -> Self {
24-
Self(bytes)
26+
Self(bytes.into())
2527
}
2628
}
2729

2830
impl From<NullifierSeed> for [u8; 32] {
2931
fn from(rho: NullifierSeed) -> Self {
30-
rho.0
32+
*rho.0
3133
}
3234
}
3335

@@ -37,22 +39,22 @@ impl From<NullifierSeed> for [u8; 32] {
3739
any(test, feature = "proptest-impl"),
3840
derive(proptest_derive::Arbitrary)
3941
)]
40-
pub struct Nullifier(pub [u8; 32]);
42+
pub struct Nullifier(pub HexDebug<[u8; 32]>);
4143

4244
impl From<[u8; 32]> for Nullifier {
4345
fn from(bytes: [u8; 32]) -> Self {
44-
Self(bytes)
46+
Self(bytes.into())
4547
}
4648
}
4749

4850
impl From<Nullifier> for [u8; 32] {
4951
fn from(n: Nullifier) -> Self {
50-
n.0
52+
*n.0
5153
}
5254
}
5355

5456
impl From<&Nullifier> for [u8; 32] {
5557
fn from(n: &Nullifier) -> Self {
56-
n.0
58+
*n.0
5759
}
5860
}

0 commit comments

Comments
 (0)