mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-26 20:22:15 +00:00
Make ephemeral keypair optional
This commit is contained in:
parent
73c336088e
commit
28bf51c492
@ -16,7 +16,7 @@ import { WrappedConnection } from "./noise";
|
|||||||
import {decode0, decode1, encode1} from "./encoder";
|
import {decode0, decode1, encode1} from "./encoder";
|
||||||
|
|
||||||
export class Handshake extends XXHandshake {
|
export class Handshake extends XXHandshake {
|
||||||
private ephemeralKeys: KeyPair;
|
private ephemeralKeys?: KeyPair;
|
||||||
private initialMsg: bytes;
|
private initialMsg: bytes;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -27,12 +27,14 @@ export class Handshake extends XXHandshake {
|
|||||||
staticKeys: KeyPair,
|
staticKeys: KeyPair,
|
||||||
connection: WrappedConnection,
|
connection: WrappedConnection,
|
||||||
remotePeer: PeerId,
|
remotePeer: PeerId,
|
||||||
ephemeralKeys: KeyPair,
|
|
||||||
initialMsg: bytes,
|
initialMsg: bytes,
|
||||||
|
ephemeralKeys?: KeyPair,
|
||||||
handshake?: XX,
|
handshake?: XX,
|
||||||
) {
|
) {
|
||||||
super(isInitiator, libp2pPrivateKey, libp2pPublicKey, prologue, staticKeys, connection, remotePeer, handshake);
|
super(isInitiator, libp2pPrivateKey, libp2pPublicKey, prologue, staticKeys, connection, remotePeer, handshake);
|
||||||
|
if (ephemeralKeys) {
|
||||||
this.ephemeralKeys = ephemeralKeys;
|
this.ephemeralKeys = ephemeralKeys;
|
||||||
|
}
|
||||||
this.initialMsg = initialMsg;
|
this.initialMsg = initialMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ export class Noise implements NoiseConnection {
|
|||||||
): Promise<XXFallback> {
|
): Promise<XXFallback> {
|
||||||
const { isInitiator, libp2pPublicKey, remotePeer, connection } = params;
|
const { isInitiator, libp2pPublicKey, remotePeer, connection } = params;
|
||||||
const handshake =
|
const handshake =
|
||||||
new XXFallback(isInitiator, this.privateKey, libp2pPublicKey, this.prologue, this.staticKeys, connection, remotePeer, ephemeralKeys, initialMsg);
|
new XXFallback(isInitiator, this.privateKey, libp2pPublicKey, this.prologue, this.staticKeys, connection, remotePeer, initialMsg, ephemeralKeys);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await handshake.propose();
|
await handshake.propose();
|
||||||
|
@ -48,10 +48,10 @@ describe("XX Fallback Handshake", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handshakeInit =
|
const handshakeInit =
|
||||||
new Handshake(true, initiatorPrivKey, initiatorPubKey, prologue, staticKeysInitiator, connectionFrom, peerB, ephemeralKeys, initialMsg);
|
new Handshake(true, initiatorPrivKey, initiatorPubKey, prologue, staticKeysInitiator, connectionFrom, peerB, initialMsg, ephemeralKeys);
|
||||||
|
|
||||||
const handshakeResp =
|
const handshakeResp =
|
||||||
new Handshake(false, responderPrivKey, responderPubKey, prologue, staticKeysResponder, connectionTo, peerA, ephemeralKeys, initialMsg);
|
new Handshake(false, responderPrivKey, responderPubKey, prologue, staticKeysResponder, connectionTo, peerA, initialMsg);
|
||||||
|
|
||||||
|
|
||||||
await handshakeInit.propose();
|
await handshakeInit.propose();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user