-
Notifications
You must be signed in to change notification settings - Fork 230
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
Encapsulate isogeny mapping in a new struct #517
Conversation
@mmagician @Pratyush I moved the definition of the coefficient to |
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.
This looks great to me, modulo some small changes.
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
- Move `isogeny_map` function from `WBParams` to `IsogenyMap` - Update BLS12_381 test-curve accordingly.
…G.md` Cargo fmt on test-curves
ec/src/hashing/curve_maps/wb/mod.rs
Outdated
pub struct IsogenyMap< | ||
'a, | ||
DOMAINE: SWCurveConfig, | ||
CODOMAINE: SWCurveConfig<BaseField = BaseField<DOMAINE>>, | ||
> { | ||
pub x_map_numerator: &'a [BaseField<CODOMAINE>], | ||
pub x_map_denominator: &'a [BaseField<CODOMAINE>], | ||
|
||
pub y_map_numerator: &'a [BaseField<CODOMAINE>], | ||
pub y_map_denominator: &'a [BaseField<CODOMAINE>], | ||
|
||
pub _phantom_domain: PhantomData<DOMAINE>, | ||
} |
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.
pub struct IsogenyMap< | |
'a, | |
DOMAINE: SWCurveConfig, | |
CODOMAINE: SWCurveConfig<BaseField = BaseField<DOMAINE>>, | |
> { | |
pub x_map_numerator: &'a [BaseField<CODOMAINE>], | |
pub x_map_denominator: &'a [BaseField<CODOMAINE>], | |
pub y_map_numerator: &'a [BaseField<CODOMAINE>], | |
pub y_map_denominator: &'a [BaseField<CODOMAINE>], | |
pub _phantom_domain: PhantomData<DOMAINE>, | |
} | |
pub struct IsogenyMap< | |
'a, | |
DOMAIN: SWCurveConfig, | |
CODOMAIN: SWCurveConfig<BaseField = BaseField<DOMAIN>>, | |
> { | |
pub x_map_numerator: &'a [BaseField<CODOMAIN>], | |
pub x_map_denominator: &'a [BaseField<CODOMAIN>], | |
pub y_map_numerator: &'a [BaseField<CODOMAIN>], | |
pub y_map_denominator: &'a [BaseField<CODOMAIN>], | |
} |
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.
@Pratyush: As you see, it says:
error[E0392]: parameter `DOMAIN` is never used
--> ec/src/hashing/curve_maps/wb/mod.rs:28:5
|
28 | DOMAIN: SWCurveConfig,
| ^^^^^^ unused parameter
|
= help: consider removing `DOMAIN`, referring to it in a field, or using a marker such as `PhantomData`
What should we do beside using PhantomData?
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, didn't realize that we we weren't using DOMAIN
. There's two options:
- Reinstate the
PhantomData<CODOMAIN>
field, but make it private. To enable constructing anIsogenyMap
, let's add anew
method which does the construction. - Change the
*_map_denominator
type signatures to be&'a [BaseField<DOMAIN>]
. Admittedly this is a bit of a hack, but this avoids adding back the field.
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.
- To enable constructing an
IsogenyMap
, let's add anew
method which does the construction.
Hmm, then new need to be a const function which means the arguments to new should be const. so I have to define constants PHI_X_NOM, PHI_X_DEN,..., before calling new. Then we should put them in a struct so we know they are related perhaps. Then the IsogenyMap struct will have some existential crisis. (because it is just there now to hold the apply function).
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.
That should be possible, since it's a simple method, no?
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.
hmm but they need to have static lifetime no? perhaps I don't know the syntax of sending an argument on the fly witth static lifetime. IsogenyMap::new(&[1,23])
complains about lifetime and it doesn't let me do IsogenyMap::new(&'static[1,23])
where my creativing reachs its limit.
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 try sending them as array instead of refrences...
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 can't because they don't have the same size across the curves.
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.
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 think the following should work:
impl</* bounds */> IsogenyMap<'a, DOMAIN, CODOMAIN> {
const fn new(
x_numerator: &'a [BaseField<CODOMAIN>],
x_denominator: &'a [BaseField<CODOMAIN>],
...
) → Self {
Self {
x_numerator,
x_denominator,
...
}
}
}
of domain field to avoid phantomData.
Description
This PR moves the definition of the coefficients of the isogeny map of WB hashing to a separate struct rather than defining it in the WBParams itself. This is done to declutter the definition of the curve and make it explicit that the four polynomials are related and defining a single map according to these suggestions from @mmagician
and @Pratyush
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