From 6941fe1109df0db38f5ade26c6d9d44a25841030 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 5 Apr 2022 20:18:10 +0000 Subject: [PATCH] Make `Debug` impl for `Proof` much less verbose For the default `{:?}` debug formatting we now only print the length of the proof, while `{#?}` continues to print the full byte vector. --- src/circuit.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/circuit.rs b/src/circuit.rs index 74aed99d..3b999fa0 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -1,5 +1,7 @@ //! The Orchard Action circuit implementation. +use std::fmt; + use group::{Curve, GroupEncoding}; use halo2_proofs::{ circuit::{floor_planner, AssignedCell, Layouter}, @@ -818,9 +820,22 @@ impl Instance { /// A proof of the validity of an Orchard [`Bundle`]. /// /// [`Bundle`]: crate::bundle::Bundle -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Proof(Vec); +impl fmt::Debug for Proof { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if f.alternate() { + f.debug_tuple("Proof").field(&self.0).finish() + } else { + // By default, only show the proof length, not its contents. + f.debug_tuple("Proof") + .field(&format_args!("{} bytes", self.0.len())) + .finish() + } + } +} + impl AsRef<[u8]> for Proof { fn as_ref(&self) -> &[u8] { &self.0