-
Notifications
You must be signed in to change notification settings - Fork 265
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
add mul
to ModelParam traits
#396
add mul
to ModelParam traits
#396
Conversation
@zhenfeizhang Thanks! do you mind adding undoing the formatting changes? (I think a git reset + git add of just the model parameters file should work) Also, I think @alexander-zw was also looking into similar things. |
ec/src/models/mod.rs
Outdated
base: &short_weierstrass_jacobian::GroupProjective<Self>, | ||
scalar: &Self::ScalarField, | ||
) -> short_weierstrass_jacobian::GroupProjective<Self> { | ||
base.mul(scalar.into_bigint()) |
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.
What I had in mind was actually something even more aggressive: to move the actual mul
code here, and call P::mul
from GroupProjective::mul
. That is, the impl of this method in GroupProjective
changes to
fn mul(...) {
P::mul(...)
}
Also, we might want to add both mul_projective
and mul_affine
methods here.
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 just tried your suggestion.
- we cannot add it directly to
ModelParameter
: we need to specify if it is TE or SW - we also cannot directly invoke it from
AffineCurve
orProjectiveCurve
, the trait is bounded byModelParameter
that does not specifyTE
orSW
working on the rest of the changes now
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.
a workaround is to add an associated type for ModelParameters
but it will be ugly and is a breaking change
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.
Ah sorry, should have been clearer, I meant that in the current strategy, instead of calling base.mul(...)
inside SWModelParameters
, we should change the implementation as follows:
// inside SW/TEModelParameters:
pub trait SW/TEModelParameters {
fn mul_projective(g: GroupProjective<Self>, scalar: ...) -> GroupProjective<Self> {
// default double-and-add impl
}
}
// inside `ProjectiveCurve`:
pub trait ProjectiveCurve {
fn mul(...); // <- no default impl anymore
}
// inside sw/te::GroupProjective:
impl ProjectiveCurve for GroupProjective {
...
fn mul() {
P::mul_projective(...)
}
}
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.
Got you. Should be fixed now.
a680ebc
to
94bcc59
Compare
94bcc59
to
84da5a7
Compare
mul
to ModelParam traits
Description
implement part of the solution suggested via
arkworks-rs/curves#66 (comment)
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.
Wrote unit testsPending
section inCHANGELOG.md
Files changed
in the GitHub PR explorer