-
Notifications
You must be signed in to change notification settings - Fork 224
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
Implement BN curves #225
Implement BN curves #225
Conversation
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
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.
Looks great, just some naming suggestions (bn256
-> bn254
).
(Should be accompanied by renaming the file in the file-system)
algebra/src/bn256/curves/g2.rs
Outdated
/// COFACTOR = | ||
#[rustfmt::skip] |
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.
Do we know what the cofactor is?
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.
Yes, in sage:
q=21888242871839275222246405745257275088696311157297823662689037894645226208583
Fq=GF(q)
E=EllipticCurve(Fq,[0,3])
ZZ.<z>=Fq[]
Fq2.<u>=GF(q^2, modulus=z^2+1)
Et=EllipticCurve(Fq2,[0,3/(9+u)])
cofactor = Et.order() // E.order()
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.
The order on G2 for BN curves is r∗(2p−r)
with r
the G1 curve order, so the G2 cofactor is always (2p-r)
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.
Yes indeed. Here is a good explanation on why: https://crypto.stackexchange.com/questions/64064/order-of-twisted-curve-in-pairings
Thanks for the helpful chronology! Given this info, what do you suggest we
should name the curve? I think bn256 doesn’t make sense if there are two
different curves with that name.
…On Sat, Jun 20, 2020 at 11:26 AM Kobi Gurkan ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In algebra/Cargo.toml
<#225 (comment)>:
> + "bn256", "bls12_377", "bls12_381", "cp6_782", "bw6_761", "mnt4_298", "mnt4_753",
"mnt6_298", "mnt6_753", "ed_on_bls12_377", "ed_on_cp6_782",
"ed_on_bw6_761", "ed_on_bls12_381", "ed_on_mnt4_298", "ed_on_mnt4_753"
]
+bn256 = []
If I remember correctly, the history goes like this:
- bn256 from cloudflare and google implement a BN curve that's
unrelated to Zcash. When the Ethereum devs ported it to the libsnark curve,
they kept the name.
- bn128 is the name that was used by libsnark and then by Zcash,
denoting 128-bit security.
- Later on, Zcash and the community mostly decided to switch to the
bn254 naming, since it wasn't 128-bit security anymore and 254-bit is the
size of the curve.
I believe that the pairing-friendly curve draft from IETF actually calls
this curve BN_SNARK1.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#225 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYSJ6WBXRWASFVGALDFABDRXT5M5ANCNFSM4OBLVEBA>
.
|
IMO bn254. |
Ok sounds good then! |
Thank you Kobi for the chronology! If we are to choose the name that makes most sense, then |
bn256 -> bn254 Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
For naming I suggest BN254_Snarks as in the literature BN254 often (always?) refers to the one from Nogami et al with parameter MCL also uses similar scheme to differentiate both: https://github.com/herumi/mcl#support-curves |
Hey @mratsim, thanks for the additional perspective! I still feel that |
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.
LGTM!
This PR implements infrastructure for BN family of curves and instantiate BN256 from Etherem (EDIT: curve renamed to BN254).
Type: Feature
Label: Ready to review
Priority: Medium
Motivation
Support of BN family that is widely used for pairing-based cryptography (Ethereum, libsnark, DIZK, Halo).
Followups