From 7b090abde7a4f6fd49bef4989f62b26ebad2c2e2 Mon Sep 17 00:00:00 2001 From: Sandeep Nishad Date: Mon, 24 Apr 2023 23:53:32 +0530 Subject: [PATCH] fix(weaversdk): ecies decrypt bug when z is less than 32Bytes Signed-off-by: Sandeep Nishad --- .../interoperation-node-sdk/src/eciesCrypto.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/weaver/sdks/fabric/interoperation-node-sdk/src/eciesCrypto.js b/weaver/sdks/fabric/interoperation-node-sdk/src/eciesCrypto.js index 1005d5a7d3..f3b6ea4134 100644 --- a/weaver/sdks/fabric/interoperation-node-sdk/src/eciesCrypto.js +++ b/weaver/sdks/fabric/interoperation-node-sdk/src/eciesCrypto.js @@ -98,18 +98,25 @@ function eciesDecryptMessage(recipientPrivateKey, cipherText, options) { const privKey = ecdsa.keyFromPrivate(recipientPrivateKey.prvKeyHex, "hex"); const Z = privKey.derive(ephPubKey.pub); // 'z' - const kdfOutput = hkdf(Z.toArray(), ECIESKDFOutput, null, null, options); // The 'null's correspond to 's1' and 's2', which are both - // empty in our SNAMCC and ESCC plugin implementations + // Append missing leading zeros to Z + let ZArray = Z.toArray(); + const zerosToAdd = 32 - ZArray.length; + for (let ii=0; ii