From 1d613c2113ebf3736420e1097a70554764e3be58 Mon Sep 17 00:00:00 2001 From: Andreas Fackler Date: Mon, 22 Oct 2018 14:04:37 +0200 Subject: [PATCH] Make hash_g2 public. This function can be useful, to avoid redundant hashing of a long message. --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4c00a56..8ef55d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,6 +98,8 @@ impl PublicKey { } /// Returns `true` if the signature matches the message. + /// + /// This is equivalent to `verify_g2(sig, hash_g2(msg))`. pub fn verify>(&self, sig: &Signature, msg: M) -> bool { self.verify_g2(sig, hash_g2(msg)) } @@ -146,6 +148,8 @@ impl PublicKeyShare { } /// Returns `true` if the signature matches the message. + /// + /// This is equivalent to `verify_g2(sig, hash_g2(msg))`. pub fn verify>(&self, sig: &SignatureShare, msg: M) -> bool { self.verify_g2(sig, hash_g2(msg)) } @@ -294,6 +298,8 @@ impl SecretKey { } /// Signs the given message. + /// + /// This is equivalent to `sign_g2(hash_g2(msg))`. pub fn sign>(&self, msg: M) -> Signature { self.sign_g2(hash_g2(msg)) } @@ -534,7 +540,7 @@ impl SecretKeySet { } /// Returns a hash of the given message in `G2`. -fn hash_g2>(msg: M) -> G2 { +pub fn hash_g2>(msg: M) -> G2 { let digest = sha3_256(msg.as_ref()); let seed = <[u32; CHACHA_RNG_SEED_SIZE]>::init_with_indices(|i| { BigEndian::read_u32(&digest.as_ref()[(4 * i)..(4 * i + 4)])