Skip to content

Commit 6b73dac

Browse files
feat(noise): remove tests for deprecated protocol
With `0.51`, we finally officially deprecated the non-spec compliant version of noise. This one needs a very heavy dependency for testing: `libsodium-sys-stable`. I propose to remove the tests now. The actual implementation is not yet removed because it would be a breaking change. Once we decide to make the next breaking change, we can also include the removal of the deprecated API. Pull-Request: #3510.
1 parent d529945 commit 6b73dac

File tree

3 files changed

+0
-192
lines changed

3 files changed

+0
-192
lines changed

Cargo.lock

Lines changed: 0 additions & 132 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

transports/noise/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ snow = { version = "0.9.0", features = ["default-resolver"], default-features =
3131

3232
[dev-dependencies]
3333
async-io = "1.2.0"
34-
ed25519-compact = "2.0.4"
3534
env_logger = "0.10.0"
3635
libp2p-tcp = { path = "../tcp", features = ["async-io"] }
37-
libsodium-sys-stable = { version = "1.19.22", features = ["fetch-latest"] }
3836
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
3937

4038
# Passing arguments to the docsrs builder in order to properly document cfg's.

transports/noise/src/protocol/x25519.rs

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -281,44 +281,8 @@ impl snow::types::Dh for Keypair<X25519> {
281281
#[cfg(test)]
282282
mod tests {
283283
use super::*;
284-
// Use the ed25519_compact for testing
285-
use ed25519_compact;
286284
use libp2p_core::identity::ed25519;
287-
// Use the libsodium-sys-stable crypto_sign imports for testing
288-
use libsodium_sys::crypto_sign_ed25519_pk_to_curve25519;
289-
use libsodium_sys::crypto_sign_ed25519_sk_to_curve25519;
290285
use quickcheck::*;
291-
use x25519_dalek::StaticSecret;
292-
293-
// ed25519 to x25519 keypair conversion must yield the same results as
294-
// obtained through libsodium.
295-
#[test]
296-
fn prop_ed25519_to_x25519_matches_libsodium() {
297-
fn prop() -> bool {
298-
let ed25519 = ed25519::Keypair::generate();
299-
let x25519 = Keypair::from(SecretKey::from_ed25519(&ed25519.secret()));
300-
301-
let sodium_sec =
302-
ed25519_sk_to_curve25519(&ed25519_compact::SecretKey::new(ed25519.encode()));
303-
let sodium_pub = ed25519_pk_to_curve25519(&ed25519_compact::PublicKey::new(
304-
ed25519.public().encode(),
305-
));
306-
307-
let our_pub = x25519.public.0;
308-
// libsodium does the [clamping] of the scalar upon key construction,
309-
// just like x25519-dalek, but this module uses the raw byte-oriented x25519
310-
// function from x25519-dalek, as defined in RFC7748, so "our" secret scalar
311-
// must be clamped before comparing it to the one computed by libsodium.
312-
// That happens in `StaticSecret::from`.
313-
//
314-
// [clamping]: http://www.lix.polytechnique.fr/~smith/ECC/#scalar-clamping
315-
let our_sec = StaticSecret::from((x25519.secret.0).0).to_bytes();
316-
317-
sodium_sec.as_ref() == Some(&our_sec) && sodium_pub.as_ref() == Some(&our_pub.0)
318-
}
319-
320-
quickcheck(prop as fn() -> _);
321-
}
322286

323287
// The x25519 public key obtained through ed25519 keypair conversion
324288
// (and thus derived from the converted secret key) must match the x25519
@@ -334,26 +298,4 @@ mod tests {
334298

335299
quickcheck(prop as fn() -> _);
336300
}
337-
338-
pub fn ed25519_pk_to_curve25519(k: &ed25519_compact::PublicKey) -> Option<[u8; 32]> {
339-
let mut out = [0u8; 32];
340-
unsafe {
341-
if crypto_sign_ed25519_pk_to_curve25519(out.as_mut_ptr(), k.as_ptr()) == 0 {
342-
Some(out)
343-
} else {
344-
None
345-
}
346-
}
347-
}
348-
349-
pub fn ed25519_sk_to_curve25519(k: &ed25519_compact::SecretKey) -> Option<[u8; 32]> {
350-
let mut out = [0u8; 32];
351-
unsafe {
352-
if crypto_sign_ed25519_sk_to_curve25519(out.as_mut_ptr(), k.as_ptr()) == 0 {
353-
Some(out)
354-
} else {
355-
None
356-
}
357-
}
358-
}
359301
}

0 commit comments

Comments
 (0)