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.
This commit is contained in:
Jack Grigg 2022-04-05 20:18:10 +00:00
parent 5b8690338e
commit 6941fe1109
1 changed files with 16 additions and 1 deletions

View File

@ -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<u8>);
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