Skip to content

Commit

Permalink
PLONK fixed_base_scalar_mul component updated. #16
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaskov committed Dec 27, 2021
1 parent ecfa36f commit 52e6276
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace nil {
typename blueprint_type::value_type x_2,
typename blueprint_type::value_type x_3,
typename blueprint_type::value_type x_4,
std::array<typename CurveType::base_field_type::value_type, 7> u) {
std::array<typename CurveType::base_field_type::value_type, 8> u) {

this->bp.add_gate(row_index,
x_3 * (-u[0] * x_2 * x_1 + u[0] * x_1 + u[0] * x_2
Expand All @@ -118,7 +118,7 @@ namespace nil {
typename blueprint_type::value_type x_2,
typename blueprint_type::value_type x_3,
typename blueprint_type::value_type x_4,
std::array<typename CurveType::base_field_type::value_type, 7> v) {
std::array<typename CurveType::base_field_type::value_type, 8> v) {

this->bp.add_gate(row_index,
x_3 * (-v[0] * x_2 * x_1 + v[0] * x_1 + v[0] * x_2
Expand Down Expand Up @@ -173,8 +173,9 @@ namespace nil {

this->bp.add_gate(j + z, w[0][cur] - (w[1][cur]*4 + w[2][cur]*2 + w[3][cur] + w[0][m1] * 8));

std::array<typename CurveType::base_field_type::value_type, 7> u;
std::array<typename CurveType::base_field_type::value_type, 7> v;
std::array<typename CurveType::base_field_type::value_type, 8> u;
std::array<typename CurveType::base_field_type::value_type, 8> v;

for (std::size_t i=0; i<7; i++){
typename CurveType::template g1_type<>::value_type omega = get_omega(3*z/5, i);
u[i] = omega.X;
Expand All @@ -192,8 +193,8 @@ namespace nil {

this->bp.add_gate(j + z, w[0][cur] - (w[1][cur]*4 + w[2][cur]*2 + w[3][m1] + w[0][m2] * 8));

std::array<typename CurveType::base_field_type::value_type, 7> u;
std::array<typename CurveType::base_field_type::value_type, 7> v;
std::array<typename CurveType::base_field_type::value_type, 8> u;
std::array<typename CurveType::base_field_type::value_type, 8> v;
for (std::size_t i=0; i<7; i++){
typename CurveType::template g1_type<>::value_type omega = get_omega(3*(z-2)/5, i);
u[i] = omega.X;
Expand All @@ -209,8 +210,8 @@ namespace nil {
// j+z, z=3 mod 5
for (std::size_t z = 3; z <= 84; z+=5){

std::array<typename CurveType::base_field_type::value_type, 7> u;
std::array<typename CurveType::base_field_type::value_type, 7> v;
std::array<typename CurveType::base_field_type::value_type, 8> u;
std::array<typename CurveType::base_field_type::value_type, 8> v;
for (std::size_t i=0; i<7; i++){
typename CurveType::template g1_type<>::value_type omega = get_omega(3*(z-3)/5, i);
u[i] = omega.X;
Expand Down
9 changes: 6 additions & 3 deletions include/nil/crypto3/zk/components/blueprint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,16 @@ namespace nil {
}

typename TBlueprintField::value_type &assignment(const value_type &var, std::size_t row_index) {
assert(var.wire_index <= assignments.size());
assert(var.wire_index < assignments.size());
if (row_index >= assignments[var.wire_index].size()){
assignments[var.wire_index].resize(row_index + 1);
}
assert(row_index < assignments[var.wire_index].size());
return (assignments[row_index][var.wire_index]);
return (assignments[var.wire_index][row_index]);
}

typename TBlueprintField::value_type assignment(const value_type &var, std::size_t row_index) const {
assert(var.wire_index <= assignments.size());
assert(var.wire_index < assignments.size());
assert(row_index < assignments[var.wire_index].size());
return (assignments[var.index][row_index]);
}
Expand Down

0 comments on commit 52e6276

Please sign in to comment.