Skip to content

Commit

Permalink
chore: derive PartialEq and Hash for FieldElement (#6610)
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored Nov 25, 2024
1 parent 2975f2a commit 7d61242
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions acvm-repo/acir_field/src/field_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::AcirField;

// XXX: Switch out for a trait and proper implementations
// This implementation is inefficient, can definitely remove hex usage and Iterator instances for trivial functionality
#[derive(Default, Clone, Copy, Eq, PartialOrd, Ord)]
#[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FieldElement<F: PrimeField>(F);

impl<F: PrimeField> std::fmt::Display for FieldElement<F> {
Expand Down Expand Up @@ -43,18 +43,6 @@ impl<F: PrimeField> std::fmt::Debug for FieldElement<F> {
}
}

impl<F: PrimeField> std::hash::Hash for FieldElement<F> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
state.write(&self.to_be_bytes());
}
}

impl<F: PrimeField> PartialEq for FieldElement<F> {
fn eq(&self, other: &Self) -> bool {
self.to_be_bytes() == other.to_be_bytes()
}
}

impl<F: PrimeField> From<i128> for FieldElement<F> {
fn from(mut a: i128) -> FieldElement<F> {
let mut negative = false;
Expand Down

0 comments on commit 7d61242

Please sign in to comment.