|
| 1 | +#define BOOST_TEST_MODULE blueprint_algebra_fields_plonk_non_native_non_native_policy_test |
| 2 | + |
| 3 | +#include <iostream> |
| 4 | + |
| 5 | +#include <boost/test/unit_test.hpp> |
| 6 | + |
| 7 | +#include <nil/blueprint/basic_non_native_policy.hpp> |
| 8 | +#include <../test/algebra/fields/plonk/non_native/glue_non_native.hpp> |
| 9 | + |
| 10 | + |
| 11 | +using namespace nil; |
| 12 | + |
| 13 | +template<typename NativeFieldType, typename NonNativeFieldType> |
| 14 | +void test_chopping( |
| 15 | + const typename NonNativeFieldType::value_type& non_native_field_el |
| 16 | +) { |
| 17 | + using non_native_policy_type = |
| 18 | + blueprint::detail::basic_non_native_policy_field_type< |
| 19 | + NativeFieldType, |
| 20 | + NonNativeFieldType |
| 21 | + >; |
| 22 | + using chunked_non_native_type = typename non_native_policy_type::chopped_value_type; |
| 23 | + |
| 24 | + auto chopping_result = non_native_policy_type::chop_non_native(non_native_field_el); |
| 25 | + std::cout << std::hex; |
| 26 | + |
| 27 | + for (std::size_t i = 0; i < 4; i++) { |
| 28 | + std::cout << chopping_result[i].data << " "; |
| 29 | + } |
| 30 | + |
| 31 | + assert( |
| 32 | + (glue_non_native< |
| 33 | + NativeFieldType, |
| 34 | + NonNativeFieldType |
| 35 | + >(chopping_result)) == non_native_field_el |
| 36 | + ); |
| 37 | +} |
| 38 | + |
| 39 | +BOOST_AUTO_TEST_SUITE(blueprint_non_native_policy_test_suite) |
| 40 | + |
| 41 | +BOOST_AUTO_TEST_CASE(blueprint_non_native_policy_25519) { |
| 42 | + using non_native_field_type = typename crypto3::algebra::curves::ed25519::base_field_type; |
| 43 | + using native_field_type = crypto3::algebra::curves::pallas::base_field_type; |
| 44 | + test_chopping<native_field_type, non_native_field_type>( |
| 45 | + 0x0 |
| 46 | + ); |
| 47 | + test_chopping<native_field_type, non_native_field_type>( |
| 48 | + 0x274dbce8d15179969bc0d49fa725bddf9de555e0ba6a693c6adb52fc9ee7a82c_cppui252 |
| 49 | + ); |
| 50 | + test_chopping<native_field_type, non_native_field_type>( |
| 51 | + 0x5ce98c61b05f47fe2eae9a542bd99f6b2e78246231640b54595febfd51eb853_cppui252 |
| 52 | + ); |
| 53 | + test_chopping<native_field_type, non_native_field_type>( |
| 54 | + 0x2ad46cbfb78773b6254adc1d80c6efa02f3bf948c37e5a2222136421d7bec942_cppui252 |
| 55 | + ); |
| 56 | + test_chopping<native_field_type, non_native_field_type>( |
| 57 | + 0x14e9693f16d75f7065ce51e1f46ae6c60841ca1e0cf264eda26398e36ca2ed69_cppui252 |
| 58 | + ); |
| 59 | + test_chopping<native_field_type, non_native_field_type>( |
| 60 | + non_native_field_type::modulus - 1 |
| 61 | + ); |
| 62 | +} |
| 63 | + |
| 64 | +BOOST_AUTO_TEST_SUITE_END() |
0 commit comments