Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ namespace nil {
var_ec_point T;
var k;

input_type(var_ec_point _T, var _k) : T(_T), k(_k) {};

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 9) {
throw std::out_of_range("Vector size does not match input size");
}
T.x[0] = input_vect[0];
T.x[1] = input_vect[1];
T.x[2] = input_vect[2];
T.x[3] = input_vect[3];
T.y[0] = input_vect[4];
T.y[1] = input_vect[5];
T.y[2] = input_vect[6];
T.y[3] = input_vect[7];
k = input_vect[8];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {T.x[0], T.x[1], T.x[2], T.x[3],
T.y[0], T.y[1], T.y[2], T.y[3],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,31 @@ namespace nil {
var_ec_point T;
var_ec_point R;

input_type (var_ec_point _T, var_ec_point _R) : T(_T), R(_R) {};

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 16) {
throw std::out_of_range("Vector size does not match input size");
}

T.x[0] = input_vect[0];
T.x[1] = input_vect[1];
T.x[2] = input_vect[2];
T.x[3] = input_vect[3];
T.y[0] = input_vect[4];
T.y[1] = input_vect[5];
T.y[2] = input_vect[6];
T.y[3] = input_vect[7];
R.x[0] = input_vect[8];
R.x[1] = input_vect[9];
R.x[2] = input_vect[10];
R.x[3] = input_vect[11];
R.y[0] = input_vect[12];
R.y[1] = input_vect[13];
R.y[2] = input_vect[14];
R.y[3] = input_vect[15];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {T.x[0], T.x[1], T.x[2], T.x[3], T.y[0], T.y[1], T.y[2], T.y[3],
R.x[0], R.x[1], R.x[2], R.x[3], R.y[0], R.y[1], R.y[2], R.y[3]};
Expand Down Expand Up @@ -315,37 +340,37 @@ namespace nil {

typename multiplication_component::result_type t0 = generate_assignments(
multiplication_instance, assignment,
typename multiplication_component::input_type({T_x, R_y}), row);
typename multiplication_component::input_type(T_x, R_y), row);
row += multiplication_instance.rows_amount;

typename multiplication_component::result_type t1 = generate_assignments(
multiplication_instance, assignment,
typename multiplication_component::input_type({T_y, R_x}), row);
typename multiplication_component::input_type(T_y, R_x), row);
row += multiplication_instance.rows_amount;

typename multiplication_component::result_type t2 = generate_assignments(
multiplication_instance, assignment,
typename multiplication_component::input_type({T_x, R_x}), row);
typename multiplication_component::input_type(T_x, R_x), row);
row += multiplication_instance.rows_amount;

typename multiplication_component::result_type t3 = generate_assignments(
multiplication_instance, assignment,
typename multiplication_component::input_type({T_y, R_y}), row);
typename multiplication_component::input_type(T_y, R_y), row);
row += multiplication_instance.rows_amount;

generate_assignments( // z0
addition_instance, assignment,
typename addition_component::input_type({t0.output, t1.output}), row);
typename addition_component::input_type(t0.output, t1.output), row);
row += addition_instance.rows_amount;

generate_assignments( // z1
addition_instance, assignment,
typename addition_component::input_type({t2.output, t3.output}), row);
typename addition_component::input_type(t2.output, t3.output), row);
row += addition_instance.rows_amount;

typename multiplication_component::result_type z2 = generate_assignments(
multiplication_instance, assignment,
typename multiplication_component::input_type({t0.output, t1.output}), row);
typename multiplication_component::input_type(t0.output, t1.output), row);
row += multiplication_instance.rows_amount;

std::array<var, 4> d_var_array = {var(component.C(0), row + 4, false, var::column_type::constant),
Expand All @@ -355,27 +380,27 @@ namespace nil {

typename multiplication_component::result_type k0 = generate_assignments(
multiplication_instance, assignment,
typename multiplication_component::input_type({d_var_array, z2.output}), row);
typename multiplication_component::input_type(d_var_array, z2.output), row);
row += multiplication_instance.rows_amount;

typename multiplication_component::result_type k1 = generate_assignments(
multiplication_instance, assignment,
typename multiplication_component::input_type({P_x, k0.output}), row);
typename multiplication_component::input_type(P_x, k0.output), row);
row += multiplication_instance.rows_amount;

typename multiplication_component::result_type k2 = generate_assignments(
multiplication_instance, assignment,
typename multiplication_component::input_type({P_y, k0.output}), row);
typename multiplication_component::input_type(P_y, k0.output), row);
row += multiplication_instance.rows_amount;

generate_assignments( // k3
addition_instance, assignment,
typename addition_component::input_type({P_x, k1.output}), row);
typename addition_component::input_type(P_x, k1.output), row);
row += addition_instance.rows_amount;

generate_assignments( // k4
subtraction_instance, assignment,
typename subtraction_component::input_type({P_y, k2.output}), row);
typename subtraction_component::input_type(P_y, k2.output), row);
row += subtraction_instance.rows_amount;

