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

BN254 - Hash-to-Curve (SVDW method) #190

Merged
merged 3 commits into from
Apr 26, 2022
Merged

BN254 - Hash-to-Curve (SVDW method) #190

merged 3 commits into from
Apr 26, 2022

Conversation

mratsim
Copy link
Owner

@mratsim mratsim commented Apr 26, 2022

This adds hash-to-curve with BN254 Snarks.

For use in Codex (cc @cskiraly)

Unfortunately there is no isogeny of degree less than 30 that would allow us to use the SSWU method (Simplified Shallue-Van Woestijne-Ulas) and so we use the generic SVDW method (Shallue-Van Woestijne) which is slower due to 2 Legendre symbols+square root+inversion.

The SVDW code path is tested with with the old v7 vectors for BLS12-381.

Note: for BN254-snarks, the usual deployed hash to curve is Fouque-Tibouchi method

FT12: Fouque and Tibouchi,
"Indifferentiable hashing to Barreto-Naehrig curves."
Proc. LATINCRYPT, 2012.

It is in particular the one:

SVDW mapping is used by Constantine, gnark and it might be used by Hubble (cc @ChihChengLiang) as Hubble uses a mix of the IETF hashing_to_curve spec + the Fouque-Tibouchi method from MCL:

FT12 seems to be similar to "encode_to_curve" in the H2C spec due to non-uniformity (NU) rising from modular arithmetic while hashing_to_curve maps to 2 points that are then summed to combat bias.
image

Compared to SSWU mapping: https://github.com/kwantam/bls12-381_hash#bib

The SvdW map is similar to the one described in FT12, except that our construction is defined at every point in the base field. This may simplify constant-time implementations.

The SWU map uses two new tricks to speed up evaluation. It also uses only field operations, and in particular does not require fast Legendre symbol or extended Euclidean algorithms, which the SvdW map requires for efficiency. This simplifies implementation---especially constant-time implementation---since both of those algorithms would require implementing arbitrary modular reductions rather than reductions modulo a fixed prime.

@mratsim mratsim changed the title Bn svdw BN254 - Hash-to-Curve (SVDW method) Apr 26, 2022
@mratsim
Copy link
Owner Author

mratsim commented Apr 26, 2022

@mratsim
Copy link
Owner Author

mratsim commented Apr 26, 2022

Benches:

image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant