diff --git a/Cargo.lock b/Cargo.lock index 8805be1d..26051ac1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,12 +8,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - [[package]] name = "aead" version = "0.3.2" @@ -983,12 +977,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ct-codecs" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3b7eb4404b8195a9abb6356f4ac07d8ba267045c8d6d220ac4dc992e6cc75df" - [[package]] name = "ctor" version = "0.1.26" @@ -1256,16 +1244,6 @@ dependencies = [ "signature 1.6.4", ] -[[package]] -name = "ed25519-compact" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a3d382e8464107391c8706b4c14b087808ecb909f6c15c34114bc42e53a9e4c" -dependencies = [ - "ct-codecs", - "getrandom 0.2.8", -] - [[package]] name = "ed25519-dalek" version = "1.0.1" @@ -1395,18 +1373,6 @@ version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a214f5bb88731d436478f3ae1f8a277b62124089ba9fb67f4f93fb100ef73c90" -[[package]] -name = "filetime" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e884668cd0c7480504233e951174ddc3b382f7c2666e3b7310b5c4e7b0c37f9" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "windows-sys", -] - [[package]] name = "flate2" version = "1.0.25" @@ -2079,26 +2045,6 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" -[[package]] -name = "libflate" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05605ab2bce11bcfc0e9c635ff29ef8b2ea83f29be257ee7d730cac3ee373093" -dependencies = [ - "adler32", - "crc32fast", - "libflate_lz77", -] - -[[package]] -name = "libflate_lz77" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39a734c0493409afcd49deee13c006a04e3586b9761a03543c6272c9c51f2f5a" -dependencies = [ - "rle-decode-fast", -] - [[package]] name = "libm" version = "0.1.4" @@ -2472,12 +2418,10 @@ dependencies = [ "async-io", "bytes", "curve25519-dalek 3.2.0", - "ed25519-compact", "env_logger 0.10.0", "futures", "libp2p-core", "libp2p-tcp", - "libsodium-sys-stable", "log", "once_cell", "quick-protobuf", @@ -2868,23 +2812,6 @@ dependencies = [ "libsecp256k1-core", ] -[[package]] -name = "libsodium-sys-stable" -version = "1.19.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c2e36a6759ec7f4d772d2e01af0bf5ba63eb114bbab488cbcf53884c6408bb9" -dependencies = [ - "cc", - "libc", - "libflate", - "minisign-verify", - "pkg-config", - "tar", - "ureq", - "vcpkg", - "zip", -] - [[package]] name = "libz-sys" version = "1.1.8" @@ -2997,12 +2924,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "minisign-verify" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "933dca44d65cdd53b355d0b73d380a2ff5da71f87f036053188bf1eab6a19881" - [[package]] name = "miniz_oxide" version = "0.6.2" @@ -3916,12 +3837,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rle-decode-fast" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" - [[package]] name = "rmp" version = "0.8.11" @@ -4462,17 +4377,6 @@ dependencies = [ "libc", ] -[[package]] -name = "tar" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" -dependencies = [ - "filetime", - "libc", - "xattr", -] - [[package]] name = "tempfile" version = "3.4.0" @@ -4830,21 +4734,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" -[[package]] -name = "ureq" -version = "2.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "338b31dd1314f68f3aabf3ed57ab922df95ffcd902476ca7ba3c4ce7b908c46d" -dependencies = [ - "base64 0.13.1", - "log", - "once_cell", - "rustls 0.20.8", - "url", - "webpki 0.22.0", - "webpki-roots", -] - [[package]] name = "url" version = "2.3.1" @@ -5489,15 +5378,6 @@ dependencies = [ "time", ] -[[package]] -name = "xattr" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc" -dependencies = [ - "libc", -] - [[package]] name = "yamux" version = "0.10.2" @@ -5541,15 +5421,3 @@ dependencies = [ "syn", "synstructure", ] - -[[package]] -name = "zip" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "537ce7411d25e54e8ae21a7ce0b15840e7bfcff15b51d697ec3266cc76bdf080" -dependencies = [ - "byteorder", - "crc32fast", - "crossbeam-utils", - "flate2", -] diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 64514f6e..e563c2ba 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -31,10 +31,8 @@ snow = { version = "0.9.0", features = ["default-resolver"], default-features = [dev-dependencies] async-io = "1.2.0" -ed25519-compact = "2.0.4" env_logger = "0.10.0" libp2p-tcp = { path = "../tcp", features = ["async-io"] } -libsodium-sys-stable = { version = "1.19.22", features = ["fetch-latest"] } quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/transports/noise/src/protocol/x25519.rs b/transports/noise/src/protocol/x25519.rs index c0902136..2e3689be 100644 --- a/transports/noise/src/protocol/x25519.rs +++ b/transports/noise/src/protocol/x25519.rs @@ -281,44 +281,8 @@ impl snow::types::Dh for Keypair { #[cfg(test)] mod tests { use super::*; - // Use the ed25519_compact for testing - use ed25519_compact; use libp2p_core::identity::ed25519; - // Use the libsodium-sys-stable crypto_sign imports for testing - use libsodium_sys::crypto_sign_ed25519_pk_to_curve25519; - use libsodium_sys::crypto_sign_ed25519_sk_to_curve25519; use quickcheck::*; - use x25519_dalek::StaticSecret; - - // ed25519 to x25519 keypair conversion must yield the same results as - // obtained through libsodium. - #[test] - fn prop_ed25519_to_x25519_matches_libsodium() { - fn prop() -> bool { - let ed25519 = ed25519::Keypair::generate(); - let x25519 = Keypair::from(SecretKey::from_ed25519(&ed25519.secret())); - - let sodium_sec = - ed25519_sk_to_curve25519(&ed25519_compact::SecretKey::new(ed25519.encode())); - let sodium_pub = ed25519_pk_to_curve25519(&ed25519_compact::PublicKey::new( - ed25519.public().encode(), - )); - - let our_pub = x25519.public.0; - // libsodium does the [clamping] of the scalar upon key construction, - // just like x25519-dalek, but this module uses the raw byte-oriented x25519 - // function from x25519-dalek, as defined in RFC7748, so "our" secret scalar - // must be clamped before comparing it to the one computed by libsodium. - // That happens in `StaticSecret::from`. - // - // [clamping]: http://www.lix.polytechnique.fr/~smith/ECC/#scalar-clamping - let our_sec = StaticSecret::from((x25519.secret.0).0).to_bytes(); - - sodium_sec.as_ref() == Some(&our_sec) && sodium_pub.as_ref() == Some(&our_pub.0) - } - - quickcheck(prop as fn() -> _); - } // The x25519 public key obtained through ed25519 keypair conversion // (and thus derived from the converted secret key) must match the x25519 @@ -334,26 +298,4 @@ mod tests { quickcheck(prop as fn() -> _); } - - pub fn ed25519_pk_to_curve25519(k: &ed25519_compact::PublicKey) -> Option<[u8; 32]> { - let mut out = [0u8; 32]; - unsafe { - if crypto_sign_ed25519_pk_to_curve25519(out.as_mut_ptr(), k.as_ptr()) == 0 { - Some(out) - } else { - None - } - } - } - - pub fn ed25519_sk_to_curve25519(k: &ed25519_compact::SecretKey) -> Option<[u8; 32]> { - let mut out = [0u8; 32]; - unsafe { - if crypto_sign_ed25519_sk_to_curve25519(out.as_mut_ptr(), k.as_ptr()) == 0 { - Some(out) - } else { - None - } - } - } }