Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [[alloc] init] C++ Cryptography Suite
# [[alloc] init] C++ Cryptography Suite

[![Twitter](https://img.shields.io/twitter/follow/alloc_init_)](https://twitter.com/alloc_init_)
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=flat-square&logo=telegram&logoColor=dark)](https://t.me/alloc_init)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,20 @@ namespace nil {
return res;
}

template<typename CurveElementType>
std::enable_if_t<is_curve_element<CurveElementType>::value, CurveElementType> constexpr
operator*(const CurveElementType &point, const std::size_t &multiplier) {
template<CurveElement CurveElementType>
constexpr CurveElementType operator*(const CurveElementType &point, const std::size_t &multiplier) {
typename CurveElementType::params_type::scalar_field_type::value_type scalar(multiplier);
return point * scalar;
}

template<typename CurveElementType>
std::enable_if_t<is_curve_element<CurveElementType>::value, CurveElementType> constexpr
operator*(const std::size_t &multiplier, const CurveElementType &point) {
template<CurveElement CurveElementType>
constexpr CurveElementType operator*(const std::size_t &multiplier, const CurveElementType &point) {
typename CurveElementType::params_type::scalar_field_type::value_type scalar(multiplier);
return point * scalar;
}

template<typename CurveElementType>
std::enable_if_t<is_curve_element<CurveElementType>::value, bool>
subgroup_check(CurveElementType point) {
template<CurveElement CurveElementType>
bool subgroup_check(CurveElementType point) {
auto scalar_modulus = CurveElementType::group_type::curve_type::scalar_field_type::modulus;
scalar_mul_inplace(point, scalar_modulus);
return point.is_zero();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ namespace nil {
namespace algebra {
namespace curves {
namespace detail {
// TODO: temporary implementation due to absence of GroupValueType type_trait
// Should be implemented as class method
template<typename GroupValueType, typename = typename std::enable_if<is_curve_group<
typename GroupValueType::group_type>::value>::type>
template<CurveElement GroupValueType>
requires CurveGroup<typename GroupValueType::group_type>
bool subgroup_check(const GroupValueType &p) {
return (p * GroupValueType::group_type::curve_type::q).is_zero();
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ namespace nil::crypto3::algebra::fields::detail {

struct FieldArchetype {
using value_type = FieldValueArchetype;
struct extension_policy { };
using underlying_field_type = FieldArchetype;
constexpr static std::size_t value_bits = 10;

struct integral_type { };
Expand All @@ -126,7 +128,7 @@ namespace nil::crypto3::algebra::fields::detail {
struct BinomialFieldExtensionParamsArchetype {
constexpr static std::size_t dimension = 3;

struct field_type { };
using field_type = FieldArchetype;

using base_field_type = FieldArchetype;
constexpr static base_field_type::value_type non_residue {};
Expand All @@ -147,9 +149,9 @@ namespace nil::crypto3::algebra::fields::detail {
using underlying_type = typename Params::base_field_type::value_type;

constexpr static std::size_t dimension = Params::dimension;
using data_type = std::array<underlying_type, dimension>;

private:
using data_type = std::array<underlying_type, dimension>;
data_type data;

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace nil {
typedef params<base_field_type> policy_type;

public:
using field_type = fields::fp3<base_field_type>;
typedef typename policy_type::integral_type integral_type;
typedef typename policy_type::extended_integral_type extended_integral_type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ namespace nil {
namespace crypto3 {
namespace algebra {
namespace fields {
template<typename BaseField>
class fp6_2over3;

namespace detail {

template<typename BaseField>
Expand All @@ -49,6 +52,7 @@ namespace nil {
typedef params<base_field_type> policy_type;

public:
using field_type = fields::fp6_2over3<base_field_type>;
typedef typename policy_type::integral_type integral_type;

constexpr static const integral_type modulus = policy_type::modulus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ namespace nil {
namespace crypto3 {
namespace algebra {
namespace fields {
template<typename BaseField>
class fp4;

namespace detail {

template<typename BaseField>
Expand All @@ -49,6 +52,7 @@ namespace nil {
typedef params<base_field_type> policy_type;

public:
using field_type = fields::fp4<base_field_type>;
typedef typename policy_type::integral_type integral_type;

constexpr static const integral_type modulus = policy_type::modulus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ namespace nil {
namespace crypto3 {
namespace algebra {
namespace fields {
template<typename BaseField>
class fp6_2over3;

namespace detail {

template<typename BaseField>
Expand All @@ -49,6 +52,7 @@ namespace nil {
typedef params<base_field_type> policy_type;

public:
using field_type = fields::fp6_2over3<base_field_type>;
typedef typename policy_type::integral_type integral_type;

constexpr static const integral_type modulus = policy_type::modulus;
Expand Down
8 changes: 7 additions & 1 deletion libs/algebra/include/nil/crypto3/algebra/fields/fpn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ namespace nil::crypto3::algebra::fields {
class fpn {
public:
using base_field_type = Params::base_field_type;
using policy_type = base_field_type;
using extension_policy = Params;
using underlying_field_type = base_field_type;

constexpr static const std::size_t modulus_bits = base_field_type::modulus_bits;
using integral_type = typename base_field_type::integral_type;
Expand All @@ -45,9 +48,12 @@ namespace nil::crypto3::algebra::fields {

using value_type = typename detail::element_fpn<Params>;

constexpr static const std::size_t arity = Params::dimension;
constexpr static const std::size_t extension_degree = Params::dimension;
constexpr static const std::size_t arity = extension_degree * underlying_field_type::arity;
constexpr static const std::size_t value_bits = arity * modulus_bits;
};

static_assert(ExtendedField<fpn<detail::BinomialFieldExtensionParamsArchetype>>);
} // namespace nil::crypto3::algebra::fields

#endif // CRYPTO3_ALGEBRA_FIELDS_FPN_EXTENSION_HPP
Loading
Loading