-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow multiplication of extension field elements directly by the BasePrimeField
element
#779
Conversation
and then multiply two ext field elements together
ff/src/fields/mod.rs
Outdated
@@ -350,6 +350,8 @@ pub trait Field: | |||
} | |||
Some(res) | |||
} | |||
|
|||
fn mul_by_base_field_elem(&self, elem: &Self::BasePrimeField) -> Self; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn mul_by_base_field_elem(&self, elem: &Self::BasePrimeField) -> Self; | |
fn mul_by_base_prime_field(&self, elem: &Self::BasePrimeField) -> Self; |
Also, should we move this into a Mul<Self::BasePrimeField, Output = Self>
bound? (And maybe add for<'a> Mul<&'a Self::BasePrimeField, Output = Self>
, MulAssign<Self::BasePrimeField>
, and for<'a> MulAssign<&'a Self::BasePrimeField>
bounds too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this initially, but we already have Mul<Self>
coming from a macro, and adding a trait bound as you suggest, and then implementing:
impl<P: QuadExtConfig> Mul<<Self as Field>::BasePrimeField> for QuadExtField<P> {
type Output = Self;
...
}
causes a conflicting implementation
error.
I believe this is what you meant, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch that's annoying...
I guess Rust doesn't know that for QuadExtField
, BasePrimeField
is always different from Self
...
But it should be able to figure that out: BasePrimeField: PrimeField
, while Self
doesn't implement that.
Where is the existing multiplication by base field? |
@Pratyush We have a method directly on
|
Actually, we also have the counterpart for
I would propose to unify these two as part of this PR, at least when it comes to the name. We could pull that method out into a separate trait, but I'm not sure it's worth it (it is not used anywhere in the arkworks org). |
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
Description
Note, there was already a method to multiply by the extension field's
BaseField
: but for a field tower, aBaseField
might not necessarily be theBasePrimeField
, but rather an extension field itself.Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the GitHub PR explorer