Skip to content
Merged
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
25 changes: 25 additions & 0 deletions noir_stdlib/src/embedded_curve_ops.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::cmp::Eq;
use crate::hash::Hash;
use crate::ops::arith::{Add, Neg, Sub};

/// A point on the embedded elliptic curve
Expand Down Expand Up @@ -63,6 +64,20 @@ impl Eq for EmbeddedCurvePoint {
}
}

impl Hash for EmbeddedCurvePoint {
fn hash<H>(self, state: &mut H)
where
H: crate::hash::Hasher,
{
if self.is_infinite {
self.is_infinite.hash(state);
} else {
self.x.hash(state);
self.y.hash(state);
}
}
}

/// Scalar for the embedded curve represented as low and high limbs
/// By definition, the scalar field of the embedded curve is base field of the proving system curve.
/// It may not fit into a Field element, so it is represented with two Field elements; its low and high limbs.
Expand Down Expand Up @@ -104,6 +119,16 @@ impl Eq for EmbeddedCurveScalar {
}
}

impl Hash for EmbeddedCurveScalar {
fn hash<H>(self, state: &mut H)
where
H: crate::hash::Hasher,
{
self.hi.hash(state);
self.lo.hash(state);
}
}

// Computes a multi scalar multiplication over the embedded curve.
// For bn254, We have Grumpkin and Baby JubJub.
// For bls12-381, we have JubJub and Bandersnatch.
Expand Down
Loading