Skip to content
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

Fast clear cofactor #46

Closed
mratsim opened this issue Jun 14, 2020 · 0 comments · Fixed by #169
Closed

Fast clear cofactor #46

mratsim opened this issue Jun 14, 2020 · 0 comments · Fixed by #169
Labels
constant time ⏳ Enhancement is suitable for secret data correctness 🛂 performance 🏁

Comments

@mratsim
Copy link
Owner

mratsim commented Jun 14, 2020

Unless the cofactor is 1 (for BN254 curves) we are unfortunately working on a subgroup of an elliptic curve.

This means that when generating a random point for testing we may be generating a point out of our subgroup of interest.

In particular for scalar multiplication accelerated by endomorphism, the point MUST be on the subgroup or the result is incorrect.

A simple way to generate a point in the proper subgroup is to scalar multiply a random point by the cofactor of the curve:

  • Q: can we use GLV multiplication for that?

More efficient ways exist and are detailed in the IETF hash-to-curve draft https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-08#section-7 and (Wahby, Boneh, 2019, Fast and simple constant-time hashingto the BLS12-381 elliptic curve, https://eprint.iacr.org/2019/403.pdf). For BLS G1 in particular we can simply multiply by 1-u with u the BLS parameter.

Note for compatibility, when a fast cofactor clearing method exist, it is usually incompatible with the "normal" scalar multiplication by the actual cofactor. As clear cofactor is only used in 2 cases, random testing and hash-to-curve, we should implement the hash-to-curve version.

For G2 see https://github.com/status-im/nim-blscurve/blob/1a18d0db/blscurve/hash_to_curve.nim#L454-L512

Sage implementation: https://github.com/cfrg/draft-irtf-cfrg-hash-to-curve/blob/ead9c911/poc/clear_h_bls12381g2.sage

@mratsim mratsim added constant time ⏳ Enhancement is suitable for secret data performance 🏁 correctness 🛂 labels Jun 14, 2020
This was referenced Jun 14, 2020
@mratsim mratsim linked a pull request Feb 10, 2022 that will close this issue
@mratsim mratsim closed this as completed Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
constant time ⏳ Enhancement is suitable for secret data correctness 🛂 performance 🏁
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant