From a1038d9fb3b186d38ffca0c5498a830d600f7ee7 Mon Sep 17 00:00:00 2001 From: Vladimir Komendantskiy Date: Sat, 9 Jun 2018 10:03:38 +0100 Subject: [PATCH] updated the tests with key initialisation --- mod.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mod.rs b/mod.rs index 710ec3c..2d2e344 100644 --- a/mod.rs +++ b/mod.rs @@ -18,7 +18,7 @@ const CHACHA_RNG_SEED_SIZE: usize = 8; const ERR_OS_RNG: &str = "could not initialize the OS random number generator"; /// A public key, or a public key share. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct PublicKey(E::G1); impl PartialEq for PublicKey { @@ -70,13 +70,11 @@ impl PartialEq for Signature { impl Signature { pub fn parity(&self) -> bool { - 2 % self - .0 - .into_affine() - .into_uncompressed() - .as_ref() - .last() - .expect("non-empty signature") == 0 + let uncomp = self.0.into_affine().into_uncompressed(); + let bytes = uncomp.as_ref(); + let parity = 0 == bytes.last().expect("non-empty signature") % 2; + debug!("Signature: {:?}, output: {}", bytes, parity); + parity } } @@ -162,7 +160,7 @@ impl PartialEq for DecryptionShare { /// A public key and an associated set of public key shares. #[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))] -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct PublicKeySet { /// The coefficients of a polynomial whose value at `0` is the "master key", and value at /// `i + 1` is key share number `i`.