-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update structs for processing public function data in rollup circuits (…
…#357) * Add missing fields to rollup public inputs * Set public data tree snapshots in merge and rollup circuits * Update root rollup public inputs snapshots * Update structs with new fields for public data checks and updates * Remove witnessed public call data and public data tree root * Update inputs to public kernel and base rollup circuits from sequencer * Format
- Loading branch information
1 parent
9730b9b
commit 1117f2f
Showing
30 changed files
with
461 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
circuits/cpp/src/aztec3/circuits/abis/public_data_read.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#pragma once | ||
#include "aztec3/constants.hpp" | ||
#include <barretenberg/stdlib/primitives/witness/witness.hpp> | ||
#include <aztec3/utils/types/native_types.hpp> | ||
#include <aztec3/utils/types/convert.hpp> | ||
#include <aztec3/utils/types/circuit_types.hpp> | ||
|
||
namespace aztec3::circuits::abis { | ||
|
||
using aztec3::GeneratorIndex; | ||
using aztec3::utils::types::CircuitTypes; | ||
using aztec3::utils::types::NativeTypes; | ||
|
||
template <typename NCT> struct PublicDataRead { | ||
typedef typename NCT::fr fr; | ||
typedef typename NCT::boolean boolean; | ||
|
||
fr leaf_index = 0; | ||
fr value = 0; | ||
|
||
bool operator==(PublicDataRead<NCT> const&) const = default; | ||
|
||
template <typename Composer> PublicDataRead<CircuitTypes<Composer>> to_circuit_type(Composer& composer) const | ||
{ | ||
static_assert((std::is_same<NativeTypes, NCT>::value)); | ||
|
||
// Capture the composer: | ||
auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; | ||
|
||
PublicDataRead<CircuitTypes<Composer>> state_transition = { | ||
to_ct(leaf_index), | ||
to_ct(value), | ||
}; | ||
|
||
return state_transition; | ||
}; | ||
|
||
template <typename Composer> PublicDataRead<NativeTypes> to_native_type() const | ||
{ | ||
static_assert((std::is_same<CircuitTypes<Composer>, NCT>::value)); | ||
|
||
auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt<Composer>(e); }; | ||
|
||
PublicDataRead<NativeTypes> state_transition = { | ||
to_nt(leaf_index), | ||
to_nt(value), | ||
}; | ||
|
||
return state_transition; | ||
}; | ||
|
||
fr hash() const | ||
{ | ||
std::vector<fr> inputs = { | ||
leaf_index, | ||
value, | ||
}; | ||
|
||
return NCT::compress(inputs, GeneratorIndex::STATE_READ); | ||
} | ||
|
||
void set_public() | ||
{ | ||
static_assert(!(std::is_same<NativeTypes, NCT>::value)); | ||
|
||
leaf_index.set_public(); | ||
value.set_public(); | ||
} | ||
|
||
boolean is_empty() const { return leaf_index == 0; } | ||
}; | ||
|
||
template <typename NCT> void read(uint8_t const*& it, PublicDataRead<NCT>& state_transition) | ||
{ | ||
using serialize::read; | ||
|
||
read(it, state_transition.leaf_index); | ||
read(it, state_transition.value); | ||
}; | ||
|
||
template <typename NCT> void write(std::vector<uint8_t>& buf, PublicDataRead<NCT> const& state_transition) | ||
{ | ||
using serialize::write; | ||
|
||
write(buf, state_transition.leaf_index); | ||
write(buf, state_transition.value); | ||
}; | ||
|
||
template <typename NCT> std::ostream& operator<<(std::ostream& os, PublicDataRead<NCT> const& state_transition) | ||
{ | ||
return os << "leaf_index: " << state_transition.leaf_index << "\n" | ||
<< "value: " << state_transition.value << "\n"; | ||
} | ||
|
||
} // namespace aztec3::circuits::abis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.