Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub trait Field:
type Inner: Debug + Eq + Clone;

fn inner(&self) -> &Self::Inner;
fn inner_mut(&mut self) -> &mut Self::Inner;
}

/// Element of an integer field modulo prime number (F_p).
Expand Down
6 changes: 6 additions & 0 deletions src/field/ark_ff_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,15 @@ impl<F: ArkWrappedField> Ring for ArkField<F> {}
impl<F: ArkWrappedField> Field for ArkField<F> {
type Inner = F;

#[inline(always)]
fn inner(&self) -> &Self::Inner {
&self.0
}

#[inline(always)]
fn inner_mut(&mut self) -> &mut Self::Inner {
&mut self.0
}
}

//
Expand Down
6 changes: 6 additions & 0 deletions src/field/ark_ff_fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,15 @@ impl<P: FpConfig<N>, const N: usize> IntRing for Fp<P, N> {
impl<P: FpConfig<N>, const N: usize> Field for Fp<P, N> {
type Inner = BigInt<N>;

#[inline(always)]
fn inner(&self) -> &Self::Inner {
&self.0.0
}

#[inline(always)]
fn inner_mut(&mut self) -> &mut Self::Inner {
&mut self.0.0
}
}

/// ConstPrimeField is only implemented for MontConfig and MontBackend
Expand Down
11 changes: 11 additions & 0 deletions src/field/crypto_bigint_boxed_monty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,17 @@ impl Field for BoxedMontyField {
fn inner(&self) -> &Self::Inner {
self.0.as_montgomery()
}

#[inline(always)]
fn inner_mut(&mut self) -> &mut Self::Inner {
// TODO: address this once possible.
unimplemented!(
"For now we keep this unimplemented. \
The method was introduced in crypto-bigint in this PR:\
https://github.com/RustCrypto/crypto-bigint/pull/1014\
but not yet available in the latest RC from the craits.io."
)
}
}

impl PrimeField for BoxedMontyField {
Expand Down
5 changes: 5 additions & 0 deletions src/field/crypto_bigint_const_monty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@ impl<Mod: Params<LIMBS>, const LIMBS: usize> Field for ConstMontyField<Mod, LIMB
fn inner(&self) -> &Self::Inner {
Uint::new_ref(self.0.as_montgomery())
}

#[inline(always)]
fn inner_mut(&mut self) -> &mut Self::Inner {
Uint::new_ref_mut(self.0.as_montgomery_mut())
}
}

impl<Mod: Params<LIMBS>, const LIMBS: usize> ConstPrimeField for ConstMontyField<Mod, LIMBS> {
Expand Down
5 changes: 5 additions & 0 deletions src/field/crypto_bigint_monty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ impl<const LIMBS: usize> Field for MontyField<LIMBS> {
fn inner(&self) -> &Self::Inner {
Uint::new_ref(self.0.as_montgomery())
}

#[inline(always)]
fn inner_mut(&mut self) -> &mut Self::Inner {
Uint::new_ref_mut(self.0.as_montgomery_mut())
}
}

impl<const LIMBS: usize> PrimeField for MontyField<LIMBS> {
Expand Down