Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: improve Debug impl for Ed25519 VerificationKeys #1272

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/1272-ed25519-debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[tendermint]` Restore hex-formatting in debug output of Ed25519 keys.
([#1272](https://github.com/informalsystems/tendermint-rs/pull/1272))
17 changes: 16 additions & 1 deletion tendermint/src/crypto/ed25519/verification_key.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
use crate::Error;

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct VerificationKey([u8; 32]);

impl core::fmt::Display for VerificationKey {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
for byte in &self.0 {
write!(f, "{byte:02x}")?;
}
Ok(())
}
}

impl core::fmt::Debug for VerificationKey {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
<Self as core::fmt::Display>::fmt(self, f)
}
}

impl VerificationKey {
#[allow(dead_code)]
pub(super) fn new(bytes: [u8; 32]) -> Self {
Expand Down