From 1d65827451b8deb071afebb8dc946ec2e8330721 Mon Sep 17 00:00:00 2001 From: ss-es <155648797+ss-es@users.noreply.github.com> Date: Fri, 27 Feb 2026 10:10:58 -0500 Subject: [PATCH 1/3] make debug match display --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 075b5f1..a377f1c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,7 +56,6 @@ pub trait Committable { #[derive(Derivative, AsRef, Into)] #[derivative( Copy(bound = ""), - Debug(bound = ""), PartialEq(bound = ""), Eq(bound = ""), PartialOrd(bound = ""), @@ -207,6 +206,13 @@ impl From<&Commitment> for TaggedBase64 { } } +#[cfg(feature = "ark-serialize")] +impl Debug for Commitment { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{}", TaggedBase64::from(self)) + } +} + #[cfg(feature = "ark-serialize")] impl Display for Commitment { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { From 3eb3e2f3d20275514d4cc1a62bec098445c70d8b Mon Sep 17 00:00:00 2001 From: ss-es <155648797+ss-es@users.noreply.github.com> Date: Fri, 27 Feb 2026 10:20:36 -0500 Subject: [PATCH 2/3] gate derived debug --- src/lib.rs | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a377f1c..a53c059 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,33 +9,34 @@ // See: https://github.com/mcarton/rust-derivative/issues/115 #![allow(clippy::non_canonical_partial_ord_impl, unused_imports)] -use arbitrary::{Arbitrary, Unstructured}; -use bitvec::vec::BitVec; +#[cfg(feature = "ark-serialize")] +use core::fmt::{self, Display, Formatter}; use core::marker::PhantomData; -use derivative::Derivative; -use derive_more::{AsRef, Into}; -use sha3::digest::{ - crypto_common::generic_array::{ArrayLength, GenericArray}, - Digest, -}; -use sha3::Keccak256; +#[cfg(feature = "ark-serialize")] +use core::str::FromStr; use std::{ convert::{TryFrom, TryInto}, fmt::Debug, hash::Hash, }; +use arbitrary::{Arbitrary, Unstructured}; #[cfg(feature = "ark-serialize")] use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; -#[cfg(feature = "ark-serialize")] -use core::fmt::{self, Display, Formatter}; -#[cfg(feature = "ark-serialize")] -use core::str::FromStr; -#[cfg(feature = "ark-serialize")] -use tagged_base64::{Tagged, TaggedBase64, Tb64Error}; - +use bitvec::vec::BitVec; +use derivative::Derivative; +use derive_more::{AsRef, Into}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; +use sha3::{ + digest::{ + crypto_common::generic_array::{ArrayLength, GenericArray}, + Digest, + }, + Keccak256, +}; +#[cfg(feature = "ark-serialize")] +use tagged_base64::{Tagged, TaggedBase64, Tb64Error}; type Array = [u8; 32]; @@ -62,6 +63,7 @@ pub trait Committable { Ord(bound = ""), Hash(bound = "") )] +#[cfg_attr(not(feature = "ark-serialize"), derivative(Debug(bound = "")))] #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] #[cfg_attr( feature = "serde", @@ -319,9 +321,10 @@ impl RawCommitmentBuilder { #[cfg(all(test, feature = "ark-serialize", feature = "serde"))] mod test { - use super::*; use std::{fmt::Debug, hash::Hash}; + use super::*; + struct DummyCommittable; impl Committable for DummyCommittable { fn commit(&self) -> Commitment { @@ -419,9 +422,10 @@ mod test { #[cfg(test)] mod test_quickcheck { - use super::INVALID_UTF8; use quickcheck_macros::quickcheck; + use super::INVALID_UTF8; + #[quickcheck] fn invalid_utf8_is_invalid(pref: Vec, suff: Vec) { let s = pref From 7f3897fa4dc7aae24aaac8bf9af1d5f2c93af8a4 Mon Sep 17 00:00:00 2001 From: ss-es <155648797+ss-es@users.noreply.github.com> Date: Mon, 2 Mar 2026 12:25:23 -0500 Subject: [PATCH 3/3] Update src/lib.rs Co-authored-by: Toralf Wittner --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index a53c059..12efcbe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -211,7 +211,7 @@ impl From<&Commitment> for TaggedBase64 { #[cfg(feature = "ark-serialize")] impl Debug for Commitment { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "{}", TaggedBase64::from(self)) + ::fmt(self, f) } }