mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 14:12:30 +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 {
|
protected dh(privateKey: bytes32, publicKey: bytes32): bytes32 {
|
||||||
try {
|
try {
|
||||||
const sharedKey = box.before(publicKey, privateKey)
|
const sharedKey = box.before(publicKey, privateKey)
|
||||||
return Buffer.from(sharedKey);
|
return Buffer.from(sharedKey.buffer, sharedKey.byteOffset, sharedKey.length);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger(e.message);
|
logger(e.message);
|
||||||
return Buffer.alloc(32);
|
return Buffer.alloc(32);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user