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
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