Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review marshalling core #186

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,31 @@ namespace nil {
pure_field_element<TTypeBase, FieldValueType, TOptions...>>::type;
} // namespace types

template<typename T, typename Enabled>
class is_compatible;
template<typename T, typename Enabled>
class is_compatible;

template<typename T>
class is_compatible <T, typename std::enable_if<nil::crypto3::algebra::is_curve_element<T>::value>::type> {
using default_endianness = option::big_endian;
public:
template <typename TEndian = default_endianness>
using type = typename nil::crypto3::marshalling::types::curve_element<field_type<TEndian>,
typename T::group_type>;
static const bool value = true;
static const bool fixed_size = true;
};
template<typename T>
class is_compatible <T, typename std::enable_if<nil::crypto3::algebra::is_curve_element<T>::value>::type> {
using default_endianness = option::big_endian;
public:
template <typename TEndian = default_endianness>
using type = typename nil::crypto3::marshalling::types::curve_element<field_type<TEndian>,
typename T::group_type>;
static const bool value = true;
static const bool fixed_size = true;
};

template<typename T>
class is_compatible <T, typename std::enable_if<nil::crypto3::algebra::is_field_element<T>::value>::type> {
using default_endianness = option::big_endian;
public:
template <typename TEndian = default_endianness>
using type = nil::crypto3::marshalling::types::field_element<
nil::crypto3::marshalling::field_type<TEndian>,
T>;
static const bool value = true;
static const bool fixed_size = true;
};
template<typename T>
class is_compatible <T, typename std::enable_if<nil::crypto3::algebra::is_field_element<T>::value>::type> {
using default_endianness = option::big_endian;
public:
template <typename TEndian = default_endianness>
using type = nil::crypto3::marshalling::types::field_element<
nil::crypto3::marshalling::field_type<TEndian>,
T>;
static const bool value = true;
static const bool fixed_size = true;
};

} // namespace marshalling
} // namespace crypto3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,62 +197,14 @@ namespace nil {
using base_impl_type::write_data;

private:
// because such an adapter uses pure byte reading,
// incompatible with crypto3::curve_element
static_assert(!parsed_options_type::has_fixed_length_limit,
"nil::crypto3::marshalling::option::fixed_length option is not applicable to "
"crypto3::curve_element type");

// because such an adapter uses pure byte reading,
// incompatible with crypto3::curve_element
static_assert(!parsed_options_type::has_fixed_bit_length_limit,
"nil::crypto3::marshalling::option::fixed_bit_length option is not applicable to "
"crypto3::curve_element type");

static_assert(!parsed_options_type::has_scaling_ratio,
"nil::crypto3::marshalling::option::scaling_ratio option is not applicable to "
"crypto3::curve_element type");

