Skip to content

Commit

Permalink
Divisions removed #148
Browse files Browse the repository at this point in the history
  • Loading branch information
vo-nil committed May 22, 2024
1 parent 3288e07 commit fdd731b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/nil/crypto3/hash/detail/h2c/h2c_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ namespace nil {
y_num += field_value_type(k_y_num[i]) * xi_powers[i];
}

return group_value_type(x_num / x_den, ci.Y * y_num / y_den, field_value_type::one());
return group_value_type(x_num * x_den.inversed(), ci.Y * y_num * y_den.inversed(), field_value_type::one());
}
};

Expand Down Expand Up @@ -265,7 +265,7 @@ namespace nil {
y_num += field_value_type(k_y_num[i][0], k_y_num[i][1]) * xi_powers[i];
}

return group_value_type(x_num / x_den, ci.Y * y_num / y_den, field_value_type::one());
return group_value_type(x_num * x_den.inversed(), ci.Y * y_num * y_den.inversed(), field_value_type::one());
}
};

Expand All @@ -288,9 +288,9 @@ namespace nil {
static const field_value_type one = field_value_type::one();

field_value_type tv1 = (suite_type::Z.pow(2u) * u.pow(4u) + suite_type::Z * u.pow(2u)).inversed();
field_value_type x1 = (-suite_type::Bi / suite_type::Ai) * (one + tv1);
field_value_type x1 = (-suite_type::Bi * suite_type::Ai.inversed()) * (one + tv1);
if (tv1.is_zero()) {
x1 = suite_type::Bi / (suite_type::Z * suite_type::Ai);
x1 = suite_type::Bi * (suite_type::Z * suite_type::Ai).inversed();
}
field_value_type gx1 = x1.pow(3u) + suite_type::Ai * x1 + suite_type::Bi;
field_value_type x2 = suite_type::Z * u.pow(2u) * x1;
Expand Down

0 comments on commit fdd731b

Please sign in to comment.