Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove individual historic roots from privateCircuitPublicInputs #1571

Merged
merged 28 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4219b44
feat: seperate public and private contexts
Maddiaa0 Aug 10, 2023
ccd42d8
feat: public processor consuming public context
Maddiaa0 Aug 11, 2023
cac043f
feat: Add to other contracts
Maddiaa0 Aug 11, 2023
d6b4437
feat: use context methods
Maddiaa0 Aug 11, 2023
9b95458
fix: use context rather than inputs more often
Maddiaa0 Aug 11, 2023
d8f1700
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Maddiaa0 Aug 12, 2023
b3c336d
Merge branch 'master' into md/p-context
Maddiaa0 Aug 14, 2023
d92fc4e
fix: codegen merge issues
Maddiaa0 Aug 14, 2023
2447886
fix: unify foreign call syntax
Maddiaa0 Aug 14, 2023
79c1e7a
feat: include block hash in public circuit public input shape
Maddiaa0 Aug 14, 2023
0fa5c7a
temp
Maddiaa0 Aug 14, 2023
5289f2b
Add blockdata into public hashing
Maddiaa0 Aug 14, 2023
25f90a1
lint
Maddiaa0 Aug 14, 2023
b97c244
snapshot
Maddiaa0 Aug 14, 2023
17b666c
remove log
Maddiaa0 Aug 14, 2023
106615a
fix: typo
Maddiaa0 Aug 15, 2023
e2dacf2
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Maddiaa0 Aug 15, 2023
8c448f9
chore: remove noirup script unused var
Maddiaa0 Aug 15, 2023
e56d3e5
chore: refactor empty in noir
Maddiaa0 Aug 15, 2023
1bf4a23
fix: ts nits
Maddiaa0 Aug 15, 2023
82125a3
feat: align privatecircuitpublicinputs
Maddiaa0 Aug 15, 2023
c0bddfc
fix: use the same method to encode values for noir to prevent misorde…
Maddiaa0 Aug 15, 2023
6dbf78e
chore: lint
Maddiaa0 Aug 15, 2023
3a974e1
Merge branch 'master' into md/priv_inputs_fix
Maddiaa0 Aug 18, 2023
9edd4cf
merge fix
Maddiaa0 Aug 18, 2023
9caac2c
fix: incorrect root provided
Maddiaa0 Aug 18, 2023
a4c9c3c
lint
Maddiaa0 Aug 18, 2023
815a502
Merge branch 'master' into md/priv_inputs_fix
Maddiaa0 Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ template <typename NCT> struct HistoricBlockData {
global_variables_hash == other.global_variables_hash;
};

template <typename Builder> void assert_is_zero()
{
static_assert((std::is_same<CircuitTypes<Builder>, NCT>::value));

private_data_tree_root.assert_is_zero();
nullifier_tree_root.assert_is_zero();
contract_tree_root.assert_is_zero();
l1_to_l2_messages_tree_root.assert_is_zero();
blocks_tree_root.assert_is_zero();
private_kernel_vk_tree_root.assert_is_zero();
public_data_tree_root.assert_is_zero();
global_variables_hash.assert_is_zero();
}

