diff --git a/noir_stdlib/src/embedded_curve_ops.nr b/noir_stdlib/src/embedded_curve_ops.nr index 8d343e89fb1..1a05b4d7574 100644 --- a/noir_stdlib/src/embedded_curve_ops.nr +++ b/noir_stdlib/src/embedded_curve_ops.nr @@ -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 @@ -63,6 +64,20 @@ impl Eq for EmbeddedCurvePoint { } } +impl Hash for EmbeddedCurvePoint { + fn hash(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. @@ -104,6 +119,16 @@ impl Eq for EmbeddedCurveScalar { } } +impl Hash for EmbeddedCurveScalar { + fn hash(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.