Skip to content

Commit

Permalink
Random functions type traits usage changed #1#2
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaskov committed Nov 7, 2020
1 parent e793f0a commit fc53806
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ macro(define_algebra_example name)
endmacro()

set(EXAMPLES_NAMES
"multiexp"
"curves"
"fields"
"pairing"
Expand Down
File renamed without changes.
22 changes: 10 additions & 12 deletions include/nil/crypto3/algebra/curves/detail/scalar_mul.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ namespace nil {
}*/

template<typename GroupValueType,
typename FieldValueType,
typename = typename std::enable_if<
::nil::crypto3::detail::is_curve_group<typename GroupValueType::group_type>::value &&
!::nil::crypto3::detail::is_field<typename GroupValueType::group_type>::value &&
::nil::crypto3::detail::is_fp_field<typename FieldValueType::field_type>::value>::type>
GroupValueType operator*(const GroupValueType &left, const FieldValueType &right) {
typename FieldValueType>
typename std::enable_if<::nil::crypto3::detail::is_curve_group<typename GroupValueType::group_type>::value &&
!::nil::crypto3::detail::is_field<typename GroupValueType::group_type>::value &&
::nil::crypto3::detail::is_fp_field<typename FieldValueType::field_type>::value, GroupValueType>::type
operator*(const GroupValueType &left, const FieldValueType &right) {

// temporary added until fixed-precision modular adaptor is ready:
typedef number<backends::cpp_int_backend<>> non_fixed_precision_modulus_type;
Expand All @@ -114,12 +113,11 @@ namespace nil {
}

template<typename GroupValueType,
typename FieldValueType,
typename = typename std::enable_if<
::nil::crypto3::detail::is_curve_group<typename GroupValueType::group_type>::value &&
!::nil::crypto3::detail::is_field<typename GroupValueType::group_type>::value &&
::nil::crypto3::detail::is_fp_field<typename FieldValueType::field_type>::value>::type>
GroupValueType operator*(const FieldValueType &left, const GroupValueType &right) {
typename FieldValueType>
typename std::enable_if<::nil::crypto3::detail::is_curve_group<typename GroupValueType::group_type>::value &&
!::nil::crypto3::detail::is_field<typename GroupValueType::group_type>::value &&
::nil::crypto3::detail::is_fp_field<typename FieldValueType::field_type>::value, GroupValueType>::type
operator*(const FieldValueType &left, const GroupValueType &right) {

return right * left;
}
Expand Down
19 changes: 11 additions & 8 deletions include/nil/crypto3/algebra/random_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@
#ifndef CRYPTO3_ALGEBRA_RANDOM_ELEMENT_HPP
#define CRYPTO3_ALGEBRA_RANDOM_ELEMENT_HPP

#include <nil/crypto3/detail/type_traits.hpp>

namespace nil {
namespace crypto3 {
namespace algebra {

template<typename CurveGroupType,
typename = typename std::enable_if<
::nil::crypto3::algebra::detail::is_field<CurveGroupType>::value &&
!(::nil::crypto3::algebra::detail::is_field<CurveGroupType>::value)>::type>
> typename CurveGroupType::value_type random_element() {
template<typename CurveGroupType>
typename std::enable_if<::nil::crypto3::detail::is_curve_group<CurveGroupType>::value,
typename CurveGroupType::value_type>::type
random_element() {

return CurveGroupType::value_type::one();
};

template<typename FieldType, typename = typename std::enable_if<
::nil::crypto3::algebra::detail::is_field<FieldType>::value>::type>
> typename FieldType::value_type random_element() {
template<typename FieldType>
typename std::enable_if<::nil::crypto3::detail::is_field<FieldType>::value,
typename FieldType::value_type>::type
random_element() {
return FieldType::value_type::one();
};

Expand Down

0 comments on commit fc53806

Please sign in to comment.