return typename plonk_ed25519_complete_addition<BlueprintFieldType, CurveType>::result_type(component, start_row_index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ namespace nil {
struct input_type {
var k;

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 1) {
throw std::out_of_range("Vector size does not match input size");
}

k = input_vect[0];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {k};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace nil {
return manifest;
}

manifest_type get_manifest(std::size_t bits_amount, bit_composition_mode mode) {
static manifest_type get_manifest(std::size_t bits_amount, bit_composition_mode mode) {
manifest_type manifest = manifest_type(
std::shared_ptr<manifest_param>(new manifest_single_value_param(9)),
false
Expand Down Expand Up @@ -134,6 +134,23 @@ namespace nil {
var_ec_point T;
var k;

input_type(var_ec_point _T, var _k) : T(_T), k(_k) {};

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 9) {
throw std::out_of_range("Vector size does not match input size");
}
T.x[0] = input_vect[0];
T.x[1] = input_vect[1];
T.x[2] = input_vect[2];
T.x[3] = input_vect[3];
T.y[0] = input_vect[4];
T.y[1] = input_vect[5];
T.y[2] = input_vect[6];
T.y[3] = input_vect[7];
k = input_vect[8];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {T.x[0], T.x[1], T.x[2], T.x[3], T.y[0], T.y[1], T.y[2], T.y[3], k};
}
Expand Down Expand Up @@ -396,4 +413,4 @@ namespace nil {
} // namespace blueprint
} // namespace nil

#endif // CRYPTO3_BLUEPRINT_COMPONENTS_VARIABLE_BASE_MULTIPLICATION_EDWARD25519_HPP
#endif // CRYPTO3_BLUEPRINT_COMPONENTS_VARIABLE_BASE_MULTIPLICATION_EDWARD25519_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ namespace nil {
struct input_type {
var scalar;

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 1) {
throw std::out_of_range("Vector size does not match input size");
}
scalar = input_vect[0];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {scalar};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ namespace nil {
var_ec_point P;
var_ec_point Q;

input_type(var_ec_point _P, var_ec_point _Q): P(_P), Q(_Q) {};

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 4) {
throw std::out_of_range("Vector size does not match input size");
}
P.x = input_vect[0];
P.y = input_vect[1];
Q.x = input_vect[2];
Q.y = input_vect[3];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {P.x, P.y, Q.x, Q.y};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ namespace nil {
input_type(var_ec_point _T, var _b): T(_T), b(_b) {};
input_type(var_ec_point _T, var _b, var _b_high): T(_T), b(_b), b_high(_b_high) {};

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 3 && input_vect.size() != 4) {
throw std::out_of_range("Vector size does not match input size");
}
if (input_vect.size() == 3) {
T.x = input_vect[0];
T.y = input_vect[1];
b = input_vect[2];
}
if (input_vect.size() == 4) {
T.x = input_vect[0];
T.y = input_vect[1];
b = input_vect[2];
b_high = input_vect[3];
}
}

std::vector<std::reference_wrapper<var>> all_vars() {
if (std::is_same<CurveType,nil::crypto3::algebra::curves::pallas>::value) {
return {T.x, T.y, b, b_high};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ namespace nil {
var x = var(0, 0, false);
var y = var(0, 0, false);

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 2) {
throw std::out_of_range("Vector size does not match input size");
}
x = input_vect[0];
y = input_vect[1];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {x, y};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ namespace nil {
struct input_type {
var input;

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 1) {
throw std::out_of_range("Vector size does not match input size");
}
input = input_vect[0];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {input};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ namespace nil {
var x = var(0, 0, false);
var y = var(0, 0, false);

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 2) {
throw std::out_of_range("Vector size does not match input size");
}
x = input_vect[0];
y = input_vect[1];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {x, y};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace nil {
constexpr static const std::size_t gates_amount = 1;
const std::size_t rows_amount = get_rows_amount(this->witness_amount());
const std::size_t empty_rows_amount = get_empty_rows_amount();
const std::string component_name = "native field division or zero";

using var = typename component_type::var;
using manifest_type = plonk_component_manifest;
Expand All @@ -94,6 +95,14 @@ namespace nil {
var x = var(0, 0, false);
var y = var(0, 0, false);

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 2) {
throw std::out_of_range("Vector size does not match input size");
}
x = input_vect[0];
y = input_vect[1];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {x, y};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ namespace nil {
var x;
var y;

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 2) {
throw std::out_of_range("Vector size does not match input size");
}
x = input_vect[0];
y = input_vect[1];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {x, y};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ namespace nil {
var x;
var y;

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 2) {
throw std::out_of_range("Vector size does not match input size");
}
x = input_vect[0];
y = input_vect[1];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {x, y};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ namespace nil {
var x = var(0, 0, false);
var y = var(0, 0, false);

input_type(var _x, var _y) : x(_x), y(_y) {};

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 2) {
throw std::out_of_range("Vector size does not match input size");
}
x = input_vect[0];
y = input_vect[1];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {x, y};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,25 @@ namespace nil {
const std::string component_name = "non-native field addition";

struct input_type {
typename non_native_policy_type::template field<operating_field_type>::non_native_var_type A;
typename non_native_policy_type::template field<operating_field_type>::non_native_var_type B;
using non_native_field = typename non_native_policy_type::template field<operating_field_type>::non_native_var_type;
non_native_field A;
non_native_field B;

input_type(non_native_field _A, non_native_field _B): A(_A), B(_B) {};

input_type(const std::vector<var>& input_vect) {
if (input_vect.size() != 8) {
throw std::out_of_range("Vector size does not match input size");
}
A[0] = input_vect[0];
A[1] = input_vect[1];
A[2] = input_vect[2];
A[3] = input_vect[3];
B[0] = input_vect[4];
B[1] = input_vect[5];
B[2] = input_vect[6];
B[3] = input_vect[7];
}

std::vector<std::reference_wrapper<var>> all_vars() {
return {A[0], A[1], A[2], A[3], B[0], B[1], B[2], B[3]};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ namespace nil {
struct input_type {
std::vector<var> bits;

input_type() {};
input_type(std::vector<var> input_vect) : bits(input_vect) {};

std::vector<std::reference_wrapper<var>> all_vars() {
std::vector<std::reference_wrapper<var>> res;
for (auto& it : bits) {
Expand Down
Loading