static_assert(
!parsed_options_type::has_sequence_elem_length_forcing,
"nil::crypto3::marshalling::option::SequenceElemLengthForcingEnabled option is not applicable to "
"crypto3::curve_element type");
static_assert(!parsed_options_type::has_sequence_size_forcing,
"nil::crypto3::marshalling::option::SequenceSizeForcingEnabled option is not applicable to "
"crypto3::curve_element type");
static_assert(!parsed_options_type::has_sequence_length_forcing,
"nil::crypto3::marshalling::option::SequenceLengthForcingEnabled option is not applicable to "
"crypto3::curve_element type");
static_assert(!parsed_options_type::has_sequence_fixed_size,
"nil::crypto3::marshalling::option::sequence_fixed_size option is not applicable to "
"crypto3::curve_element type");
static_assert(
!parsed_options_type::has_sequence_fixed_size_use_fixed_size_storage,
"nil::crypto3::marshalling::option::SequenceFixedSizeUseFixedSizeStorage option is not applicable to "
"crypto3::curve_element type");
static_assert(!parsed_options_type::has_sequence_size_field_prefix,
"nil::crypto3::marshalling::option::sequence_size_field_prefix option is not applicable to "
"crypto3::curve_element type");
static_assert(
!parsed_options_type::has_sequence_ser_length_field_prefix,
"nil::crypto3::marshalling::option::sequence_ser_length_field_prefix option is not applicable to "
"crypto3::curve_element type");
static_assert(
!parsed_options_type::has_sequence_elem_ser_length_field_prefix,
"nil::crypto3::marshalling::option::sequence_elem_ser_length_field_prefix option is not applicable to "
"crypto3::curve_element type");
static_assert(
!parsed_options_type::has_sequence_elem_fixed_ser_length_field_prefix,
"nil::crypto3::marshalling::option::SequenceElemSerLengthFixedFieldPrefix option is not applicable to "
"crypto3::curve_element type");
static_assert(
!parsed_options_type::has_sequence_trailing_field_suffix,
"nil::crypto3::marshalling::option::sequence_trailing_field_suffix option is not applicable to "
"crypto3::curve_element type");
static_assert(
!parsed_options_type::has_sequence_termination_field_suffix,
"nil::crypto3::marshalling::option::sequence_termination_field_suffix option is not applicable to "
"crypto3::curve_element type");
static_assert(!parsed_options_type::has_fixed_size_storage,
"nil::crypto3::marshalling::option::fixed_size_storage option is not applicable to "
"crypto3::curve_element type");
Expand All @@ -262,10 +214,6 @@ namespace nil {
static_assert(!parsed_options_type::has_orig_data_view,
"nil::crypto3::marshalling::option::orig_data_view option is not applicable to "
"crypto3::curve_element type");
static_assert(
!parsed_options_type::has_versions_range,
"nil::crypto3::marshalling::option::exists_between_versions (or similar) option is not applicable to "
"crypto3::curve_element type");
};

/// @brief Equality comparison operator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@
#ifndef CRYPTO3_MARSHALLING_FIELD_ELEMENT_HPP
#define CRYPTO3_MARSHALLING_FIELD_ELEMENT_HPP

#include <ratio>
#include <limits>
#include <type_traits>

#include <nil/marshalling/status_type.hpp>
#include <nil/marshalling/options.hpp>
#include <nil/marshalling/types/integral.hpp>
#include <nil/marshalling/types/array_list.hpp>
#include <nil/marshalling/types/tag.hpp>
#include <nil/marshalling/types/detail/adapt_basic_field.hpp>
Expand Down Expand Up @@ -268,75 +265,9 @@ namespace nil {
using base_impl_type::write_data;

private:
// because such an adapter uses pure byte reading,
// incompatible with crypto3::field_element
static_assert(!parsed_options_type::has_fixed_length_limit,
"nil::crypto3::marshalling::option::fixed_length option is not applicable to "
"crypto3::field_element type");

// because such an adapter uses pure byte reading,
// incompatible with crypto3::field_element
static_assert(!parsed_options_type::has_fixed_bit_length_limit,
"nil::crypto3::marshalling::option::fixed_bit_length option is not applicable to "
"crypto3::field_element type");

static_assert(!parsed_options_type::has_scaling_ratio,
"nil::crypto3::marshalling::option::scaling_ratio option is not applicable to "
"crypto3::field_element type");

static_assert(
!parsed_options_type::has_sequence_elem_length_forcing,
"nil::crypto3::marshalling::option::SequenceElemLengthForcingEnabled option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_sequence_size_forcing,
"nil::crypto3::marshalling::option::SequenceSizeForcingEnabled option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_sequence_length_forcing,
"nil::crypto3::marshalling::option::SequenceLengthForcingEnabled option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_sequence_fixed_size,
"nil::crypto3::marshalling::option::sequence_fixed_size option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_fixed_size_use_fixed_size_storage,
"nil::crypto3::marshalling::option::SequenceFixedSizeUseFixedSizeStorage option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_sequence_size_field_prefix,
"nil::crypto3::marshalling::option::sequence_size_field_prefix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_ser_length_field_prefix,
"nil::crypto3::marshalling::option::sequence_ser_length_field_prefix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_elem_ser_length_field_prefix,
"nil::crypto3::marshalling::option::sequence_elem_ser_length_field_prefix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_elem_fixed_ser_length_field_prefix,
"nil::crypto3::marshalling::option::SequenceElemSerLengthFixedFieldPrefix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_trailing_field_suffix,
"nil::crypto3::marshalling::option::sequence_trailing_field_suffix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_termination_field_suffix,
"nil::crypto3::marshalling::option::sequence_termination_field_suffix option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_fixed_size_storage,
"nil::crypto3::marshalling::option::fixed_size_storage option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_custom_storage_type,
"nil::crypto3::marshalling::option::custom_storage_type option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_orig_data_view,
"nil::crypto3::marshalling::option::orig_data_view option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_versions_range,
"nil::crypto3::marshalling::option::exists_between_versions (or similar) option is not applicable to "
"crypto3::field_element type");
};

