diff --git a/src/handshake-ik.ts b/src/handshake-ik.ts index ca7ea9a..92a1cbd 100644 --- a/src/handshake-ik.ts +++ b/src/handshake-ik.ts @@ -101,7 +101,7 @@ export class IKHandshake implements IHandshake { return this.ik.encryptWithAd(cs, Buffer.alloc(0), plaintext); } - public getRemoteEphemeralKeys(): KeyPair { + public getLocalEphemeralKeys(): KeyPair { if (!this.session.hs.e) { throw new Error("Ephemeral keys do not exist."); } diff --git a/src/noise.ts b/src/noise.ts index eb7dc14..304b3d3 100644 --- a/src/noise.ts +++ b/src/noise.ts @@ -136,8 +136,8 @@ export class Noise implements INoiseConnection { } catch (e) { // IK failed, go to XX fallback let ephemeralKeys; - if (!params.isInitiator) { - ephemeralKeys = ikHandshake.getRemoteEphemeralKeys(); + if (params.isInitiator) { + ephemeralKeys = ikHandshake.getLocalEphemeralKeys(); } return await this.performXXFallbackHandshake(params, payload, e.initialMsg, ephemeralKeys); }