Merge pull request #22 from poanetwork/afck-fmt

Use Formatter debug helpers. Hide SecretKeyShares.
This commit is contained in:
Vladimir Komendantskiy 2018-09-03 11:16:32 +01:00 committed by GitHub
commit 76ac2a5415
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View File

@ -130,7 +130,7 @@ impl fmt::Debug for PublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let uncomp = self.0.into_affine().into_uncompressed(); let uncomp = self.0.into_affine().into_uncompressed();
let bytes = uncomp.as_ref(); let bytes = uncomp.as_ref();
write!(f, "PublicKey({:?})", HexBytes(bytes)) f.debug_tuple("PublicKey").field(&HexBytes(bytes)).finish()
} }
} }
@ -171,7 +171,9 @@ impl fmt::Debug for PublicKeyShare {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let uncomp = (self.0).0.into_affine().into_uncompressed(); let uncomp = (self.0).0.into_affine().into_uncompressed();
let bytes = uncomp.as_ref(); let bytes = uncomp.as_ref();
write!(f, "PublicKeyShare({:?})", HexBytes(bytes)) f.debug_tuple("PublicKeyShare")
.field(&HexBytes(bytes))
.finish()
} }
} }
@ -208,7 +210,7 @@ impl fmt::Debug for Signature {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let uncomp = self.0.into_affine().into_uncompressed(); let uncomp = self.0.into_affine().into_uncompressed();
let bytes = uncomp.as_ref(); let bytes = uncomp.as_ref();
write!(f, "Signature({:?})", HexBytes(bytes)) f.debug_tuple("Signature").field(&HexBytes(bytes)).finish()
} }
} }
@ -238,7 +240,9 @@ impl fmt::Debug for SignatureShare {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let uncomp = (self.0).0.into_affine().into_uncompressed(); let uncomp = (self.0).0.into_affine().into_uncompressed();
let bytes = uncomp.as_ref(); let bytes = uncomp.as_ref();
write!(f, "SignatureShare({:?})", HexBytes(bytes)) f.debug_tuple("SignatureShare")
.field(&HexBytes(bytes))
.finish()
} }
} }
@ -313,7 +317,7 @@ impl Drop for SecretKey {
/// A debug statement where the secret prime field element is redacted. /// A debug statement where the secret prime field element is redacted.
impl fmt::Debug for SecretKey { impl fmt::Debug for SecretKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "SecretKey(...)") f.debug_tuple("SecretKey").field(&"...").finish()
} }
} }
@ -445,9 +449,7 @@ pub struct SecretKeyShare(SecretKey);
impl fmt::Debug for SecretKeyShare { impl fmt::Debug for SecretKeyShare {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let uncomp = self.0.public_key().0.into_affine().into_uncompressed(); f.debug_tuple("SecretKeyShare").field(&"...").finish()
let bytes = uncomp.as_ref();
write!(f, "SecretKeyShare({:?})", HexBytes(bytes))
} }
} }

View File

@ -56,7 +56,7 @@ impl Clone for Poly {
/// A debug statement where the `coeff` vector of prime field elements has been redacted. /// A debug statement where the `coeff` vector of prime field elements has been redacted.
impl Debug for Poly { impl Debug for Poly {
fn fmt(&self, f: &mut Formatter) -> fmt::Result { fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "Poly {{ coeff: ... }}") f.debug_struct("Poly").field("coeff", &"...").finish()
} }
} }
@ -689,7 +689,10 @@ impl Drop for BivarPoly {
/// A debug statement where the `coeff` vector has been redacted. /// A debug statement where the `coeff` vector has been redacted.
impl Debug for BivarPoly { impl Debug for BivarPoly {
fn fmt(&self, f: &mut Formatter) -> fmt::Result { fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "BivarPoly {{ degree: {}, coeff: ... }}", self.degree) f.debug_struct("BivarPoly")
.field("degree", &self.degree)
.field("coeff", &"...")
.finish()
} }
} }