mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 14:12:30 +00:00
Fix hash value
This commit is contained in:
parent
207627a31f
commit
5aa43f92e3
@ -106,7 +106,8 @@ export abstract class AbstractHandshake {
|
|||||||
|
|
||||||
protected dh(privateKey: bytes32, publicKey: bytes32): bytes32 {
|
protected dh(privateKey: bytes32, publicKey: bytes32): bytes32 {
|
||||||
try {
|
try {
|
||||||
return Buffer.from(box.before(publicKey, privateKey), 0, 32);
|
const sharedKey = box.before(publicKey, privateKey)
|
||||||
|
return Buffer.from(sharedKey);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger(e.message);
|
logger(e.message);
|
||||||
return Buffer.alloc(32);
|
return Buffer.alloc(32);
|
||||||
@ -118,9 +119,8 @@ export abstract class AbstractHandshake {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected getHash(a: bytes, b: bytes): bytes32 {
|
protected getHash(a: bytes, b: bytes): bytes32 {
|
||||||
return Buffer.from(
|
const hashValue = hash.sha256().update(Buffer.from([...a, ...b])).digest();
|
||||||
hash.sha256().update(Buffer.from([...a, ...b])).digest('hex')
|
return Buffer.from(hashValue);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected mixKey(ss: SymmetricState, ikm: bytes32): void {
|
protected mixKey(ss: SymmetricState, ikm: bytes32): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user