non-test code compiles

This commit is contained in:
DieMyst 2021-01-18 20:14:40 +03:00
parent a0261bc331
commit 256cf96436
3 changed files with 6 additions and 9 deletions

View File

@ -14,12 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
extern crate rand;
use crate::ed25519::{Keypair as Libp2pKeyPair}; use crate::ed25519::{Keypair as Libp2pKeyPair};
use ed25519_dalek::SignatureError; use ed25519_dalek::SignatureError;
use ed25519_dalek::{PublicKey, Signer}; use ed25519_dalek::{PublicKey, Signer};
use signature::{Signature as SigSignature};
use core::fmt::{Debug}; use core::fmt::{Debug};
use std::fmt; use std::fmt;
use rand::rngs::OsRng; use rand::rngs::OsRng;
@ -77,10 +75,8 @@ impl KeyPair {
pub fn verify(pk: &PublicKey, msg: &[u8], signature: Signature) -> Result<(), String> { pub fn verify(pk: &PublicKey, msg: &[u8], signature: Signature) -> Result<(), String> {
// let signature = ed25519_dalek::Signature::from_bytes(signature) // let signature = ed25519_dalek::Signature::from_bytes(signature)
// .map_err(|err| format!("Cannot convert bytes to a signature: {:?}", err))?; // .map_err(|err| format!("Cannot convert bytes to a signature: {:?}", err))?;
let result = pk.verify_strict(msg, &signature) pk.verify_strict(msg, &signature)
.map_err(|err| format!("Signature verification failed: {:?}", err))?; .map_err(|err| format!("Signature verification failed: {:?}", err))
Err("Signature is not valid.".to_string())
} }
} }

View File

@ -90,7 +90,7 @@ impl <'de>serde::Deserialize<'de> for PublicKeyHashable {
impl<'de> Visitor<'de> for PKVisitor { impl<'de> Visitor<'de> for PKVisitor {
type Value = PublicKeyHashable; 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") formatter.write_str("byte array or base58 string")
} }

View File

@ -212,7 +212,8 @@ impl TrustGraph {
// - that trust must converge to one of the root weights // - that trust must converge to one of the root weights
// - there should be more than 1 trust in the chain // - there should be more than 1 trust in the chain
let self_signed = last.issued_by == last.trust.issued_for; 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 { if self_signed && converges_to_root && cur_chain.len() > 1 {
terminated_chains.push(cur_chain); terminated_chains.push(cur_chain);