From 5c2bac71baeb18188aad7c8d7fc90ca851e347ab Mon Sep 17 00:00:00 2001 From: jeanmon Date: Fri, 1 Sep 2023 12:38:46 +0000 Subject: [PATCH] 1407 - remove read request membership witnesses from public inputs of private kernel --- .../abis/combined_accumulated_data.hpp | 28 +-------- .../native_private_kernel_circuit.test.cpp | 4 -- .../native_private_kernel_circuit_init.cpp | 4 -- ...e_private_kernel_circuit_ordering.test.cpp | 1 - .../circuits.js/src/cbind/circuits.gen.ts | 63 ------------------- .../kernel/combined_accumulated_data.ts | 11 ---- .../circuits.js/src/tests/factories.ts | 1 - 7 files changed, 1 insertion(+), 111 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index 5e47215404e..e3e2800a69c 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -31,8 +31,6 @@ template struct CombinedAccumulatedData { AggregationObject aggregation_object{}; std::array read_requests{}; - std::array, MAX_READ_REQUESTS_PER_TX> - read_request_membership_witnesses{}; std::array new_commitments{}; std::array new_nullifiers{}; @@ -62,7 +60,6 @@ template struct CombinedAccumulatedData { // for serialization, update with new fields MSGPACK_FIELDS(aggregation_object, read_requests, - read_request_membership_witnesses, new_commitments, new_nullifiers, nullified_commitments, @@ -79,18 +76,7 @@ template struct CombinedAccumulatedData { public_data_reads); boolean operator==(CombinedAccumulatedData const& other) const { - return aggregation_object == other.aggregation_object && read_requests == other.read_requests && - read_request_membership_witnesses == other.read_request_membership_witnesses && - new_commitments == other.new_commitments && new_nullifiers == other.new_nullifiers && - nullified_commitments == other.nullified_commitments && private_call_stack == other.private_call_stack && - public_call_stack == other.public_call_stack && new_l2_to_l1_msgs == other.new_l2_to_l1_msgs && - encrypted_logs_hash == other.encrypted_logs_hash && - unencrypted_logs_hash == other.unencrypted_logs_hash && - encrypted_log_preimages_length == other.encrypted_log_preimages_length && - unencrypted_log_preimages_length == other.unencrypted_log_preimages_length && - new_contracts == other.new_contracts && optionally_revealed_data == other.optionally_revealed_data && - public_data_update_requests == other.public_data_update_requests && - public_data_reads == other.public_data_reads; + return msgpack_derived_equals(*this, other); }; template CombinedAccumulatedData> to_circuit_type(Builder& builder) const @@ -112,7 +98,6 @@ template struct CombinedAccumulatedData { }, to_ct(read_requests), - map(read_request_membership_witnesses, to_circuit_type), to_ct(new_commitments), to_ct(new_nullifiers), @@ -153,7 +138,6 @@ template struct CombinedAccumulatedData { }, to_nt(read_requests), - map(read_request_membership_witnesses, to_native_type), to_nt(new_commitments), to_nt(new_nullifiers), @@ -184,7 +168,6 @@ template struct CombinedAccumulatedData { aggregation_object.add_proof_outputs_as_public_inputs(); set_array_public(read_requests); - set_array_public(read_request_membership_witnesses); set_array_public(new_commitments); set_array_public(new_nullifiers); @@ -211,15 +194,6 @@ template struct CombinedAccumulatedData { } } - template - void set_array_public(std::array, SIZE>& arr) - { - static_assert(!(std::is_same::value)); - for (auto& e : arr) { - e.set_public(); - } - } - template void set_array_public(std::array, SIZE>& arr) { static_assert(!(std::is_same::value)); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit.test.cpp index 3b171e79e34..14fe520d7dc 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit.test.cpp @@ -69,7 +69,6 @@ TEST_F(native_private_kernel_tests, native_accumulate_transient_read_requests) << " with code: " << builder.get_first_failure().code; ASSERT_TRUE(array_length(public_inputs.end.new_commitments) == 1); ASSERT_TRUE(array_length(public_inputs.end.read_requests) == 1); - ASSERT_TRUE(array_length(public_inputs.end.read_request_membership_witnesses) == 1); auto private_inputs_inner = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args()); @@ -94,7 +93,6 @@ TEST_F(native_private_kernel_tests, native_accumulate_transient_read_requests) << " with code: " << builder.get_first_failure().code; ASSERT_TRUE(array_length(public_inputs.end.new_commitments) == 2); ASSERT_TRUE(array_length(public_inputs.end.read_requests) == 2); - ASSERT_TRUE(array_length(public_inputs.end.read_request_membership_witnesses) == 2); auto& previous_kernel = private_inputs_inner.previous_kernel; previous_kernel.public_inputs = public_inputs; @@ -128,7 +126,6 @@ TEST_F(native_private_kernel_tests, native_transient_read_requests_no_match) << " with code: " << builder.get_first_failure().code; ASSERT_TRUE(array_length(public_inputs.end.new_commitments) == 1); ASSERT_TRUE(array_length(public_inputs.end.read_requests) == 1); - ASSERT_TRUE(array_length(public_inputs.end.read_request_membership_witnesses) == 1); auto private_inputs_inner = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args()); @@ -153,7 +150,6 @@ TEST_F(native_private_kernel_tests, native_transient_read_requests_no_match) << " with code: " << builder.get_first_failure().code; ASSERT_TRUE(array_length(public_inputs.end.new_commitments) == 2); ASSERT_TRUE(array_length(public_inputs.end.read_requests) == 2); - ASSERT_TRUE(array_length(public_inputs.end.read_request_membership_witnesses) == 2); auto& previous_kernel = private_inputs_inner.previous_kernel; previous_kernel.public_inputs = public_inputs; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp index a406869f3ad..53df785c288 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp @@ -144,10 +144,6 @@ void update_end_values(DummyCircuitBuilder& builder, builder.do_assert(is_array_empty(public_inputs.end.read_requests), "public_inputs.end.read_requests must start as empty in initial kernel iteration", CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); - builder.do_assert( - is_array_empty(public_inputs.end.read_request_membership_witnesses), - "public_inputs.end.read_request_membership_witnesses must start as empty in initial kernel iteration", - CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); builder.do_assert(public_inputs.end.encrypted_log_preimages_length == NT::fr(0), "public_inputs.end.encrypted_log_preimages_length must start as 0 in initial kernel iteration", CircuitErrorCode::PRIVATE_KERNEL__UNSUPPORTED_OP); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp index a0fa2ab3c15..a368d0179ac 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp @@ -102,7 +102,6 @@ TEST_F(native_private_kernel_ordering_tests, native_matching_some_read_requests_ previous_kernel.public_inputs.end.new_nullifiers = new_nullifiers; previous_kernel.public_inputs.end.new_commitments = siloed_commitments; previous_kernel.public_inputs.end.read_requests = read_requests; - previous_kernel.public_inputs.end.read_request_membership_witnesses = read_request_membership_witnesses; PrivateKernelInputsOrdering private_inputs{ previous_kernel, std::array{} }; diff --git a/yarn-project/circuits.js/src/cbind/circuits.gen.ts b/yarn-project/circuits.js/src/cbind/circuits.gen.ts index a0a37dceb42..a955e53cecf 100644 --- a/yarn-project/circuits.js/src/cbind/circuits.gen.ts +++ b/yarn-project/circuits.js/src/cbind/circuits.gen.ts @@ -39,7 +39,6 @@ import { PublicDataRead, PublicDataUpdateRequest, PublicKernelInputs, - ReadRequestMembershipWitness, TxContext, VerificationKeyData, isCircuitError, @@ -181,55 +180,6 @@ export function fromNativeAggregationState(o: NativeAggregationState): MsgpackNa }; } -interface MsgpackReadRequestMembershipWitness { - leaf_index: Buffer; - sibling_path: Tuple; - is_transient: boolean; - hint_to_commitment: Buffer; -} - -export function toReadRequestMembershipWitness(o: MsgpackReadRequestMembershipWitness): ReadRequestMembershipWitness { - if (o.leaf_index === undefined) { - throw new Error('Expected leaf_index in ReadRequestMembershipWitness deserialization'); - } - if (o.sibling_path === undefined) { - throw new Error('Expected sibling_path in ReadRequestMembershipWitness deserialization'); - } - if (o.is_transient === undefined) { - throw new Error('Expected is_transient in ReadRequestMembershipWitness deserialization'); - } - if (o.hint_to_commitment === undefined) { - throw new Error('Expected hint_to_commitment in ReadRequestMembershipWitness deserialization'); - } - return new ReadRequestMembershipWitness( - Fr.fromBuffer(o.leaf_index), - mapTuple(o.sibling_path, (v: Buffer) => Fr.fromBuffer(v)), - o.is_transient, - Fr.fromBuffer(o.hint_to_commitment), - ); -} - -export function fromReadRequestMembershipWitness(o: ReadRequestMembershipWitness): MsgpackReadRequestMembershipWitness { - if (o.leafIndex === undefined) { - throw new Error('Expected leafIndex in ReadRequestMembershipWitness serialization'); - } - if (o.siblingPath === undefined) { - throw new Error('Expected siblingPath in ReadRequestMembershipWitness serialization'); - } - if (o.isTransient === undefined) { - throw new Error('Expected isTransient in ReadRequestMembershipWitness serialization'); - } - if (o.hintToCommitment === undefined) { - throw new Error('Expected hintToCommitment in ReadRequestMembershipWitness serialization'); - } - return { - leaf_index: toBuffer(o.leafIndex), - sibling_path: mapTuple(o.siblingPath, (v: Fr) => toBuffer(v)), - is_transient: o.isTransient, - hint_to_commitment: toBuffer(o.hintToCommitment), - }; -} - interface MsgpackNewContractData { contract_address: Buffer; portal_contract_address: Buffer; @@ -490,7 +440,6 @@ export function fromPublicDataRead(o: PublicDataRead): MsgpackPublicDataRead { interface MsgpackCombinedAccumulatedData { aggregation_object: MsgpackNativeAggregationState; read_requests: Tuple; - read_request_membership_witnesses: Tuple; new_commitments: Tuple; new_nullifiers: Tuple; nullified_commitments: Tuple; @@ -514,9 +463,6 @@ export function toCombinedAccumulatedData(o: MsgpackCombinedAccumulatedData): Co if (o.read_requests === undefined) { throw new Error('Expected read_requests in CombinedAccumulatedData deserialization'); } - if (o.read_request_membership_witnesses === undefined) { - throw new Error('Expected read_request_membership_witnesses in CombinedAccumulatedData deserialization'); - } if (o.new_commitments === undefined) { throw new Error('Expected new_commitments in CombinedAccumulatedData deserialization'); } @@ -562,9 +508,6 @@ export function toCombinedAccumulatedData(o: MsgpackCombinedAccumulatedData): Co return new CombinedAccumulatedData( toNativeAggregationState(o.aggregation_object), mapTuple(o.read_requests, (v: Buffer) => Fr.fromBuffer(v)), - mapTuple(o.read_request_membership_witnesses, (v: MsgpackReadRequestMembershipWitness) => - toReadRequestMembershipWitness(v), - ), mapTuple(o.new_commitments, (v: Buffer) => Fr.fromBuffer(v)), mapTuple(o.new_nullifiers, (v: Buffer) => Fr.fromBuffer(v)), mapTuple(o.nullified_commitments, (v: Buffer) => Fr.fromBuffer(v)), @@ -589,9 +532,6 @@ export function fromCombinedAccumulatedData(o: CombinedAccumulatedData): Msgpack if (o.readRequests === undefined) { throw new Error('Expected readRequests in CombinedAccumulatedData serialization'); } - if (o.readRequestMembershipWitnesses === undefined) { - throw new Error('Expected readRequestMembershipWitnesses in CombinedAccumulatedData serialization'); - } if (o.newCommitments === undefined) { throw new Error('Expected newCommitments in CombinedAccumulatedData serialization'); } @@ -637,9 +577,6 @@ export function fromCombinedAccumulatedData(o: CombinedAccumulatedData): Msgpack return { aggregation_object: fromNativeAggregationState(o.aggregationObject), read_requests: mapTuple(o.readRequests, (v: Fr) => toBuffer(v)), - read_request_membership_witnesses: mapTuple(o.readRequestMembershipWitnesses, (v: ReadRequestMembershipWitness) => - fromReadRequestMembershipWitness(v), - ), new_commitments: mapTuple(o.newCommitments, (v: Fr) => toBuffer(v)), new_nullifiers: mapTuple(o.newNullifiers, (v: Fr) => toBuffer(v)), nullified_commitments: mapTuple(o.nullifiedCommitments, (v: Fr) => toBuffer(v)), diff --git a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts index 43f4134ab41..623174eb8d4 100644 --- a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts @@ -15,7 +15,6 @@ import { NUM_FIELDS_PER_SHA256, } from '../../cbind/constants.gen.js'; import { assertMemberLength, makeTuple } from '../../index.js'; -import { makeEmptyReadRequestMembershipWitness } from '../../tests/factories.js'; import { serializeToBuffer } from '../../utils/serialize.js'; import { AggregationObject, @@ -23,7 +22,6 @@ import { EthAddress, Fr, FunctionData, - ReadRequestMembershipWitness, } from '../index.js'; /** @@ -295,10 +293,6 @@ export class CombinedAccumulatedData { * All the read requests made in this transaction. */ public readRequests: Tuple, - /** - * All the read request membership witnesses made in this transaction. - */ - public readRequestMembershipWitnesses: Tuple, /** * The new commitments made in this transaction. */ @@ -360,7 +354,6 @@ export class CombinedAccumulatedData { public publicDataReads: Tuple, ) { assertMemberLength(this, 'readRequests', MAX_READ_REQUESTS_PER_TX); - assertMemberLength(this, 'readRequestMembershipWitnesses', MAX_READ_REQUESTS_PER_TX); assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX); assertMemberLength(this, 'nullifiedCommitments', MAX_NEW_NULLIFIERS_PER_TX); @@ -379,7 +372,6 @@ export class CombinedAccumulatedData { return serializeToBuffer( this.aggregationObject, this.readRequests, - this.readRequestMembershipWitnesses, this.newCommitments, this.newNullifiers, this.nullifiedCommitments, @@ -411,7 +403,6 @@ export class CombinedAccumulatedData { return new CombinedAccumulatedData( reader.readObject(AggregationObject), reader.readArray(MAX_READ_REQUESTS_PER_TX, Fr), - reader.readArray(MAX_READ_REQUESTS_PER_TX, ReadRequestMembershipWitness), reader.readArray(MAX_NEW_COMMITMENTS_PER_TX, Fr), reader.readArray(MAX_NEW_NULLIFIERS_PER_TX, Fr), reader.readArray(MAX_NEW_NULLIFIERS_PER_TX, Fr), @@ -433,7 +424,6 @@ export class CombinedAccumulatedData { return new CombinedAccumulatedData( finalData.aggregationObject, makeTuple(MAX_READ_REQUESTS_PER_TX, Fr.zero), - makeTuple(MAX_READ_REQUESTS_PER_TX, makeEmptyReadRequestMembershipWitness), finalData.newCommitments, finalData.newNullifiers, finalData.nullifiedCommitments, @@ -464,7 +454,6 @@ export class CombinedAccumulatedData { return new CombinedAccumulatedData( AggregationObject.makeFake(), makeTuple(MAX_READ_REQUESTS_PER_TX, Fr.zero), - makeTuple(MAX_READ_REQUESTS_PER_TX, () => ReadRequestMembershipWitness.empty(BigInt(0))), makeTuple(MAX_NEW_COMMITMENTS_PER_TX, Fr.zero), makeTuple(MAX_NEW_NULLIFIERS_PER_TX, Fr.zero), makeTuple(MAX_NEW_NULLIFIERS_PER_TX, Fr.zero), diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 17a3a72340f..fe5d2be747e 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -204,7 +204,6 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated return new CombinedAccumulatedData( makeAggregationObject(seed), tupleGenerator(MAX_READ_REQUESTS_PER_TX, fr, seed + 0x80), - tupleGenerator(MAX_READ_REQUESTS_PER_TX, i => makeReadRequestMembershipWitness(i * 123), seed + 0x90), tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x300),