360 likes | 365 Views
Delve into a captivating lecture on Astrophysics and Cryptology, covering topics like Quicksort, DeGrasse Tyson’s Essay, Cryptography, and the fascinating realms of astrophysical simulations. Discover the computational intricacies of astrophysics, the exponential growth in understanding the universe, and the impact of Moore’s Law on computational power. Unravel the mysteries of the universe through mathematical simulations and logarithmic scales, reflecting on the profound insights gained from scaling by factors of 10. Explore the intersection of liberal arts disciplines with computing, from grammar to astronomy, and ponder the eternal mysteries that may persist even beyond one's lifetime.
E N D
Lecture 13: Astrophysics and Cryptology David Evans http://www.cs.virginia.edu/~evans CS200: Computer Science University of Virginia Computer Science
Menu • Quicksort Recap • DeGrasse Tyson’s Essay • Cryptography (CS588 condensed) CS 200 Spring 2002
Quicksort C. A. R. Hoare, 1961 CS 200 Spring 2002
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)))))) CS 200 Spring 2002
filter (define (filter f lst) (insertlg (lambda (el rest) (if (f el) (cons el rest) rest)) lst null)) How much work is filter? (n) CS 200 Spring 2002
(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)))))) 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) CS 200 Spring 2002
(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)))))) 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 list We need log2 n splits to get down to empty list Best (Average) Case: (n log2 n) we filter log2n times, each is (n) CS 200 Spring 2002
> (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 CS 200 Spring 2002
Growth of time to sort random list n2 (bubblesort) n log2n (quicksort) CS 200 Spring 2002
Science’s Endless Golden Age CS 200 Spring 2002
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)? When we double the size of the simulation, the work octuples! (Just like oceanography octopi simulations) (n3) CS 200 Spring 2002
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? CS 200 Spring 2002
(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))) CS 200 Spring 2002
> (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? CS 200 Spring 2002
Correction from Lecture 1: Liberal Arts Yes, we need to understand meaning to describe computations • 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 Trivium Interfaces between components, discourse between programs and users Logic for controlling and reasoning about computations Yes (last few lectures) Yes (PS 1, 2, 3) Quadrivium Yes, its called GEB for a reason! No, but astronomy uses CS a lot. Yes (Neil DeGrasses Tyson says so!) CS 200 Spring 2002
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: Bold (Possibly Untrue) Claim since Mr. Jefferson founded it! CS 200 Spring 2002
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. CS 200 Spring 2002
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? CS 200 Spring 2002
Cryptology (CS588 Condensed) CS 200 Spring 2002
Eve Terminology Insecure Channel Ciphertext Encrypt Decrypt Plaintext Plaintext Alice Bob C = E(P) P = D(C) E must be invertible: P = D (E (P)) CS 200 Spring 2002
Eve “The enemy knows the system being used.” Claude Shannon Insecure Channel Ciphertext Encrypt Decrypt Plaintext Plaintext K K Alice Bob C = E(P, K) P = D(C, K) CS 200 Spring 2002
Jefferson Wheel Cipher CS 200 Spring 2002
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 CS 200 Spring 2002
Enigma Coming to US in April! CS 200 Spring 2002
Bletchley Park CS 200 Spring 2002
Lorenz Cipher Machine CS 200 Spring 2002
Perfectly Secure Cipher: One-Time Pad • Mauborgne/Vernam [1917] • xor (): 0 0 = 0 1 0 = 1 0 1 = 1 1 1 = 0 a a = 0 a 0 = a a b b = a • E(P, K) = P K D(C, K) = C K = (P K) K = P CS 200 Spring 2002
Why perfectly secure? For any given ciphertext, all plaintexts are equally possible. Ciphertext: 0100111110101 Key: 1100000100110 Plaintext: 1000111010011 = “CS” 1 B 0 CS 200 Spring 2002
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 CS 200 Spring 2002
“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 CS 200 Spring 2002
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 CS 200 Spring 2002
From http://www.codesandciphers.org.uk/lorenz/fish.htm CS 200 Spring 2002
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! CS 200 Spring 2002
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 CS 200 Spring 2002
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 CS 200 Spring 2002
Charge • PS4 • No new Computer Science concepts • You should be able to do it now • Lots of practice with lists and recursion • No bombs dropping, but a little bit of motivation (prize for first person/group to decipher secret message) CS 200 Spring 2002