Make `Debug` impl for `TransmittedNoteCiphertext` less verbose

We now print the ciphertexts as hex bytes, for which we unambiguously
encode them in RPC outputs (vs 32-byte values which are more complex).
This commit is contained in:
Jack Grigg 2022-04-05 22:38:10 +00:00
parent 6941fe1109
commit caca664b20
2 changed files with 14 additions and 2 deletions

View File

@ -30,6 +30,7 @@ fpe = "0.5"
group = "0.11" group = "0.11"
halo2_gadgets = "=0.1.0-beta.3" halo2_gadgets = "=0.1.0-beta.3"
halo2_proofs = "=0.1.0-beta.4" halo2_proofs = "=0.1.0-beta.4"
hex = "0.4"
lazy_static = "1" lazy_static = "1"
memuse = { version = "0.2", features = ["nonempty"] } memuse = { version = "0.2", features = ["nonempty"] }
pasta_curves = "0.3" pasta_curves = "0.3"
@ -48,7 +49,6 @@ plotters = { version = "0.3.0", optional = true }
[dev-dependencies] [dev-dependencies]
criterion = "0.3" criterion = "0.3"
halo2_gadgets = { version = "=0.1.0-beta.3", features = ["test-dependencies"] } halo2_gadgets = { version = "=0.1.0-beta.3", features = ["test-dependencies"] }
hex = "0.4"
proptest = "1.0.0" proptest = "1.0.0"
zcash_note_encryption = { version = "0.1", features = ["pre-zip-212"] } zcash_note_encryption = { version = "0.1", features = ["pre-zip-212"] }

View File

@ -1,4 +1,6 @@
//! Data structures used for note construction. //! Data structures used for note construction.
use std::fmt;
use group::GroupEncoding; use group::GroupEncoding;
use pasta_curves::pallas; use pasta_curves::pallas;
use rand::RngCore; use rand::RngCore;
@ -236,7 +238,7 @@ impl Note {
} }
/// An encrypted note. /// An encrypted note.
#[derive(Debug, Clone)] #[derive(Clone)]
pub struct TransmittedNoteCiphertext { pub struct TransmittedNoteCiphertext {
/// The serialization of the ephemeral public key /// The serialization of the ephemeral public key
pub epk_bytes: [u8; 32], pub epk_bytes: [u8; 32],
@ -247,6 +249,16 @@ pub struct TransmittedNoteCiphertext {
pub out_ciphertext: [u8; 80], pub out_ciphertext: [u8; 80],
} }
impl fmt::Debug for TransmittedNoteCiphertext {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TransmittedNoteCiphertext")
.field("epk_bytes", &self.epk_bytes)
.field("enc_ciphertext", &hex::encode(self.enc_ciphertext))
.field("out_ciphertext", &hex::encode(self.out_ciphertext))
.finish()
}
}
/// Generators for property testing. /// Generators for property testing.
#[cfg(any(test, feature = "test-dependencies"))] #[cfg(any(test, feature = "test-dependencies"))]
#[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] #[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))]