Skip to content

Commit

Permalink
adding a x/y getter, useful for plume
Browse files Browse the repository at this point in the history
  • Loading branch information
signorecello committed Feb 18, 2025
1 parent c36268d commit 4cf335c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ where
}
}

trait BigCurveTrait {
pub trait BigCurveTrait<BigNum> {
fn x(self) -> BigNum;
fn y(self) -> BigNum;
fn neg(self) -> Self;
fn point_at_infinity() -> Self;
fn offset_generator() -> Self;
Expand All @@ -257,17 +259,24 @@ trait BigCurveTrait {
fn hash_to_curve<let N: u32>(seed: [u8; N]) -> Self;
}

impl<BigNum, CurveParams> BigCurveTrait for BigCurve<BigNum, CurveParams>
impl<BigNum, CurveParams> BigCurveTrait<BigNum> for BigCurve<BigNum, CurveParams>
where
CurveParams: CurveParamsTrait<BigNum>,
BigNum: BigNumTrait,
{

fn hash_to_curve<let N: u32>(seed: [u8; N]) -> Self {
let r = hash_to_curve::<BigNum, N>(seed, CurveParams::a(), CurveParams::b());
BigCurve { x: r.0, y: r.1, is_infinity: false }
}

fn x(self) -> BigNum {
self.x
}

fn y(self) -> BigNum {
self.y
}

/**
* @brief negate a point
**/
Expand Down

0 comments on commit 4cf335c

Please sign in to comment.