template <typename Builder> HistoricBlockData<CircuitTypes<Builder>> to_circuit_type(Builder& builder) const
{
static_assert((std::is_same<NativeTypes, NCT>::value));
Expand Down
137 changes: 18 additions & 119 deletions circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "call_context.hpp"
#include "contract_deployment_data.hpp"

#include "aztec3/circuits/abis/historic_block_data.hpp"
#include "aztec3/constants.hpp"
#include "aztec3/utils/types/circuit_types.hpp"
#include "aztec3/utils/types/convert.hpp"
Expand Down Expand Up @@ -45,13 +46,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {
fr encrypted_log_preimages_length = 0;
fr unencrypted_log_preimages_length = 0;

fr historic_private_data_tree_root = 0;
fr historic_nullifier_tree_root = 0;
fr historic_contract_tree_root = 0;
fr historic_l1_to_l2_messages_tree_root = 0;
fr historic_blocks_tree_root = 0;
fr historic_public_data_tree_root = 0;
fr historic_global_variables_hash = 0;
HistoricBlockData<NCT> historic_block_data{};

ContractDeploymentData<NCT> contract_deployment_data{};

Expand All @@ -73,13 +68,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {
unencrypted_logs_hash,
encrypted_log_preimages_length,
unencrypted_log_preimages_length,
historic_private_data_tree_root,
historic_nullifier_tree_root,
historic_contract_tree_root,
historic_l1_to_l2_messages_tree_root,
historic_blocks_tree_root,
historic_public_data_tree_root,
historic_global_variables_hash,
historic_block_data,
contract_deployment_data,
chain_id,
version);
Expand All @@ -95,13 +84,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {
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 &&
historic_private_data_tree_root == other.historic_private_data_tree_root &&
historic_nullifier_tree_root == other.historic_nullifier_tree_root &&
historic_contract_tree_root == other.historic_contract_tree_root &&
historic_l1_to_l2_messages_tree_root == other.historic_l1_to_l2_messages_tree_root &&
historic_blocks_tree_root == other.historic_blocks_tree_root &&
historic_public_data_tree_root == other.historic_public_data_tree_root &&
historic_global_variables_hash == other.historic_global_variables_hash &&
historic_block_data == other.historic_block_data &&
contract_deployment_data == other.contract_deployment_data && chain_id == other.chain_id &&
version == other.version;
};
Expand Down Expand Up @@ -137,13 +120,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {
to_ct(encrypted_log_preimages_length),
to_ct(unencrypted_log_preimages_length),

to_ct(historic_private_data_tree_root),
to_ct(historic_nullifier_tree_root),
to_ct(historic_contract_tree_root),
to_ct(historic_l1_to_l2_messages_tree_root),
to_ct(historic_blocks_tree_root),
to_ct(historic_public_data_tree_root),
to_ct(historic_global_variables_hash),
to_circuit_type(historic_block_data),

to_circuit_type(contract_deployment_data),

Expand Down Expand Up @@ -182,13 +159,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {
to_nt(encrypted_log_preimages_length),
to_nt(unencrypted_log_preimages_length),

to_nt(historic_private_data_tree_root),
to_nt(historic_nullifier_tree_root),
to_nt(historic_contract_tree_root),
to_nt(historic_l1_to_l2_messages_tree_root),
to_nt(historic_blocks_tree_root),
to_nt(historic_public_data_tree_root),
to_nt(historic_global_variables_hash),
to_native_type(historic_block_data),

to_native_type(contract_deployment_data),

Expand Down Expand Up @@ -226,13 +197,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {
inputs.push_back(encrypted_log_preimages_length);
inputs.push_back(unencrypted_log_preimages_length);

inputs.push_back(historic_private_data_tree_root);
inputs.push_back(historic_nullifier_tree_root);
inputs.push_back(historic_contract_tree_root);
inputs.push_back(historic_l1_to_l2_messages_tree_root);
inputs.push_back(historic_blocks_tree_root);
inputs.push_back(historic_public_data_tree_root);
inputs.push_back(historic_global_variables_hash);
spread_arr_into_vec(historic_block_data.to_array(), inputs);

inputs.push_back(contract_deployment_data.hash());

Expand Down Expand Up @@ -282,13 +247,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
opt_fr encrypted_log_preimages_length;
opt_fr unencrypted_log_preimages_length;

opt_fr historic_private_data_tree_root;
opt_fr historic_nullifier_tree_root;
opt_fr historic_contract_tree_root;
opt_fr historic_l1_to_l2_messages_tree_root;
opt_fr historic_blocks_tree_root;
opt_fr historic_public_data_tree_root;
opt_fr historic_global_variables_hash;
std::optional<HistoricBlockData<NCT>> historic_block_data;

std::optional<ContractDeploymentData<NCT>> contract_deployment_data;

Expand All @@ -310,13 +269,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
unencrypted_logs_hash,
encrypted_log_preimages_length,
unencrypted_log_preimages_length,
historic_private_data_tree_root,
historic_nullifier_tree_root,
historic_contract_tree_root,
historic_l1_to_l2_messages_tree_root,
historic_blocks_tree_root,
historic_public_data_tree_root,
historic_global_variables_hash,
historic_block_data,
contract_deployment_data,
chain_id,
version);
Expand Down Expand Up @@ -345,13 +298,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
opt_fr const& encrypted_log_preimages_length,
opt_fr const& unencrypted_log_preimages_length,

opt_fr const& historic_private_data_tree_root,
opt_fr const& historic_nullifier_tree_root,
opt_fr const& historic_contract_tree_root,
opt_fr const& historic_l1_to_l2_messages_tree_root,
opt_fr const& historic_blocks_tree_root,
opt_fr const& historic_public_data_tree_root,
opt_fr const& historic_global_variables_hash,
std::optional<HistoricBlockData<NCT>> const& historic_block_data,

std::optional<ContractDeploymentData<NCT>> const& contract_deployment_data,

Expand All @@ -371,13 +318,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
, unencrypted_logs_hash(unencrypted_logs_hash)
, encrypted_log_preimages_length(encrypted_log_preimages_length)
, unencrypted_log_preimages_length(unencrypted_log_preimages_length)
, historic_private_data_tree_root(historic_private_data_tree_root)
, historic_nullifier_tree_root(historic_nullifier_tree_root)
, historic_contract_tree_root(historic_contract_tree_root)
, historic_l1_to_l2_messages_tree_root(historic_l1_to_l2_messages_tree_root)
, historic_blocks_tree_root(historic_blocks_tree_root)
, historic_public_data_tree_root(historic_public_data_tree_root)
, historic_global_variables_hash(historic_global_variables_hash)
, historic_block_data(historic_block_data)
, contract_deployment_data(contract_deployment_data)
, chain_id(chain_id)
, version(version){};
Expand Down Expand Up @@ -409,13 +350,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
new_inputs.encrypted_log_preimages_length = std::nullopt;
new_inputs.unencrypted_log_preimages_length = std::nullopt;

new_inputs.historic_private_data_tree_root = std::nullopt;
new_inputs.historic_nullifier_tree_root = std::nullopt;
new_inputs.historic_contract_tree_root = std::nullopt;
new_inputs.historic_l1_to_l2_messages_tree_root = std::nullopt;
new_inputs.historic_blocks_tree_root = std::nullopt;
new_inputs.historic_public_data_tree_root = std::nullopt;
new_inputs.historic_global_variables_hash = std::nullopt;
new_inputs.historic_block_data = std::nullopt;

new_inputs.contract_deployment_data = std::nullopt;

Expand Down Expand Up @@ -480,13 +415,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
make_unused_element_zero(builder, encrypted_log_preimages_length);
make_unused_element_zero(builder, unencrypted_log_preimages_length);

make_unused_element_zero(builder, historic_private_data_tree_root);
make_unused_element_zero(builder, historic_nullifier_tree_root);
make_unused_element_zero(builder, historic_contract_tree_root);
make_unused_element_zero(builder, historic_l1_to_l2_messages_tree_root);
make_unused_element_zero(builder, historic_blocks_tree_root);
make_unused_element_zero(builder, historic_public_data_tree_root);
make_unused_element_zero(builder, historic_global_variables_hash);
make_unused_element_zero(builder, historic_block_data);

make_unused_element_zero(builder, contract_deployment_data);

Expand Down Expand Up @@ -525,13 +454,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
(*encrypted_log_preimages_length).set_public();
(*unencrypted_log_preimages_length).set_public();

(*historic_private_data_tree_root).set_public();
(*historic_nullifier_tree_root).set_public();
(*historic_contract_tree_root).set_public();
(*historic_l1_to_l2_messages_tree_root).set_public();
(*historic_blocks_tree_root).set_public();
(*historic_public_data_tree_root).set_public();
(*historic_global_variables_hash).set_public();
(*historic_block_data).set_public();

(*contract_deployment_data).set_public();

Expand Down Expand Up @@ -572,13 +495,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
to_ct(encrypted_log_preimages_length),
to_ct(unencrypted_log_preimages_length),

to_ct(historic_private_data_tree_root),
to_ct(historic_nullifier_tree_root),
to_ct(historic_contract_tree_root),
to_ct(historic_l1_to_l2_messages_tree_root),
to_ct(historic_blocks_tree_root),
to_ct(historic_public_data_tree_root),
to_ct(historic_global_variables_hash),
to_circuit_type(historic_block_data),

to_circuit_type(contract_deployment_data),

Expand Down Expand Up @@ -619,13 +536,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
to_nt(encrypted_log_preimages_length),
to_nt(unencrypted_log_preimages_length),

to_nt(historic_private_data_tree_root),
to_nt(historic_nullifier_tree_root),
to_nt(historic_contract_tree_root),
to_nt(historic_l1_to_l2_messages_tree_root),
to_nt(historic_blocks_tree_root),
to_nt(historic_public_data_tree_root),
to_nt(historic_global_variables_hash),
to_native_type(historic_block_data),

to_native_type(contract_deployment_data),

Expand Down Expand Up @@ -667,13 +578,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
inputs.push_back(*encrypted_log_preimages_length);
inputs.push_back(*unencrypted_log_preimages_length);

inputs.push_back(*historic_private_data_tree_root);
inputs.push_back(*historic_nullifier_tree_root);
inputs.push_back(*historic_contract_tree_root);
inputs.push_back(*historic_l1_to_l2_messages_tree_root);
inputs.push_back(*historic_blocks_tree_root);
inputs.push_back(*historic_public_data_tree_root);
inputs.push_back(*historic_global_variables_hash);
spread_arr_opt_into_vec((*historic_block_data).to_array(), inputs);

inputs.push_back((*contract_deployment_data).hash());

Expand Down Expand Up @@ -710,13 +615,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
.encrypted_log_preimages_length = encrypted_log_preimages_length.value(),
.unencrypted_log_preimages_length = unencrypted_log_preimages_length.value(),

.historic_private_data_tree_root = historic_private_data_tree_root.value(),
.historic_nullifier_tree_root = historic_nullifier_tree_root.value(),
.historic_contract_tree_root = historic_contract_tree_root.value(),
.historic_l1_to_l2_messages_tree_root = historic_l1_to_l2_messages_tree_root.value(),
.historic_blocks_tree_root = historic_blocks_tree_root.value(),
.historic_public_data_tree_root = historic_public_data_tree_root.value(),
.historic_global_variables_hash = historic_global_variables_hash.value(),
.historic_block_data = historic_block_data.value(),

.contract_deployment_data = contract_deployment_data.value(),

Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ void common_contract_logic(DummyBuilder& builder,
private_call.contract_leaf_membership_witness.sibling_path);

auto const& purported_contract_tree_root =
private_call.call_stack_item.public_inputs.historic_contract_tree_root;
private_call.call_stack_item.public_inputs.historic_block_data.contract_tree_root;

builder.do_assert(
computed_contract_tree_root == purported_contract_tree_root,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace {
using NT = aztec3::utils::types::NativeTypes;

using aztec3::circuits::abis::CombinedConstantData;
using aztec3::circuits::abis::HistoricBlockData;
using aztec3::circuits::abis::KernelCircuitPublicInputs;
using aztec3::circuits::abis::private_kernel::PrivateKernelInputsInit;
using aztec3::utils::array_push;
Expand All @@ -27,19 +26,11 @@ void initialise_end_values(PrivateKernelInputsInit<NT> const& private_inputs,
// Define the constants data.
auto const& private_call_public_inputs = private_inputs.private_call.call_stack_item.public_inputs;
auto const constants = CombinedConstantData<NT>{
.block_data =
HistoricBlockData<NT>{
// TODO(dbanks12): remove historic root from app circuit public inputs and
// add it to PrivateCallData: https://github.com/AztecProtocol/aztec-packages/issues/778
// Then use this:
// .private_data_tree_root = private_inputs.private_call.historic_private_data_tree_root,
.private_data_tree_root = private_call_public_inputs.historic_private_data_tree_root,
.nullifier_tree_root = private_call_public_inputs.historic_nullifier_tree_root,
.contract_tree_root = private_call_public_inputs.historic_contract_tree_root,
.l1_to_l2_messages_tree_root = private_call_public_inputs.historic_l1_to_l2_messages_tree_root,
.public_data_tree_root = private_call_public_inputs.historic_public_data_tree_root,
.global_variables_hash = private_call_public_inputs.historic_global_variables_hash,
},
.block_data = private_call_public_inputs.historic_block_data,
// TODO(dbanks12): remove historic root from app circuit public inputs and
// add it to PrivateCallData: https://github.com/AztecProtocol/aztec-packages/issues/778
// Then use this:
// .private_data_tree_root = private_inputs.private_call.historic_private_data_tree_root,
.tx_context = private_inputs.tx_request.tx_context,
};

Expand Down
Loading