1
1
#pragma once
2
2
3
+ #include " aztec3/circuits/abis/function_selector.hpp"
3
4
#include " aztec3/constants.hpp"
4
5
#include " aztec3/utils/types/circuit_types.hpp"
5
6
#include " aztec3/utils/types/convert.hpp"
@@ -31,7 +32,7 @@ template <typename NCT> struct FunctionLeafPreimage {
31
32
using fr = typename NCT::fr;
32
33
using uint32 = typename NCT::uint32;
33
34
34
- uint32 function_selector = 0 ;
35
+ FunctionSelector<NCT> function_selector = {} ;
35
36
boolean is_internal = false ;
36
37
boolean is_private = false ;
37
38
fr vk_hash = 0 ;
@@ -54,7 +55,11 @@ template <typename NCT> struct FunctionLeafPreimage {
54
55
auto to_ct = [&](auto & e) { return aztec3::utils::types::to_ct (builder, e); };
55
56
56
57
FunctionLeafPreimage<CircuitTypes<Builder>> preimage = {
57
- to_ct (function_selector), to_ct (is_internal), to_ct (is_private), to_ct (vk_hash), to_ct (acir_hash),
58
+ function_selector.to_circuit_type (builder),
59
+ to_ct (is_internal),
60
+ to_ct (is_private),
61
+ to_ct (vk_hash),
62
+ to_ct (acir_hash),
58
63
};
59
64
60
65
return preimage;
@@ -63,10 +68,11 @@ template <typename NCT> struct FunctionLeafPreimage {
63
68
template <typename Builder> FunctionLeafPreimage<NativeTypes> to_native_type () const
64
69
{
65
70
static_assert (std::is_same<CircuitTypes<Builder>, NCT>::value);
71
+ auto to_native_type = []<typename T>(T& e) { return e.template to_native_type <Builder>(); };
66
72
auto to_nt = [&](auto & e) { return aztec3::utils::types::to_nt<Builder>(e); };
67
73
68
74
FunctionLeafPreimage<NativeTypes> preimage = {
69
- to_nt (function_selector), to_nt (is_internal), to_nt (is_private), to_nt (vk_hash), to_nt (acir_hash),
75
+ to_native_type (function_selector), to_nt (is_internal), to_nt (is_private), to_nt (vk_hash), to_nt (acir_hash),
70
76
};
71
77
72
78
return preimage;
@@ -86,7 +92,7 @@ template <typename NCT> struct FunctionLeafPreimage {
86
92
fr hash () const
87
93
{
88
94
std::vector<fr> const inputs = {
89
- function_selector, fr (is_internal), fr (is_private), vk_hash, acir_hash,
95
+ function_selector. value , fr (is_internal), fr (is_private), vk_hash, acir_hash,
90
96
};
91
97
return NCT::compress (inputs, GeneratorIndex::FUNCTION_LEAF);
92
98
}
0 commit comments