Use hex_fmt 0.2.0.

master
Andreas Fackler 7 years ago committed by Marc Brinkmann
parent 2ca1d2ef7d
commit 29b40fffa7
  1. 2
      Cargo.toml
  2. 18
      src/lib.rs

@ -19,7 +19,7 @@ categories = ["cryptography"]
byteorder = "1.2.3" byteorder = "1.2.3"
errno = "0.2.4" errno = "0.2.4"
failure = "0.1" failure = "0.1"
hex_fmt = "0.1" hex_fmt = "0.2"
init_with = "1.1.0" init_with = "1.1.0"
lazy_static = "1.1.0" lazy_static = "1.1.0"
log = "0.4.1" log = "0.4.1"

@ -87,7 +87,7 @@ impl Hash for PublicKey {
impl fmt::Debug for PublicKey { 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();
f.debug_tuple("PublicKey").field(&HexFmt(uncomp)).finish() write!(f, "PublicKey({:0.10})", HexFmt(uncomp))
} }
} }
@ -135,9 +135,7 @@ pub struct PublicKeyShare(PublicKey);
impl fmt::Debug for PublicKeyShare { 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();
f.debug_tuple("PublicKeyShare") write!(f, "PublicKeyShare({:0.10})", HexFmt(uncomp))
.field(&HexFmt(uncomp))
.finish()
} }
} }
@ -173,7 +171,7 @@ pub struct Signature(#[serde(with = "serde_impl::projective")] G2);
impl fmt::Debug for Signature { 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();
f.debug_tuple("Signature").field(&HexFmt(uncomp)).finish() write!(f, "Signature({:0.10})", HexFmt(uncomp))
} }
} }
@ -188,7 +186,7 @@ impl Signature {
let uncomp = self.0.into_affine().into_uncompressed(); let uncomp = self.0.into_affine().into_uncompressed();
let xor_bytes: u8 = uncomp.as_ref().iter().fold(0, |result, byte| result ^ byte); let xor_bytes: u8 = uncomp.as_ref().iter().fold(0, |result, byte| result ^ byte);
let parity = 0 != xor_bytes.count_ones() % 2; let parity = 0 != xor_bytes.count_ones() % 2;
debug!("Signature: {}, parity: {}", HexFmt(uncomp), parity); debug!("Signature: {:0.10}, parity: {}", HexFmt(uncomp), parity);
parity parity
} }
} }
@ -201,9 +199,7 @@ pub struct SignatureShare(pub Signature);
impl fmt::Debug for SignatureShare { 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();
f.debug_tuple("SignatureShare") write!(f, "SignatureShare({:0.10})", HexFmt(uncomp))
.field(&HexFmt(uncomp))
.finish()
} }
} }
@ -317,7 +313,7 @@ impl SecretKey {
/// field element. /// field element.
pub fn reveal(&self) -> String { pub fn reveal(&self) -> String {
let uncomp = self.public_key().0.into_affine().into_uncompressed(); let uncomp = self.public_key().0.into_affine().into_uncompressed();
format!("SecretKey({})", HexFmt(uncomp)) format!("SecretKey({:0.10})", HexFmt(uncomp))
} }
} }
@ -376,7 +372,7 @@ impl SecretKeyShare {
/// field element. /// field element.
pub fn reveal(&self) -> String { pub fn reveal(&self) -> String {
let uncomp = self.0.public_key().0.into_affine().into_uncompressed(); let uncomp = self.0.public_key().0.into_affine().into_uncompressed();
format!("SecretKeyShare({})", HexFmt(uncomp)) format!("SecretKeyShare({:0.10})", HexFmt(uncomp))
} }
} }

Loading…
Cancel
Save