BLS Epliptic Curve
BLS Epliptic Curve
Barreto-Naehrig Curves
1 Introduction
Pairing-based cryptography requires pairing-friendly curves. These are parame-
terised by their embedding degree k. The embedding degree dictates to an extent
the security level efficiently achievable on the curve.
While it is well known that super-singular curves are viable and useful candi-
dates, they are limited in terms of the possible values of the embedding degree.
Furthermore the highest embedding degree possible for super-singular elliptic
curves (k = 6) requires us to use curves of characteristic 3, which is rather
awkward from an implementation point of view (we refer the reader to a recent
paper on arithmetic in GF(3m ) by Ahmadi, Hankerson and Menezes [1]). At-
tention has therefore switched to consideration of non-supersingular curves of
prime characteristic, for which there is no such limitation. Nonetheless finding
suitable curves, or ideally whole families of suitable curves, has proven to be
non-trivial [2].
In this context the security of pairing-based cryptography depends on finding
curves whose order n is divisible by a large prime r such that generic attacks on
small group orders (Pohlig-Hellman attacks) can be resisted. It is also important
that k lg(p), where p is the modulus, is large enough to resist index-calculus
attacks.
?
Funded by the Brazilian Government/Coordination for the Improvement of Higher
Education Personnel (CAPES)
Given this scenario, Barreto-Naehrig (BN) curves with their embedding de-
gree of 12 are particularly significant, as before their discovery only MNT
curves [3] of embedding degree 3, 4 and 6 were known to support rare curves
of prime order (r = n). The prime order requirement is significant in terms of
efficiency of implementation [2], and is crucial for certain applications [4]. Fur-
thermore since BN curves define a whole family of curves, there are plenty to
choose from. One potential drawback of using BN curves is Schirokauer’s pro-
posed discrete logarithm algorithm [5], which may be applicable to BN primes
because of their special format. In this case, it might be necessary to rescale
parameters accordingly.
2 Bilinear Pairings
A bilinear pairing is a map e : G1 × G2 → G3 where G1 , G2 are additive groups,
G3 is a multiplicative group, and the map is linear in each component:
Let Fp be the prime field with characteristic p and let E(Fp ) be an elliptic
curve defined over Fp . Let n be the order of E(Fp ), let r be a large prime dividing
n, and let k be the least positive integer such that r | pk − 1 and r2 - pk − 1.
We call such an integer k the embedding degree of r with regard to Fp , and we
know that the r-torsion group of the curve is contained in E(Fpk ) and the r-th
roots of unity are contained in Fpk .
Let [a]P denote the multiplication of a point P ∈ E by a scalar a ∈ Z, and
let ∞ ∈ E denote the point at infinity. A Miller [6] function fr,P (·) is a rational
function on E with r zeroes at P , one pole at [r]P and r − 1 poles at ∞:
The most efficient pairing computation algorithms are derived from Miller’s
algorithm [6], which computes a Miller function fr,P evaluated at a point Q.
2
Algorithm 1 describes the BKLS algorithm [7] commonly used to compute the
Tate pairing, including the denominator elimination optimisation that may be
applied for even embedding degree. The algorithm needs Fpk arithmetic (squar-
ing and multiplication), elliptic curve arithmetic (point addition and doubling),
computation of the line function lA,B (C) that intercepts points A, B and its
evaluation at a point C, and a final exponentiation in Fpk .
3 Barreto-Naehrig Curves
t(x) = 6x2 + 1
n(x) = 36x4 − 36x3 + 18x2 − 6x + 1
p(x) = 36x4 − 36x3 + 24x2 − 6x + 1 .
3
Because BN curves have embedding degree k = 12, pairings are computed
over points in E(Fp12 ). A common optimisation [7] is to take one of the points
in E(Fp ) ⊂ E(Fp12 ) and the other in E(Fp12 ). However, it is possible to do
better than this: By using an appropriate map, we can compress certain points
in E(Fp12 ) to points in a sextic twist E 0 (Fp2 ). Let ξ ∈ Fp2 be such that W 6 − ξ
is irreducible over Fp2 [W ] whenever p ≡ 1 (mod 6). Then there exists a curve
E 0 /Fp2 : y 02 = x03 +b/ξ that is a sextic twist of E/Fp and whose order is divisible
by n. In fact, the order of the sextic twist E 0 /Fp2 is n(2p − n).
Let z ∈ Fp12 be a root of W 6 − ξ. We can build an injective group homo-
morphism ψ : E 0 (Fp2 ) → E(Fp12 ) as (x0 , y 0 ) 7→ (x0 z 2 , y 0 z 3 ). This allows us to
map points in the sextic twist E 0 (Fp2 ) to points in E(Fp12 ), and if ξ is used to
construct the extension field Fp12 then multiplication by powers of z does not
incur any multiplication overhead.
We chose x such that p is a 256-bit prime subject to the following congruences:
p ≡ 7 (mod 8) (so that we can use −2 as a quadratic non-residue, optimising
arithmetic operations on Fp2 ), p ≡ 4 (mod 9) (as suggested in [9] to compute
cube roots efficiently), and p ≡ 1 (mod 6) (so that we can find ξ ∈ Fp2 such
that W 6 − ξ is irreducible over Fp2 [W ]). The elliptic curve equation is given
by E/Fp : y 2 = x3 + 3, and G = (1, 2) is a generator of E(Fp ). For a 256-bit
modulus, the x which defines the curve is just a 64-bit number.
Observe from Algorithm 1 that the Ate pairing benefits from r having low
Hamming weight. In the context of BN curves, this is facilitated by prefer-
ring an x value of low Hamming weight. For example, we find that r has a
Hamming weight of 90 and t has a Hamming weight of 28 if we choose x =
-6000000000001F2D (hex).
4
Table 2. Multiplication and squaring algorithms for finite extension fields
5
curve arithmetic over E 0 (Fp2 ). Instead of using r to control the Miller loop, the
Ate pairing uses s = t − 1, which in the case of BN curves provides for roughly
half the number of iterations needed to compute the Tate pairing. Algorithm 2
describes the BKLS algorithm adapted to compute the Ate pairing.
The formula for the slope of the line function lA,B that intercepts two points
A = (xA , yA ) and B = (xB , yB ) is
yB − yA
λA,B = .
xB − xA
If A, B ∈ E(Fp12 ), the slope is an element of Fp12 . We can easily derive this
from the slope of the line function lA0 ,B 0 that intercepts A0 , B 0 ∈ E 0 (Fp2 ), where
A0 , B 0 are the images of A, B under ψ:
0 0
(yB − yA )z 3
λA,B = 0 0 = (λA0 ,B 0 )z ,
(xB − xA )z 2
so computing λA,B ∈ Fp12 amounts to computing λA0 ,B 0 ∈ Fp2 . We use this slope
to evaluate lA,B (P ) as follows:
lA,B (P ) = (xP − xA )λA,B − (yP − yA )
= (xP − x0A · z 2 )(λA0 ,B 0 )z − (yP − yA0
· z3)
0
= (−yP ) + (xP · λA0 ,B 0 )z + (yA − x0A · λA0 ,B 0 )z 3 .
In practise the use of projective coordinates for E(Fp2 ) point doublings and
additions is a little faster, even though for the pairing calculation elliptic curve
operations take up relatively little time compared with the Fp12 operations.
As xP , yP ∈ Fp and x0A , yA0
, λA0 ,B 0 ∈ Fp2 , again we can avoid Fp12 arithmetic
entirely when computing lA,B (P ). The resulting value has a sparse representation
in Fp12 , needing only five Fp elements instead of twelve. However, the Miller
variable is a full Fp12 element. For a given point P , the value −yP is constant,
so it needs to be computed only once during the pairing computation.
6
7 Final Exponentiation
Both the Ate and Tate pairing algorithms compute a final exponentiation after
the Miller loop. A common optimisation of this computation is to factor (pk −
1)/n into three parts: An easy exponentiation to the power of (pk/2 − 1), an
equally easy exponentiation to the power of (pk/2 + 1)/Φk (p) (easy because of
the Frobenius), and a ‘hard’ exponentiation to the power of Φk (p)/n, where
Φk is the k-th cyclotomic polynomial [11]. In the context of BN curves, these
exponents translate to (p6 − 1), (p2 + 1), and (p4 − p2 + 1)/n.
Recall that p and n have a special form: Both are polynomials on x. Therefore
this hard part of the final exponentiation can be computed explicitly as a large
polynomial in x. This can in turn be expressed to the base p as
p3 + (6x2 + 1)p2 + (36x3 − 18x2 + 12x + 1)p + (36x3 − 30x2 + 18x − 2) .
Now the standard continuation is to use the method of multi-exponentiation
combined with the Frobenius [12], so that the final exponentiation is the calcu-
lation of
3 2 2 3
−18x2 +12x+1 3
−30x2 +18x−2
(f p ) · (f p )6x +1
· (f p )36x · f 36x .
However, multi-exponentiation is expensive in terms of memory as it requires
extensive precomputation. So instead we exploit the specific and fixed form of
the final exponent to obtain Algorithm 3 which can easily be verified to produce
the equivalent result, but only requires simple exponentiation.
7
set enhancements to facilitate the implementation of popular cryptographic al-
gorithms. Fortunately these enhancements are also relevant to our efforts here.
Specifically the architecture supports a ACX|HI|LO triple of registers that
can be used to accumulate the partial products that arise when employing the
popular Comba/Montgomery technique for multi-precision multiplication [14].
This is supported by a modified MADDU instruction which carries out an unsigned
integer multiplication and addition to the triple register.
One architectural feature of particular significance is the 2 KB instruction
cache. This is appropriate for an algorithm which spends most of its time in a
small inner loop, as say for a modular exponentiation as required by the RSA
algorithm. However it is problematical for the more complex algorithms consid-
ered here. Therefore we found that it was hard to avoid frequent cache misses,
which are particularly expensive at the higher clock speeds. In particular it was
self-defeating to try and use the popular optimisation of loop-unrolling, as the
reduction in instruction count was more than offset by an increase in clock cycle
count.
By using stack allocation for the multiprecision variables it was possible to
keep the RAM requirement within the 16 KB allocation. However this could
have been a problem if we were to use methods which are more memory-hungry
(like multi-exponentiation).
9 Results
The performance of the Ate and Tate pairings was measured on two platforms:
The Philips HiPerSmartTM platform described in Section 8, and a 32-bit Intel
Pentium IV 3.0 GHz (Prescott) processor.
Our programs used the MIRACL library3 , which implements multi-precision
number arithmetic, and supports a number of powerful optional optimizations. In
particular it supports completely unrolled assembly language support for fixed-
size big number multiplication and modular reduction. Internally, prime field
elements are in Montgomery representation [15], which allows for fast reduction
without divisions. The memory for big numbers can be allocated from the heap,
or more efficiently from the stack, which is the case for our experiments. When
required to multiply big numbers by a small integer, multiplications by numbers
less than or equal to 6 are instead carried out by up to 3 modular additions.
Table 3 lists the number of instructions required to compute the pairings
on the smartcard, as well as the number of cache misses. The count of clock
cycles, the average Clocks Per Instruction (CPI), and the actual time needed to
compute the pairing is listed in Tables 4 and 5. The timings for the 3.0 GHz
Pentium IV are listed in Table 6. Here the implementation takes full advantage
of the Pentium’s SSE2 instruction set enhancements.
Our smartcard hardware emulator is only cycle-accurate up to 20.57 MHz,
but the maximum supported speed for the smartcard is 36 MHz. At this clock
3
http://www.shamus.ie
8
Table 3. Instructions required (% icache misses) — Philips HiPerSmartTM
frequency the Ate pairing over BN curves should take approximately 3 seconds,
which is not adequate for use at the moment. Nevertheless it is anticipated that,
with improvements in technology, BN curves might be practical even on such
resource constrained devices in the near future.
10 Conclusions
We have described the first implementation of both the Ate and Tate pairings
over Barreto-Naehrig curves.
Because of the restrictions imposed on the selection of primes for BN curves,
we have not used primes congruent to 1 (mod 12), and therefore our finite fields
are not strictly pairing-friendly in the sense of Koblitz and Menezes [16]. We
have used the technique of towering extensions to construct the extension field
Fp12 , and our choice of non-residues for the reduction polynomials that define
the extensions still allows for efficient finite field arithmetic.
In order to avoid full Fp12 arithmetic throughout the pairing computation,
we have provided explicit Fp2 -formulae for the evaluation of the line function
lA,B (C) required by the Miller algorithm, thus alleviating part of the burden
imposed by using the k = 12 embedding degree. The value of lA,B (C) computed
by the Ate (resp. Tate) pairing uses five (resp. six) Fp components instead of
twelve.
Our method for the final exponentiation is both faster and less memory-
intensive than previous methods in the literature which are based on multi-
exponentiation. We also observe that the analysis of Hess, Smart and Ver-
9
Table 6. Timings in milliseconds on a 32-bit 3.0 GHz Intel Pentium IV
cauteren [8] for the settings of BN curves (k = 12, lg(p) = lg(r) = 256) is
more optimistic with regard to the Ate pairing than our experimental results.
References
1. Omran Ahmadi, Darrel Hankerson, and Alfred Menezes. Software implementation
of arithmetic in GF(3m ). In WAIFI 2007 (to be published), 2007.
2. David Freeman, Michael Scott, and Edlyn Teske. A taxonomy of pairing-friendly el-
liptic curves. Cryptology ePrint Archive, Report 2006/372, 2006. http://eprint.
iacr.org/.
3. Atsuko Miyaji, Masaki Nakabayashi, and Sunzou Takano. New explicit condi-
tions of elliptic curve traces for FR-reduction. IEICE Trans. Fundamentals, E84-
A(5):1234–1243, May 2001.
4. D. Boneh, B. Lynn, and H. Schacham. Short signatures from the Weil pairing.
Journal of Cryptology, 17(4):297–319, 2004.
5. Oliver Schirokauer. The number field sieve for integers of low weight. Cryptology
ePrint Archive, Report 2006/107, 2006. http://eprint.iacr.org/.
6. Victor S. Miller. The Weil pairing, and its efficient calculation. Journal of Cryp-
tology, 17(4):235–261, September 2004.
7. Paulo S. L. M. Barreto, Hae Y. Kim, Ben Lynn, and Michael Scott. Efficient algo-
rithms for pairing-based cryptosystems. In CRYPTO 2002, number 2442 in Lec-
ture Notes in Computer Science, pages 354–369, Berlin Heidelberg, 2002. Springer-
Verlag.
8. Florian Hess, Nigel P. Smart, and Frederik Vercauteren. The Eta Pairing Revisited.
IEEE Transactions on Information Theory, 52(10):4595–4602, October 2006.
9. Paulo S. L. M. Barreto and Michael Naehrig. Pairing-friendly elliptic curves of
prime order. In B. Preneel and S. Tavares, editors, SAC 2005, number 3897
in Lecture Notes in Computer Science, pages 319–331, Berlin Heidelberg, 2006.
Springer-Verlag.
10. Augusto Jun Devegili, Colm Ó hÉigeartaigh, Michael Scott, and Ricardo Dahab.
Multiplication and squaring on pairing-friendly fields. Cryptology ePrint Archive,
Report 2006/471, 2006. http://eprint.iacr.org/.
11. Robert Granger, Dan Page, and Nigel P. Smart. High security pairing-based cryp-
tography revisited. In Florian Hess, Sebastian Pauli, and Michael E. Pohst, edi-
tors, ANTS, volume 4076 of Lecture Notes in Computer Science, pages 480–494.
Springer, 2006.
10
12. Alfred J. Menezes, Paul C. van Oorschot, and Scott A. Vanstone. Handbook of
Applied Cryptography. CRC Press, Boca Raton, 1996.
13. Michael Scott, Neil Costigan, and Wesam Abdulwahab. Implementing crypto-
graphic pairings on smartcards. In L. Goubin and M. Matsui, editors, CHES 2006,
volume 4249 of Lecture Notes in Computer Science, pages 134–147, 2006.
14. Johann Großschädl and Erkay Savas. Instruction set extensions for fast arithmetic
in finite fields GF(p) and GF(2m ). In Marc Joye and Jean-Jacques Quisquater,
editors, CHES 2004, volume 3156 of Lecture Notes in Computer Science, pages
133–147. Springer, 2004.
15. Peter L. Montgomery. Modular multiplication without trial division. Mathematics
of Computation, 44(170):519–521, April 1985.
16. Neal Koblitz and Alfred Menezes. Pairing-based cryptography at high security
levels. In N.P. Smart, editor, Cryptography and Coding 2005, volume 3796 of
Lecture Notes in Computer Science, pages 13–36, Berlin Heidelberg, 2005. Springer-
Verlag.
11