-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Elligator2 hash-to-curve for Bandersnatch (#758)
* Implement Elligator2 hash-to-curve for Bandersnatch curve * Add relevant entry to `CHANGELOG.md` * Remove sha3 unused dependancy * Include the script to compute an efficient z for elligator2 map. * move Elligator2 for Bandersnatch from Pending to Features --------- Co-authored-by: Marcin <marcin.gorny.94@protonmail.com>
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Arguments: | ||
# - F, a field object, e.g., F = GF(2^521 - 1) | ||
# - A and B, the coefficients of the curve y^2 = x^3 + A * x + B | ||
def find_z_sswu(F, A, B): | ||
R.<xx> = F[] | ||
# Polynomial ring over F | ||
g = xx^3 + F(A) * xx + F(B) | ||
# y^2 = g(x) = x^3 + A * x + B | ||
ctr = F.gen() | ||
while True: | ||
for Z_cand in (F(ctr), F(-ctr)): | ||
# Criterion 1: Z is non-square in F. | ||
if is_square(Z_cand): | ||
continue | ||
# Criterion 2: Z != -1 in F. | ||
if Z_cand == F(-1): | ||
continue | ||
# Criterion 3: g(x) - Z is irreducible over F. | ||
if not (g - Z_cand).is_irreducible(): | ||
continue | ||
# Criterion 4: g(B / (Z * A)) is square in F. | ||
if is_square(g(B / (Z_cand * A))): | ||
return Z_cand | ||
ctr += 1 | ||
|
||
# Finds the smallest z in term of non-zero bit | ||
# in sage representation for consturcting | ||
# elligator2 map for a curve defined over field F. | ||
# Argument: | ||
# - F, a field object, e.g., F = GF(2^255 - 19) | ||
def find_z_ell2(F): | ||
ctr = F.gen() | ||
while True: | ||
for Z_cand in (F(ctr), F(-ctr)): | ||
# Z must be a non-square in F. | ||
if is_square(Z_cand): | ||
continue | ||
return Z_cand | ||
ctr += 1 |
228787b
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.
Hello, I am having following issue with this commit.
UPD: it is most probably my fault for using this crate directly with a github link.