Skip to content

Commit

Permalink
Merge pull request #1259 from privacy-scaling-explorations/fix/ecdh-p…
Browse files Browse the repository at this point in the history
…ublish-key

fix(cli): generate ecdh shared key only one time
  • Loading branch information
0xmad authored Feb 29, 2024
2 parents 27b80ce + a75ccae commit 27d8f64
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 27d8f64

Please sign in to comment.