-
Notifications
You must be signed in to change notification settings - Fork 13
/
base_field.hpp
86 lines (72 loc) · 3.95 KB
/
base_field.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//---------------------------------------------------------------------------//
// Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Ilias Khairullin <ilias@nil.foundation>
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//---------------------------------------------------------------------------//
#ifndef CRYPTO3_ALGEBRA_FIELDS_PALLAS_BASE_FIELD_HPP
#define CRYPTO3_ALGEBRA_FIELDS_PALLAS_BASE_FIELD_HPP
#include <nil/crypto3/algebra/fields/detail/element/fp.hpp>
#include <nil/crypto3/algebra/fields/params.hpp>
#include <nil/crypto3/algebra/fields/field.hpp>
namespace nil {
namespace crypto3 {
namespace algebra {
namespace fields {
/**
* @brief A struct representing a pallas curve.
*/
struct pallas_base_field : public field<255> {
typedef field<255> policy_type;
constexpr static const std::size_t modulus_bits = policy_type::modulus_bits;
constexpr static const std::size_t number_bits = policy_type::number_bits;
constexpr static const std::size_t value_bits = modulus_bits;
constexpr static const std::size_t arity = 1;
typedef typename policy_type::integral_type integral_type;
typedef typename policy_type::extended_integral_type extended_integral_type;
#ifdef __ZKLLVM__
typedef __zkllvm_field_pallas_base value_type;
#else
constexpr static const integral_type modulus =
0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001_cppui_modular255;
typedef typename policy_type::modular_backend modular_backend;
constexpr static const modular_params_type modulus_params = modulus.backend();
typedef boost::multiprecision::number<
boost::multiprecision::backends::modular_adaptor<
modular_backend,
boost::multiprecision::backends::modular_params_ct<modular_backend, modulus_params>>>
modular_type;
typedef typename detail::element_fp<params<pallas_base_field>> value_type;
#endif
};
constexpr typename std::size_t const pallas_base_field::modulus_bits;
constexpr typename std::size_t const pallas_base_field::number_bits;
constexpr typename std::size_t const pallas_base_field::value_bits;
#ifdef __ZKLLVM__
#else
constexpr typename pallas_base_field::integral_type const pallas_base_field::modulus;
#endif
using pallas_fq = pallas_base_field;
} // namespace fields
} // namespace algebra
} // namespace crypto3
} // namespace nil
#endif // CRYPTO3_ALGEBRA_FIELDS_PALLAS_BASE_FIELD_HPP