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 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')