Skip to content

Commit

Permalink
intial root
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Mar 29, 2023
1 parent 2be3a16 commit 1565f45
Show file tree
Hide file tree
Showing 11 changed files with 675 additions and 0 deletions.
1 change: 1 addition & 0 deletions cpp/src/aztec3/circuits/abis/membership_witness.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "aztec3/utils/types/circuit_types.hpp"
#include "aztec3/utils/types/convert.hpp"
namespace aztec3::circuits::abis {

using aztec3::utils::types::CircuitTypes;
Expand Down
59 changes: 59 additions & 0 deletions cpp/src/aztec3/circuits/abis/rollup/base/previous_rollup_data.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#pragma once
#include "aztec3/circuits/abis/append_only_tree_snapshot.hpp"
#include "aztec3/circuits/abis/membership_witness.hpp"
#include "aztec3/circuits/abis/rollup/base/base_rollup_public_inputs.hpp"
#include "aztec3/constants.hpp"
#include <aztec3/utils/types/native_types.hpp>
#include <aztec3/utils/types/circuit_types.hpp>
#include <aztec3/utils/types/convert.hpp>
#include <type_traits>

namespace aztec3::circuits::abis {

using aztec3::utils::types::CircuitTypes;
using aztec3::utils::types::NativeTypes;
using std::is_same;

template <typename NCT> struct PreviousRollupData {
BaseRollupPublicInputs<NCT> base_rollup_public_inputs;

NativeTypes::Proof proof;
std::shared_ptr<NativeTypes::VK> vk;
NativeTypes::uint32 vk_index;
MembershipWitness<NCT, ROLLUP_VK_TREE_HEIGHT> vk_sibling_path;

bool operator==(PreviousRollupData<NCT> const&) const = default;
};

template <typename NCT> void read(uint8_t const*& it, PreviousRollupData<NCT>& obj)
{
using serialize::read;

read(it, obj.base_rollup_public_inputs);
read(it, obj.proof);
read(it, obj.vk);
read(it, obj.vk_index);
read(it, obj.vk_sibling_path);
};

template <typename NCT> void write(std::vector<uint8_t>& buf, PreviousRollupData<NCT> const& obj)
{
using serialize::write;

write(buf, obj.base_rollup_public_inputs);
write(buf, obj.proof);
write(buf, *obj.vk);
write(buf, obj.vk_index);
write(buf, obj.vk_sibling_path);
};

template <typename NCT> std::ostream& operator<<(std::ostream& os, PreviousRollupData<NCT> const& obj)
{
return os << "merge_rollup_public_inputs: " << obj.base_rollup_public_inputs << "\n"
<< "proof: " << obj.proof << "\n"
<< "vk: " << obj.vk << "\n"
<< "vk_index: " << obj.vk_index << "\n"
<< "vk_sibling_path: " << obj.vk_sibling_path << "\n";
};

} // namespace aztec3::circuits::abis
54 changes: 54 additions & 0 deletions cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@


#pragma once
#include "aztec3/circuits/abis/append_only_tree_snapshot.hpp"
#include "aztec3/circuits/abis/rollup/base/previous_rollup_data.hpp"
#include "aztec3/constants.hpp"
#include <aztec3/utils/types/native_types.hpp>
#include <aztec3/utils/types/circuit_types.hpp>
#include <aztec3/utils/types/convert.hpp>
#include <ostream>

namespace aztec3::circuits::abis {

using aztec3::utils::types::CircuitTypes;
using aztec3::utils::types::NativeTypes;

template <typename NCT> struct RootRollupInputs {
typedef typename NCT::fr fr;

// All below are shared between the base and merge rollups
std::array<PreviousRollupData<NCT>, 2> previous_rollup_data;

std::array<fr, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT> new_historic_private_data_tree_root_sibling_path;
std::array<fr, CONTRACT_TREE_ROOTS_TREE_HEIGHT> new_historic_contract_tree_root_sibling_path;

bool operator==(RootRollupInputs<NCT> const&) const = default;
};

template <typename NCT> void read(uint8_t const*& it, RootRollupInputs<NCT>& obj)
{
using serialize::read;

read(it, obj.previous_rollup_data);
read(it, obj.new_historic_private_data_tree_roots);
read(it, obj.new_historic_contract_tree_roots);
};

template <typename NCT> void write(std::vector<uint8_t>& buf, RootRollupInputs<NCT> const& obj)
{
using serialize::write;

write(buf, obj.previous_rollup_data);
write(buf, obj.new_historic_private_data_tree_roots);
write(buf, obj.new_historic_contract_tree_roots);
};

template <typename NCT> std::ostream& operator<<(std::ostream& os, RootRollupInputs<NCT> const& obj)
{
return os << "previous_rollup_data: " << obj.previous_rollup_data << "\n"
<< "new_historic_private_data_tree_roots: " << obj.new_historic_private_data_tree_roots << "\n"
<< "new_historic_contract_tree_roots: " << obj.new_historic_contract_tree_roots << "\n";
}

} // namespace aztec3::circuits::abis
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@

#pragma once
#include "aztec3/circuits/abis/append_only_tree_snapshot.hpp"
#include <aztec3/utils/types/native_types.hpp>
#include <aztec3/utils/types/circuit_types.hpp>
#include <aztec3/utils/types/convert.hpp>
#include <ostream>

namespace aztec3::circuits::abis {

using aztec3::utils::types::CircuitTypes;
using aztec3::utils::types::NativeTypes;

template <typename NCT> struct RootRollupPublicInputs {
typedef typename NCT::fr fr;
typedef typename NCT::AggregationObject AggregationObject;

// All below are shared between the base and merge rollups
AggregationObject end_aggregation_object;

AppendOnlyTreeSnapshot<NCT> start_private_data_tree_snapshot;
AppendOnlyTreeSnapshot<NCT> end_private_data_tree_snapshot;

AppendOnlyTreeSnapshot<NCT> start_nullifier_tree_snapshot;
AppendOnlyTreeSnapshot<NCT> end_nullifier_tree_snapshot;

AppendOnlyTreeSnapshot<NCT> start_contract_tree_snapshot;
AppendOnlyTreeSnapshot<NCT> end_contract_tree_snapshot;

AppendOnlyTreeSnapshot<NCT> start_tree_of_private_data_tree_roots_snapshot;
AppendOnlyTreeSnapshot<NCT> end_tree_of_private_data_tree_roots_snapshot;

AppendOnlyTreeSnapshot<NCT> start_tree_of_historic_contract_tree_roots_snapshot;
AppendOnlyTreeSnapshot<NCT> end_tree_of_historic_contract_tree_roots_snapshot;

std::array<fr, 2> calldata_hash;

bool operator==(RootRollupPublicInputs<NCT> const&) const = default;
};

template <typename NCT> void read(uint8_t const*& it, RootRollupPublicInputs<NCT>& obj)
{
using serialize::read;

read(it, obj.end_aggregation_object);
read(it, obj.start_private_data_tree_snapshot);
read(it, obj.end_private_data_tree_snapshot);
read(it, obj.start_nullifier_tree_snapshot);
read(it, obj.end_nullifier_tree_snapshot);
read(it, obj.start_contract_tree_snapshot);
read(it, obj.end_contract_tree_snapshot);
read(it, obj.start_tree_of_private_data_tree_roots_snapshot);
read(it, obj.end_tree_of_private_data_tree_roots_snapshot);
read(it, obj.start_tree_of_historic_contract_tree_roots_snapshot);
read(it, obj.end_tree_of_historic_contract_tree_roots_snapshot);
read(it, obj.calldata_hash);
};

template <typename NCT> void write(std::vector<uint8_t>& buf, RootRollupPublicInputs<NCT> const& obj)
{
using serialize::write;

write(buf, obj.end_aggregation_object);
write(buf, obj.start_private_data_tree_snapshot);
write(buf, obj.end_private_data_tree_snapshot);
write(buf, obj.start_nullifier_tree_snapshot);
write(buf, obj.end_nullifier_tree_snapshot);
write(buf, obj.start_contract_tree_snapshot);
write(buf, obj.end_contract_tree_snapshot);
write(buf, obj.start_tree_of_private_data_tree_roots_snapshot);
write(buf, obj.end_tree_of_private_data_tree_roots_snapshot);
write(buf, obj.start_tree_of_historic_contract_tree_roots_snapshot);
write(buf, obj.end_tree_of_historic_contract_tree_roots_snapshot);
write(buf, obj.calldata_hash);
};

template <typename NCT> std::ostream& operator<<(std::ostream& os, RootRollupPublicInputs<NCT> const& obj)
{
return os << "end_aggregation_object: " << obj.end_aggregation_object << "\n"
<< "start_private_data_tree_snapshot: " << obj.start_private_data_tree_snapshot << "\n"
<< "end_private_data_tree_snapshot: " << obj.end_private_data_tree_snapshot << "\n"
<< "start_nullifier_tree_snapshot: " << obj.start_nullifier_tree_snapshot << "\n"
<< "end_nullifier_tree_snapshot: " << obj.end_nullifier_tree_snapshot << "\n"
<< "start_contract_tree_snapshot: " << obj.start_contract_tree_snapshot << "\n"
<< "end_contract_tree_snapshot: " << obj.end_contract_tree_snapshot << "\n"
<< "start_tree_of_private_data_tree_roots_snapshot: "
<< obj.start_tree_of_private_data_tree_roots_snapshot << "\n"
<< "end_tree_of_private_data_tree_roots_snapshot: " << obj.end_tree_of_private_data_tree_roots_snapshot
<< "\n"
<< "start_tree_of_historic_contract_tree_roots_snapshot: "
<< obj.start_tree_of_historic_contract_tree_roots_snapshot << "\n"
<< "end_tree_of_historic_contract_tree_roots_snapshot: "
<< obj.end_tree_of_historic_contract_tree_roots_snapshot << "\n"
<< "calldata_hash: " << obj.calldata_hash << "\n";
};

} // namespace aztec3::circuits::abis
1 change: 1 addition & 0 deletions cpp/src/aztec3/circuits/rollup/base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
barretenberg_module(
aztec3_circuits_rollup
aztec3_circuits_kernel
barretenberg
)
Loading

0 comments on commit 1565f45

Please sign in to comment.