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
8 changes: 7 additions & 1 deletion src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ pub trait HasPrimeFieldConfig {
/// the same, otherwise operations should panic in debug mode.
///
/// Constant prime fields are considered a special case of dynamic prime fields.
pub trait PrimeField: Field + HasPrimeFieldConfig + FromWithConfig<Self::Integer> {
pub trait PrimeField:
Field
+ HasPrimeFieldConfig
+ FromWithConfig<Self::Integer>
+ for<'a> FromWithConfig<&'a Self::Integer>
{
fn modulus(cfg: &Self::Config) -> Self::Integer;

fn modulus_minus_one_div_two(cfg: &Self::Config) -> Self::Integer;
Expand Down Expand Up @@ -107,6 +112,7 @@ pub trait ConstPrimeField:
+ From<u128>
+ From<Self::Inner>
+ From<Self::Integer>
+ for<'a> From<&'a Self::Integer>
{
const MODULUS: Self::Integer;
const MODULUS_MINUS_ONE_DIV_TWO: Self::Integer;
Expand Down
9 changes: 9 additions & 0 deletions src/field/ark_ff_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,15 @@ impl<F: ArkWrappedPrimeField + From<num_bigint::BigUint>, const N: usize> From<B
}
}

impl<'a, F: ArkWrappedPrimeField + From<num_bigint::BigUint>, const N: usize> From<&'a BigInt<N>>
for ArkField<F>
{
#[inline(always)]
fn from(value: &'a BigInt<N>) -> Self {
Self::from(*value)
}
}

impl<F: ArkWrappedPrimeField + From<num_bigint::BigUint>, const N: usize> From<ark_ff::BigInt<N>>
for ArkField<F>
{
Expand Down
7 changes: 7 additions & 0 deletions src/field/ark_ff_fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ impl<P: FpConfig<N>, const N: usize> From<BigInt<N>> for Fp<P, N> {
}
}

impl<'a, P: FpConfig<N>, const N: usize> From<&'a BigInt<N>> for Fp<P, N> {
#[inline(always)]
fn from(value: &'a BigInt<N>) -> Self {
Self::from(*value)
}
}

impl<P: FpConfig<N>, const N: usize> From<Fp<P, N>> for BigInt<N> {
#[inline(always)]
fn from(value: Fp<P, N>) -> Self {
Expand Down
Loading