Efficient Implementation of Cryptographic pairings Mike Scott Dublin City University.

Slides:



Advertisements
Similar presentations
Key Management Nick Feamster CS 6262 Spring 2009.
Advertisements

Pairing Friendly Elliptic Curves of Prime Order with Embedding degree 12 Paulo Barreto and Michael Naehrig Presented by Mike Scott.
An Introduction to Pairing Based Cryptography Dustin Moody October 31, 2008.
Cryptography and Network Security
Parshuram Budhathoki FAU October 25, /25/2012 Ph.D. Preliminary Exam, Department of Mathematics, FAU.
Graduate School of Natural Science and Technology Okayama University Yumi Sakemi, Hidehiro Kato, Shoichi Takeuchi, Yasuyuki Nogami and Yoshitaka Morikawa.
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
The XTR public key system (extended version of Crypto 2000 presentation) Arjen K. Lenstra Citibank, New York Technical University Eindhoven Eric R. Verheul.
Implementing Cryptographic Pairings on Smartcards Mike Scott.
Great Theoretical Ideas in Computer Science.
YSLInformation Security -- Public-Key Cryptography1 Elliptic Curve Cryptography (ECC) For the same length of keys, faster than RSA For the same degree.
CNS2010handout 8 :: introduction to number theory1 computer and network security matt barrie.
Cryptography and Network Security Chapter 4
1 Efficient Algorithms for Elliptic Curve Cryptosystems Original article by Jorge Guajardo and Christof Paar Of WPI ECE Department Presentation by Curtis.
The RSA Cryptosystem and Factoring Integers (II) Rong-Jaye Chen.
Factoring 1 Factoring Factoring 2 Factoring  Security of RSA algorithm depends on (presumed) difficulty of factoring o Given N = pq, find p or q and.
Hidden pairings and trapdoor DDH groups Alexander W. Dent Joint work with Steven D. Galbraith.
Dr. Lo’ai Tawalbeh Fall 2005 Chapter 10 – Key Management; Other Public Key Cryptosystems Dr. Lo’ai Tawalbeh Computer Engineering Department Jordan University.
CMSC 414 Computer and Network Security Lecture 6 Jonathan Katz.
Cryptography1 CPSC 3730 Cryptography Chapter 9 Public Key Cryptography and RSA.
CPE5021 Advanced Network Security --- Advanced Cryptography: Elliptic Curve Cryptography --- Lecture 3 CPE5021 Advanced Network Security --- Advanced Cryptography:
RSA Question 2 Bob thinks that p and q are primes but p isn’t. Then, Bob thinks ©Bob:=(p-1)(q-1) = Á(n). Is this true ? Bob chooses a random e (1 < e
Lecture 6: Public Key Cryptography
The RSA Algorithm Rocky K. C. Chang, March
Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Copyright © The McGraw-Hill Companies, Inc. Permission required.
May 29, 2008 GNFS polynomials Peter L. Montgomery Microsoft Research, USA 1 Abstract The Number Field Sieve is asymptotically the fastest known algorithm.
Implementing Cryptographic Pairings Mike Scott TexPoint fonts used in EMF: AAAA A A AAAA A AA A A A.
FINITE FIELDS 7/30 陳柏誠.
CPSC 3730 Cryptography and Network Security
Information Security and Management 4. Finite Fields 8
Cryptography and Network Security Introduction to Finite Fields.
The Polynomial Time Algorithm for Testing Primality George T. Gilbert.
By: Hector L Contreras SSGT / USMC
Great Theoretical Ideas in Computer Science.
Great Theoretical Ideas in Computer Science.
PRIMES is in P Manindra Agrawal NUS Singapore / IIT Kanpur.
Advanced Algebraic Algorithms on Integers and Polynomials Prepared by John Reif, Ph.D. Analysis of Algorithms.
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
Cryptography and Network Security (CS435) Part Eight (Key Management)
Cryptography and Network Security Chapter 10 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Chapter 4 – Finite Fields
Data Security and Encryption (CSE348) 1. Lecture # 12 2.
Chapter 3 (B) – Key Management; Other Public Key Cryptosystems.
Scott CH Huang COM 5336 Cryptography Lecture 6 Public Key Cryptography & RSA Scott CH Huang COM 5336 Cryptography Lecture 6.
Understanding Cryptography by Christof Paar and Jan Pelzl These slides were prepared by Tim Güneysu, Christof Paar and Jan Pelzl.
Information Security Lab. Dept. of Computer Engineering 87/121 PART I Symmetric Ciphers CHAPTER 4 Finite Fields 4.1 Groups, Rings, and Fields 4.2 Modular.
9/22/15UB Fall 2015 CSE565: S. Upadhyaya Lec 7.1 CSE565: Computer Security Lecture 7 Number Theory Concepts Shambhu Upadhyaya Computer Science & Eng. University.
CS Modular Division and RSA1 RSA Public Key Encryption To do RSA we need fast Modular Exponentiation and Primality generation which we have shown.
Cryptography and Network Security Chapter 4. Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic.
11 RSA Variants.  Scheme ◦ Select s.t. p and q = 3 mod 4 ◦ n=pq, public key =n, private key =p,q ◦ y= e k (x)=x (x+b) mod n ◦ x=d k (y)=  y mod n.
Key Management Network Systems Security Mort Anvari.
Pertemuan #5 Pengantar ke Number Theory Kuliah Pengaman Jaringan.
9.1 Primes and Related Congruence Equations 23 Sep 2013.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Implementation of Public Key Encryption Algorithms
Introduction to Elliptic Curve Cryptography CSCI 5857: Encoding and Encryption.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
1 The RSA Algorithm Rocky K. C. Chang February 23, 2007.
Cryptography services Lecturer: Dr. Peter Soreanu Students: Raed Awad Ahmad Abdalhalim
Key Exchange in Systems VPN usually has two phases –Handshake protocol: key exchange between parties sets symmetric keys –Traffic protocol: communication.
Public Key Encryption Major topics The RSA scheme was devised in 1978
CSE565: Computer Security Lecture 7 Number Theory Concepts
An Introduction to Pairing Based Cryptography
D. Cheung – IQC/UWaterloo, Canada D. K. Pradhan – UBristol, UK
Introduction to Number Theory
An Introduction to Pairing Based Cryptography
Lecture 20 Guest lecturer: Neal Gupta
RS – Reed Solomon List Decoding.
Mathematical Background for Cryptography
Presentation transcript:

Efficient Implementation of Cryptographic pairings Mike Scott Dublin City University

First Steps  To do Pairing based Crypto we need two things Efficient algorithms Suitable elliptic curves  We have got both! (Maybe not quite enough suitable curves?)

What’s a Pairing?  e(P,Q) where P and Q are points on an elliptic curve.  It has the property of bilinearity  e(aP,bQ) = e(bP,aQ) = e(P,Q) ab  We use the Tate pairing.

Hard problems… 1. Given aP and P, its hard to find a 2. Given e(P,Q) a and e(P,Q) its hard to find a. 3. Given {P,sP,aP,Q,sQ,bQ} its hard to find e(P,Q) sab

Making it secure  Recall that on a pairing friendly elliptic curve E(F q ), the curve order has a large prime divisor r, and where k is the smallest integer such that r|q k -1  k is the embedding degree, a.k.a. the security multiplier  Pairings evaluates as element in F q k

Making it secure  If r is 160-bits, then Pohlig-Hellman attacks will take ~ 2 80 steps  If k.lg(q) ~ 1024 bits, Discrete Log attacks will also take ~ 2 80 steps  So we can achieve appropriate levels of cryptographic security

Modified Tate Pairing  Supersingular curves support a distortion map, Φ(Q) which evaluates as a point on E(F q k ) if Q is on E(F q ).  So choose P and Q on E(F q ), then ê(P,Q) =e(P, Φ(Q))  Is an alternative, nicer (Type 1) pairing, with the extra property ê(P,Q) = ê(Q,P)

A quick protocol..  Sakai and Kasahara non-interactive ID-based key exchange.  A trusted authority with secret s give Alice sA, where A is derived in a public way from Alices identity.  The trusted authority gives Bob sB.  They share a key ê (sA,B)= ê (sB,A)!  No interaction required!

What choices?  If q=p a prime, maximum k=2  If q=2 m, maximum k=4  If q=3 m, maximum k=6  We need group size r ≥ 160 bits  We need q k ~ 1024 bits  We know r | q+1-t  (t is trace of the Frobenius ≤ 2 √q)

Constrained…  These constraints are… well… constraining!  I have an irrational aversion to F 3 m !  So what about Hyperelliptic curves…?  Not very promising in practice…  Fortunately, we have an alternative choice – certain families of ordinary elliptic curves over F p

Ordinary Elliptic Curves  There are the MNT curves, with k={3,4,6}  There are Freeman curves with k=10  There are Barreto-Naehrig curves with k=12

Ordinary Elliptic Curves  These curves all have r~p, which is nice, as it means P can be over the smallest possible field for given level of security  If we relax this, many more families can be found (e.g. Brezing-Weng)  If we allow lg(r) ≤ 2.lg(p) then curves for any k are plentiful (Cocks-Pinch)

The bad news..  No distortion map  (Type 3 pairing)  In e(P,Q), while P can be in E(F p ), Q cannot.  The best we can do is to put Q on a lower order “twist” E(F p k/w ), where always w=2, (but w=4 and w=6 are possible).  For example for BN curves we can use w=6 and put Q on E(F p 2 )  e(P,Q) ≠ e(Q,P)

Implementation  For simplicity (for now)  Assume k=2d, d=1, p=3 mod 4  Elements in F p 2 can be represented as (a+ib), where a and b are in F p and i=√-1 because -1 is a quadratic non-residue (think “imaginary number”)  Assume P is in E(F p ), Q in E(F p 2 )

Basic Algorithm for e(P,Q) m ← 1, T ← P for i=lg(r)-1 downto 0 do m ← m 2.l T,T (Q)/v 2T (Q) T ← 2.T if r i = 1 m ← m.l T,P (Q)/v T+P (Q) T=T+P end if end forMillers Algorithm m ← m (p-1) Final Exponentiation return m (p+1)/r

l T,T (Q) = (y q -y j ) – λ j (x q -x j ) v 2T (Q) =x q -x j+1 Explaining the Algorithm Q(x q,y q ) T=(x j,y j ) x q -x j y q -y j Line of slope λ j x j+1,y j+1

Optimizations  Choose r to have a low Hamming weight  By cunning choice of Q as a point on the twisted curve and using only even k=2d, the v(.) functions become elements in F p d and hence get “wiped out” by the final exponentiation, which always includes p d -1 as a factor of the exponent.  Now the algorithm simplifies to…

Improved Algorithm m ← 1, T ← P for i=lg(r)-1 downto 0 do m ← m 2.l T,T (Q) T ← 2.T if r i = 1 m ← m.l T,P (Q) T=T+P end if end for m ← m (p-1) return m (p+1)/r

A useful Observation..  Observe the line m ← m (p-1)  Part of the final exponentiation – raising to the power of (p k -1)/r  Now for any c in F p, c (p-1) = 1 mod p (Fermat)  Therefore m can be multiplied by any constant at any time in the Miller loop without effecting the final result!

Further optimization ideas  Truncate the loop in Miller’s algorithm, and still get a viable pairing.  Optimize the final exponentiation  Exploit the Frobenius – an element of any extension field F q k can easily be raised to any power of q. For example in F p 2 (a+ib) p = (a-ib)

Further optimization ideas  Precomputation!  If P is fixed, all the T values can be precomputed and stored – with significant savings.  P may be a fixed public value or a fixed secret key – depends on the protocol.

The η T pairing - 1  For the supersingular curves of low characteristic, the basic algorithm can be drastically simplified by integrating the distortion map, the point multiplication, and the action of the Frobenius directly into the main Miller loop. Also exploits the simple group order. This is a Type 1 pairing.

The η T pairing - 2  In characteristic 2, k=4.  r =2 m ± 2 [(m+1)]/2 + 1  Elements in F 2 m are represented as a polynomial with m coefficients in F 2  Elements in the extension field F 2 4m are represented as a polynomial with 4 coefficients in F 2 m  e.g. a+bX+cX 2 +dX 3 represented as [a,b,c,d].

The η T pairing - 3  Let s=[0,1,1,0] and t=[0,1,0,0] (derived from the distortion map)  Then on the supersingular curve y 2 +y=x 3 +x+b, where b=0 or 1  And m= 3 mod 8  A pairing e(P,Q), where P=(x P,y P ) and Q=(x Q,y Q ), can be calculated as

The η T pairing - 4 u←x P +1 f←u(x P +x Q +1)+y P +y Q +b+1+(u+x Q )s+t for i=1 to (m+1)/2 do u←x P x P ←√x P y P ←√y P g←u(x P +x Q )+y P +y Q +x P +(u+x Q )s+t f←f.g x Q ←x Q 2 y Q ←y Q 2 end for return f (2 2m -1)(2 m -2 (m+1)/2 +1)

The η T pairing - 5  This is very fast! <5 seconds on an msp430 wireless sensor network node, with m=271 (C – no asm)  Note truncated loop (m+1)/2.  Final exponentiation very fast using Frobenius.  Ideal in low power, resource constrained environment.

Ate Pairing for ordinary curves E(F p )  Truncated Loop pairing, related to Tate pairing.  Number of iterations in Miller loop may be much shorter – lg(t-1) instead of lg(r), and for some families of curves t can be much less than r  Parameters “change sides”, now P is on the twisted curve and Q is on the curve over the base field.  Works particularly well with curves that allow a higher order (sextic) twist.

Extension Field Arithmetic  For non-supersingular curves over F p k there is a need to implement very efficient extension field arithmetic.  A new challenge for cryptographers (although XTR and OEFs require it)  Simple generic polynomial representation will be slow, and misses optimization opportunities.

Towering extensions  Consider p=5 mod 8  Then a suitable representation for F p 2 would be (a+xb), where a,b are in F p, x=(-2) 1/2, as -2 will be a QNR.  Then a suitable representation for F p 4 would be (a+xb), where a,b are in F p 2, x=(-2) 1/4  Etc!

Towering extensions  In practise it may be sufficient to restrict k=2 i 3 j for i≥1, j≥0, as this covers most useful cases.  So only need to deal with cubic and quadratic towering.  These need only be efficiently developed once (using Karatsuba, fast squaring, inversion, square roots etc.)

Multiplication & Squaring (quadratic extension)  Using Karatsuba..  (a+ib)(c+id) = ac- bd+i[(a+b)(c+d)-ac-bd]  Requires 3 modmuls…  OR 3 multiplications and 2 modular reductions (“lazy” reduction)  (a+ib)(a+ib)=(a+b)(a-b)+i.2ab

Multiplication & Squaring (cubic extension)  Toom-Cook for multiplication?  Chung-Hasan for squaring?  A problem with both methods is the requirement for division by small constants…  Not a problem thanks to the “useful observation”!

Choice of irreducible polynomial  A binomial is the simplest, x n +δ, and the easiest to tower over.  For example for k=12 BN curves  X 6 +(1+√-2) as a sextic tower over x 2 +2, where (1+√-2) is neither a cube nor a square. ..and so the sextic extension can be constructed as a cubic over a quadratic

Choice of irreducible polynomial  In general the k-th extension can often be constructed as x k/2 +(α+√β) towered over x 2 +√β, where α, β in {-1,+1,-2,+2}  In practise this seems to work well, and the small values for α, β lead to useful speed-ups.  Not too restrictive..

The Final Exponentiation - 1  Note that the exponent is (p k -1)/r  This is a number dependent only on fixed, system parameters  So maybe we can choose p, k and r to make it easier (Low Hamming Weight?)  If k=2d is even then (p k -1)/r = (p d -1).[(p d +1)/r]

The Final Exponentiation - 2  We know that r divides (p d +1) and not (p d -1) from the definition of k.  Exponentiation to the power of p d is “for free” using the Frobenius, so exponentiation to the power of p d -1 costs just a Frobenius and a single extension field division – cheap!

The Final Exponentiation - 3  In fact we know that the factorisation of (p k -1) always includes Φ k (p), where Φ k (.) is the k- th cyclotomic polynomial, and that r|Φ k (p).  For example p 6 -1 = (p 3 -1)(p+1)(p 2 -p+1)  Where Φ 6 (p) = p 2 -p+1

The Final Exponentiation - 4  So the final exponent is general breaks down as… (p d -1).[(p d +1)/Φ k (p)].Φ k (p)/r  All except the final Φ k (p)/r part can be easily dealt with using the Frobenius.

The Final Exponentiation - 5  However this “hard” exponent e can always be represented to base p as e=e 0 +e 1 p+e 2 p 2 … f e = f e 0 +e 1 p+e 2 p 2 … = f e 0.(f p ) e 1.(f p 2 ) e 2 …  Which can be calculated using the Frobenius and the well known method of multi-exponentiation.

The Final Exponentiation - 6  Another idea is to exploit the special form of the “hard part” of the final exponentiation for a particular curve  If k is divisible by 2 the pairing value can be “compressed” times 2 and Lucas exponentiation used.  If k is divisible by 3 the pairing value can be “compressed” times 3 and XTR exponentiation used.

Case study – k=6 MNT curves  Assuming a prime order curve, then the hard part of the final exponent is (p 2 -p+1)/r, where r=p+1-t  Then the exponent is p±σ, where σ ~ t  So the final exponentiation is f p.f ±σ  Which just costs a Frobenius and one half-length exponentiation!

Products of pairings  Arises in many protocols  e(P,Q).e(R,S)  3 ideas The multiplication of P and R by r occur in “lock-step”, so use Montgomery’s trick, affine coordinates, only one modular inversion Share the “Miller variable” m (so only one squaring of m in the Miller loop) Share the final exponentiation

Implementation – more complex than RSA or ECC!  There are many choices of curves, and of embedding degrees, and of pairings. It is not at all obvious which is “best” for any given application. The optimal pairing to use depends not just on the security level, but also on the protocol to be implemented.

Implementation – more complex than RSA or ECC!  For example (a) p~512 bits and k=2, or (b) p~170 bits and k=6 MNT curve?  On the face of it same security.  Smaller p size means faster base field point multiplications – so (b) looks better  Which is important only if point multiplications are required by the protocol.  (a) pairing is much faster if precomputation is possible  (b) must be used for short signatures  (b) requires Q on the twist E’(F p 3 ) which is more complicated than (a) for which Q can be on E’(F p )  The (b) curves are hard to find, whereas (a) types are plentiful.  (a) is much simpler to implement with the smaller extension.. Smaller code

Implementation – more complex than RSA or ECC!  For maximum efficiency each implementation must be highly specialised according to its parameters.  A k=2 Cocks-Pinch implementation will be quite different from a k=6 MNT implementation.

Some timings – 80-bit security  32-bit 3GHz PIV  Tate Pairing  k=2, p~512 bits Cocks-Pinch  w/o precomp. = 6.7ms  With precomp. = 3.0ms  Point mul. = 2.9ms

Some timings – 80-bit security  32-bit 3GHz PIV  Tate Pairing  k=2, p~512 bits with Efficient Endomorphism (Scott ’05)  w/o precomp. = 5.1ms  With precomp. = 3.0ms  Point mul. = 1.9ms

Some timings – 80-bit security  32-bit 3GHz PIV  Ate pairing  k=4, p~256 bits FST curve  w/o precomp. = 9.1ms  With precomp. = 3.1ms  Point mul. = 1.1ms

Some timings – 80-bit security  32-bit 3GHz PIV  Tate pairing  k=6, p~160 bits MNT curve  w/o precomp. = 6.2ms  With precomp. = 4.5ms  Point mul. = 0.6ms

Some timings – 80-bit security  8-bit 16MHz Atmel128  Tate pairing  k=4, p~256 bits MNT curve  With precomp. = 7.75 seconds

Some timings – 80-bit security  8-bit 16MHz Atmel128  η T pairing  k=4, m=271 bits, supersingular curve  w/o precomp = 2.6 seconds

Some timings – 128-bit security  3.4GHz PIV 32-bit  Tate pairing  k=12, p~256 bits BN curve  w/o precomp. = 34.0ms  Ate pairing  w/o precomp. = 23.2ms

Questions Anyone?