From 5aa43f92e312141cb30286cb4864593bcad413fc Mon Sep 17 00:00:00 2001 From: Matija Petrunic Date: Tue, 7 Apr 2020 11:16:43 +0200 Subject: [PATCH] Fix hash value --- src/handshakes/abstract-handshake.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/handshakes/abstract-handshake.ts b/src/handshakes/abstract-handshake.ts index 9834628..feb0a6d 100644 --- a/src/handshakes/abstract-handshake.ts +++ b/src/handshakes/abstract-handshake.ts @@ -106,7 +106,8 @@ export abstract class AbstractHandshake { protected dh(privateKey: bytes32, publicKey: bytes32): bytes32 { try { - return Buffer.from(box.before(publicKey, privateKey), 0, 32); + const sharedKey = box.before(publicKey, privateKey) + return Buffer.from(sharedKey); } catch (e) { logger(e.message); return Buffer.alloc(32); @@ -118,9 +119,8 @@ export abstract class AbstractHandshake { } protected getHash(a: bytes, b: bytes): bytes32 { - return Buffer.from( - hash.sha256().update(Buffer.from([...a, ...b])).digest('hex') - ); + const hashValue = hash.sha256().update(Buffer.from([...a, ...b])).digest(); + return Buffer.from(hashValue); } protected mixKey(ss: SymmetricState, ikm: bytes32): void {