Skip to content

Commit

Permalink
chore: explicitly import CurveTrait for sub trait method and remo…
Browse files Browse the repository at this point in the history
…ve some default implementations (#20)

* chore: explicitly import `CurveTrait` for `sub` trait method

* Remove default implementations that error
  • Loading branch information
asterite authored Jan 3, 2025
1 parent 145da0a commit 42875fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod test;
mod bjj;

pub use crate::scalar_field::ScalarField;
use std::ops::{Add, Neg, Sub};

pub struct Curve<Params> {
x: Field,
Expand All @@ -23,23 +24,10 @@ trait TECurveParameterTrait {
}

/// Defines methods that a valid Curve implementation must satisfy
trait CurveTrait<Params>: std::ops::Add + std::ops::Sub + std::cmp::Eq + std::ops::Neg {
fn default() -> Self {
std::default::Default::default()
}
trait CurveTrait<Params>: 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<let NScalarSlices: u32>(self, x: ScalarField<NScalarSlices>) -> Self;
fn msm<let N: u32, let NScalarSlices: u32>(
Expand Down
1 change: 1 addition & 0 deletions src/test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -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<BabyJubJubParams>;
Expand Down

0 comments on commit 42875fd

Please sign in to comment.