Date post: | 13-Dec-2015 |
Category: |
Documents |
Upload: | sherilyn-shields |
View: | 220 times |
Download: | 0 times |
David Evanshttp://www.cs.virginia.edu/~evans
Lecture 13: Astrophysics and Cryptology
CS200: Computer ScienceUniversity of Virginia
Computer Science
13 February 2002 CS 200 Spring 2002 2
Menu
• Quicksort Recap
• DeGrasse Tyson’s Essay
• Cryptography (CS588 condensed)
13 February 2002 CS 200 Spring 2002 4
Quicksort
(define (quicksort cf lst) (if (null? lst) lst (append (quicksort cf (filter (lambda (el) (cf el (car lst))) (cdr lst))) (list (car lst)) (quicksort cf (filter (lambda (el) (not (cf el (car lst)))) (cdr lst))))))
13 February 2002 CS 200 Spring 2002 5
filter
(define (filter f lst) (insertlg (lambda (el rest)
(if (f el) (cons el rest) rest)) lst null)) How much work is filter?
(n)
13 February 2002 CS 200 Spring 2002 6
Quicksort
• filter is (n)• How much work is Quicksort if the input
list is sorted?
Worst Case: (n2)we filter n times, each is (n)
(define (quicksort cf lst) (if (null? lst) lst (append (quicksort cf (filter (lambda (el) (cf el (car lst))) (cdr lst))) (list (car lst)) (quicksort cf (filter (lambda (el) (not (cf el (car lst)))) (cdr lst))))))
13 February 2002 CS 200 Spring 2002 7
Quicksort
• filter is (n)• How much work is Quicksort if the input list is
random?
Each time we split the list, each piece is approximately ½ the length of the original listWe need log2 n splits to get down to empty listBest (Average) Case: (n log2 n)
we filter log2 n times, each is (n)
(define (quicksort cf lst) (if (null? lst) lst (append (quicksort cf (filter (lambda (el) (cf el (car lst))) (cdr lst))) (list (car lst)) (quicksort cf (filter (lambda (el) (not (cf el (car lst)))) (cdr lst))))))
13 February 2002 CS 200 Spring 2002 8
> (define r1000 (rand-int-list 1000))> (time (sort < r1000))cpu time: 1372 real time: 1372 gc time: 0> (time (quicksort < r1000))cpu time: 71 real time: 70 gc time: 0> (define r2000 (rand-int-list 2000))> (time (sort < r2000))cpu time: 5909 real time: 5909 gc time: 0> (time (quicksort < r2000))cpu time: 180 real time: 180 gc time: 0> (time (quicksort < (revintsto 1000)))cpu time: 2684 real time: 2684 gc time: 0
13 February 2002 CS 200 Spring 2002 9
0
2000
4000
6000
8000
10000
12000
2
10
18
26
34
42
50
58
66
74
82
90
98
n log2 n(quicksort)
n2 (bubblesort)
Growth of time to sort random list
13 February 2002 CS 200 Spring 2002 11
Astrophysics• “If you’re going to use your computer to simulate
some phenomenon in the universe, then it only becomes interesting if you change the scale of that phenomenon by at least a factor of 10. … For a 3D simulation, an increase by a factor of 10 in each of the three dimensions increases your volume by a factor of 1000.”
• How much work is astrophysics simulation (in notation)?
(n3)When we double the size of the simulation, the work octuples! (Just like oceanography octopi simulations)
13 February 2002 CS 200 Spring 2002 12
Astrophysics and Moore’s Law• Simulating universe is (n3)• Moore’s law: computing power
doubles every 18 months• Tyson: to understand something
new about the universe, need to scale by 10x
• How long does it take to know twice as much about the universe?
13 February 2002 CS 200 Spring 2002 13
(define (computing-power nyears) (if (= nyears 0) 1 (* 1.587 (computing-power (- nyears 1))))) ;;; doubling every 18 months = ~1.587 * every 12 months(define (simulation-work scale) (* scale scale scale)) ;;; Simulation is O(n^3) work(define (log10 x) (/ (log x) (log 10))) ;;; primitive log is natural (base e)(define (knowledge-of-universe scale) (log10 scale)) ;;; knowledge of the universe is log 10 the scale of universe we can simulate(define (find-knowledge-of-universe nyears) (define (find-biggest-scale scale) ; today, can simulate size 10 universe (if (> (/ (simulation-work scale) 1000) (computing-power nyears)) (- scale 1) (find-biggest-scale (+ scale 1)))) (knowledge-of-universe (find-biggest-scale 1)))
13 February 2002 CS 200 Spring 2002 14
> (find-knowledge-of-universe 0)1.0> (find-knowledge-of-universe 1)1.041392685158225> (find-knowledge-of-universe 2)1.1139433523068367> (find-knowledge-of-universe 5)1.322219294733919> (find-knowledge-of-universe 10)1.6627578316815739> (find-knowledge-of-universe 15)2.0> (find-knowledge-of-universe 30)3.00560944536028> (find-knowledge-of-universe 60)5.0115366121349325> (find-knowledge-of-universe 80)6.348717927935257
Will there be any mystery left in the Universe when you die?
13 February 2002 CS 200 Spring 2002 15
Liberal Arts• Grammar: study of meaning in written
expression• Rhetoric: comprehension of verbal
and written discourse• Logic: argumentative discourse for
discovering truth• Arithmetic: understanding numbers• Geometry: quantification of space• Music: number in time• Astronomy: laws of the planets and
stars
Yes, we need to understandmeaning to describe
computations
Interfaces between components, discourse
between programs and users
Logic for controlling and reasoning about
computations
Yes (last few lectures)
Yes (PS 1, 2, 3)
Yes, its called GEB for a reason!
No, but astronomy uses CS a lot.
Triv
ium
Qua
driv
ium
Correction from Lecture 1:
Yes (Neil DeGrasses Tyson says so!)
13 February 2002 CS 200 Spring 2002 16
Bold (Possibly Untrue) Claim
This course is the most consistent with the original intent of a Liberal Arts education of any course offered at UVA this semester!
Correction from Lecture 1:
since Mr. Jefferson founded it!
13 February 2002 CS 200 Spring 2002 17
The Endless Golden Age
• Golden Age – period in which knowledge/quality of something doubles quickly
• At any point in history, half of what is known about astrophysics was discovered in the previous 15 years!
• Moore’s law today, but other advances previously: telescopes, photocopiers, clocks, etc.
13 February 2002 CS 200 Spring 2002 18
The Real Golden Rule?Why do fields like astrophysics, medicine, biology and computer science (?) have “endless golden ages”, but fields like– music (1775-1825)– rock n’ roll (1962-1973, or whatever was popular when you
were 16)– philosophy (400BC-350BC?)– art (1875-1925?)– soccer (1950-1974)– baseball (1925-1950)– movies (1930-1940)
have short golden ages? What about mathematics?
13 February 2002 CS 200 Spring 2002 20
Terminology
Encrypt DecryptPlaintextCiphertext
Plaintext
Alice Bob
Eve
Insecure Channel
C = E(P)P = D(C)E must be invertible: P = D (E (P))
13 February 2002 CS 200 Spring 2002 21
Encrypt DecryptPlaintextCiphertext
Plaintext
Alice Bob
Insecure Channel
C = E(P, K)P = D(C, K)
K K
“The enemy knows the system being used.”
Claude Shannon
Eve
13 February 2002 CS 200 Spring 2002 23
Enigma• About 50,000 used by Nazi’s in
WWII• Modified throughout WWII,
believed to be perfectly secure• Broken by Bletchley Park led by
Alan Turing (and 30,000 others)• First computer (Collossus)
developed to break Nazi codes (but kept secret through 1970s)
• Allies used decrypted Enigma messages to plan D-Day
13 February 2002 CS 200 Spring 2002 27
Perfectly Secure Cipher: One-Time Pad
• Mauborgne/Vernam [1917]• xor ():
0 0 = 0 1 0 = 10 1 = 1 1 1 = 0a a = 0a 0 = aa b b = a
• E(P, K) = P KD(C, K) = C K = (P K) K = P
13 February 2002 CS 200 Spring 2002 28
For any given ciphertext, all plaintexts are equally possible.
Ciphertext: 0100111110101
Key: 1100000100110
Plaintext: 1000111010011 = “CS”
Why perfectly secure?
1
0 B
13 February 2002 CS 200 Spring 2002 29
If its “perfect” why is it broken?
• Cannot reuse K
• Need to generate truly random bit sequence as long as all messages
• Need to securely distribute key
13 February 2002 CS 200 Spring 2002 30
“One-Time” Pad’s in Practice• Lorenz Machine –
Nazi high command in WWII– Pad generated by 12 rotors– Receiver and sender set up
rotors in same positions– One operator retransmitted a
message (but abbreviated message header the second time!)
– Enough for Bletchley Park to figure out key – and structure of machine that generated it!
– But still had to try all configurations
13 February 2002 CS 200 Spring 2002 31
Colossus – First Programmable Computer• Bletchley Park, 1944• Read ciphertext and
Lorenz wheel patterns from tapes
• Tried each alignment, calculated correlation with German
• Decoded messages (63M letters by 10 Colossus machines) that enabled Allies to know German troop locations to plan D-Day
• Destroyed in 1960, kept secret until 1970s
13 February 2002 CS 200 Spring 2002 33
Problem Set 4
• Break a simplified Lorenz Cipher
• Removed one wheel, made initial positions of all groups of wheels have to match
• Small rotors
• Its REALLY AMAZING that the British were able to break the real Lorenz in 1943 and it is still hard for us today!
13 February 2002 CS 200 Spring 2002 34
Motivation Helps…
Confronted with the prospect of defeat, the Allied cryptanalysts had worked night and day to penetrate German ciphers. It would appear that fear was the main driving force, and that adversity is one of the foundations of successful codebreaking.
Simon Singh, The Code Book
13 February 2002 CS 200 Spring 2002 35
Modern Ciphers
• 128-bit keys, encrypt 128-bit blocks
• Brute force attack– Try 1 Trillion keys per second– Would take 10790283070806000000 years
to try all keys! – If that’s not enough, can use 256-bit key
• No known techniques that do better than brute force search