Skip to content

Commit 722d0f2

Browse files
refactor: apply suggestions from code review
Co-authored-by: mscdex <[email protected]>
1 parent 5e0c4ee commit 722d0f2

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

lib/protocol/kex.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,10 +1675,7 @@ const createKeyExchange = (() => {
16751675
const isServer = this._protocol._server;
16761676
if (isServer && !this._S_CT2) {
16771677
// server
1678-
const C_PK2 = otherPublicKey.slice(
1679-
0,
1680-
1184
1681-
);
1678+
const C_PK2 = otherPublicKey.slice(0, 1184);
16821679
const C_PK1 = otherPublicKey.slice(1184);
16831680

16841681
if (C_PK1.length !== 32) {
@@ -1704,17 +1701,9 @@ const createKeyExchange = (() => {
17041701

17051702
const C_PK2_DER = Buffer.allocUnsafe(templateDER.length);
17061703

1707-
templateDER.copy(
1708-
C_PK2_DER,
1709-
0,
1710-
0,
1711-
templateDER.length - 1184
1712-
);
1704+
templateDER.copy(C_PK2_DER, 0, 0, templateDER.length - 1184);
17131705

1714-
C_PK2.copy(
1715-
C_PK2_DER,
1716-
templateDER.length - 1184
1717-
);
1706+
C_PK2.copy(C_PK2_DER, templateDER.length - 1184);
17181707

17191708
const { sharedKey: K_PQ, ciphertext: S_CT2 } = encapsulate(
17201709
createPublicKey({
@@ -1756,10 +1745,7 @@ const createKeyExchange = (() => {
17561745
}),
17571746
});
17581747

1759-
const K_PQ = decapsulate(
1760-
this._mlkemKeys.privateKey,
1761-
S_CT2
1762-
);
1748+
const K_PQ = decapsulate(this._mlkemKeys.privateKey, S_CT2);
17631749

17641750
// K = HASH(K_PQ || K_CL) from 2.4 on draft
17651751
const K = createHash('sha256')

0 commit comments

Comments
 (0)