diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71ee4d5e743..e92f513a023 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -272,6 +272,22 @@ jobs: timeout-minutes: 25 run: earthly-ci --no-output ./yarn-project/+prover-client-test + client-proof-tests: + needs: build + runs-on: ${{ github.actor }}-x86 + steps: + - { + uses: actions/checkout@v4, + with: { ref: "${{ github.event.pull_request.head.sha }}" }, + } + - uses: ./.github/ci-setup-action + with: + dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}" + concurrency_key: client-proof-tests-${{ github.actor }}-x86 + - name: "Client Proof Tests" + timeout-minutes: 25 + run: earthly-ci --no-output ./yarn-project/+run-e2e --test=client_prover_integration/client_prover_integration.test.ts + build-acir-tests: needs: build runs-on: ${{ github.actor }}-x86 @@ -461,6 +477,7 @@ jobs: barretenberg-acir-tests-sol, noir-test, noir-packages-test, + client-proof-tests, ] if: always() steps: diff --git a/yarn-project/end-to-end/src/client_prover_integration/client_prover_integration.test.ts b/yarn-project/end-to-end/src/client_prover_integration/client_prover_integration.test.ts index ec6c32d11a6..ed244b2da64 100644 --- a/yarn-project/end-to-end/src/client_prover_integration/client_prover_integration.test.ts +++ b/yarn-project/end-to-end/src/client_prover_integration/client_prover_integration.test.ts @@ -4,13 +4,8 @@ import { type BBNativeProofCreator } from '@aztec/pxe'; import { ClientProverTest } from './client_prover_test.js'; -const TIMEOUT = 300_000; - -async function verifyProof(_1: ClientProtocolArtifact, _2: Tx, _3: BBNativeProofCreator) { - // TODO(@PhilWindle): Will verify proof once the circuits are fixed - await Promise.resolve(); - //const result = await proofCreator.verifyProof(circuitType, tx.proof); - expect(true).toBeTruthy(); +async function verifyProof(circuitType: ClientProtocolArtifact, tx: Tx, proofCreator: BBNativeProofCreator) { + await expect(proofCreator.verifyProof(circuitType, tx.proof)).resolves.not.toThrow(); } describe('client_prover_integration', () => { @@ -32,47 +27,39 @@ describe('client_prover_integration', () => { await t.tokenSim.check(); }); - it( - 'private transfer less than balance', - async () => { - logger.info( - `Starting test using function: ${provenAsset.address}:${provenAsset.methods.balance_of_private.selector}`, - ); - const balance0 = await provenAsset.methods.balance_of_private(accounts[0].address).simulate(); - const amount = balance0 / 2n; - expect(amount).toBeGreaterThan(0n); - const interaction = provenAsset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0); - const provenTx = await interaction.prove(); + it('private transfer less than balance', async () => { + logger.info( + `Starting test using function: ${provenAsset.address}:${provenAsset.methods.balance_of_private.selector}`, + ); + const balance0 = await provenAsset.methods.balance_of_private(accounts[0].address).simulate(); + const amount = balance0 / 2n; + expect(amount).toBeGreaterThan(0n); + const interaction = provenAsset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0); + const provenTx = await interaction.prove(); - // This will recursively verify all app and kernel circuits involved in the private stage of this transaction! - logger.info(`Verifying kernel tail proof`); - await verifyProof('PrivateKernelTailArtifact', provenTx, proofCreator!); + // This will recursively verify all app and kernel circuits involved in the private stage of this transaction! + logger.info(`Verifying kernel tail proof`); + await verifyProof('PrivateKernelTailArtifact', provenTx, proofCreator!); - await interaction.send().wait(); - tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount); - }, - TIMEOUT, - ); + await interaction.send().wait(); + tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount); + }); - it( - 'public transfer less than balance', - async () => { - logger.info( - `Starting test using function: ${provenAsset.address}:${provenAsset.methods.balance_of_public.selector}`, - ); - const balance0 = await provenAsset.methods.balance_of_public(accounts[0].address).simulate(); - const amount = balance0 / 2n; - expect(amount).toBeGreaterThan(0n); - const interaction = provenAsset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0); - const provenTx = await interaction.prove(); + it('public transfer less than balance', async () => { + logger.info( + `Starting test using function: ${provenAsset.address}:${provenAsset.methods.balance_of_public.selector}`, + ); + const balance0 = await provenAsset.methods.balance_of_public(accounts[0].address).simulate(); + const amount = balance0 / 2n; + expect(amount).toBeGreaterThan(0n); + const interaction = provenAsset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, 0); + const provenTx = await interaction.prove(); - // This will recursively verify all app and kernel circuits involved in the private stage of this transaction! - logger.info(`Verifying kernel tail to public proof`); - await verifyProof('PrivateKernelTailToPublicArtifact', provenTx, proofCreator!); + // This will recursively verify all app and kernel circuits involved in the private stage of this transaction! + logger.info(`Verifying kernel tail to public proof`); + await verifyProof('PrivateKernelTailToPublicArtifact', provenTx, proofCreator!); - await interaction.send().wait(); - tokenSim.transferPublic(accounts[0].address, accounts[1].address, amount); - }, - TIMEOUT, - ); + await interaction.send().wait(); + tokenSim.transferPublic(accounts[0].address, accounts[1].address, amount); + }); }); diff --git a/yarn-project/pxe/src/kernel_prover/bb_prover/bb_native_proof_creator.ts b/yarn-project/pxe/src/kernel_prover/bb_prover/bb_native_proof_creator.ts index 7f4fba37064..15eed0996a9 100644 --- a/yarn-project/pxe/src/kernel_prover/bb_prover/bb_native_proof_creator.ts +++ b/yarn-project/pxe/src/kernel_prover/bb_prover/bb_native_proof_creator.ts @@ -8,7 +8,6 @@ import { type PrivateKernelTailCircuitPublicInputs, Proof, type VERIFICATION_KEY_LENGTH_IN_FIELDS, - makeEmptyProof, } from '@aztec/circuits.js'; import { siloNoteHash } from '@aztec/circuits.js/hash'; import { randomBytes, sha256 } from '@aztec/foundation/crypto'; @@ -23,9 +22,9 @@ import { convertPrivateKernelInnerInputsToWitnessMap, convertPrivateKernelInnerOutputsFromWitnessMap, convertPrivateKernelTailForPublicOutputsFromWitnessMap, + convertPrivateKernelTailInputsToWitnessMap, convertPrivateKernelTailOutputsFromWitnessMap, - executeTail, - executeTailForPublic, + convertPrivateKernelTailToPublicInputsToWitnessMap, } from '@aztec/noir-protocol-circuits-types'; import { type ACVMField, WASMSimulator } from '@aztec/simulator'; import { type NoirCompiledCircuit } from '@aztec/types/noir'; @@ -294,7 +293,7 @@ export async function generateKeyForNoirCircuit( await fs.writeFile(bytecodePath, bytecode); // args are the output path and the input bytecode path - const args = ['-o', outputPath, '-b', bytecodePath]; + const args = ['-o', `${outputPath}/${VK_FILENAME}`, '-b', bytecodePath]; const timer = new Timer(); let result = await executeBB(pathToBB, `write_${key}`, args, log); // If we succeeded and the type of key if verification, have bb write the 'fields' version too @@ -468,25 +467,12 @@ export class BBNativeProofCreator implements ProofCreator { public async createProofTail( inputs: PrivateKernelTailCircuitPrivateInputs, ): Promise> { - // if (!inputs.isForPublic()) { - // const witnessMap = convertPrivateKernelTailInputsToWitnessMap(inputs); - // return await this.createSafeProof(witnessMap, 'PrivateKernelTailArtifact'); - // } - if (!inputs.isForPublic()) { - const result = await executeTail(inputs); - return { - publicInputs: result, - proof: makeEmptyProof(), - }; + const witnessMap = convertPrivateKernelTailInputsToWitnessMap(inputs); + return await this.createSafeProof(witnessMap, 'PrivateKernelTailArtifact'); } - // const witnessMap = convertPrivateKernelTailToPublicInputsToWitnessMap(inputs); - // return await this.createSafeProof(witnessMap, 'PrivateKernelTailToPublicArtifact'); - const result = await executeTailForPublic(inputs); - return { - publicInputs: result, - proof: makeEmptyProof(), - }; + const witnessMap = convertPrivateKernelTailToPublicInputsToWitnessMap(inputs); + return await this.createSafeProof(witnessMap, 'PrivateKernelTailToPublicArtifact'); } public async createAppCircuitProof(partialWitness: Map, bytecode: Buffer): Promise {