Skip to content

Commit

Permalink
Merge pull request #134 from bltavares/update-ed25519-dalek
Browse files Browse the repository at this point in the history
Update ed25519-dalek to the latest version
  • Loading branch information
bltavares authored Feb 6, 2021
2 parents e3f304e + ce05a4e commit 8d8cbef
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ edition = "2018"
[dependencies]
blake2-rfc = "0.2.18"
byteorder = "1.3.4"
ed25519-dalek = "=1.0.0-pre.3"
ed25519-dalek = "1.0.1"
anyhow = "1.0.26"
flat-tree = "5.0.0"
lazy_static = "1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/key_pair.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Generate an `Ed25519` keypair.
pub use ed25519_dalek::{ExpandedSecretKey, Keypair, PublicKey, SecretKey, Signature};
pub use ed25519_dalek::{ExpandedSecretKey, Keypair, PublicKey, SecretKey, Signature, Verifier};

use anyhow::{bail, ensure, Result};
use rand::rngs::{OsRng, StdRng};
Expand Down
6 changes: 1 addition & 5 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
//! Convenience wrapper to import all of Hypercore's core.
//!
//! ```rust
//!
//! use hypercore::prelude::*;
//!
//! fn main () {
//! let feed = Feed::default();
//! }
//! let feed = Feed::default();
//! ```
pub use crate::feed::Feed;
// pub use feed_builder::FeedBuilder;
Expand Down
11 changes: 6 additions & 5 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use random_access_memory::RandomAccessMemory;
use random_access_storage::RandomAccess;
use sleep_parser::*;
use std::borrow::Borrow;
use std::convert::TryFrom;
use std::fmt::Debug;
use std::ops::Range;
use std::path::PathBuf;
Expand Down Expand Up @@ -157,10 +158,10 @@ where
}

/// Search the signature stores for a `Signature`, starting at `index`.
pub fn next_signature<'a>(
&'a mut self,
pub fn next_signature(
&mut self,
index: u64,
) -> futures::future::BoxFuture<'a, Result<Signature>> {
) -> futures::future::BoxFuture<'_, Result<Signature>> {
let bytes = async_std::task::block_on(async {
self.signatures
.read(HEADER_OFFSET + 64 * index, 64)
Expand All @@ -170,7 +171,7 @@ where
async move {
let bytes = bytes?;
if not_zeroes(&bytes) {
Ok(Signature::from_bytes(&bytes)?)
Ok(Signature::try_from(&bytes[..])?)
} else {
Ok(self.next_signature(index + 1).await?)
}
Expand All @@ -187,7 +188,7 @@ where
.await
.map_err(|e| anyhow!(e))?;
ensure!(not_zeroes(&bytes), "No signature found");
Ok(Signature::from_bytes(&bytes)?)
Ok(Signature::try_from(&bytes[..])?)
}

/// Write a `Signature` to `self.Signatures`.
Expand Down
3 changes: 2 additions & 1 deletion tests/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ed25519_dalek;

use tempfile;

use std::convert::TryFrom;
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -107,7 +108,7 @@ async fn deterministic_signatures() {
expected_signatures
);

let compat_signature = Signature::from_bytes(&compat_signature_struct).unwrap();
let compat_signature = Signature::try_from(&compat_signature_struct[..]).unwrap();
feed.verify(feed.len() - 1, &compat_signature)
.await
.expect("Could not verify compat signature of hypercore v9");
Expand Down

0 comments on commit 8d8cbef

Please sign in to comment.