From a75ccae86338c1d62435cec83309ae3668a906b9 Mon Sep 17 00:00:00 2001 From: 0xmad <0xmad@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:32:28 -0600 Subject: [PATCH] fix(cli): generate ecdh shared key only one time --- cli/ts/commands/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/ts/commands/publish.ts b/cli/ts/commands/publish.ts index 26f299da56..7545f5fa40 100644 --- a/cli/ts/commands/publish.ts +++ b/cli/ts/commands/publish.ts @@ -204,6 +204,7 @@ export const publishBatch = async ({ ]); const encryptionKeypair = new Keypair(); + const sharedKey = Keypair.genEcdhSharedKey(encryptionKeypair.privKey, coordinatorPubKey); const payload: [IMessageContractParams, IG1ContractParams][] = messages.map( ({ salt, stateIndex, voteOptionIndex, newVoteWeight, nonce }) => { @@ -223,7 +224,6 @@ export const publishBatch = async ({ // sign the command with the user private key const signature = command.sign(userMaciPrivKey); - const sharedKey = Keypair.genEcdhSharedKey(encryptionKeypair.privKey, coordinatorPubKey); const message = command.encrypt(signature, sharedKey); return [message.asContractParam(), encryptionKeypair.pubKey.asContractParam()];