Skip to content

Commit

Permalink
Upd dalek
Browse files Browse the repository at this point in the history
  • Loading branch information
hacker-volodya committed Mar 22, 2024
1 parent 55b18c8 commit 2b97e20
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ ctr = "0.9.1"
aes = "0.8.1"
log = "0.4.14"
rand_core = "0.6.3"
x25519-dalek = { version = "2.0.0-pre.1", optional = true }
curve25519-dalek = { version = "4.0.0-pre.2", optional = true }
x25519-dalek = { version = "2.0.1", features = ["static_secrets"], optional = true }
curve25519-dalek = { version = "4.1.2", optional = true }
tokio = { version = "1.36", features = ["net", "io-util"] }
tokio-util = { version = "0.7.10", features = ["codec"] }
thiserror = "1"
Expand Down
1 change: 1 addition & 0 deletions src/integrations/dalek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ impl AdnlPublicKey for PublicKey {
fn edwards_to_montgomery<P: AdnlPublicKey>(public_key: &P) -> PublicKey {
PublicKey::from(
CompressedEdwardsY::from_slice(&public_key.edwards_repr())
.unwrap()
.decompress()
.unwrap()
.to_montgomery()
Expand Down
6 changes: 3 additions & 3 deletions src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
extern crate alloc;

use std::error::Error;

use super::*;
use alloc::vec::Vec;
use futures::{SinkExt, StreamExt};
Expand Down Expand Up @@ -176,7 +174,7 @@ fn test_public_key_consistency() {

#[tokio::test]
async fn integrity_test() {
let server_private = StaticSecret::new(rand::thread_rng());
let server_private = StaticSecret::random_from_rng(rand::thread_rng());
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let port = listener.local_addr().unwrap().port();
let server_public = server_private.public();
Expand All @@ -201,4 +199,6 @@ async fn integrity_test() {

// receive result
let result = client.next().await.expect("packet must be received").expect("packet must be decoded properly");

assert_eq!(result, "hello".as_bytes());
}
6 changes: 3 additions & 3 deletions src/wrappers/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::task::{Context, Poll};

use crate::{AdnlBuilder, AdnlError, AdnlHandshake, AdnlPrivateKey, AdnlPublicKey};
use pin_project::pin_project;
use tokio::io::{empty, AsyncRead, AsyncWrite, AsyncReadExt, AsyncWriteExt};
use tokio::io::{AsyncRead, AsyncWrite, AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpStream, ToSocketAddrs};
use tokio_util::bytes::Bytes;
use tokio_util::codec::{Decoder, Encoder, Framed};
use tokio_util::codec::{Decoder, Framed};
use x25519_dalek::StaticSecret;
use futures::{Sink, SinkExt, Stream, StreamExt};

Expand All @@ -27,7 +27,7 @@ impl AdnlPeer<TcpStream> {
ls_addr: A,
) -> Result<AdnlPeer<TcpStream>, AdnlError> {
// generate private key
let local_secret = StaticSecret::new(rand::rngs::OsRng);
let local_secret = StaticSecret::random_from_rng(rand::rngs::OsRng);

// use TcpStream as transport for our ADNL connection
let transport = TcpStream::connect(ls_addr).await?;
Expand Down

0 comments on commit 2b97e20

Please sign in to comment.