Skip to content

Commit

Permalink
Move methods to private trait
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave committed Nov 6, 2023
1 parent 9214e2c commit 7d5a521
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,6 @@ pub trait FieldElementWithInteger: FieldElement + From<Self::Integer> {

/// Returns the prime modulus `p`.
fn modulus() -> Self::Integer;

/// Returns the integer representation of the additive identity.
fn zero_integer() -> Self::Integer;

/// Returns the integer representation of the multiplicative identity.
fn one_integer() -> Self::Integer;
}

/// Methods common to all `FieldElementWithInteger` implementations that are private to the crate.
Expand Down Expand Up @@ -296,9 +290,23 @@ pub(crate) trait FieldElementWithIntegerExt: FieldElementWithInteger {
}
false
}

/// Returns the integer representation of the additive identity.
fn zero_integer() -> Self::Integer;

/// Returns the integer representation of the multiplicative identity.
fn one_integer() -> Self::Integer;
}

impl<F: FieldElementWithInteger> FieldElementWithIntegerExt for F {}
impl<F: FieldElementWithInteger> FieldElementWithIntegerExt for F {
fn zero_integer() -> Self::Integer {
0usize.try_into().unwrap()
}

fn one_integer() -> Self::Integer {
1usize.try_into().unwrap()
}
}

/// Methods common to all `FieldElement` implementations that are private to the crate.
pub(crate) trait FieldElementExt: FieldElement {
Expand Down Expand Up @@ -701,14 +709,6 @@ macro_rules! make_field {
fn modulus() -> Self::Integer {
$fp.p as $int
}

fn zero_integer() -> Self::Integer {
0
}

fn one_integer() -> Self::Integer {
1
}
}

impl FftFriendlyFieldElement for $elem {
Expand Down

0 comments on commit 7d5a521

Please sign in to comment.