diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index 96a4e206f3a..c9b1b3653ec 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -343,7 +343,9 @@ void common_contract_logic(DummyBuilder& builder, const auto& storage_contract_address = private_call_public_inputs.call_context.storage_contract_address; const auto& portal_contract_address = private_call.portal_contract_address; - const auto private_call_vk_hash = stdlib::recursion::verification_key::hash_native(private_call.vk); + // TODO(#3062) VKs are mocked out for now + // const auto private_call_vk_hash = stdlib::recursion::verification_key::hash_native(private_call.vk); + const auto private_call_vk_hash = 0; const auto is_contract_deployment = public_inputs.constants.tx_context.is_contract_deployment_tx; @@ -367,9 +369,10 @@ void common_contract_logic(DummyBuilder& builder, native_new_contract_data, format(PRIVATE_KERNEL_CIRCUIT_ERROR_MESSAGE_BEGINNING, "too many contracts created in one tx")); - builder.do_assert(contract_dep_data.constructor_vk_hash == private_call_vk_hash, - "constructor_vk_hash doesn't match private_call_vk_hash", - CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONSTRUCTOR_VK_HASH); + // TODO(#3062) VKs are mocked out for now + // builder.do_assert(contract_dep_data.constructor_vk_hash == private_call_vk_hash, + // "constructor_vk_hash doesn't match private_call_vk_hash", + // CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONSTRUCTOR_VK_HASH); // must imply == derived address builder.do_assert(storage_contract_address == new_contract_address, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp index 40fdd7ddb3a..2cec4cc659a 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.test.cpp @@ -250,21 +250,22 @@ TEST_F(native_private_kernel_init_tests, contract_deployment_call_stack_item_has CircuitErrorCode::PRIVATE_KERNEL__PRIVATE_CALL_STACK_ITEM_HASH_MISMATCH); } -TEST_F(native_private_kernel_init_tests, contract_deployment_incorrect_constructor_vk_hash_fails) -{ - auto private_inputs = do_private_call_get_kernel_inputs_init(true, constructor, standard_test_args()); - - // Pollute the constructor vk hash in the tx_request. - private_inputs.tx_request.tx_context.contract_deployment_data.constructor_vk_hash = NT::fr::random_element(); - - DummyBuilder builder = - DummyBuilder("private_kernel_tests__contract_deployment_incorrect_constructor_vk_hash_fails"); - native_private_kernel_circuit_initial(builder, private_inputs); - - EXPECT_EQ(builder.failed(), true); - EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONSTRUCTOR_VK_HASH); - EXPECT_EQ(builder.get_first_failure().message, "constructor_vk_hash doesn't match private_call_vk_hash"); -} +// TODO(#3062) VKs are mocked out for now +// TEST_F(native_private_kernel_init_tests, contract_deployment_incorrect_constructor_vk_hash_fails) +// { +// auto private_inputs = do_private_call_get_kernel_inputs_init(true, constructor, standard_test_args()); + +// // Pollute the constructor vk hash in the tx_request. +// private_inputs.tx_request.tx_context.contract_deployment_data.constructor_vk_hash = NT::fr::random_element(); + +// DummyBuilder builder = +// DummyBuilder("private_kernel_tests__contract_deployment_incorrect_constructor_vk_hash_fails"); +// native_private_kernel_circuit_initial(builder, private_inputs); + +// EXPECT_EQ(builder.failed(), true); +// EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONSTRUCTOR_VK_HASH); +// EXPECT_EQ(builder.get_first_failure().message, "constructor_vk_hash doesn't match private_call_vk_hash"); +// } TEST_F(native_private_kernel_init_tests, contract_deployment_incorrect_contract_address_fails) { diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp index dd00dc1dd79..c465978ec79 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp @@ -193,8 +193,10 @@ std::pair, ContractDeploymentData> create_private_call_d // for private calls - to generate the function leaf, etc auto const private_circuit_vk = is_circuit ? utils::get_verification_key_from_file() : utils::fake_vk(); - const NT::fr private_circuit_vk_hash = - stdlib::recursion::verification_key::hash_native(private_circuit_vk); + // TODO(#3062) VKs are mocked out for now + // const NT::fr private_circuit_vk_hash = + // stdlib::recursion::verification_key::hash_native(private_circuit_vk); + const NT::fr private_circuit_vk_hash = 0; ContractDeploymentData contract_deployment_data{}; NT::fr contract_tree_root = 0; // TODO(david) set properly for constructor? @@ -529,8 +531,10 @@ bool validate_deployed_contract_address(PrivateKernelInputsInit const& priva auto tx_request = private_inputs.tx_request; auto cdd = private_inputs.tx_request.tx_context.contract_deployment_data; - auto private_circuit_vk_hash = - stdlib::recursion::verification_key::hash_native(private_inputs.private_call.vk); + // TODO(#3062) VKs are mocked out for now + // auto private_circuit_vk_hash = + // stdlib::recursion::verification_key::hash_native(private_inputs.private_call.vk); + auto private_circuit_vk_hash = 0; auto expected_constructor_hash = compute_constructor_hash( private_inputs.private_call.call_stack_item.function_data, tx_request.args_hash, private_circuit_vk_hash); diff --git a/yarn-project/circuits.js/src/contract/contract_tree/contract_tree.ts b/yarn-project/circuits.js/src/contract/contract_tree/contract_tree.ts index 13d88c315d0..fe3325d11aa 100644 --- a/yarn-project/circuits.js/src/contract/contract_tree/contract_tree.ts +++ b/yarn-project/circuits.js/src/contract/contract_tree/contract_tree.ts @@ -73,7 +73,9 @@ export function generateFunctionLeaves(functions: ContractFunctionDao[], wasm: C const isInternal = f.isInternal; const isPrivate = f.functionType === FunctionType.SECRET; // All non-unconstrained functions have vks - const vkHash = hashVKStr(f.verificationKey!, wasm); + // TODO we'd need to have a defined length of the VK for this to be computed in noir + // const vkHash = hashVKStr(f.verificationKey!, wasm); + const vkHash = Buffer.alloc(32, 0); // TODO // FIXME: https://github.com/AztecProtocol/aztec3-packages/issues/262 // const acirHash = keccak(Buffer.from(f.bytecode, 'hex')); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts index 381f29785f8..e9383e81b77 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts @@ -177,5 +177,5 @@ describe('e2e_deploy_contract', () => { minTxsPerBlock: 1, }); } - }); + }, 60_000); }); diff --git a/yarn-project/end-to-end/src/guides/up_quick_start.sh b/yarn-project/end-to-end/src/guides/up_quick_start.sh index 61d11961684..625da141ab5 100755 --- a/yarn-project/end-to-end/src/guides/up_quick_start.sh +++ b/yarn-project/end-to-end/src/guides/up_quick_start.sh @@ -4,8 +4,8 @@ set -eux # docs:start:declare-accounts -ALICE="0x0f394e8bd156e15153376a711e3054821c2a1c1047dcfb3745d636a57fb42ab1" -BOB="0x2b67f90f0044596190644ddafea4152de47bd4781559493860fa7358e19d090a" +ALICE="0x16efad912187aa8ef0dcc6ef4f3743ab327b06465d4d229943f2fe3f88b06ad9" +BOB="0x17f5e66bfe7dafc76434268bcb3968a8bc207b476aeed78d1e4a2f02aad45842" ALICE_PRIVATE_KEY="0x2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281" # docs:end:declare-accounts @@ -15,9 +15,9 @@ aztec-cli deploy \ --salt 0 \ --args $ALICE -aztec-cli check-deploy --contract-address 0x2f45f498b7912c779dde8e3594622e36d7908088b09e99ab91caaafb40d1f9ef +aztec-cli check-deploy --contract-address 0x0ed3aaa22d69559ee368b32fbafb24b49b103c0a07bd834fd519c8157553ec1f -CONTRACT="0x2f45f498b7912c779dde8e3594622e36d7908088b09e99ab91caaafb40d1f9ef" +CONTRACT="0x0ed3aaa22d69559ee368b32fbafb24b49b103c0a07bd834fd519c8157553ec1f" # docs:end:deploy # docs:start:mint-private diff --git a/yarn-project/pxe/package.json b/yarn-project/pxe/package.json index 740bf098a5b..37b929e7323 100644 --- a/yarn-project/pxe/package.json +++ b/yarn-project/pxe/package.json @@ -38,6 +38,7 @@ "@aztec/foundation": "workspace:^", "@aztec/key-store": "workspace:^", "@aztec/noir-compiler": "workspace:^", + "@aztec/noir-protocol-circuits": "workspace:^", "@aztec/types": "workspace:^", "koa": "^2.14.2", "koa-router": "^12.0.0", diff --git a/yarn-project/pxe/src/kernel_prover/proof_creator.ts b/yarn-project/pxe/src/kernel_prover/proof_creator.ts index 40d24e15759..84be723b22f 100644 --- a/yarn-project/pxe/src/kernel_prover/proof_creator.ts +++ b/yarn-project/pxe/src/kernel_prover/proof_creator.ts @@ -1,5 +1,4 @@ import { - CircuitError, CircuitsWasm, KernelCircuitPublicInputs, KernelCircuitPublicInputsFinal, @@ -9,14 +8,12 @@ import { PrivateKernelInputsOrdering, Proof, makeEmptyProof, - privateKernelSimInit, - privateKernelSimInner, - privateKernelSimOrdering, } from '@aztec/circuits.js'; import { siloCommitment } from '@aztec/circuits.js/abis'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; import { elapsed } from '@aztec/foundation/timer'; +import { executeInit, executeInner, executeOrdering } from '@aztec/noir-protocol-circuits'; import { CircuitSimulationStats } from '@aztec/types/stats'; /** @@ -109,11 +106,7 @@ export class KernelProofCreator implements ProofCreator { } public async createProofInit(privateInputs: PrivateKernelInputsInit): Promise { - const wasm = await CircuitsWasm.get(); - const [duration, result] = await elapsed(() => privateKernelSimInit(wasm, privateInputs)); - if (result instanceof CircuitError) { - throw new CircuitError(result.code, result.message); - } + const [duration, result] = await elapsed(() => executeInit(privateInputs)); this.log(`Simulated private kernel init`, { eventName: 'circuit-simulation', circuitName: 'private-kernel-init', @@ -131,11 +124,7 @@ export class KernelProofCreator implements ProofCreator { } public async createProofInner(privateInputs: PrivateKernelInputsInner): Promise { - const wasm = await CircuitsWasm.get(); - const [duration, result] = await elapsed(() => privateKernelSimInner(wasm, privateInputs)); - if (result instanceof CircuitError) { - throw new CircuitError(result.code, result.message); - } + const [duration, result] = await elapsed(() => executeInner(privateInputs)); this.log(`Simulated private kernel inner`, { eventName: 'circuit-simulation', circuitName: 'private-kernel-inner', @@ -153,12 +142,7 @@ export class KernelProofCreator implements ProofCreator { } public async createProofOrdering(privateInputs: PrivateKernelInputsOrdering): Promise { - const wasm = await CircuitsWasm.get(); - this.log('Executing private kernel simulation ordering...'); - const [duration, result] = await elapsed(() => privateKernelSimOrdering(wasm, privateInputs)); - if (result instanceof CircuitError) { - throw new CircuitError(result.code, result.message); - } + const [duration, result] = await elapsed(() => executeOrdering(privateInputs)); this.log(`Simulated private kernel ordering`, { eventName: 'circuit-simulation', circuitName: 'private-kernel-ordering', diff --git a/yarn-project/pxe/tsconfig.json b/yarn-project/pxe/tsconfig.json index 1190999ce69..3106fcd762f 100644 --- a/yarn-project/pxe/tsconfig.json +++ b/yarn-project/pxe/tsconfig.json @@ -24,6 +24,9 @@ { "path": "../noir-compiler" }, + { + "path": "../noir-protocol-circuits" + }, { "path": "../types" } diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index e46fc104a11..4d0a66312bc 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -648,7 +648,7 @@ __metadata: languageName: unknown linkType: soft -"@aztec/noir-protocol-circuits@workspace:noir-protocol-circuits": +"@aztec/noir-protocol-circuits@workspace:^, @aztec/noir-protocol-circuits@workspace:noir-protocol-circuits": version: 0.0.0-use.local resolution: "@aztec/noir-protocol-circuits@workspace:noir-protocol-circuits" dependencies: @@ -757,6 +757,7 @@ __metadata: "@aztec/foundation": "workspace:^" "@aztec/key-store": "workspace:^" "@aztec/noir-compiler": "workspace:^" + "@aztec/noir-protocol-circuits": "workspace:^" "@aztec/types": "workspace:^" "@jest/globals": ^29.5.0 "@rushstack/eslint-patch": ^1.1.4