Ask Your Question
3

Efficiently computing tower fields for pairings

asked 5 years ago

anonymous user

Anonymous

updated 5 years ago

Hello all,

I'm messing around trying to create a toy bls12-381 implementation. In order to create the required tower of fields, I'm doing this:

reset()
F = GF(0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab)
g1curve = EllipticCurve(F, [0,4])

K2.<x> = PolynomialRing(F)
F2.<u> = F.extension(x^2+1)
K6.<y> = PolynomialRing(F2)
F6.<v> = F2.extension(y^3 - (u+1))
K12.<z> = PolynomialRing(F6)
F12.<w> = F6.extension(z^2 - v)

Such towering is described in multiple places, e.g, Optimal Ate Pairings at the 128-bit Security level (hxxps://hal.archives-ouvertes.fr/hal-01620848/document), Implementing Pairings at the 192-bit Security Level (hxxps://eprint.iacr.org/2012/232.pdf) and Faster Subgroup Checks for BLS12-381 (hxxps://pdfs.semanticscholar.org/f413/bf4f22f682043616261e463abd0fd9fdcc54.pdf).

I am implementing example code given in Guide to Pairing Based Cryptography (hxxps://www.crcpress.com/Guide-to-Pairing-Based-Cryptography/Mrabet-Joye/p/book/9781498729505) that relies on the w F12p element defined in the above extension tower. However, the last step, of this code appears to take an inordinate amount of time (yet to see it complete).

Taking the cue from faster subgroup checks for bls12, I tried to redefine this as:

F12.<w> = F6.extension(x^2 - v)

but this fails with a type conversion error.

I've tried to search this site to find out how I might generate F12 directly from F2 as I've seen comments indicating that performance of towers of field extensions is... not great and this is also my experience. I have tried to define Fp12 entirely in terms of x from the first PolynomialRing, but I haven't found a way to try to extend directly from Fp2 to Fp12 yet (I only need Fp12 and its sextic twist. I have seen how to create a homomorphism to embed one elements in another field, but I haven't yet tried to use this to simplify. Can this be done? Is there a way to make this performant?

Apologies for the broken links, I'm not allowed to include links yet.


Update: Following @rburing's comment, I noted that the tower field is as follows:

Fp2=Fp[a]/(a2+1)

Fp6=Fp2[b]/(b3(a+1))
Fp12=Fp12[c]/(c2b)

From this we have that b3=a+1 and c2=b, hence c alone being a sixth root of a+1. If c is a sixth root, then c2 is a third root, so c2=(a+1)(1/3) and we can see also that b=a+1. To give sage some help, we cube both terms. I think therefore that:

Fp12=Fp2[a]/((a+1)(a+1)3)

which can be represented two ways in sage:

F12.<w> = F2.extension((u+1)-(x^2+2)^3)
F12a.<q> = F2.extension((u+1)-(u+1)^3)

Sage dislikes the latter ("finite field in u is not alphanumeric") but the former at least constructs and object in a second or two, and gives:

F12
Univariate Quotient Polynomial Ring in w over Finite Field in u of size 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787^2 with modulus w^6 + 6*w^4 + 12*w^2 + 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559786*u + 7

My question is, is this the correct object?

Preview: (hide)

Comments

Note w is a sixth root of u+1, since w is a square root of v and v is a cube root of u+1. So you can define the extension from Fp2=Fp[u]/(u2+1) to Fp12 by Fp12:=Fp2[w]/(w6(u+1)), and put v=w2.

rburing gravatar imagerburing ( 5 years ago )

@rburing Thanks. Unfortunately, this is hard to translate to sage, because F12p[w] for example is defined by F12.<w> = ... and I can't use w on the RHS of that expression (nor can I use v, because that's the polynomial ring in the intermediate extension field F6p and my hypothesis is that sage just can't cope with this level of towering, so I was hoping simply not to use anything in F6or K6 and associated terms. Have edited my question with what I think is the correct derivation based on your comment.

zahllos gravatar imagezahllos ( 5 years ago )

By my comment I meant that after defining F2 with generator u, you can do (instead of your code):

R.<y> = PolynomialRing(F2)
F12.<w> = F2.extension(y^6 - (u+1))
v = w^2
rburing gravatar imagerburing ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

dan_fulea gravatar image

We can start with a default version of F=Fq, q=p12, construct w inside it, ask for the minimal polynomial P of w, and work further with F. Or construct KF by using K=Fp[X]/(P). Let us construct w in the "default" world.

F = GF(0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab)
p = F.characteristic()
F12.<G> = GF(p^12)    # G is the generator, we will not need it below

u = sqrt(F12(-1))
R12.<Y> = PolynomialRing(F12)

v = (Y^3 - (u+1)).roots(multiplicities=False)[0]
w = sqrt(v)

P = w.minpoly()

As expected, we get a polynomial P of degree 12, and now we may want to switch to

K.<W> = GF(p^12, modulus=P)

Here,

sage: P                                                                                                                              
x^12 + 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559785*x^6 + 2
sage:
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 1,051 times

Last updated: Jan 31 '20