diff --git a/src/key_pair.rs b/src/key_pair.rs index 41f463c..0af1529 100644 --- a/src/key_pair.rs +++ b/src/key_pair.rs @@ -14,12 +14,10 @@ * limitations under the License. */ -extern crate rand; - use crate::ed25519::{Keypair as Libp2pKeyPair}; use ed25519_dalek::SignatureError; use ed25519_dalek::{PublicKey, Signer}; -use signature::{Signature as SigSignature}; + use core::fmt::{Debug}; use std::fmt; use rand::rngs::OsRng; @@ -77,10 +75,8 @@ impl KeyPair { pub fn verify(pk: &PublicKey, msg: &[u8], signature: Signature) -> Result<(), String> { // let signature = ed25519_dalek::Signature::from_bytes(signature) // .map_err(|err| format!("Cannot convert bytes to a signature: {:?}", err))?; - let result = pk.verify_strict(msg, &signature) - .map_err(|err| format!("Signature verification failed: {:?}", err))?; - - Err("Signature is not valid.".to_string()) + pk.verify_strict(msg, &signature) + .map_err(|err| format!("Signature verification failed: {:?}", err)) } } diff --git a/src/public_key_hashable.rs b/src/public_key_hashable.rs index 811b337..3f01d11 100644 --- a/src/public_key_hashable.rs +++ b/src/public_key_hashable.rs @@ -90,7 +90,7 @@ impl <'de>serde::Deserialize<'de> for PublicKeyHashable { impl<'de> Visitor<'de> for PKVisitor { type Value = PublicKeyHashable; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("byte array or base58 string") } diff --git a/src/trust_graph.rs b/src/trust_graph.rs index 3da66aa..820fcd2 100644 --- a/src/trust_graph.rs +++ b/src/trust_graph.rs @@ -212,7 +212,8 @@ impl TrustGraph { // - that trust must converge to one of the root weights // - there should be more than 1 trust in the chain let self_signed = last.issued_by == last.trust.issued_for; - let converges_to_root = roots.contains(last.issued_by.as_ref()); + let issued_by: &PublicKeyHashable = last.issued_by.as_ref(); + let converges_to_root = roots.contains(issued_by); if self_signed && converges_to_root && cur_chain.len() > 1 { terminated_chains.push(cur_chain);