Modular Arithmetic and Primality

Modular Arithmetic and Primality Modular Arithmetic and Primality

axon.cs.byu.edu
from axon.cs.byu.edu More from this publisher
01.01.2015 Views

Given an integer p, we want to state if it is prime or not (i.e. it is only divisible by 1 and itself) Could check all factors, but... All known approaches to factoring take exponential time How about trying to divide by all numbers less then p/2 We have Fermat’s little theorem Some examples If p is prime, then a p-1 ≡ 1 mod p for any a such that 1 ≤ a < p CS 312 - Complexity Examples - Arithmetic and RSA 28

function primality(N) Input: Positive integer N Output: yes/no // a is random positive integer between 2 and N-1 a = uniform(2 … N-1) if (modexp(a, N-1, N) == 1): return yes else: return no Is this correct CS 312 - Complexity Examples - Arithmetic and RSA 29

Given an integer p, we want to state if it is prime or not<br />

(i.e. it is only divisible by 1 <strong>and</strong> itself)<br />

Could check all factors, but...<br />

All known approaches to factoring take exponential time<br />

How about trying to divide by all numbers less then p/2<br />

We have Fermat’s little theorem<br />

Some examples<br />

If p is prime, then a p-1 ≡ 1 mod p<br />

for any a such that 1 ≤ a < p<br />

CS 312 - Complexity Examples - <strong>Arithmetic</strong> <strong>and</strong> RSA 28

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!