diff --git a/CHANGELOG.md b/CHANGELOG.md index 5285ddf31..1653eec3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ replacing `x.unitary_inverse()` with `let mut tmp = x.clone(); tmp.conjugate()` - #53 (ark-poly) Add `Zero` trait bound to `Polynomial`. - #106 (ark-ff, ark-ec) Add `Zeroize` trait bound to `Field, ProjectiveGroup, AffineGroup` traits. +- #108 (ark-ff) Add `extension_degree()` method to `Field`. ### Features - #20 (ark-poly) Add structs/traits for multivariate polynomials diff --git a/ff/src/fields/macros.rs b/ff/src/fields/macros.rs index 31766a0f6..5eb633811 100644 --- a/ff/src/fields/macros.rs +++ b/ff/src/fields/macros.rs @@ -158,6 +158,10 @@ macro_rules! impl_Fp { impl Field for $Fp

{ type BasePrimeField = Self; + fn extension_degree() -> u64 { + 1 + } + #[inline] fn double(&self) -> Self { let mut temp = *self; diff --git a/ff/src/fields/mod.rs b/ff/src/fields/mod.rs index 0a147e197..3fcfbf98a 100644 --- a/ff/src/fields/mod.rs +++ b/ff/src/fields/mod.rs @@ -115,6 +115,10 @@ pub trait Field: Self::BasePrimeField::characteristic() } + /// Returns the extension degree of this field with respect + /// to `Self::BasePrimeField`. + fn extension_degree() -> u64; + /// Returns `self + self`. #[must_use] fn double(&self) -> Self; diff --git a/ff/src/fields/models/cubic_extension.rs b/ff/src/fields/models/cubic_extension.rs index c2a659a3b..3621d8784 100644 --- a/ff/src/fields/models/cubic_extension.rs +++ b/ff/src/fields/models/cubic_extension.rs @@ -140,6 +140,10 @@ impl One for CubicExtField

{ impl Field for CubicExtField

{ type BasePrimeField = P::BasePrimeField; + fn extension_degree() -> u64 { + 3 * P::BaseField::extension_degree() + } + fn double(&self) -> Self { let mut result = *self; result.double_in_place(); diff --git a/ff/src/fields/models/quadratic_extension.rs b/ff/src/fields/models/quadratic_extension.rs index a193220fe..85b396c8d 100644 --- a/ff/src/fields/models/quadratic_extension.rs +++ b/ff/src/fields/models/quadratic_extension.rs @@ -164,6 +164,10 @@ impl One for QuadExtField

{ impl Field for QuadExtField

{ type BasePrimeField = P::BasePrimeField; + fn extension_degree() -> u64 { + 2 * P::BaseField::extension_degree() + } + fn double(&self) -> Self { let mut result = *self; result.double_in_place();