Skip to content

Commit

Permalink
transports/noise: Have NoiseAuthenticated::xx use X25519Spec
Browse files Browse the repository at this point in the history
We support two versions of the Noise XX handshake with X25519, but only one of
them is compliant with the specification and thus compliant with other
implementations. We should always default to the spec compliant handshake.

Fixes bug introduced in libp2p#2887
  • Loading branch information
mxinden committed Sep 29, 2022
1 parent 04b07c4 commit 9179a5d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions transports/noise/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,12 @@ pub struct NoiseAuthenticated<P, C: Zeroize, R> {
config: NoiseConfig<P, C, R>,
}

impl NoiseAuthenticated<XX, X25519, ()> {
impl NoiseAuthenticated<XX, X25519Spec, ()> {
/// Create a new [`NoiseAuthenticated`] for the `XX` handshake pattern using X25519 DH keys.
///
/// For now, this is the only combination that is guaranteed to be compatible with other libp2p implementations.
pub fn xx(id_keys: &identity::Keypair) -> Result<Self, NoiseError> {
let dh_keys = Keypair::<X25519>::new();
let dh_keys = Keypair::<X25519Spec>::new();
let noise_keys = dh_keys.into_authentic(id_keys)?;
let config = NoiseConfig::xx(noise_keys);

Expand Down

0 comments on commit 9179a5d

Please sign in to comment.