Skip to content

Commit

Permalink
add missing to_nt converts (#167)
Browse files Browse the repository at this point in the history
* add missing to_nt converts

* Simplify `to_nt`.

---------

Co-authored-by: Suyash Bagad <[email protected]>
  • Loading branch information
iAmMichaelConnor and suyash67 committed Mar 29, 2023
1 parent eb3e6d9 commit c4484b2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cpp/src/barretenberg/stdlib/types/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ template <typename Composer> typename NT::grumpkin_point to_nt(typename CT<Compo

template <typename Composer> typename NT::bn254_point to_nt(typename CT<Composer>::bn254_point const& e)
{
return NT::bn254_point{ e.x.get_value(), e.y.get_value() };
return e.get_value();
};

template <typename Composer>
Expand All @@ -178,6 +178,13 @@ std::optional<typename NT::grumpkin_point> to_nt(std::optional<typename CT<Compo
return e ? std::make_optional<typename NT::grumpkin_point>(to_nt<Composer>(*e)) : std::nullopt;
};

template <typename Composer> std::vector<typename NT::fr> to_nt(std::vector<typename CT<Composer>::fr> const& vec)
{
auto ref_to_nt = [&](typename CT<Composer>::fr const& e) { return to_nt<Composer>(e); };

return map(vec, ref_to_nt);
};

template <typename Composer>
std::optional<std::vector<typename NT::fr>> to_nt(std::optional<std::vector<typename CT<Composer>::fr>> const& vec)
{
Expand Down

0 comments on commit c4484b2

Please sign in to comment.