On Karatsuba Multiplication Algorithm

Slides:



Advertisements
Similar presentations
MS 101: Algorithms Instructor Neelima Gupta
Advertisements

Week 3 - Friday.  What did we talk about last time?  AES  Public key cryptography.
hap8.html#chap8ex5.
Insertion Sort by: Jordan Mash CS32 Bryce Boe. How does it work? Essentially the same way you order anything in day to day life. –Cards –Straws –Arrays?
Fast Fourier Transform Lecture 6 Spoken Language Processing Prof. Andrew Rosenberg.
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.
Advanced Information Security 4 Field Arithmetic
Great Theoretical Ideas in Computer Science.
CS252: Systems Programming Ninghui Li Topic 3: Programming in a FIZ: Simple Functional Programming Language.
OOP/Java1 Public Key Crytography From: Introduction to Algorithms Cormen, Leiserson and Rivest.
1 Efficient Algorithms for Elliptic Curve Cryptosystems Original article by Jorge Guajardo and Christof Paar Of WPI ECE Department Presentation by Curtis.
Public Key Crytography1 From: Introduction to Algorithms Cormen, Leiserson and Rivest.
Notes on the analysis of multiplication algorithms.. Dr. M. Sakalli, Marmara University.
FFT1 The Fast Fourier Transform by Jorge M. Trabal.
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
Cryptography1 CPSC 3730 Cryptography Chapter 9 Public Key Cryptography and RSA.
CSC 2300 Data Structures & Algorithms January 30, 2007 Chapter 2. Algorithm Analysis.
Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann.
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
Fall 2010/Lecture 311 CS 426 (Fall 2010) Public Key Encryption and Digital Signatures.
IHP Im Technologiepark Frankfurt (Oder) Germany IHP Im Technologiepark Frankfurt (Oder) Germany ©
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 5 Instructor: Paul Beame TA: Gidon Shavit.
CSE 597E Fall 2001 PennState University1 Digital Signature Schemes Presented By: Munaiza Matin.
 Introduction  Requirements for RSA  Ingredients for RSA  RSA Algorithm  RSA Example  Problems on RSA.
