Score:5

What are the structural differences between BLS12-381 and BLS12-377?

pw flag

What's the difference between BLS12-381 and BLS12-377?

Previously I thought their basic cryptographic algorithms were same, so it's easy to construct BLS12-381 from BLS12-377, or construct BLS12-377 from BLS12-381, by just changing some curve parameters. Is this correct?

However, in some fields, such as ZK-proof, someone told me that their constructions are totally different, which makes no sense to me.

So I would like to know the concrete differences between BLS12-377 and BLS12-381, such as scalar and related computation, point and related computation, etc.

DannyNiu avatar
vu flag
Can you add a quote from the person who claimed such difference?
Xing Chang avatar
pw flag
@DannyNiu he told me in a meeting, so no viewable materials, and not sure if it's correct.
DannyNiu avatar
vu flag
@XingChang It's fine to transcribe non-public material here for the sake of record. Do provide a translation if necessary.
fgrieu avatar
ng flag
[reposted with major change]. I [read](https://medium.com/asecuritysite-when-bob-met-alice/the-wonderful-bls12-curves-just-ready-for-a-privacy-respecting-world-fe731386e722) that BLS12–377 has twist type D, while BLS12-381 has twist type M, which does suggest they are different breeds. But I'm clueless about the meaning of that, and the implications. I'm trying to read [this](http://indigo.ie/~mscott/twists.pdf) which mentions the two twist types, but it all flies high above my head for now.
Aman Grewal avatar
gb flag
Based on the paper @fgrieu mentioned, it looks like the differences don't matter for high-level application code or for security proofs. But they do matter for implementations. A library that was designed *just* for bls12-281 can't be changed to use bls12-377 just by changing a few constants.
Score:1
cn flag

Both are curves of the Barreto-Lynn-Scott family with an embedding degree of 12. They were constructed as a consequence of the improvements to the Number Field Sieve for computing discrete logarithms in fields $\mathbb{F}_{p^n}$ with a prime $p$ and a small value $n$ that severely impacted the security level of BN curves that were previously widely used for instantiating pairing-based cryptography in practice. (See https://eprint.iacr.org/2016/1102.pdf).

The interesting thing about these BLS12 curves is that they are "pairing friendly". To be precise, they are meant to be used in the frame of pairing-cryptography where we have an efficient "Type-III" pairing (where an efficient isomorphism $\mathbb{G}_2\rightarrow \mathbb{G}_1$ is believed not to exist) that can be computed in practice. Our pairing is a bilinear map: $$e: \mathbb{G}_1 \times \mathbb{G}_2 \rightarrow \mathbb{G}_t$$

Our pairing is defined over these groups $\mathbb{G}_{\{1,2,t\}}$ and good candidates for these groups are defined over elliptic curves, since elliptic curves allow for faster arithmetic and smaller bit sizes than groups defined over finite fields directly.

So, here comes the elliptic curves: BLS12-381 was first introduced in 2017, while BLS12-377 was introduced in 2018.

The first difference between both is their base field:

  • BLS12-377 is defined over the field generated by the prime q = 0x01ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d44300000008508c00000000001 which is a 377 bit prime.
  • BLS12-381 is defined over the field generated by the prime q = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab which is a 381 bit prime.

This is roughly the size of the coordinates of the points on each curve. Both are smaller than 384 bits, but larger than 320 bits, which from an implementation point of view mean they can be represented using only 6 words of 64 bits each. Nothing dramatically different there.

Notice that they are both believed to have a "security level" of ~120 bits, following the latest advances in breaking such curves. This is not great, but still acceptable and still considered infeasible to break with today's knowledge and tech. Here's a good blog post on the topic.

Next difference, as pointed out by @fgrieu, both have a different kind of "twist". Both were constructed following construction 6.6 in the 2006 taxonomy of pairing-friendly curves paper, in the case where $k \equiv 0 \mod 6$, and as such have a "CM Discriminant" equal to 3 (here's a table with the different parameters). This means they both have a twist of degree 6 (aka "sextic twist"), which is what the paper about constructing BLS12 curves recommended for fast arithmetic and probably why they were constructed using this method. There are always 2 possible sextic twists for such BLS12 curves, but they have different orders depending on the parameters and curves at hand. The "right twist" for our usage is the one whose order is divisible by $r$, the size of the pairing-friendly subgroup (we'll see below why). The $r$ values of both are:

  • for BLS12-381: r= 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001
  • for BLS12-377: r= 0x12ab655e9a2ca55660b44d1e5c37b00159aa76fed00000010a11800000000001

And because of that, they have a different type of twist:

  • BLS12-381 has a "type-M twist": $(E_t/\mathbb{F}_p^2): Y^2 = X^3+4(u+1)$
  • BLS12-377 has a "type-D twist": $(E_t/\mathbb{F}_p^2): Y^2 = X^3+1/u$

Note that they both have a low-hamming weight $u$ value, which is good since it will be the number of addition steps in Miller Loop's algorithm to compute pairings:

  • BLS12-381 has $u = -0xd201000000010000 = -2^{63}-2^{62}-2^{60}-2^{57}-2^{48}-2^{16}$, with a hamming weight of 6
  • BLS12-377 has $u = 0x8508c00000000001 = 2^{63}+2^{58}+2^{56}+2^{51}+2^{47}+2^{46}+1$, with a hamming weight of 7

One the other side, given its slightly smaller field size, one could expect BLS12-377 to have slightly better performance compared to BLS12-381, which might well counter-act the lower hamming weight of its value $u$... The latter is also used more broadly and has seen better adoption so far and that means it has probably more refined implementations.

So now that we've seen all these parameters, the elliptic curves at hand, $E(F_q)$, have only one big subgroup of order $r$ and while it is a good candidate for our group $\mathbb{G}_1$, we need two different yet "compatible" groups to define our pairing. But a cool thing is that we can "extend" the field over which we're defining our elliptic curve, and by doing so we can end up with an elliptic curve $E'$ defined over its extension $F_{q^k}$ of degree $k$ that will contain more than 1 subgroup of said order $r$ for sure. In the BLS12 family case, our extension is of degree 12 (the famous embedding degree mentioned in my very first sentence), and that is giving us a good candidate for our group $\mathbb{G}_2$.

Now, the twist is becoming important here, because when we're working in a field extension of degree 12, doing arithmetic is really slow! So a "trick" to speed up computation is to rely on a way to map our curve $E({F}_{q^{12}})$ onto a nicer curve defined over a lower degree field and this is where the twist of order divisible by $r$ comes in! (By Lagrange's theorem, to have a subgroup of size $r$ its order must be divisible by $r$.) And we can use a map from the curve to its twist to operate in the twist instead of in the extension field. So, the fact that they both have a twist of degree 6 means that we can reduce our extension field by a factor of six when using the twist, which is the biggest divisor of 12 that isn't 12 itself. So having $\mathbb{G}_2$ be on the twist means we're doing computation in $F_{q^2}$ instead of ${F}_{q^{12}}$, and it's much easier to do computation there.

This difference in term of twist means that we don't have the same map to map from the twisted curve onto the original curve. But my belief is that the recent formulas we have to compute pairings can operate entirely in the twist, and so the difference of twist type might not matter at all at the implementation level depending on which formulas are implemented for the curves' arithmetic.

Finally to really answer your question with a more concrete example, while the two are not exactly the same, they still have a lot in common at the implementation level, e.g. the Go Kilic BLS12-377 library is actually adapted from the Go Kilic BLS12-381 one, with relatively few changes, the main differences being mostly the curve parameters and the field parameters, which have consequences on the way we do arithmetic (especially in the assembly code), but the bulk of the code itself remains the same for both.

PS: a good read about BLS12-381 and pairing-friendly curves is "BLS12-381 for the rest of us", it also covers a lot of the above in more details.

Xing Chang avatar
pw flag
thanks for your great work! let me learn and understand
Robert Zaremba avatar
in flag
From a usage perspective, what's the advantage of BLS12_377 over BLS12_381?
cn flag
BLS12-381 tends to be a tad faster in practice, it also has gotten broader adoption from what I've seen.
Mathdropout avatar
cn flag
BLS12-377 has a base field with high 2-adicity. This makes it better suited for one-layer recursion.
cn flag
That's a good point I should maybe detail more, the subgroup order $r$ is chosen to allow efficient FFT-based polynomial multiplications: that the 2-adicity of BLS12-381 is 32 and that of BLS12-377 is 47 wrt to their subgroup order $r$, meaning they are both fit for SNARK applications but as you pointed out the base field of BLS12-381 has a 2-adicity of 1, while the base field of BLS12-377 has one of 46 making it better for "proofs of proofs", e.g. one-layer recursion.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.