2323#include " scl/math/ec_ops.h"
2424#include " scl/math/ff.h"
2525#include " scl/math/number.h"
26+ #include " scl/math/ops.h"
2627
2728namespace scl ::math {
2829
@@ -36,7 +37,7 @@ namespace scl::math {
3637 * @see Secp256k1
3738 */
3839template <typename Curve>
39- class EC {
40+ class EC final : Add<EC<Curve>>, Eq<EC<Curve>>, Print<EC<Curve>> {
4041 public:
4142 /* *
4243 * @brief The field that this curve is defined over.
@@ -121,17 +122,6 @@ class EC {
121122 return *this ;
122123 }
123124
124- /* *
125- * @brief Add two points.
126- * @param lhs the left hand point
127- * @param rhs the right hand point
128- * @return the sum of two EC points.
129- */
130- friend EC operator +(const EC& lhs, const EC& rhs) {
131- EC copy (lhs);
132- return copy += rhs;
133- }
134-
135125 /* *
136126 * @brief Double this point.
137127 * @return this after doubling.
@@ -160,17 +150,6 @@ class EC {
160150 return *this ;
161151 }
162152
163- /* *
164- * @brief Subtract two EC points.
165- * @param lhs the left hand point
166- * @param rhs the right hand point
167- * @return the difference of two EC points.
168- */
169- friend EC operator -(const EC& lhs, const EC& rhs) {
170- EC copy (lhs);
171- return copy -= rhs;
172- }
173-
174153 /* *
175154 * @brief Perform a scalar multiplication.
176155 * @param scalar the scalar
@@ -243,15 +222,6 @@ class EC {
243222 return *this ;
244223 }
245224
246- /* *
247- * @brief Compute the negation of this EC point.
248- * @return the negation of this EC point.
249- */
250- EC operator -() {
251- EC copy (*this );
252- return copy.Negate ();
253- }
254-
255225 /* *
256226 * @brief Check if this EC point is equal to another EC point.
257227 * @param other the other EC point
@@ -261,20 +231,6 @@ class EC {
261231 return CurveEqual<Curve>(m_value, other.m_value );
262232 }
263233
264- /* *
265- * @brief Equality operator for EC points.
266- */
267- friend bool operator ==(const EC& lhs, const EC& rhs) {
268- return lhs.Equal (rhs);
269- }
270-
271- /* *
272- * @brief In-equality operator for EC points.
273- */
274- friend bool operator !=(const EC& lhs, const EC& rhs) {
275- return !(lhs == rhs);
276- }
277-
278234 /* *
279235 * @brief Check if this point is equal to the point at inifity.
280236 * @return true if this point is equal to the point at inifity.
@@ -298,14 +254,6 @@ class EC {
298254 return CurveToString<Curve>(m_value);
299255 }
300256
301- /* *
302- * @brief Write the curve point to a STL output stream.
303- * @see EC::ToString.
304- */
305- friend std::ostream& operator <<(std::ostream& os, const EC& point) {
306- return os << point.ToString ();
307- }
308-
309257 /* *
310258 * @brief Write this point to a buffer.
311259 * @param dest the destination
0 commit comments