CSCI 398 Research Topics in Computer Science Yana Kortsarts Computer Science Department Widener University Chester, PA.
Pseudo-random Number Generation Qiuliang Tang. Random Numbers in Cryptography ► The keystream in the one-time pad ► The secret key in the DES encryption.
RSA Encryption & Cryptography
The RSA Algorithm Rocky K. C. Chang, March
1 Network Security Lecture 6 Public Key Algorithms Waleed Ejaz
CS 627 Elliptic Curves and Cryptography Paper by: Aleksandar Jurisic, Alfred J. Menezes Published: January 1998 Presented by: Sagar Chivate.
Extended Euclidean Algorithm Presented by Lidia Abrams Anne Cheng.
1 Chapter 5 Divide and Conquer Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Better way for sorting – heap sort , , Department of Computer Science and Information Engineering, Chung Cheng University, Chayi, Taiwan.
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
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.
Public-Key Encryption
The RSA Algorithm. Content Review of Encryption RSA An RSA example.
Divide & Conquer  Themes  Reasoning about code (correctness and cost)  recursion, induction, and recurrence relations  Divide and Conquer  Examples.
Karatsuba’s Algorithm for Integer Multiplication
1Computer Sciences Department. Book: Introduction to Algorithms, by: Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Electronic:
Applied Symbolic Computation1 Applied Symbolic Computation (CS 300) Karatsuba’s Algorithm for Integer Multiplication Jeremy R. Johnson.
Scott CH Huang COM 5336 Cryptography Lecture 6 Public Key Cryptography & RSA Scott CH Huang COM 5336 Cryptography Lecture 6.
Public Key Cryptosystems RSA Diffie-Hellman Department of Computer Engineering Sharif University of Technology 3/8/2006.
Faster Implementation of Modular Exponentiation in JavaScript
1 Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
1 Chapter 4-2 Divide and Conquer Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Zero Knowledge Proofs Matthew Pouliotte Anthony Pringle Cryptography November 22, 2005 “A proof is whatever convinces me.” -~ Shimon Even.
Ch1 - Algorithms with numbers Basic arithmetic Basic arithmetic Addition Addition Multiplication Multiplication Division Division Modular arithmetic Modular.
Introduction to Cryptography Lecture 9. Public – Key Cryptosystems Each participant has a public key and a private key. It should be infeasible to determine.
Lecture 9 Elliptic Curves. In 1984, Hendrik Lenstra described an ingenious algorithm for factoring integers that relies on properties of elliptic curves.
Computer Security Lecture 5 Ch.9 Public-Key Cryptography And RSA Prepared by Dr. Lamiaa Elshenawy.
1 How to Multiply Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. integers, matrices, and polynomials.
Young CS 331 D&A of Algo. Topic: Divide and Conquer1 Divide-and-Conquer General idea: Divide a problem into subprograms of the same kind; solve subprograms.
R. Johnsonbaugh, Discrete Mathematics 5 th edition, 2001 Chapter 3 Algorithms.
Lecture 3 (Chapter 9) Public-Key Cryptography and RSA Prepared by Dr. Lamiaa M. Elshenawy 1.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 16.
1 The RSA Algorithm Rocky K. C. Chang February 23, 2007.
Efficient Montgomery Modular Multiplication Algorithm Using Complement and Partition Techniques Speaker: Te-Jen Chang.
week 8Complexity of Algorithms1 Elementary Number Theory Given positive integers a and b, we use the notation a¦b to indicated that a divides b, i.e.,
RSA Algorithm Date: 96/10/17 Wun-Long Yang. Outline Introduction to RSA algorithm RSA efficient implementation & profiling.
Administrative Details Grade – 80% test, 20% homework 4-5 homework assignments Office hours after lesson Tel
An Optimized Hardware Architecture for the Montgomery Multiplication Algorithm Miaoqing Huang Nov. 5, 2010.
Public Key Cryptosystem
D. Cheung – IQC/UWaterloo, Canada D. K. Pradhan – UBristol, UK
Administrative Details
ICS 353: Design and Analysis of Algorithms
The Application of Elliptic Curves Cryptography in Embedded Systems
Advanced Analysis of Algorithms
Presentation transcript:

On Karatsuba Multiplication Algorithm Associate Prof. Fang

1. Introduction Certain public key cryptographic algorithms such as RSA and ECC, the large integer multiplication is the basic operation of multiple precision integer arithmetic

1. Introduction The literature about multiplication arithmetic covers: Classical Knuth multiplication(O(n2)) Karatsuba multiplication(O(nlog3)) Fast Fourier Transform trick(O(nlogn)) Schönhage-Strassen trick(O(nlognloglogn)) …

1. Introduction Most of the multiplication techniques are “divide and conquer” tools. But, Daniel J. Bernstein said: “It is a mistake to use a single method recursively all the way down to tiny problems. The optimal algorithm will generally use a different method for the next level of reduction, and so on.”

1. Introduction My short paper presents a new multiplication trick by using classical Knuth multiplication and Karatsuba multiplication, and finds the condition under which the efficiency of multiplication is optimal in theory and in practice.

2. Classical Knuth multiplication Let p=(u1u2…un)b, q=(v1v2…vm)b, the product is w=pq=(w1w2…wm+n)b. Here is the classical Knuth multiplication to compute the product w: step1. w1, w2,…,wm+n←0, j←m; step2. if vj =0 then wj←0 goto step6; step3. i←n, k←0; step4. t←ui×vj+wi+j+k, wi+j←t mod b, k ← ; step5. i←i-1, if i>0 then goto step4 else wj←k; step6. j←j-1, if j>0 then goto step2 else exit; It is obvious that the time complexity of this algorithm is O (mn).

3. Karatsuba multiplication Let p=(u1u2…un)b, q=(v1v2…vn)b. In 1963, Karatsuba wrote p×q as the following formula: where r0= p0q0 , r1 = p1q1, r2 = ( p1 + p0 )(q1 + q0 ) . We can obtain the product by using “divide and conquer” method recursively. Let T(n) be computation time of multiplication p×q, we can get the recursion of time complexity easily: So we get T(n)=9nlog3-10n=O(nlog3)

