forked from AztecProtocol/aztec-packages
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(avm): to_radix gadget (AztecProtocol#6368)
Please read [contributing guidelines](CONTRIBUTING.md) and remove this line.
- Loading branch information
1 parent
9cca814
commit 89dd25f
Showing
19 changed files
with
848 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
include "../avm_main.pil"; | ||
|
||
namespace avm_conversion(256); | ||
|
||
pol commit clk; | ||
|
||
// Selector for Radix Operation | ||
pol commit to_radix_le_sel; | ||
to_radix_le_sel * (1 - to_radix_le_sel) = 0; | ||
|
||
// ===== DRAFT: Planned Constraints for To Radix LE | ||
// Similar to the binary trace; multi-row decomposition of the input using the number of limbs specified as the row count. | ||
// (1) limb_ctr' - limb_ctr + 1 = 0; // Next row decrements the limb_ctr | ||
// (2) Check equality to 0 of limb_ctr to terminate the operations. | ||
// (3) An accumulation column to track the partial re-composition of the limbs | ||
// (4) Range check each row.limb < radix | ||
// (5) TODO: Is there a risk of over/under flow. | ||
|
||
pol commit input; | ||
pol commit radix; | ||
pol commit num_limbs; |
47 changes: 47 additions & 0 deletions
47
barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_conversion.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,47 @@ | ||
|
||
#pragma once | ||
#include "../../relation_parameters.hpp" | ||
#include "../../relation_types.hpp" | ||
#include "./declare_views.hpp" | ||
|
||
namespace bb::Avm_vm { | ||
|
||
template <typename FF> struct Avm_conversionRow { | ||
FF avm_conversion_to_radix_le_sel{}; | ||
}; | ||
|
||
inline std::string get_relation_label_avm_conversion(int index) | ||
{ | ||
switch (index) {} | ||
return std::to_string(index); | ||
} | ||
|
||
template <typename FF_> class avm_conversionImpl { | ||
public: | ||
using FF = FF_; | ||
|
||
static constexpr std::array<size_t, 1> SUBRELATION_PARTIAL_LENGTHS{ | ||
3, | ||
}; | ||
|
||
template <typename ContainerOverSubrelations, typename AllEntities> | ||
void static accumulate(ContainerOverSubrelations& evals, | ||
const AllEntities& new_term, | ||
[[maybe_unused]] const RelationParameters<FF>&, | ||
[[maybe_unused]] const FF& scaling_factor) | ||
{ | ||
|
||
// Contribution 0 | ||
{ | ||
Avm_DECLARE_VIEWS(0); | ||
|
||
auto tmp = (avm_conversion_to_radix_le_sel * (-avm_conversion_to_radix_le_sel + FF(1))); | ||
tmp *= scaling_factor; | ||
std::get<0>(evals) += tmp; | ||
} | ||
} | ||
}; | ||
|
||
template <typename FF> using avm_conversion = Relation<avm_conversionImpl<FF>>; | ||
|
||
} // namespace bb::Avm_vm |
Oops, something went wrong.