-
Notifications
You must be signed in to change notification settings - Fork 246
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
Pseduo-remove MapToCurve::new, renamed to check_parameters #679
Conversation
MapToCurve::new seemingly originates from a more runtime oriented elliptic curve crate: https://github.com/armfazh/redox-ecc/blob/master/src/ellipticcurve.rs#L36 Arguably test_parameters should be inherent methods, invoked by whoever defined the parameters, but maybe not? I left the trait method for now.
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
rustfmt is wrong that f()? should be preferred over f() ?, as errors paths should often be highlighted, but nobody merged that fix yet, so whatever. rust-lang/rustfmt#5595
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 left two comments to potentially simplify the interface further.
@@ -24,7 +24,7 @@ where | |||
M2C: MapToCurve<T>, | |||
{ | |||
field_hasher: H2F, | |||
curve_mapper: M2C, | |||
_curve_mapper: PhantomData<M2C>, |
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.
how about bundling the two phantoms, then:
_phantom: PhantomData<(T, M2C)>,
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 forget if this goes away later or not, but maybe it stays, so sure let's merge them.
@@ -79,13 +79,13 @@ pub trait WBConfig: SWCurveConfig + Sized { | |||
} | |||
|
|||
pub struct WBMap<P: WBConfig> { | |||
swu_field_curve_hasher: SWUMap<P::IsogenousCurve>, | |||
swu_field_curve_hasher: PhantomData<SWUMap<P::IsogenousCurve>>, |
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's not needed anymore IIUC?
I think we can remove this field, and change curve_params
to:
phantom: PhantomData<P>,
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.
Almost:
fn() -> P
is covariant inP
https://doc.rust-lang.org/nomicon/subtyping.htmlSWUMap<P::IsogenousCurve>
isfn() -> P::IsogenousCurve
which is covariant inP::IsogenousCurve
.
We know the story here of course, but in principle you cannot say the associated type P::IsogenousCurve
is covariant in P
. It's be fine to do this in practice, given it's all static in practice, but maybe leave it for 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.
Sure, it also doesn't affect the user's end.
…rkworks-rs#679)" This reverts commit 85546e4.
…rs#679) Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu> Co-authored-by: ¨Jeff <¨burdges@gnunet.org¨>
Co-authored-by: Jeff Burdges <burdges@gnunet.org>
This reverts commit bd13d1e.
…rkworks-rs#679)" This reverts commit 40e8b67.
This reverts commit 5dfeedf.
* Implement Elligator2 hash to curve for Twisted Edward curves * - Update the pull request number for Elligator2 map in CHANGELOG.md - Fix fmt errors in other parts of the repo. * Remove diagnostic `println`s * Remove irrelevant comment as elligator is not based on pasta Co-authored-by: mmagician <marcin.gorny.94@protonmail.com> * Referencing RFC9380 for hash-to-curve instead of the draft, plus comment clean up. Co-authored-by: mmagician <marcin.gorny.94@protonmail.com> * Cite new reference for hash-to-curve Co-authored-by: mmagician <marcin.gorny.94@protonmail.com> * Make sig0 function of elligator2 map boolean instead of 0u8, 1u8 Co-authored-by: mmagician <marcin.gorny.94@protonmail.com> * Move parity method from `curve_maps::swu` to `curve_maps` as it is used by both swu and elligator. * Remove map-to-curve sanity checks from release build. * cargo fmt * - apply new naming convention for map2curves - rename `new` to `check_parameters` * fix the documentation for `Elligator2Map::check_parameters` * Call elements of the field `element` not `point` in SWU hash-to-curve map * Mention moving of `parity` function in breaking changes. * fmt * move \#659 from pending bto features in `CHANGELOG.md` * bring back `new` and MapToCurve Object. * `cargo fmt` * Move Elligator2 pre-computatable values to `Elligator2Config` * Pre-computatable Elligator2 test example * Move Elligator2 `MapToCurve` implementation to its own folder. * Fix reference to the Elligator paper * Make elligator curve map a static object following revert of revert of #679 * Remove whitespace * Stricter check on SWU parameters Co-authored-by: Marcin <marcin.gorny.94@protonmail.com> --------- Co-authored-by: mmagician <marcin.gorny.94@protonmail.com> Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu> Co-authored-by: Pratyush Mishra <pratyush795@gmail.com>
Description
MapToCurve::new seemingly originates from a more runtime oriented elliptic curve crate: https://github.com/armfazh/redox-ecc/blob/master/src/ellipticcurve.rs#L36
Arguably test_parameters should be inherent methods, invoked by whoever defined the parameters, but maybe not? I left the trait method for now. I suspect the hash-to-curve code would benefit form a wider more idiomatic rewrite btw.
Rebase of #627 but also moved to personal github, so maintainers could make changes. See previous discussion: #627 (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.
Pending
section inCHANGELOG.md
Files changed
in the GitHub PR explorer