Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 9da6da0

Browse files
CblPOK-gitIluvmagick
authored andcommitted
add new non native policies
1 parent 897ba2f commit 9da6da0

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

include/nil/blueprint/basic_non_native_policy.hpp

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define CRYPTO3_BLUEPRINT_BASIC_NON_NATIVE_POLICY_HPP
2828

2929
#include <nil/crypto3/algebra/curves/pallas.hpp>
30+
#include <nil/crypto3/algebra/curves/vesta.hpp>
3031
#include <nil/crypto3/algebra/curves/ed25519.hpp>
3132

3233
#include <nil/crypto3/zk/snark/arithmetization/plonk/constraint_system.hpp>
@@ -164,6 +165,93 @@ namespace nil {
164165

165166
};
166167

168+
/*
169+
* Specialization for non-native bls12381 scalar field element on pallas base field
170+
*/
171+
template<>
172+
struct basic_non_native_policy_field_type<typename crypto3::algebra::curves::pallas::base_field_type,
173+
typename crypto3::algebra::fields::bls12_scalar_field<381>> {
174+
175+
constexpr static const std::uint32_t ratio = 1;
176+
177+
typedef crypto3::zk::snark::plonk_variable<typename crypto3::algebra::fields::bls12_base_field<381>::value_type>
178+
non_native_var_type;
179+
};
180+
181+
182+
/*
183+
* Specialization for non-native bls12381 scalar field element on bls12381 base field
184+
*/
185+
template<>
186+
struct basic_non_native_policy_field_type<typename crypto3::algebra::fields::bls12_base_field<381>,
187+
typename crypto3::algebra::fields::bls12_scalar_field<381>> {
188+
189+
constexpr static const std::uint32_t ratio = 1;
190+
191+
typedef crypto3::zk::snark::plonk_variable<typename crypto3::algebra::fields::bls12_base_field<381>::value_type>
192+
non_native_var_type;
193+
};
194+
195+
196+
/*
197+
* Specialization for non-native bls12-381 base field element on Pallas base field
198+
*/
199+
template<>
200+
struct basic_non_native_policy_field_type<typename crypto3::algebra::curves::pallas::base_field_type,
201+
typename crypto3::algebra::fields::bls12_base_field<381>> {
202+
constexpr static const std::uint32_t ratio = 0; // not implemented yet
203+
using var = crypto3::zk::snark::plonk_variable<typename crypto3::algebra::curves::pallas::base_field_type>;
204+
typedef std::array<var, ratio> non_native_var_type;
205+
};
206+
207+
/*
208+
* Specialization for non-native Pallas base field element on bls12-381 base field
209+
*/
210+
template<>
211+
struct basic_non_native_policy_field_type<typename crypto3::algebra::fields::bls12_base_field<381>,
212+
typename crypto3::algebra::curves::pallas::base_field_type> {
213+
214+
constexpr static const std::uint32_t ratio = 0; // not implemented yet
215+
using var = crypto3::zk::snark::plonk_variable<typename crypto3::algebra::fields::bls12_base_field<381>>;
216+
typedef std::array<var, ratio> non_native_var_type;
217+
};
218+
219+
/*
220+
* Specialization for non-native Pallas scalar field element on bls12-381 base field
221+
*/
222+
template<>
223+
struct basic_non_native_policy_field_type<typename crypto3::algebra::fields::bls12_base_field<381>,
224+
typename crypto3::algebra::curves::pallas::scalar_field_type> {
225+
226+
constexpr static const std::uint32_t ratio = 0; // not implemented yet
227+
using var = crypto3::zk::snark::plonk_variable<typename crypto3::algebra::fields::bls12_base_field<381>>;
228+
typedef std::array<var, ratio> non_native_var_type;
229+
};
230+
231+
/*
232+
* Specialization for non-native Ed25519 base field element on bls12-381 base field
233+
*/
234+
template<>
235+
struct basic_non_native_policy_field_type<typename crypto3::algebra::fields::bls12_base_field<381>,
236+
typename crypto3::algebra::curves::ed25519::base_field_type> {
237+
constexpr static const std::uint32_t ratio = 0; // not implemented yet
238+
using var = crypto3::zk::snark::plonk_variable<typename crypto3::algebra::fields::bls12_base_field<381>>;
239+
typedef std::array<var, ratio> non_native_var_type;
240+
};
241+
242+
/*
243+
* Specialization for non-native Ed25519 scalar field element on bls12-381 base field
244+
*/
245+
template<>
246+
struct basic_non_native_policy_field_type<typename crypto3::algebra::fields::bls12_base_field<381>,
247+
typename crypto3::algebra::curves::ed25519::scalar_field_type> {
248+
constexpr static const std::uint32_t ratio = 0; // not implemented yet
249+
using var = crypto3::zk::snark::plonk_variable<typename crypto3::algebra::fields::bls12_base_field<381>>;
250+
typedef std::array<var, ratio> non_native_var_type;
251+
};
252+
253+
254+
167255
/*
168256
* Native element type.
169257
*/
@@ -189,6 +277,17 @@ namespace nil {
189277
using field = typename detail::basic_non_native_policy_field_type<BlueprintFieldType, OperatingFieldType>;
190278
};
191279

280+
template<>
281+
class basic_non_native_policy<typename crypto3::algebra::fields::bls12_base_field<381>> {
282+
283+
using BlueprintFieldType = typename crypto3::algebra::fields::bls12_base_field<381>;
284+
285+
public:
286+
template<typename OperatingFieldType>
287+
using field = typename detail::basic_non_native_policy_field_type<BlueprintFieldType, OperatingFieldType>;
288+
};
289+
290+
192291

193292

194293
} // namespace blueprint

0 commit comments

Comments
 (0)