Skip to content

Commit

Permalink
Restore previous Debug impl for PublicKeyBytes (MystenLabs#3445)
Browse files Browse the repository at this point in the history
  • Loading branch information
mystenmark authored Jul 22, 2022
1 parent b8b657f commit 7dd5637
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions crates/sui-types/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,20 @@ pub type AggregateAccountSignature = Ed25519AggregateSignature;
//

#[serde_as]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
pub struct PublicKeyBytes(#[serde_as(as = "Readable<Base64, Bytes>")] [u8; PublicKey::LENGTH]);

impl PublicKeyBytes {
fn fmt_impl(
&self,
f: &mut std::fmt::Formatter<'_>,
) -> std::result::Result<(), std::fmt::Error> {
let s = hex::encode(&self.0);
write!(f, "k#{}", s)?;
Ok(())
}
}

impl TryFrom<PublicKeyBytes> for PublicKey {
type Error = signature::Error;

Expand All @@ -70,11 +81,15 @@ impl AsRef<[u8]> for PublicKeyBytes {
}
}

impl std::fmt::Debug for PublicKeyBytes {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
self.fmt_impl(f)
}
}

impl Display for PublicKeyBytes {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
let s = hex::encode(&self.0);
write!(f, "k#{}", s)?;
Ok(())
self.fmt_impl(f)
}
}

Expand Down

0 comments on commit 7dd5637

Please sign in to comment.