-
Notifications
You must be signed in to change notification settings - Fork 139
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
Clean up codes and docs in pairing of BN256 & Pluto #147
Open
John-Gong-Math
wants to merge
1
commit into
privacy-scaling-explorations:main
Choose a base branch
from
John-Gong-Math:pairing-cleanup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+131
−76
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is may go beyond the scope of this PR, but could we specify how this
NAF
representation?And also, what do we mean by
NAF
? I assumed "non-adjacent form", but that can't be it since there are many consecutive non-zero entries...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 am also wondering why there are consecutive non-zero entries in this case?
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 also don't know exact reason.
But, I found that there was similar discussion about NAF representation.
ethereum/go-ethereum#27957
In addition, I found that there are several sources for
6u + 2 NAF
value.https://github.com/cloudflare/bn256/blob/master/optate.go#L115
https://github.com/AntelopeIO/bn256/blob/4370b6964a4fccc599c42fa7449fb042e59372c5/src/optate.h#L142
https://github.com/randombit/pairings.py/blob/master/bn256.py#L121
https://github.com/matter-labs/pairing/blob/master/src/bn256/mod.rs#L28
Seems that they use different NAF algorithm for representation.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 have found some answers. @davidnevadoc @John-Gong-Math
Simple answer:
This
SIX_U_PLUS_2_NAF
is not realNAF
representation.At least, it includes the consecutive non-zero entries.
The real
SIX_U_PLUS_2_NAF
presentation is:Even though the current
SIX_U_PLUS_2_NAF
looks weird, it is correct for computation.Since it is a borrow from other repos, like go-ethereum.
I still don't know what algo is used for this "NAF" representation.
Long answer:
First of all, the
bn256
curve inhalo2curves
repo is, in essence,bn254
(oralt_bn_128
) curve, whereu = 4965661367192848881
.The go-ethereum developers found & discussed the issue here.
Also, they resolved the issue in this PR.
If you want more information about
bn254
curve, you should read this.Many projects(go-ethereum, matter-labs, Antelope) use the
bn256
curve, same ashalo2curves
.They all use the same
SIX_U_PLUS_2_NAF
value(weird NAF from sameu
value).Hence, I believe that the current
SIX_U_PLUS_2_NAF
could've been "borrowed" from other project.(@kilic can you give some info about this?)
The real NAF representation of
SIX_U_PLUS_2_NAF
can be computed with cloudflare tool.We can find more details & code here. (You need to use the correct
u
value for computation)After all of this inquiry, I think we have 2 options:
SIX_PLUS_2_NAF
Since they are all valid for computation, I think we can determine which one to use.
In case of 1st option, it is good for compatibility.(identical to value in other repos)
In case of 2nd option, it does not bring confusion we had.