Download presentation
Presentation is loading. Please wait.
1
implementations in a functional language
Prime factorization implementations in a functional language
2
Introduction Introduction Fermat’s algorithm Pollard’s rho algorithm Goal: Get a better understanding of the implementation and application of different factorization algorithms (Fermat’s, Pollard’s rho, Quadratic sieve, Elliptic curve) Elliptic curve factorization Summary
3
Fermat’s algorithm Observation:
Introduction Fermat’s algorithm Observation: All composite numbers can be written as the difference between two squared numbers, i.e. Pollard’s rho algorithm Elliptic curve factorization Summary
4
Fermat’s algorithm Algorithm:
Introduction Algorithm: Assume n is an odd number (otherwise, factor out 2 until is odd). Define , Iteratively find If is a square , then and are factors of . If then stop and report as a prime. Fermat’s algorithm Pollard’s rho algorithm Elliptic curve factorization Summary
5
Fermat’s algorithm Is the algorithm correct? Does it terminate?
Introduction Fermat’s algorithm Pollard’s rho algorithm Elliptic curve factorization Is the algorithm correct? Does it terminate? Summary
6
Fermat’s algorithm Correctness: The algorithm is correct iff
Introduction Correctness: The algorithm is correct iff Assume Then Fermat’s algorithm Pollard’s rho algorithm Elliptic curve factorization Summary Now assume Then Leading to the factor
7
Fermat’s algorithm Termination:
Introduction Fermat’s algorithm Pollard’s rho algorithm Termination: Termination follows trivially from the fact that we iterate over a finite range. Elliptic curve factorization Summary
8
Fermat’s algorithm Code: Introduction Fermat’s algorithm Pollard’s rho
(define (fermat-single n) (let* ((s (get-sqrt n)) (r (cdr s)) (m (- (expt r 2) n)) (r-stop (/ (+ n 1) 2))) (letrec ((iterator (lambda () (if (>= r r-stop) (cons n '()) (begin (set! s (get-sqrt m)) (if (car s) (cons (+ r (cdr s)) (- r (cdr s))) (set! m (+ m (* 2 r) 1)) (set! r (+ r 1)) (iterator)))))))) (cons r r) (iterator))))) Pollard’s rho algorithm Elliptic curve factorization Summary
9
Fermat’s algorithm Running times: Introduction Fermat’s algorithm
Pollard’s rho algorithm Elliptic curve factorization Summary
10
Pollard’s rho algorithm
Introduction Fermat’s algorithm Observation: If and are in different residue class modulo , but in the same class modulo a proper divisor of , then will result in a proper divisor of . Pollard’s rho algorithm Elliptic curve factorization Summary
11
Pollard’s rho algorithm
Introduction Algorithm: Choose a “random” function Define , , , and Iteratively find If then is a factor If then go to step 1 or report as “maybe prime” Fermat’s algorithm Pollard’s rho algorithm Elliptic curve factorization Summary
12
Pollard’s rho algorithm
Introduction Fermat’s algorithm Pollard’s rho algorithm Elliptic curve factorization Is the algorithm correct? Does it terminate? Summary
13
Pollard’s rho algorithm
Introduction Correctness: Since the range of is finite, the and values must cycle. It should be clear that cycles twice as fast as , so if we go through a cycle with then , so If, however, , then is a non-trivial factor of . Fermat’s algorithm Pollard’s rho algorithm Elliptic curve factorization Summary
14
Pollard’s rho algorithm
Introduction Fermat’s algorithm Pollard’s rho algorithm Termination: Termination follows from the cycling of the values and guaranteed termination when cycling has happened. Elliptic curve factorization Summary
15
Pollard’s rho algorithm
Introduction Code: Fermat’s algorithm (define (pollard-rho-single n) (let ((a 2) (b 2) (c 1)) (letrec ((iterator (lambda () (begin (set! a (modulo (+ (expt a 2) c) n)) (set! b (modulo (+ (expt b 2) c) n)) (let ((d (gcd (- a b) n))) (cond ((and (> d 1) (< d n)) (cons d (quotient n d))) ((= d n) (if (= c 2) (cons n '()) (begin (set! a 2) (set! b 2) (set! c (+ c 1)) (iterator)))) (else (iterator)))))))) Pollard’s rho algorithm Elliptic curve factorization Summary
16
Pollard’s rho algorithm
Introduction Running times: Fermat’s algorithm ? The algorithm is too fast even without optimizations when the number has any “small” factors (smaller than 10 digits). I have had problems finding enough values to analyse on that give non-eligible running times, but are still feasible to factorize. (It factors into x in 2,5s) Pollard’s rho algorithm Elliptic curve factorization Summary
17
Pollard’s rho algorithm
Introduction Running times: Fermat’s algorithm Pollard’s rho algorithm Elliptic curve factorization Summary
18
Elliptic curve factorization
Introduction Fermat’s algorithm Observation: Iteratively applying a group function to a series of points starting on a random point in a group defined by an elliptic curve modulo the number we are factorizing we will eventually find a generator for the subgroup we iterate over. Using the order of this subgroup, we can determine a factor of n. Pollard’s rho algorithm Elliptic curve factorization Summary
19
Elliptic curve factorization
Introduction Code: Fermat’s algorithm (define (elliptic-curve-single n) (let ((a 1) (p (cons 0 5)) (e 2)) (letrec ((iterator (lambda () (begin (set! p (point-expt p e a)) (set! e (+ e 1)) (if (not (pair? p)) (if (symbol? p) (cons n '()) (cons p (quotient n p))) (iterator)))))) (iterator))))) Pollard’s rho algorithm Elliptic curve factorization Summary
20
Elliptic curve factorization
Introduction Running times: Fermat’s algorithm Pollard’s rho algorithm Elliptic curve factorization Summary
21
Summary The following insight was gained through the project
Introduction Fermat’s algorithm Pollard’s rho algorithm The following insight was gained through the project The elliptic curve algorithm is not fast in it’s ”natural form”, but becomes fast as elliptic curve knowledge is applied as optimizations. The implementation of the sieving process in quadratic sieve is complex and confusing A better understanding of the implemented algorithms Elliptic curve factorization Summary
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.