From 42875fd10b1c6a307d4eeab383d6ae2522abcd2b Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Fri, 3 Jan 2025 13:05:05 -0300 Subject: [PATCH] chore: explicitly import `CurveTrait` for `sub` trait method and remove some default implementations (#20) * chore: explicitly import `CurveTrait` for `sub` trait method * Remove default implementations that error --- src/lib.nr | 16 ++-------------- src/test.nr | 1 + 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/lib.nr b/src/lib.nr index 86342ec..2aa4a8c 100644 --- a/src/lib.nr +++ b/src/lib.nr @@ -3,6 +3,7 @@ mod test; mod bjj; pub use crate::scalar_field::ScalarField; +use std::ops::{Add, Neg, Sub}; pub struct Curve { x: Field, @@ -23,23 +24,10 @@ trait TECurveParameterTrait { } /// Defines methods that a valid Curve implementation must satisfy -trait CurveTrait: std::ops::Add + std::ops::Sub + std::cmp::Eq + std::ops::Neg { - fn default() -> Self { - std::default::Default::default() - } +trait CurveTrait: Add + Sub + Eq + Neg + Default { fn new(x: Field, y: Field) -> Self; fn zero() -> Self; fn one() -> Self; - - fn add(self, x: Self) -> Self { - self + x - } - fn sub(self, x: Self) -> Self { - self - x - } - fn neg(self) -> Self { - std::ops::Neg::neg(self) - } fn dbl(self) -> Self; fn mul(self, x: ScalarField) -> Self; fn msm( diff --git a/src/test.nr b/src/test.nr index 8f218f1..0aab732 100644 --- a/src/test.nr +++ b/src/test.nr @@ -2,6 +2,7 @@ use crate::bjj::BabyJubJubParams; use crate::Curve; use crate::scalar_field::ScalarField; +use crate::CurveTrait; use ec::{consts::te::baby_jubjub, tecurve::affine::Point as TEPoint}; type BabyJubJub = Curve;