diff --git a/package-lock.json b/package-lock.json index 9f3393e..a66feb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fhevmjs", - "version": "0.6.0-8", + "version": "0.6.0-9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "fhevmjs", - "version": "0.6.0-8", + "version": "0.6.0-9", "license": "BSD-3-Clause-Clear", "dependencies": { "@types/keccak": "^3.0.4", diff --git a/package.json b/package.json index abb4b0e..e084732 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fhevmjs", - "version": "0.6.0-8", + "version": "0.6.0-9", "description": "fhEVM SDK for blockchain using TFHE", "main": "lib/node.js", "types": "lib/node/node.d.ts", diff --git a/src/sdk/reencrypt.ts b/src/sdk/reencrypt.ts index 8883299..72b0825 100644 --- a/src/sdk/reencrypt.ts +++ b/src/sdk/reencrypt.ts @@ -71,6 +71,10 @@ export const reencryptRequest = throw new Error("Gateway didn't response correctly"); } + if (json.status === 'failure') { + throw new Error("The reencryption didn't succeed"); + } + const client = new_client(kmsSignatures, userAddress, 'default'); try { @@ -88,7 +92,10 @@ export const reencryptRequest = // Duplicate payloadForRequest and replace ciphertext_handle with ciphertext_digest. const { ciphertext_handle, ...p } = payloadForRequest; // TODO check all ciphertext digests are all the same - const payloadForVerification = { ...p, ciphertext_digest: json.response[0].ciphertext_digest }; + const payloadForVerification = { + ...p, + ciphertext_digest: json.response[0].ciphertext_digest, + }; const decryption = process_reencryption_resp_from_js( client,