mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-24 23:02:34 +00:00
Avoid allocating new buffer
This commit is contained in:
parent
5aa43f92e3
commit
17f8fb3140
@ -107,7 +107,7 @@ export abstract class AbstractHandshake {
|
||||
protected dh(privateKey: bytes32, publicKey: bytes32): bytes32 {
|
||||
try {
|
||||
const sharedKey = box.before(publicKey, privateKey)
|
||||
return Buffer.from(sharedKey);
|
||||
return Buffer.from(sharedKey.buffer, sharedKey.byteOffset, sharedKey.length);
|
||||
} catch (e) {
|
||||
logger(e.message);
|
||||
return Buffer.alloc(32);
|
||||
|
Loading…
x
Reference in New Issue
Block a user