aboutsummaryrefslogtreecommitdiffstats
path: root/src/protocol.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol.rs')
-rw-r--r--src/protocol.rs13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/protocol.rs b/src/protocol.rs
index 6028bf2..5726efd 100644
--- a/src/protocol.rs
+++ b/src/protocol.rs
@@ -3,8 +3,6 @@ use std::net::TcpStream;
use std::time::Duration;
use std::io::{Read, Write};
use std::cmp;
-use crypto::digest::Digest;
-use crypto::blake2b::Blake2b;
use sodiumoxide::crypto::stream::*;
use rand::{OsRng, Rng};
use protobuf::Message;
@@ -14,6 +12,7 @@ use integer_encoding::{VarIntReader, VarIntWriter};
use errors::*;
use network_msgs::*;
use metadata_msgs::Index;
+use make_discovery_key;
#[derive(Debug)]
pub enum DatNetMessage {
@@ -130,16 +129,6 @@ fn test_bsxii_continued() {
assert_eq!(a, c);
}
-// TODO: move to lib.rs?
-pub fn make_discovery_key(key: &[u8]) -> Vec<u8> {
- // calculate discovery key
- let mut discovery_key = [0; 32];
- let mut hash = Blake2b::new_keyed(32, key);
- hash.input(&"hypercore".as_bytes());
- hash.result(&mut discovery_key);
- discovery_key.to_vec()
-}
-
/// Represents a bi-directional connection to a network peer
///
/// Spec says nonce is 32 bytes, by dat implementation (hypercore-protocol) is 24 bytes.