-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
124 additions
and
101 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
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
70 changes: 70 additions & 0 deletions
70
circuits/cpp/src/aztec3/circuits/abis/complete_address.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,70 @@ | ||
#pragma once | ||
#include "aztec3/circuits/abis/coordinate.hpp" | ||
#include "aztec3/circuits/abis/point.hpp" | ||
#include "aztec3/utils/types/circuit_types.hpp" | ||
#include "aztec3/utils/types/convert.hpp" | ||
#include "aztec3/utils/types/native_types.hpp" | ||
|
||
#include <barretenberg/barretenberg.hpp> | ||
|
||
namespace aztec3::circuits::abis { | ||
|
||
using aztec3::utils::types::CircuitTypes; | ||
using aztec3::utils::types::NativeTypes; | ||
|
||
template <typename NCT> struct CompleteAddress { | ||
using fr = typename NCT::fr; | ||
using boolean = typename NCT::boolean; | ||
|
||
fr address; | ||
Point<NCT> public_key; | ||
fr partial_address; | ||
|
||
// for serialization, update with new fields | ||
MSGPACK_FIELDS(address, public_key, partial_address); | ||
bool operator==(CompleteAddress<NCT> const&) const = default; | ||
|
||
template <typename Builder> CompleteAddress<CircuitTypes<Builder>> to_circuit_type(Builder& builder) const | ||
{ | ||
static_assert((std::is_same<NativeTypes, NCT>::value)); | ||
|
||
auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; | ||
|
||
CompleteAddress<CircuitTypes<Builder>> complete_address = { to_ct(address), | ||
to_ct(public_key), | ||
to_ct(partial_address) }; | ||
|
||
return complete_address; | ||
}; | ||
|
||
template <typename Builder> CompleteAddress<NativeTypes> to_native_type() const | ||
{ | ||
static_assert((std::is_same<CircuitTypes<Builder>, NCT>::value)); | ||
|
||
auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt<Builder>(e); }; | ||
|
||
CompleteAddress<NativeTypes> complete_address = { to_nt(address), to_nt(public_key), to_nt(partial_address) }; | ||
|
||
return complete_address; | ||
}; | ||
|
||
void set_public() | ||
{ | ||
static_assert(!(std::is_same<NativeTypes, NCT>::value)); | ||
|
||
address.set_public(); | ||
public_key.set_public(); | ||
partial_address.set_public(); | ||
} | ||
|
||
void assert_is_zero() | ||
{ | ||
static_assert(!(std::is_same<NativeTypes, NCT>::value)); | ||
|
||
address.assert_is_zero(); | ||
public_key.assert_is_zero(); | ||
partial_address.assert_is_zero(); | ||
} | ||
}; | ||
|
||
} // 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
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.