Skip to content

Commit

Permalink
fix(cli): generate ecdh shared key only one time
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmad committed Feb 29, 2024
1 parent 27b80ce commit a75ccae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cli/ts/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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()];
Expand Down

0 comments on commit a75ccae

Please sign in to comment.