Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/evmone_precompiles/ecc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ ProjPoint<Curve> add(const ProjPoint<Curve>& p, const AffinePoint<Curve>& q) noe
}

template <typename Curve>
ProjPoint<Curve> dbl(const ProjPoint<Curve>& p) noexcept
constexpr ProjPoint<Curve> dbl(const ProjPoint<Curve>& p) noexcept
{
const auto& [x1, y1, z1] = p;

Expand Down
27 changes: 0 additions & 27 deletions lib/evmone_precompiles/pairing/bn254/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,33 +192,6 @@ constexpr ecc::ProjPoint<E2> add(
return {X3, Y3, Z3};
}

/// Computes `Q + Q` in Jacobian coordinates.
constexpr ecc::ProjPoint<E2> dbl(const ecc::ProjPoint<E2>& Q) noexcept
{
const auto& x = Q.x;
const auto& y = Q.y;
const auto& z = Q.z;

const auto y_squared = y * y;
const auto x_squared = x * x;
const auto z_squared = z * z;
const auto y_4 = y_squared * y_squared;
const auto _4y_4 = y_4 + y_4 + y_4 + y_4;

const auto R = y_squared + y_squared;
const auto A = (x + R);
const auto S = A * A - x_squared - _4y_4; // 2xR = (x+R)^2 - x^2 - R^2
const auto M = x_squared + x_squared + x_squared;

const auto N = y + z;

const auto Xp = M * M - (S + S);
const auto Yp = M * (S - Xp) - (_4y_4 + _4y_4);
const auto Zp = N * N - y_squared - z_squared; // 2yz = (y+z)^2 - y^2 - z^2

return {Xp, Yp, Zp};
}

/// Computes `N` doubles of the point `a` in Jacobian coordinates.
template <int N>
constexpr ecc::ProjPoint<E2> n_dbl(const ecc::ProjPoint<E2>& a) noexcept
Expand Down