4. A new multiplication trick Theorem 1. There exists n such that the computational time of Knuth classical multiplication is less than that of Karatsuba multiplication.

4. A new multiplication trick Proof Let T1(n) be computation time of classical Knuth multiplication and T2(n) be computation time of Karatsuba multiplication. According to the previous analysis, we have T1(n)=n2, T2(n)=9nlog3-10n There exists n such that T1(n)≤T2(n), that is n2 ≤ 9 nlog 3 −10n < 9 ⋅ nlog 3 we can calculate Therefore, if n<256, then classical Knuth multiplication is more efficient than Karatsuba multiplication.

4. A new multiplication trick Theorem 2: the efficiency of Karatsuba multiplication is optimal when n>16(n=2k), Karatsuba multiplication algorithm is called recursively, and if n=16, then recursion call is returned, classical Knuth multiplication is used to compute the product of two smaller integers. Proof Let T(n) be computation time of Karatsuba multiplication. We assume that if n>m then Karatsuba algorithm is called recursively, else classical Knuth multiplication is used. Therefore, we have

4. A new multiplication trick Let n=2k, h(k)=T(n)=T(2k), T(n) can be written as Let m=2i, we get Let f(i)=(4i+10·2i)/3i, the value of function f(i) is minimum when That is, when i=4, m=2i=16, the value of T(n) is minimum.

5. Experiment results and conclusion Precondition: some simple assembly language codes may be called to compute the product of two 32-bit positive integers. The time complexity of this base operation is O(1). _ _asm{ mov eax, x xor edx, edx mul y ; Product in edx:eax mov ebx, p mov dword ptr [ebx], eax mov dword ptr [ebx+4], edx }

5. Experiment results and conclusion Test environment:AMD Athlon CPU 1.1GHz, 256M RAM, Windows XP OS and MS Visual C++ 6.0 compiler.

5. Experiment results and conclusion Table 1: the computation time comparison of three algorithms Digits (radix 232) Knuth Karatsuba New trick 256 0.03 0.01 512 0.04 0.11 1024 0.17 0.381 0.05 2048 0.721 0.961 0.13 4096 2.734 2.874 8192 10.966 8.322 1.141 Where Digits is the length of multiplier integer in radix 232 representation.

5. Experiment results and conclusion Table 1 shows that the new multiplication trick obviously decreases computational time than that of the classical Knuth multiplication and Karatsuba multiplication.

References R. L. Rivest, A. Shamir, L. Adleman, “A Method for Obtaining Digital Signatures and Public-Key Cryptosystems”. Communications of the ACM,1978,21(2), pp. 120-126. Michael Rosing, Implementing Elliptic Curve Cryptography, Manning Publications Co. , Greenwich, 1999. Anatoly A. Karatsuba, Y. Ofman, “Multiplication of multi-digit numbers on automata”, Soviet Physics Doklady 7, 1963, pp. 595-596. Dan Zuras, “On Squaring and Multiplying Large Integers”, ARITH-11: IEEE Symposium on Computer Arithmetic, 1993, pp. 260-271. Reprinted as “More on Multiplying and Squaring Large Integers”, IEEE Transactions on Computers, volume 43, number 8, August 1994, pp. 899-908. E. Oran Brigham, The fast Fourier transform and its applications, Prentice-Hall, Englewood Cliffs, New Jersey, 1988. A. SchÖnhage and V. Strassen, “Schnelle Multiplikation groβer Zahlen”, Computing 7, 1971, pp. 281-292.

References Daniel J. Bernstein. “Multidigit Multiplication for Mathematicians”. http://cr.yp.to/papers/m3.pdf, 2001.08.11. Donald E. Knuth, The Art of Computer Programming, Vol 2 Seminumerical Algorithms (second edition), Addison-Wesley, Massachusetts, 1981. Tom St Denis, BigNum Math Implementing Cryptographic Multiple Precision Arithmetic, SYNGRESS Publishing, 2003. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein, Introduction to Algorithms(Second Edition), The MIT Press, Massachusetts, 2001. A. Menezes, P. van, Oorschot, S. Vanstone, Handbook of Applied Cryptography, CRC Press Inc., 1996.

Thank you!