# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

4 Pages

### lect13-4up

Course: CPS 001, Fall 2009
School: Duke
Rating:

Word Count: 888

#### Document Preview

of Outline implementation RSA algorithm for key generation select two prime numbers p, q compute n = p q v = (p-1) (q-1) select small odd integer k such that gcd(k, v) = 1 compute d such that (d k)%v = 1 RSA algorithm for encryption/decryption encryption: compute E(M) = (Mk)%n decryption: compute D(M) = (E(M)d)%n RSA algorithm for key generation Input: none Computation: select two prime integers p, q compute...

Register Now

#### Unformatted Document Excerpt

Coursehero >> North Carolina >> Duke >> CPS 001

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
of Outline implementation RSA algorithm for key generation select two prime numbers p, q compute n = p q v = (p-1) (q-1) select small odd integer k such that gcd(k, v) = 1 compute d such that (d k)%v = 1 RSA algorithm for encryption/decryption encryption: compute E(M) = (Mk)%n decryption: compute D(M) = (E(M)d)%n RSA algorithm for key generation Input: none Computation: select two prime integers p, q compute integers n = p q v = (p-1) (q-1) select small odd integer k such that gcd(k, v) = 1 compute integer d such that (d k)%v = 1 Output: n, k, and d CompSci 001 13.1 CompSci 001 13.2 RSA algorithm for encryption Input: integers k, n, M M is integer representation of plaintext message Computation: let C be integer representation of ciphertext C = (Mk)%n Output: integer C ciphertext or encrypted message RSA algorithm for decryption Input: integers d, n, C C is integer representation of ciphertext message Computation: let D be integer representation of decrypted ciphertext D = (Cd)%n Output: integer D decrypted message CompSci 001 13.3 CompSci 001 13.4 This seems hard How to find big primes? How to find mod inverse? How to compute greatest common divisor? How to translate text input to numeric values? Most importantly: RSA manipulates big numbers Java integers are of limited size how can we handle this? Two key items make the implementation easier understanding the math Javas BigInteger class What is a BigInteger? Java class to represent and perform operations on integers of arbitrary precision Provides analogues to Javas primitive integer operations, e.g. addition and subtraction multiplication and division Along with operations for modular arithmetic gcd calculation generation of primes http://java.sun.com/j2se/1.5.0/docs/api/ CompSci 001 13.5 CompSci 001 13.6 Using BigInteger If we understand what mathematical computations are involved in the RSA algorithm, we can use Javas BigInteger methods to perform them To declare a BigInteger named B BigInteger B; Randomly generated primes BigInteger probablePrime(int b, Random rng) Returns random positive BigInteger of bit length b that is probably prime probability that BigInteger is not prime < 2-100 Random is Javas class for random number generation The following statement Random rng = new Random(); creates a new random number generator named rng What about randomized algorithms in general? Predefined constants BigInteger.ZERO BigInteger.ONE CompSci 001 13.7 CompSci 001 13.8 probablePrime Example: randomly generate two BigInteger primes named p and q of bit length 32 : Integer operations Suppose have declared and assigned values for p and q and now want to perform integer operations on them use methods add, subtract, multiply, divide result BigInteger of operations is a BigInteger Examples: BigInteger BigInteger BigInteger BigInteger w x y z = = = = p.add(q); p.subtract(q); p.multiply(q); p.divide(q); /* create a random number generator */ Random rng = new Random(); /* declare p and q as type BigInteger */ BigInteger p, q; /* assign values to p and q as required */ p = BigInteger.probablePrime(32, rng); 13.9 q CompSci 001 = BigInteger.probablePrime(32, rng); CompSci 001 13.10 Greatest common divisor The greatest common divisor of two numbers x and y is the largest number that divides both x and y this is usually written as gcd(x,y) Example: gcd(20,30) = 10 20 is divided by 1,2,4,5,10,20 30 is divided by 1,2,3,5,6,10,15,30 Example: gcd(13,15) = 1 13 is divided by 1,13 15 is divided by 1,3,5,15 When the gcd of two numbers is one, these numbers are said to be relatively prime Eulers Phi Function For a positive integer n, (n) is the number of positive integers less than n and relatively prime to n Examples: (3) = 2 1,2 (4) = 2 1,2,3 (but 2 is not relatively prime to 4) (5) = 4 1,2,3,4 For any prime number p, (p) = p-1 For any integer n that is the product of two distinct primes p and q, (n) = (p) (q) = (p-1)(q-1) CompSci 001 13.11 CompSci 001 13.12 Relative primes Suppose we have an integer x and want to find an odd integer z such that 1 < z < x, and z is relatively prime to x We know that x and z are relatively prime if their greatest common divisor is one randomly generate prime values for z until gcd(x,z)=1 if x is a product of distinct primes, there is a value of z satisfying this equality Relative BigInteger primes Suppose we have declared a BigIn...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Duke - CPS - 001
1 WHAT YOU SHOULD KNOW (and More) FOR THE LAB FINALExplanation of JavaWhat is an object? o An object is a value of a class type o An example is: String, Sound or a Robot What is a primitive type? o A primitive type is a number type or Boolean typ
Duke - CPS - 001
Todays topicsBinary Numbers Brookshear 1.1-1.6 Slides from Prof. Marti Hearst of UC Berkeley SIMS Upcoming Networks Interactive Introduction to Graph Theoryhttp:/www.utm.edu/cgi-bin/caldwell/tutor/departments/math/graph/introDigital ComputersWh
Duke - CPS - 001
Normalize Sounds Make the whole sound as loud as possible How loud can it be? The max positive value is 32767 The max negative value is -32768Creating a Sound Clip To clip the This out of This is a test. Determine where it starts and stops U
Duke - CPS - 001
Today's topicsRevisiting numbers &amp; text Methods Loops Arrays Reading Great Ideas, Chapter 4Types for NumbersThe type String is not a built-in type, technically it's a class There are many numerical types in Java We'll use two int, represents inte
Duke - CPS - 001
Welcome!Principles of Computer Science CompSci 1 LSRC B101 M, W, F 10:20-11:10 Professor Jeff ForbesTodays topicsWhat is this course about? How are we going to learn that? Who is this guy talking to us? Where do we go from here? An overview of co
Duke - CPS - 170
Historical Perspective I Logic IntroCPS 170 Ron Parr Logic was one of the classical foundations of AI Dream: A Knowledge-Based agent Tell the agent facts Agent uses rules of inference to deduce consequences Example: prolog Distinction between
Duke - CPS - 170
Why Study Games? Many human activities can be modeled as games Negotiations Bidding TCP/IP Military confrontations Pursuit/EvasionGamesCPS 170 Ron Parr Games are used to train the mind Human game-playing, animal play-fightingWhy Are Gam
Duke - CPS - 270
COMPSCI 270 - Articial Intelligence Project I Playing the Game of OthelloDue date: September 291DescriptionIn this programming project you will design and implement an Othello playing program. If you are unfamiliar with the rules of Othello th
Duke - CPS - 271
9/11/2007What Makes a Good Prediction? Obviously: One that gives best performance in the future, but how do we pick this in advance?Choosing PredictorsCPS 271 Ron ParrRegression figures provided by Christopher Bishop and 2007 Christopher Bish
Duke - CPS - 296
Lecture notes 4: DualityVincent Conitzer1Introductionmaximize 3x1 + 2x2 subject to 4x1 + 2x2 16 x1 + 2x2 8 x1 + x2 5 x1 0; x2 0Let us again consider the linear program for our original painting problem instance:We already know that the
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. Susan Rodger Section: Introduction (Ch. 1) (handout)What will we do in CPS 140? Questions Can you write a program to determine if a string is an integer? 9998.89 8abab 789342 Can you do this if your m
Duke - CPS - 296
Lecture notes ?: Constraint and column generation, and the cutting stock problemVincent Conitzer1IntroductionSo far, we have assumed that we can explicitly write down the entire linear program. In many settings, this is not feasible: there may
Duke - CPS - 296
Lecture notes ?: Network flow problemsVincent Conitzer1IntroductionWe now consider network flow problems. Such problems have some very nice properties. Specifically, we consider the minimum cost network flow problem, also known as the transshi
Duke - CPS - 170
Lecture notes ?: Solving (mixed) integer programs using branch and boundVincent ConitzerWe now turn to solving (mixed) integer programs. There are several dierent approaches to this; most of them are based on solving various LP relaxations of the i
Duke - CPS - 296
Lecture notes ?: Solving (mixed) integer programs using branch and boundVincent ConitzerWe now turn to solving (mixed) integer programs. There are several dierent approaches to this; most of them are based on solving various LP relaxations of the i
Duke - CPS - 296
Lecture notes ?: An illustrative example: the core and network owVincent Conitzer1IntroductionWe will now consider an example from cooperative game theory (also known as coalitional game theory), the less-known sibling of noncooperative game t
Duke - CPS - 296
CPS 296.2 - Linear and integer programmingHomework 1: modeling and interpreting problems as linear and integer programs (due 2/28 before class)Please read the rules for assignments on the course web page. Contact Vince (conitzer@cs.duke.edu) with
Duke - CPS - 170
Lecture notes 1: Introduction to linear and (mixed) integer programsVincent Conitzer1An exampleWe will start with a simple example. Suppose we are in the business of selling reproductions of two dierent paintings. We can sell any number of rep
Duke - CPS - 296
Lecture notes 1: Introduction to linear and (mixed) integer programsVincent Conitzer1An exampleWe will start with a simple example. Suppose we are in the business of selling reproductions of two dierent paintings. We can sell any number of rep
Duke - CPS - 140
Section: Finite Automata Deterministic Finite Accepter (or Automata) A DFA=(Q,q0,F)input tape a a tape head b b a b head movescurrent state 0 1where Q is nite set of states is tape (input) alphabet q0 is initial state F Q is set of nal states.
Duke - CPS - 140
CompSci 140Project 1 Project Due: Thursday, Feb. 7, Midnight 30 pointsSpring 2008The company MACROBOTS has hired you to write an interpretor for a simple programming language called ROBOBABY for programming their robots. This language allows th
Duke - CPS - 124
Transformations in OpenGL Translate Rotate Scale Push Matrix Pop MatrixOpenGL Functions Transformations in OpenGL are not drawing commands. They are retained as part of the graphics state. When drawing commands are issued, the current transf
Duke - CPS - 182
CS182 2006, Reynolds and Astrachan I) Introduction (1 page) II) Motivation (3 pages) 1) Types of anonymity A) Onion routing examines routing anonymity 2) Who needs it? A) Well, criminals, naturally! B) But also: the government and the military C) Soc
Duke - CPS - 182
Executive Summary -Understanding `Everquest'- I. Situating our Issue: The Unbelievable &amp; `Everquest' This paper will use as its starting point various press releases regarding cases of murder, suicide, and the generally hard-to-believe around `Everqu
Duke - CPS - 182
!&quot;#\$%&amp;'&quot;()*\$+,%'(-./)'&quot;)0)1'('.02)!&quot;3'%\$&quot;45&quot;.6 7)*2\$/5%)8\$9)0.).-5):;/'&amp;)&lt;&quot;=;/.%,&gt;'&quot;(-;')8'4*\$4+;.5%)?&amp;'5&quot;&amp;5)@AB? C%\$#5/\$%)7/.%0&amp;-0&quot; B):0,)BDDE8'4)B 72.-\$;(-)&amp;\$+,%'(-./)F5%5)#'%/.)#\$%4;20.5=).\$)5&quot;&amp;\$;%0(5)'&quot;\$30.'\$&quot;)G,)022\$F'&quot;()&amp;\$&quot;.5&quot;.H &amp;%50.\$%/)
Duke - CPS - 100
Search, Backtracking,HeuristicsExhaustive Search/HeuristicsHow do you find a needle in a haystack? How does a computer play chess? Why would you write that program?We use binary search trees to organize data, in searching we don't need to
Duke - FEB - 100
Search, Backtracking,HeuristicsExhaustive Search/HeuristicsHow do you find a needle in a haystack? How does a computer play chess? Why would you write that program?We use binary search trees to organize data, in searching we don't need to
Duke - CPS - 100
APTs and structuring data/informationIs an element in an array, Where is an element in an array? DIY: use a loop Use Collections, several options public boolean contains(String[] list, Tradeoffs?}String target){ for(String s : list){ if (s.
Duke - JAN - 100
APTs and structuring data/informationIs an element in an array, Where is an element in an array? DIY: use a loop Use Collections, several options public boolean contains(String[] list, Tradeoffs?}String target){ for(String s : list){ if (s.
Duke - CPS - 100
Search, Backtracking,HeuristicsHow do you find a needle in a haystack? How does a computer play chess? Why would you write that program?How does Mapquest/Googlemap find routes from one place to another? Shortest path algorithms Longest
Duke - FEB - 100
Search, Backtracking,HeuristicsHow do you find a needle in a haystack? How does a computer play chess? Why would you write that program?How does Mapquest/Googlemap find routes from one place to another? Shortest path algorithms Longest
Duke - CPS - 214
INTERNATIONAL STANDARDISO/IEC 10589Second edition 2002-11-15Information technology Telecommunications and information exchange between systems Intermediate System to Intermediate System intra-domain routeing information exchange protocol for u
Duke - CPS - 049
Homework 1 solutionsFebruary 9, 2007Question 1 1. Because anchor texts tend to have more accurate descriptions of web pages they point to than the actual web pages, search quality can be improved. 2. Anchor texts help search non-text information as
Duke - CPS - 049
Duke - CPS - 210
Things Change Myth that placement is irrelevant View that OS is concerned only with the main-secondary levels of memory hierarchy New architectures / new views of the memory hierarchy Scale - larger address spaces You are Workload assumptions he
Duke - CPS - 271
Where We Stand Markov Decision ProcessesCPS 271 Ron Parr Search and planning for deterministic domains Efficient manipulation of probability distributions Decision Theory Act to maximize expected utility How do we do this? Markov Decision Pro
Duke - CPS - 271
Objectives CPS 271 AgentsRon Parr Explain the perspective taken in textbook Provide a framework onto which we will attach our algorithms Why search, plan, learn, predict? Because agents need these activities Establish a common vocabularyWhat
Duke - CPS - 210
Rethinking OS DesignYou are here Productivity applications Workload Process control Personal (PDAs), Embedded Services &amp; API Internal Structure Policies / Mechanisms(Traditional) Unix Abstractions Processes - thread of control with context Files
Duke - CPS - 271
Review CSPs IICPS 271 Ron Parr CSPs are NP-hard decision problems Can formulate SAT instances as CSPs Paths don't matter often use local search What's special about CSPs? Special problem description language Use CSP specific heuristics, metho
Duke - CPS - 271
What is game theory? Games II Game TheoryRon Parr CPS 271 A general theory of rational behavior in the presence of other agents Minimax is a special case Actions can be simultaneous Information can be incomplete Optimal strategies may be stoch
Duke - CPS - 210
Remote Execution to Save Local EnergyCompute locally on battery power vs Transmit to wired compute server + Idle in low power mode + Receive results Why and when it works? How? The mechanisms required.Effectiveness?(Rudenko et al) Identical,
Duke - CPS - 210
Interprocess Communication Messages Assume no explicit sharing of data elements in the address spaces of processes wishing to cooperate/communicate. Essence of message- passing is copying (although implementations may avoid actual copies whenever p
Duke - CPS - 110
Threads and ConcurrencyA First Look at Some Key ConceptskernelThe software component that controls the hardware directly, and implements the core privileged OS functions. Modern hardware has features that allow the OS kernel to protect itself fro
Duke - CPS - 110
Sleep/Wakeup and Condition VariablesExample: Await/AwakeConsider a very simple use of sleep/wakeup to implement two new primitives: currentThread-&gt;Await()Block the calling thread. Thread:Awake()If the target thread is sleeping in a previous A
Duke - CPS - 210
Rethinking OS DesignYou are here Productivity applications Workload Process control Personal (PDAs), Embedded Services &amp; API Internal Structure Policies / MechanismsEnergy Efficiency Metrics Power consumption in watts (mW ). Battery lifetime
Duke - CPS - 210
Welcome to CPS 210Theme for Spring 2001: Energy-aware OS for mobile/embedded computing Graduate Level Operating Systems readings, discussions, and programming projectsLogistics/www.cs.duke.edu education/courses/spring01/cps210 / Systems Quals
Duke - CPS - 110
Monitors and SemaphoresAnnotated Condition Variable ExampleCondition *cv; Lock* cvMx; int waiter = 0; Must hold lock when calling Wait. Wait atomically releases lock and sleeps until next Signal.void await() { cvMx-&gt;Lock(); waiter = waiter + 1;
Duke - CPS - 108
Language specific concepts: Java/C+qJava code/modules organized into packages C+ has namespaces, not often used (broken in g+) http:/www.acm.org/classics/may96/ On the Criteria To Be Used in Decomposing Systems into Modules, David Parnas We're
Duke - CPS - 110
Outline for Today Administrative Review session tomorrow 3pm D106 Exam available in hardcopy at review session and in pdf online afterwards If you havent demoed assignment 5, combine with assignment 6 Course evals today stop me at 3:15WHY?I
Duke - CPS - 189
A Glimpse of Expert Programmers Mental ImageryMarian Petre Alan F. BlackwellCentre for Informatics Education Research Faculty of Mathematics and Computing Open University Milton Keynes, U.K. m.petre@open.ac.ukKEYWORDS:MRC Applied Psychology Uni
Duke - CPS - 189
Anoopa Sharma Today's Shakespeare There is nothing either good or bad, But thinking makes it so. -Hamlet, II:2CPS 6Gambling Fool 1. The student must write a program that allows a user to gamble a specific amount of money. There is a slot machine t
Duke - WEEK - 189
Anoopa Sharma Today's Shakespeare There is nothing either good or bad, But thinking makes it so. -Hamlet, II:2CPS 6Gambling Fool 1. The student must write a program that allows a user to gamble a specific amount of money. There is a slot machine t
Duke - CPS - 189
Ayelet Schleicher CPS 189s (Week 5)Cache Conscious Programming in Undergraduate Computer Science By Alvin LebeckProfessor Lebeck, in this paper, claims that students studying software design and implementation should be taught about cache behavio
Duke - WEEK - 189
Ayelet Schleicher CPS 189s (Week 5)Cache Conscious Programming in Undergraduate Computer Science By Alvin LebeckProfessor Lebeck, in this paper, claims that students studying software design and implementation should be taught about cache behavio
Duke - CPS - 189
Session 12a4What are We Doing When We Teach Programming?Sally Fincher, Computing Laboratory, University of Kent at Canterbury, UKAbstract: The academic discipline of Computer Science is confounded by the practice of its curriculum. Uniquely, it p
Duke - CPS - 189
Ayelet Schleicher CPS 189 (Week 6)CPS 006 Assignment For the first problem, students were required to write a program that would play a three-wheel slot machine and follow specific conditions. The program had to consist of at least two meaningful f
Duke - WEEK - 189
Ayelet Schleicher CPS 189 (Week 6)CPS 006 Assignment For the first problem, students were required to write a program that would play a three-wheel slot machine and follow specific conditions. The program had to consist of at least two meaningful f
Duke - CPS - 189
Thomas Finley What are We Doing When We Teach Programming? by Sally Fincher The first approach is easily the most radical: syntax-free. It is so radical I had to read it five times before I was ready to believe my eyes saw what they saw: it is progra
Duke - WEEK - 189
Thomas Finley What are We Doing When We Teach Programming? by Sally Fincher The first approach is easily the most radical: syntax-free. It is so radical I had to read it five times before I was ready to believe my eyes saw what they saw: it is progra
Duke - CPS - 189
AN EMPIRICALSTUDY OF NOVICE PROGRAM COMPREHENSION IN THE IMPERATIVE AND OBJECT-ORIENTEDSTYLESVennila Ramalingam and Susan WiedenbeckComputer Science and Engineering Department University of Nebraska Lincoln, NE 68588-0115 USA Susan @cse.unl.eduKE
Duke - CPS - 149
ACM Intercollegiate Programming Contest Pacific NW Region 1999Problem E The Same GameThe game named &quot;Same&quot; is a single-person game played on a 10 by 15 board. Each square contains a ball colored red (R), green (G), or blue (B). Two balls belong to