From abf8ff168a0663fe0f73e83c0275c465dcb1e591 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Fri, 14 Jul 2023 15:20:42 -0300 Subject: [PATCH] Use ecdsa private key for signing instead of encryption key (d'oh!) --- .../src/e2e_account_contracts.test.ts | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts index 344579d33b66..aaa06c5ca726 100644 --- a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts +++ b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts @@ -39,22 +39,22 @@ async function createNewAccount( aztecRpcServer: AztecRPCServer, abi: ContractAbi, args: any[], - privateKey: Buffer, + encryptionPrivateKey: Buffer, createWallet: CreateAccountImplFn, ) { const salt = Fr.random(); - const publicKey = await generatePublicKey(privateKey); + const publicKey = await generatePublicKey(encryptionPrivateKey); const { address, partialAddress } = await getContractDeploymentInfo(abi, args, salt, publicKey); - await aztecRpcServer.addAccount(privateKey, address, partialAddress, abi); + await aztecRpcServer.addAccount(encryptionPrivateKey, address, partialAddress, abi); await deployContract(aztecRpcServer, publicKey, abi, args, salt); - const wallet = new AccountWallet(aztecRpcServer, await createWallet(address, partialAddress, privateKey)); + const wallet = new AccountWallet(aztecRpcServer, await createWallet(address, partialAddress, encryptionPrivateKey)); return { wallet, address, partialAddress }; } type CreateAccountImplFn = ( address: AztecAddress, partialAddress: PartialContractAddress, - privateKey: Buffer, + encryptionPrivateKey: Buffer, ) => Promise; function itShouldBehaveLikeAnAccountContract(abi: ContractAbi, argsFn: () => any[], createWallet: CreateAccountImplFn) { @@ -67,13 +67,13 @@ function itShouldBehaveLikeAnAccountContract(abi: ContractAbi, argsFn: () => any beforeEach(async () => { context = await setup(); - const privateKey = randomBytes(32); + const encryptionPrivateKey = randomBytes(32); const { aztecRpcServer } = context; ({ wallet, address, partialAddress } = await createNewAccount( aztecRpcServer, abi, argsFn(), - privateKey, + encryptionPrivateKey, createWallet, )); @@ -116,15 +116,21 @@ function itShouldBehaveLikeAnAccountContract(abi: ContractAbi, argsFn: () => any describe('e2e_account_contracts', () => { describe('schnorr account', () => { - const createSchnorrWallet = async (address: AztecAddress, partial: PartialContractAddress, privateKey: Buffer) => - new SingleKeyAccountContract(address, partial, privateKey, await Schnorr.new()); + const createSchnorrWallet = async ( + address: AztecAddress, + partial: PartialContractAddress, + encryptionPrivateKey: Buffer, + ) => new SingleKeyAccountContract(address, partial, encryptionPrivateKey, await Schnorr.new()); itShouldBehaveLikeAnAccountContract(SchnorrAccountContractAbi, () => [], createSchnorrWallet); }); - describe.skip('ecdsa account', () => { - const createEcdsaWallet = async (address: AztecAddress, _partial: PartialContractAddress, privateKey: Buffer) => - new StoredKeyAccountContract(address, privateKey, await Ecdsa.new()); + describe('ecdsa account', () => { + const createEcdsaWallet = async ( + address: AztecAddress, + _partial: PartialContractAddress, + _encryptionPrivateKey: Buffer, + ) => new StoredKeyAccountContract(address, ecdsaPrivateKey, await Ecdsa.new()); let ecdsaPrivateKey: Buffer; let ecdsaPublicKey: Buffer;