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
14 changes: 7 additions & 7 deletions lib/evmone_precompiles/pairing/bn254/fields.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ struct Fq12Config
using Fq12 = ecc::ExtFieldElem<Fq12Config>;

/// Multiplies two Fq^2 field elements
constexpr Fq2 multiply(const Fq2& a, const Fq2& b)
constexpr Fq2 multiply(const Fq2& a, const Fq2& b) noexcept
{
const auto& [a0, a1] = a.coeffs;
const auto& [b0, b1] = b.coeffs;
return Fq2({a0 * b0 - a1 * b1, a1 * b0 + a0 * b1});
}

/// Squares an Fq^2 field element.
constexpr Fq2 sqr(const Fq2& a)
constexpr Fq2 sqr(const Fq2& a) noexcept
{
const auto& [a0, a1] = a.coeffs;

Expand All @@ -60,7 +60,7 @@ constexpr Fq2 sqr(const Fq2& a)
}

/// Multiplies two Fq^6 field elements
constexpr Fq6 multiply(const Fq6& a, const Fq6& b)
constexpr Fq6 multiply(const Fq6& a, const Fq6& b) noexcept
{
const auto& [a0, a1, a2] = a.coeffs;
const auto& [b0, b1, b2] = b.coeffs;
Expand All @@ -79,7 +79,7 @@ constexpr Fq6 multiply(const Fq6& a, const Fq6& b)
}

/// Multiplies two Fq^12 field elements
constexpr Fq12 multiply(const Fq12& a, const Fq12& b)
constexpr Fq12 multiply(const Fq12& a, const Fq12& b) noexcept
{
const auto& [a0, a1] = a.coeffs;
const auto& [b0, b1] = b.coeffs;
Expand All @@ -96,7 +96,7 @@ constexpr Fq12 multiply(const Fq12& a, const Fq12& b)
}

/// Inverses the Fq^2 field element
inline Fq2 inverse(const Fq2& f)
inline Fq2 inverse(const Fq2& f) noexcept
{
const auto& [a0, a1] = f.coeffs;

Expand All @@ -113,7 +113,7 @@ inline Fq2 inverse(const Fq2& f)
}

/// Inverses the Fq^6 field element
inline Fq6 inverse(const Fq6& f)
inline Fq6 inverse(const Fq6& f) noexcept
{
const auto& [a0, a1, a2] = f.coeffs;

Expand All @@ -138,7 +138,7 @@ inline Fq6 inverse(const Fq6& f)
}

/// Inverses the Fq^12 field element
inline Fq12 inverse(const Fq12& f)
inline Fq12 inverse(const Fq12& f) noexcept
{
const auto& [a0, a1] = f.coeffs;

Expand Down
12 changes: 6 additions & 6 deletions lib/evmone_precompiles/pairing/bn254/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ inline constexpr std::array<std::array<Fq2, 5>, 3> FROBENIUS_COEFFS = {{
}};

/// Verifies that affine point over Fq^2 field is on the twisted curve.
constexpr bool is_on_twisted_curve(const ecc::AffinePoint<E2>& p)
constexpr bool is_on_twisted_curve(const ecc::AffinePoint<E2>& p) noexcept
{
const auto x3 = p.x * p.x * p.x;
const auto y2 = p.y * p.y;
Expand Down Expand Up @@ -243,7 +243,7 @@ constexpr ecc::ProjPoint<E2> mul_by_X(const ecc::ProjPoint<E2>& a) noexcept

/// Checks that point `p_aff` is in proper subgroup of points from twisted curve over Fq2 field.
/// For more details see https://eprint.iacr.org/2022/348.pdf Example 1 from 3.1.2 Examples
constexpr bool g2_subgroup_check(const ecc::AffinePoint<E2>& p_aff)
constexpr bool g2_subgroup_check(const ecc::AffinePoint<E2>& p_aff) noexcept
{
const auto p = ecc::ProjPoint<E2>{p_aff};

Expand Down Expand Up @@ -377,7 +377,7 @@ constexpr void lin_func(

/// Computes `a^2` for `a` from `Fq^4 = Fq^2[V](V^2 - ksi)` where `V` is from Fq^2 extended field.
/// For more reference see https://eprint.iacr.org/2010/354.pdf Algorithm 9
constexpr std::pair<Fq2, Fq2> fq4_square(const std::pair<Fq2, Fq2>& a)
constexpr std::pair<Fq2, Fq2> fq4_square(const std::pair<Fq2, Fq2>& a) noexcept
{
const auto& a0 = a.first;
const auto& a1 = a.second;
Expand All @@ -394,7 +394,7 @@ constexpr std::pair<Fq2, Fq2> fq4_square(const std::pair<Fq2, Fq2>& a)

/// Computes `c^2` for `x` from Fq^12 where `x^(FieldPrime^6 - 1) == 1`.
/// This is Fq^12 subgroup called cyclotomic polynomials or group of `r` roots of unity.
constexpr Fq12 cyclotomic_square(const Fq12& c)
constexpr Fq12 cyclotomic_square(const Fq12& c) noexcept
{
const auto& g = c.coeffs[0];
const auto& h = c.coeffs[1];
Expand Down Expand Up @@ -426,7 +426,7 @@ constexpr Fq12 cyclotomic_square(const Fq12& c)

/// Computes `cyclotomic_square` N times.
template <int N>
constexpr Fq12 n_cyclotomic_square(const Fq12& c)
constexpr Fq12 n_cyclotomic_square(const Fq12& c) noexcept
{
auto r = c;
for (int i = 0; i < N; ++i)
Expand All @@ -437,7 +437,7 @@ constexpr Fq12 n_cyclotomic_square(const Fq12& c)

/// Computes `a^X` where `X` is the curve seed parameter
/// and `a` is from cyclotomic subgroup of Fq^12.
constexpr Fq12 cyclotomic_pow_to_X(const Fq12& a)
constexpr Fq12 cyclotomic_pow_to_X(const Fq12& a) noexcept
{
auto t0 = cyclotomic_square(a);
auto t2 = cyclotomic_square(t0);
Expand Down