From c8ed8167f0144e6908c6a812f72b10cdf05b9694 Mon Sep 17 00:00:00 2001 From: Kenedy Ribeiro Date: Mon, 27 Nov 2023 15:11:34 -0300 Subject: [PATCH 1/2] CU-86a12v3tv - Fix decrypt on example wallet, it has a buffer problem --- packages/neon-dappkit/src/NeonSigner.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/neon-dappkit/src/NeonSigner.ts b/packages/neon-dappkit/src/NeonSigner.ts index 0dfc72a..391b6d9 100644 --- a/packages/neon-dappkit/src/NeonSigner.ts +++ b/packages/neon-dappkit/src/NeonSigner.ts @@ -107,13 +107,13 @@ export class NeonSigner implements Neo3Signer { const macKey = hash.subarray(32) const cipher = crypto.createCipheriv('aes-256-cbc', encryptionKey, iv) - const firstChunk = cipher.update(messageBuffer) + const firstChunk = cipher.update(Buffer.from(messageBuffer)) const secondChunk = cipher.final() const ciphertext = Buffer.concat([firstChunk, secondChunk]) const dataToMac = Buffer.concat([iv, Buffer.from(ephemPublicKey, 'hex'), ciphertext]) - const hmacSha = crypto.createHmac('sha256', macKey).update(dataToMac).digest() + const hmacSha = crypto.createHmac('sha256', Buffer.from(macKey)).update(dataToMac).digest() const mac = Buffer.from(hmacSha) return { @@ -146,7 +146,7 @@ export class NeonSigner implements Neo3Signer { Buffer.from(payload.ephemPublicKey, 'hex'), Buffer.from(payload.cipherText, 'hex'), ]) - const realMac = crypto.createHmac('sha256', macKey).update(dataToMac).digest() + const realMac = crypto.createHmac('sha256', Buffer.from(macKey)).update(dataToMac).digest() if (payload.dataTag !== realMac.toString('hex')) { throw new Error('invalid payload: hmac misalignment') From 8dd223eaf6df1d4869849363c793087d37d4edf3 Mon Sep 17 00:00:00 2001 From: Kenedy Ribeiro Date: Mon, 27 Nov 2023 15:24:12 -0300 Subject: [PATCH 2/2] CU-86a12v3tv - Fix decrypt on example wallet, it has a buffer problem - rush changes --- .../neon-dappkit/CU-86a12v3tv_2023-11-27-18-17.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@cityofzion/neon-dappkit/CU-86a12v3tv_2023-11-27-18-17.json diff --git a/common/changes/@cityofzion/neon-dappkit/CU-86a12v3tv_2023-11-27-18-17.json b/common/changes/@cityofzion/neon-dappkit/CU-86a12v3tv_2023-11-27-18-17.json new file mode 100644 index 0000000..54c48b9 --- /dev/null +++ b/common/changes/@cityofzion/neon-dappkit/CU-86a12v3tv_2023-11-27-18-17.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@cityofzion/neon-dappkit", + "comment": "Changes were made to methods that take Buffer as a parameter to ensure that the parameter is in fact Buffer", + "type": "patch" + } + ], + "packageName": "@cityofzion/neon-dappkit" +} \ No newline at end of file