template<typename TTypeBase,
Expand Down Expand Up @@ -520,75 +451,9 @@ namespace nil {
using base_impl_type::write_data;

private:
// because such an adapter uses pure byte reading,
// incompatible with crypto3::field_element
static_assert(!parsed_options_type::has_fixed_length_limit,
"nil::crypto3::marshalling::option::fixed_length option is not applicable to "
"crypto3::field_element type");

// because such an adapter uses pure byte reading,
// incompatible with crypto3::field_element
static_assert(!parsed_options_type::has_fixed_bit_length_limit,
"nil::crypto3::marshalling::option::fixed_bit_length option is not applicable to "
"crypto3::field_element type");

static_assert(!parsed_options_type::has_scaling_ratio,
"nil::crypto3::marshalling::option::scaling_ratio option is not applicable to "
"crypto3::field_element type");

static_assert(
!parsed_options_type::has_sequence_elem_length_forcing,
"nil::crypto3::marshalling::option::SequenceElemLengthForcingEnabled option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_sequence_size_forcing,
"nil::crypto3::marshalling::option::SequenceSizeForcingEnabled option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_sequence_length_forcing,
"nil::crypto3::marshalling::option::SequenceLengthForcingEnabled option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_sequence_fixed_size,
"nil::crypto3::marshalling::option::sequence_fixed_size option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_fixed_size_use_fixed_size_storage,
"nil::crypto3::marshalling::option::SequenceFixedSizeUseFixedSizeStorage option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_sequence_size_field_prefix,
"nil::crypto3::marshalling::option::sequence_size_field_prefix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_ser_length_field_prefix,
"nil::crypto3::marshalling::option::sequence_ser_length_field_prefix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_elem_ser_length_field_prefix,
"nil::crypto3::marshalling::option::sequence_elem_ser_length_field_prefix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_elem_fixed_ser_length_field_prefix,
"nil::crypto3::marshalling::option::SequenceElemSerLengthFixedFieldPrefix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_trailing_field_suffix,
"nil::crypto3::marshalling::option::sequence_trailing_field_suffix option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_sequence_termination_field_suffix,
"nil::crypto3::marshalling::option::sequence_termination_field_suffix option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_fixed_size_storage,
"nil::crypto3::marshalling::option::fixed_size_storage option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_custom_storage_type,
"nil::crypto3::marshalling::option::custom_storage_type option is not applicable to "
"crypto3::field_element type");
static_assert(!parsed_options_type::has_orig_data_view,
"nil::crypto3::marshalling::option::orig_data_view option is not applicable to "
"crypto3::field_element type");
static_assert(
!parsed_options_type::has_versions_range,
"nil::crypto3::marshalling::option::exists_between_versions (or similar) option is not applicable to "
"crypto3::field_element type");
};

template<typename TTypeBase,
Expand Down
Loading
Loading