-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite tests for non native field operations #107
- Loading branch information
1 parent
2ff2d19
commit c63077b
Showing
4 changed files
with
337 additions
and
48 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
50 changes: 50 additions & 0 deletions
50
test/algebra/fields/plonk/non_native/chop_and_glue_non_native.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,50 @@ | ||
template<typename FieldType, typename NonNativeFieldType> | ||
std::array<typename FieldType::value_type, 4> chop_non_native(typename NonNativeFieldType::value_type input) { | ||
typename NonNativeFieldType::integral_type input_integral = | ||
typename NonNativeFieldType::integral_type( | ||
input.data); | ||
|
||
std::array<typename FieldType::value_type, 4> output; | ||
|
||
typename NonNativeFieldType::integral_type base = 1; | ||
typename NonNativeFieldType::integral_type mask = (base << 66) - 1; | ||
|
||
output[0] = input_integral & mask; | ||
output[1] = (input_integral >> 66) & mask; | ||
output[2] = (input_integral >> 132) & mask; | ||
output[3] = (input_integral >> 198) & mask; | ||
|
||
return output; | ||
} | ||
|
||
template<typename FieldType, typename NonNativeFieldType> | ||
typename NonNativeFieldType::value_type glue_non_native(std::array<typename FieldType::value_type, 4> input) { | ||
typename NonNativeFieldType::integral_type base = 1; | ||
typename NonNativeFieldType::integral_type chunk_size = (base << 66); | ||
|
||
std::array<typename FieldType::integral_type, 4> input_integral; | ||
|
||
for (std::size_t i = 0; i < input.size(); i++) { | ||
assert(input[i] < chunk_size); | ||
input_integral[i] = typename FieldType::integral_type(input[i].data); | ||
} | ||
|
||
typename NonNativeFieldType::integral_type output_integral | ||
= input_integral[0] + (input_integral[1] << 66) + (input_integral[2] << 132) + (input_integral[3] << 198); | ||
|
||
typename NonNativeFieldType::value_type output = typename NonNativeFieldType::value_type (output_integral); | ||
|
||
return output; | ||
} | ||
|
||
template <typename FieldType, typename NonNativeFieldType> | ||
std::vector<typename FieldType::value_type> create_public_input(std::array<typename FieldType::value_type, 4> a, std::array<typename FieldType::value_type, 4> b) { | ||
std::vector<typename FieldType::value_type> public_input; | ||
for (std::size_t i = 0; i < a.size(); i++){ | ||
public_input.push_back(a[i]); | ||
} | ||
for (std::size_t i = 0; i < b.size(); i++){ | ||
public_input.push_back(b[i]); | ||
} | ||
return public_input; | ||
} |
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.