CSE 311 Lecture 11: Modular Arithmetic. Emina Torlak and Kevin Zatloukal

Size: px
Start display at page:

Download "CSE 311 Lecture 11: Modular Arithmetic. Emina Torlak and Kevin Zatloukal"

Transcription

1 CSE 311 Lecture 11: Modular Arithmetic Emina Torlak and Kevin Zatloukal 1

2 Topics Sets and set operations A quick wrap-up of Lecture 10. Modular arithmetic basics Arithmetic over a finite domain (a.k.a computer arithmetic). Modular arithmetic properties Congruence, addition, multiplication, proofs. Modular arithmetic and integer representations Unsigned, sign-magnitude, and two s complement representation. Applications of modular arithmetic Hashing, pseudo-random numbers, ciphers. 2

3 Sets and set operations A quick wrap-up of Lecture 10.

4 3

5 Sets and set operations A set is a collection of elements. Write a B (or a B) to say that a is (or isn t) an element in the set B. The order of elements doesn t matter, and duplicates don t matter. A B A = B x. x A x B A B A B A B x. x A x B Sets and are equal if they have the same elements. is a subset of if every element of is also in. Sets can be built from predicates or using set operations. A B = {x : (x A) (x B)} A B = {x : (x A) (x B)} A B = {x : (x A) (x B)} A B = {x : (x A) (x B)} A = {x : x A} = {x : (x A)} 4

6 This is Boolean algebra again A B = {x : (x A) (x B)} A B = {x : (x A) (x B)} A = {x : x A} = {x : (x A)} Union is defined using. Intersection is defined using. Complement works like. This means that all equivalences from Boolean algebra translate directly into set theory, and you can use them in your proofs! 5

7 More sets Power set, Cartesian product, and Russell s paradox. 6

8 Power set A (A) = {B : B A} Power set of a set is the set of all subsets of. Examples Let Days = {M, W, F}. (Days) = ( ) = A 7

9 Power set A (A) = {B : B A} Power set of a set is the set of all subsets of. Examples Let Days = {M, W, F}. (Days) = {, {M}, {W}, {F}, {M, W}, {M, F}, {W, F}, {M, W, F}} ( ) = A 7

10 Power set A (A) = {B : B A} Power set of a set is the set of all subsets of. Examples Let Days = {M, W, F}. (Days) = {, {M}, {W}, {F}, {M, W}, {M, F}, {W, F}, {M, W, F}} ( ) = { } A 7

11 Cartesian product The Cartesian product of two sets is the set of all of their ordered pairs. A B = {(a, b) : a A b B} Examples R R Z Z is the real plane. is the set of all pairs of integers. 8

12 Cartesian product The Cartesian product of two sets is the set of all of their ordered pairs. A B = {(a, b) : a A b B} Examples R R is the real plane. Z Z is the set of all pairs of integers. If A = {1, 2}, B = {a, b, c}, then A B = 8

13 Cartesian product The Cartesian product of two sets is the set of all of their ordered pairs. A B = {(a, b) : a A b B} Examples R R is the real plane. Z Z is the set of all pairs of integers. If A = {1, 2}, B = {a, b, c}, then. A B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)} 8

14 Cartesian product The Cartesian product of two sets is the set of all of their ordered pairs. A B = {(a, b) : a A b B} Examples R R is the real plane. Z Z is the set of all pairs of integers. If A = {1, 2}, B = {a, b, c}, then. A B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)} A = 8

15 Cartesian product The Cartesian product of two sets is the set of all of their ordered pairs. A B = {(a, b) : a A b B} Examples R R is the real plane. Z Z is the set of all pairs of integers. If A = {1, 2}, B = {a, b, c}, then. A B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)} A = {(a, b) : a A b } = {(a, b) : a A F} =. 8

16 Russell s paradox Let S S = {x : x x} be the set of all sets that don t contain themselves. 9

17 Russell s paradox Let S S = {x : x x} S be the set of all sets that don t contain themselves. The definition of is contradictory, hence the paradox. 9

18 Russell s paradox Let S S = {x : x x} S be the set of all sets that don t contain themselves. The definition of is contradictory, hence the paradox. Suppose that S S. Then, by definition of S, S S, which is a contradiction. 9

19 Russell s paradox Let S S = {x : x x} S be the set of all sets that don t contain themselves. The definition of is contradictory, hence the paradox. Suppose that S S. Then, by definition of S, S S, which is a contradiction. Suppose that S S. Then, by definition of S, S S, which is a contradiction too. 9

20 Russell s paradox Let S S = {x : x x} S be the set of all sets that don t contain themselves. The definition of is contradictory, hence the paradox. Suppose that S S. Then, by definition of S, S S, which is a contradiction. Suppose that S S. Then, by definition of S, S S, which is a contradiction too. To avoid the paradox Define with respect to a universe of discourse. S S = {x U : x x} S S S U With this definition, and there is no contradiction because. 9

21 Working with sets Representing sets as bitvectors and applications of bitvectors. 10

22 Representing sets as bitvectors Suppose that universe is. We can represent every set U {1, 2,, n} B U b 1 b 2 b n where b i = 1 if i B = 0 if i B b i as a vector of bits: This is called the characteristic vector of set. B 11

23 Representing sets as bitvectors Suppose that universe is. We can represent every set U {1, 2,, n} B U b 1 b 2 b n where b i = 1 if i B = 0 if i B b i as a vector of bits: This is called the characteristic vector of set. Given characteristic vectors for and, what is the vector for A B = A B = A B B 11

24 Representing sets as bitvectors Suppose that universe is. We can represent every set U {1, 2,, n} B U b 1 b 2 b n where b i = 1 if i B = 0 if i B b i as a vector of bits: This is called the characteristic vector of set. A A B = ( a 1 + b 1 ) ( a n + b n ) A B = Given characteristic vectors for and, what is the vector for B B 11

25 Representing sets as bitvectors Suppose that universe is. We can represent every set U {1, 2,, n} B U b 1 b 2 b n where b i = 1 if i B = 0 if i B b i as a vector of bits: This is called the characteristic vector of set. A A B = ( a 1 + b 1 ) ( a n + b n ) A B = ( a 1 b 1 ) ( a n b n ) Given characteristic vectors for and, what is the vector for B B 11

26 Unix/Linux file permissions $ ls -l drwxr-xr-x... Documents/ -rw-r--r--... file1 Permissions maintained as bitvectors. Letter means the bit is 1. - means the bit is zero. 12

27 Bitwise operations z = x y z = x & y z = x ^ y (x y) y = x Note that. 13

28 Private key cryptography Alice wants to communicate a message secretly to Bob, so that eavesdropper Eve who sees their conversation can t understand. Alice and Bob can get together ahead of time and privately share a secret key. K How can they communicate securely in this setting? m m Sender (Alice) plaintext message encrypt key cyphertext decrypt key plaintext message Receiver (Bob) Eavesdropper (Eve) 14

29 One-time pad Alice and Bob privately share a random -bitvector. Eve doesn t know. n K Later, Alice has -bit message to send to Bob. Alice computes C = m K. Alice sends C to Bob. Bob computes, which is. Eve can t figure out from unless she can guess. And that s very unlikely for large m m = C K (m K) K = m m C K n n K 15

30 Modular arithmetic basics Arithmetic over a finite domain (a.k.a computer arithmetic). 16

31 Modular arithmetic in action What does this Java program output? public class Seconds { final static int SEC_IN_YEAR = 364*24*60*60; public static void main(string args[]) { System.out.println("Number of seconds in years: " + (SEC_IN_YEAR*10100)); } } 17

32 Modular arithmetic in action What does this Java program output? public class Seconds { final static int SEC_IN_YEAR = 364*24*60*60; public static void main(string args[]) { System.out.println("Number of seconds in years: " + (SEC_IN_YEAR*10100)); } } $javac Test.java $java -Xmx128M -Xms16M Test Number of seconds in years: You ll recognize this as integer overflow. It happens because computers use modular arithmetic to operate on finite integer data types, such as int. 17

33 It all starts with divisibility Divisibility is the core concept behind modular arithmetic. a b a b a Z, b Z a b k Z. b = ka Definition: divides, written as. For,. 18

34 It all starts with divisibility Divisibility is the core concept behind modular arithmetic. a b a b a Z, b Z a b k Z. b = ka Definition: divides, written as. For,. Examples: which of the following are true and which are false?

35 It all starts with divisibility Divisibility is the core concept behind modular arithmetic. a b a b a Z, b Z a b k Z. b = ka Definition: divides, written as. For,. Examples: which of the following are true and which are false? 5 1 F 1 5 T

36 It all starts with divisibility Divisibility is the core concept behind modular arithmetic. a b a b a Z, b Z a b k Z. b = ka Definition: divides, written as. For,. Examples: which of the following are true and which are false? 5 1 F 1 5 T 25 5 F 5 25 T

37 It all starts with divisibility Divisibility is the core concept behind modular arithmetic. a b a b a Z, b Z a b k Z. b = ka Definition: divides, written as. For,. Examples: which of the following are true and which are false? 5 1 F 1 5 T 25 5 F 5 25 T 5 0 T 0 5 F

38 It all starts with divisibility Divisibility is the core concept behind modular arithmetic. a b a b a Z, b Z a b k Z. b = ka Definition: divides, written as. For,. Examples: which of the following are true and which are false? 5 1 F 1 5 T 25 5 F 5 25 T 5 0 T 0 5 F 2 3 F 3 2 F 18

39 Division theorem Division theorem For a Z, d Z with d > 0, there exist unique integers with such that. a = dq + r q, r 0 r < d a d q = a div d r = a mod d If we divide by, we get a unique quotient and nonnegative remainder. 19

40 Division theorem Division theorem For a Z, d Z with d > 0, there exist unique integers with such that. a = dq + r q, r 0 r < d a d q = a div d r = a mod d If we divide by, we get a unique quotient and nonnegative remainder. r 0 a < 0 mod is not % Note that even if, so. public class NotMod { public static void main(string args[]) { System.out.println("-5 mod 2 = 1."); System.out.println("-5 % 2 = " + (-5 % 2)) } } $javac NotMod.java $java -Xmx128M -Xms16M NotMod -5 mod 2 = % 2 = -1 19

41 Example: arithmetic mod 7 + a + 7 b = (a + b) mod a 7 b = (a b) mod

42 Modular arithmetic properties Congruence, addition, multiplication, proofs. 21

43 Congruence modulo a positive integer a b m a b (mod m) a, b, m Z m > 0 a b (mod m) m (a b) Definition: is congruent to modulo, written as For with, 22

44 Congruence modulo a positive integer a b m a b (mod m) a, b, m Z m > 0 a b (mod m) m (a b) Definition: is congruent to modulo, written as For with, Examples: what do these mean and when are they true? x 0 (mod 2) 1 19 (mod 5) y 2 (mod 7) 22

45 Congruence modulo a positive integer a b m a b (mod m) a, b, m Z m > 0 a b (mod m) m (a b) Definition: is congruent to modulo, written as For with, Examples: what do these mean and when are they true? x 0 (mod 2) True for every x 1 19 (mod 5) y 2 (mod 7) that is divisible by 2, i.e., even. 22

46 Congruence modulo a positive integer a b m a b (mod m) a, b, m Z m > 0 a b (mod m) m (a b) Definition: is congruent to modulo, written as For with, Examples: what do these mean and when are they true? x 0 (mod 2) True for every x 1 19 (mod 5) 1 19 = 20 y 2 (mod 7) that is divisible by 2, i.e., even. True because is divisible by 5. 22

47 Congruence modulo a positive integer a b m a b (mod m) a, b, m Z m > 0 a b (mod m) m (a b) Definition: is congruent to modulo, written as For with, Examples: what do these mean and when are they true? x 0 (mod 2) True for every x that is divisible by 2, i.e., even (mod 5) True because 1 19 = 20 is divisible by 5. y 2 (mod 7) y y = 2 + 7k k Z True for every of the form where. 22

48 Congruence and equality Congruence property Let a, b, m Z with m > 0. Then, if and only if. a b (mod m) a mod m = b mod m 23

49 Congruence and equality Congruence property Let a, b, m Z with m > 0. Then, if and only if. a b (mod m) Proof: Suppose that. a b (mod m) a mod m = b mod m a mod m = b mod m Suppose that. 23

50 Congruence and equality Congruence property Let a, b, m Z with m > 0. Then, if and only if. a b (mod m) Proof: Suppose that. a b (mod m) Then by definition of congruence. So for some by definition of divides. Therefore,. Taking both sides modulo, we get Suppose that. a mod m = b mod m m a b a b = km k Z a = b + km m a mod m = (b + km) mod m = b mod m. a mod m = b mod m 23

51 Congruence and equality Congruence property Let a, b, m Z with m > 0. Then, if and only if. a b (mod m) Proof: Suppose that. a b (mod m) Then by definition of congruence. So for some by definition of divides. Therefore,. Taking both sides modulo, we get Suppose that. a mod m = b mod m m a b a b = km k Z a = b + km m a mod m = (b + km) mod m = b mod m. a mod m = b mod m a = mq + (a mod m) b = ms + (b mod m) By the division theorem, and for some q, s Z. Then, a b = (mq + (a mod m)) (ms + (b mod m)) = m(q s) + (a mod m b mod m) = m(q s), since a mod m = b mod m. Therefore, and so. m (a b) a b (mod m) 23

52 mod m (mod m) The function vs the predicate mod m a Z a mod m {0, 1,, m 1} The function takes any and maps it to a remainder. In other words, remainder modulo mod m m places all integers that have the same into the same group (a.k.a. congruence class ). (mod m) a, b Z a b mod m The predicate compares and returns true if and only if and are in the same group according to the function. 24

53 Modular addition property Modular addition property Let m be a positive integer ( m Z with m > 0). If and, then. a b (mod m) c d (mod m) a + c b + d (mod m) 25

54 Modular addition property Modular addition property Let m be a positive integer ( m Z with m > 0). If and, then. a b (mod m) c d (mod m) a + c b + d (mod m) Proof: Suppose that a b (mod m) and c d (mod m). By the definition of congruence, there are k and j such that a b = km and c d = jm. Adding these equations together, we get (a + c) (b + d) = m(j + k). Reapplying the definition of congruence, we get that. (a + c) (b + d) (mod m) 25

55 Modular multiplication property Modular multiplication property Let m be a positive integer ( m Z with m > 0). If and, then. a b (mod m) c d (mod m) ac bd (mod m) 26

56 Modular multiplication property Modular multiplication property Let m be a positive integer ( m Z with m > 0). If and, then. a b (mod m) c d (mod m) ac bd (mod m) Proof: Suppose that a b (mod m) and c d (mod m). By the definition of congruence, there are k and j such that a b = km and c d = jm. So, a = km + b and c = jm + b. Multiplying these equations together, we get ac = (km + b)(jm + d) = kj m 2 + kmd + bjm + bd. Rearranging gives us ac bd = m(kjm + kd + bj). Reapplying the definition of congruence, we get that. ac bd (mod m) 26

57 Example: a proof using modular arithmetic n Z n 2 0 (mod 4) n 2 1 (mod 4) Let, and prove that or. 27

58 Example: a proof using modular arithmetic n Z n 2 0 (mod 4) n 2 1 (mod 4) Let, and prove that or. Let s look at a few examples: 0 2 = 0 0 (mod 4) 1 2 = 1 1 (mod 4) 2 2 = 4 0 (mod 4) 3 2 = 9 1 (mod 4) 4 2 = 16 0 (mod 4) 27

59 Example: a proof using modular arithmetic n Z n 2 0 (mod 4) n 2 1 (mod 4) Let, and prove that or. Let s look at a few examples: 0 2 = 0 0 (mod 4) 1 2 = 1 1 (mod 4) 2 2 = 4 0 (mod 4) 3 2 = 9 1 (mod 4) 4 2 = 16 0 (mod 4) It looks like n 0 (mod 2) n 2 0 (mod 4) n 1 (mod 2) n 2 1 (mod 4) 27

60 Example: a proof using modular arithmetic n Z n 2 0 (mod 4) n 2 1 (mod 4) Let, and prove that or. Let s look at a few examples: 0 2 = 0 0 (mod 4) 1 2 = 1 1 (mod 4) 2 2 = 4 0 (mod 4) 3 2 = 9 1 (mod 4) 4 2 = 16 0 (mod 4) It looks like n 0 (mod 2) n 2 0 (mod 4) n 1 (mod 2) n 2 1 (mod 4) Proof by cases: Case 1 ( is even): n n Case 2 ( is odd): 27

61 Example: a proof using modular arithmetic n Z n 2 0 (mod 4) n 2 1 (mod 4) Let, and prove that or. Let s look at a few examples: 0 2 = 0 0 (mod 4) 1 2 = 1 1 (mod 4) 2 2 = 4 0 (mod 4) 3 2 = 9 1 (mod 4) 4 2 = 16 0 (mod 4) It looks like n 0 (mod 2) n 2 0 (mod 4) n 1 (mod 2) n 2 1 (mod 4) Proof by cases: Case 1 ( is even): n n 0 (mod 2) Suppose. Then for some integer k. So n 2 = (2k) 2 = 4k 2. Therefore, by definition of congruence,. n Case 2 ( is odd): n 2 n = 2k 0 (mod 4) 27

62 Example: a proof using modular arithmetic n Z n 2 0 (mod 4) n 2 1 (mod 4) Let, and prove that or. Let s look at a few examples: 0 2 = 0 0 (mod 4) 1 2 = 1 1 (mod 4) 2 2 = 4 0 (mod 4) 3 2 = 9 1 (mod 4) 4 2 = 16 0 (mod 4) It looks like n 0 (mod 2) n 2 0 (mod 4) n 1 (mod 2) n 2 1 (mod 4) Proof by cases: Case 1 ( is even): n n 0 (mod 2) Suppose. Then for some integer k. So n 2 = (2k) 2 = 4k 2. Therefore, by definition of congruence,. n Case 2 ( is odd): n 2 n = 2k 0 (mod 4) n 1 (mod 2) n = 2k + 1 Suppose. Then for some integer k. So n 2 = (2k + 1 ) 2 = 4 k 2 + 4k + 1 = 4( + k) + 1. Therefore, by definition of congruence,. n 2 k 2 1 (mod 4) 27

63 Modular arithmetic and integer representations Unsigned, sign-magnitude, and two s complement representation. 28

64 Unsigned integer representation x n x = n 1 i=0 b i2 i b i {0, 1} bn 1 b 2 b 1 b 0 Represent integer as a sum of powers of 2: If where each, then the representation is. 29

65 Unsigned integer representation x n x = n 1 i=0 b i2 i b i {0, 1} bn 1 b 2 b 1 b 0 Represent integer as a sum of powers of 2: If where each, then the representation is. Examples: 99 = = n = 8 99 = = So for : 29

66 Unsigned integer representation x n x = n 1 i=0 b i2 i b i {0, 1} bn 1 b 2 b 1 b 0 Represent integer as a sum of powers of 2: If where each, then the representation is. Examples: 99 = = n = 8 99 = = So for : This works for unsigned integers. How do we represented signed integers? 29

67 Sign-magnitude integer representation 2 n 1 < x < 2 n 1 x n If, represent with bits as follows: Use the first bit as the sign (0 for positive and 1 for negative), and the remaining bits as the (unsigned) value. n 1 Examples: 99 = = n = 8 99 = = So for : 30

68 Sign-magnitude integer representation 2 n 1 < x < 2 n 1 x n If, represent with bits as follows: Use the first bit as the sign (0 for positive and 1 for negative), and the remaining bits as the (unsigned) value. n 1 Examples: 99 = = n = 8 99 = = = So for : The problem with this representation is that our standard arithmetic algorithms no longer work, e.g., adding the representation of -18 and 99 doesn t give the representation of

69 Two s complement integer representation x n Represent with bits as follows: If 0 x < 2 n 1, use the n-bit unsigned representation of x. If, use the -bit unsigned representation of. 2 n 1 x < 0 n x 2 n 31

70 Two s complement integer representation x n Represent with bits as follows: If 0 x < 2 n 1, use the n-bit unsigned representation of x. If, use the -bit unsigned representation of. 2 n 1 x < 0 n x 2 n Key property: Two s complement representation of any number so arithmetic works. y mod 2 n mod 2 n y is equivalent to 31

71 Two s complement integer representation x n Represent with bits as follows: If 0 x < 2 n 1, use the n-bit unsigned representation of x. If, use the -bit unsigned representation of. 2 n 1 x < 0 n x 2 n Key property: Two s complement representation of any number so arithmetic works. y mod 2 n mod 2 n y is equivalent to Examples: So for : 99 = = = = 238 = = n = 8 99 = = =

72 Computing the two s complement representation 2 n 1 x < 0 x n 2 n x For, is represented using the -bit unsigned representation of. Here is an easy way to compute this value: n n Compute the -bit unsigned representation of. Flip the bits of x to get the representation of 2 1 x. This works because the string of all 1 s represents 2 n 1. Add 1 to get. 2 n x x 32

73 Applications of modular arithmetic Hashing, pseudo-random numbers, ciphers. 33

74 Hashing Problem: We want to map a small number of data values from a large domain {0, 1,, M 1} into a small set of locations {0, 1,, n 1} to be able to quickly check if a value is present. Solution: Compute hash(x) = x mod p for a prime p close to n. Or, compute for a prime close to. hash(x) = ax + b mod p p n This approach depends on all of the bits of data the data. Helps avoid collisions due to similar values. But need to manage them if they occur. 34

75 Pseudo-random number generation Linear Congruential method x n+1 = (a x n + c) mod m, a, c, m x 0 Choose random and produce a long sequences of s. x n 35

76 Simple ciphers Ceasar or shi! cipher: Treat letters as numbers: A = 0, B = 1, f (p) = (p + k) mod 26 f 1 (p) = (p k) mod 26 More general version: f (p) = (ap + b) mod 26 f 1 (p) = ( a 1 (p b)) mod 26 36

77 Summary Sets can be represented efficiently using bitvectors. This representation is used heavily in the real world. With this representation, set operations reduce to fast bitwise operations. Modular arithmetic is arithmetic over a finite domain. Key notions are divisibility and congruency. mod m Modular arithmetic is the basis of computing. Used with two s complement representation to implement computer arithmetic. Also used in hashing, pseudo-random number generation, and cryptography. 37

CSE 311: Foundations of Computing. Lecture 10: Set Operations & Representation, Modular Arithmetic

CSE 311: Foundations of Computing. Lecture 10: Set Operations & Representation, Modular Arithmetic CSE 311: Foundations of Computing Lecture 10: Set Operations & Representation, Modular Arithmetic Definitions A and B are equal if they have the same elements A = B x (x A x B) A is a subset of B if every

More information

CSE 311: Foundations of Computing. Lecture 10: Set Operations & Representation, Modular Arithmetic

CSE 311: Foundations of Computing. Lecture 10: Set Operations & Representation, Modular Arithmetic CSE 311: Foundations of Computing Lecture 10: Set Operations & Representation, Modular Arithmetic Definitions A and B are equalif they have the same elements A = B x(x A x B) A is a subsetof B if every

More information

CSE 311: Foundations of Computing. Lecture 10: Set Operations & Representation, Modular Arithmetic

CSE 311: Foundations of Computing. Lecture 10: Set Operations & Representation, Modular Arithmetic CSE 311: Foundations of Computing Lecture 10: Set Operations & Representation, Modular Arithmetic Definitions A and B are equalif they have the same elements A = B x(x A x B) A is a subsetof B if every

More information

cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications

cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications arithmetic mod 7 a + 7 b = (a + b) mod 7 a 7 b = (a b) mod 7 5 6 0 1 2 4 3 + 0 1 2 3 4 5 6 0 0 1 2 3 4 5 6 1

More information

CSE 311 Lecture 13: Primes and GCD. Emina Torlak and Kevin Zatloukal

CSE 311 Lecture 13: Primes and GCD. Emina Torlak and Kevin Zatloukal CSE 311 Lecture 13: Primes and GCD Emina Torlak and Kevin Zatloukal 1 Topics Modular arithmetic applications A quick wrap-up of Lecture 12. Primes Fundamental theorem of arithmetic, Euclid s theorem, factoring.

More information

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications n-bit unsigned integer representation Represent integer x as sum of powers of 2: If x = n 1 i=0 b i 2 i where each b i

More information

Number theory (Chapter 4)

Number theory (Chapter 4) EECS 203 Spring 2016 Lecture 12 Page 1 of 8 Number theory (Chapter 4) Review Compute 6 11 mod 13 in an efficient way What is the prime factorization of 100? 138? What is gcd(100, 138)? What is lcm(100,138)?

More information

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors Math.3336: Discrete Mathematics Primes and Greatest Common Divisors Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu

More information

CS March 17, 2009

CS March 17, 2009 Discrete Mathematics CS 2610 March 17, 2009 Number Theory Elementary number theory, concerned with numbers, usually integers and their properties or rational numbers mainly divisibility among integers

More information

CSE 311: Foundations of Computing. Lecture 12: Two s Complement, Primes, GCD

CSE 311: Foundations of Computing. Lecture 12: Two s Complement, Primes, GCD CSE 311: Foundations of Computing Lecture 12: Two s Complement, Primes, GCD n-bit Unsigned Integer Representation Represent integer as sum of powers of 2: If 2 where each {0,1} then representation is b

More information

10 Modular Arithmetic and Cryptography

10 Modular Arithmetic and Cryptography 10 Modular Arithmetic and Cryptography 10.1 Encryption and Decryption Encryption is used to send messages secretly. The sender has a message or plaintext. Encryption by the sender takes the plaintext and

More information

Encryption: The RSA Public Key Cipher

Encryption: The RSA Public Key Cipher Encryption: The RSA Public Key Cipher Michael Brockway March 5, 2018 Overview Transport-layer security employs an asymmetric public cryptosystem to allow two parties (usually a client application and a

More information

Public Key Cryptography

Public Key Cryptography Public Key Cryptography Spotlight on Science J. Robert Buchanan Department of Mathematics 2011 What is Cryptography? cryptography: study of methods for sending messages in a form that only be understood

More information

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences. MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences. Congruences Let n be a postive integer. The integers a and b are called congruent modulo n if they have the same

More information

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications casting out 3s Theorem: A positive integer n is divisible by 3 if and only if the sum of its decimal digits is divisible

More information

Carmen s Core Concepts (Math 135)

Carmen s Core Concepts (Math 135) Carmen s Core Concepts (Math 135) Carmen Bruni University of Waterloo Week 8 1 The following are equivalent (TFAE) 2 Inverses 3 More on Multiplicative Inverses 4 Linear Congruence Theorem 2 [LCT2] 5 Fermat

More information

Mathematics of Cryptography

Mathematics of Cryptography UNIT - III Mathematics of Cryptography Part III: Primes and Related Congruence Equations 1 Objectives To introduce prime numbers and their applications in cryptography. To discuss some primality test algorithms

More information

Discrete Mathematics GCD, LCM, RSA Algorithm

Discrete Mathematics GCD, LCM, RSA Algorithm Discrete Mathematics GCD, LCM, RSA Algorithm Abdul Hameed http://informationtechnology.pk/pucit abdul.hameed@pucit.edu.pk Lecture 16 Greatest Common Divisor 2 Greatest common divisor The greatest common

More information

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography David R. Wilkins Copyright c David R. Wilkins 2006 Contents 9 Introduction to Number Theory and Cryptography 1 9.1 Subgroups

More information

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography David R. Wilkins Copyright c David R. Wilkins 2000 2013 Contents 9 Introduction to Number Theory 63 9.1 Subgroups

More information

Review. CS311H: Discrete Mathematics. Number Theory. Computing GCDs. Insight Behind Euclid s Algorithm. Using this Theorem. Euclidian Algorithm

Review. CS311H: Discrete Mathematics. Number Theory. Computing GCDs. Insight Behind Euclid s Algorithm. Using this Theorem. Euclidian Algorithm Review CS311H: Discrete Mathematics Number Theory Instructor: Işıl Dillig What does it mean for two ints a, b to be congruent mod m? What is the Division theorem? If a b and a c, does it mean b c? What

More information

Integers and Division

Integers and Division Integers and Division Notations Z: set of integers N : set of natural numbers R: set of real numbers Z + : set of positive integers Some elements of number theory are needed in: Data structures, Random

More information

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2 Contents 1 Recommended Reading 1 2 Public Key/Private Key Cryptography 1 2.1 Overview............................................. 1 2.2 RSA Algorithm.......................................... 2 3 A Number

More information

CS483 Design and Analysis of Algorithms

CS483 Design and Analysis of Algorithms CS483 Design and Analysis of Algorithms Lectures 2-3 Algorithms with Numbers Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments

More information

Cryptography and Number Theory

Cryptography and Number Theory Chapter 2 Cryptography and Number Theory 2.1 Cryptography and Modular Arithmetic 2.1.1 Introduction to Cryptography For thousands of years people have searched for ways to send messages in secret. For

More information

Final Exam Math 105: Topics in Mathematics Cryptology, the Science of Secret Writing Rhodes College Tuesday, 30 April :30 11:00 a.m.

Final Exam Math 105: Topics in Mathematics Cryptology, the Science of Secret Writing Rhodes College Tuesday, 30 April :30 11:00 a.m. Final Exam Math 10: Topics in Mathematics Cryptology, the Science of Secret Writing Rhodes College Tuesday, 0 April 2002 :0 11:00 a.m. Instructions: Please be as neat as possible (use a pencil), and show

More information

Mathematical Foundations of Public-Key Cryptography

Mathematical Foundations of Public-Key Cryptography Mathematical Foundations of Public-Key Cryptography Adam C. Champion and Dong Xuan CSE 4471: Information Security Material based on (Stallings, 2006) and (Paar and Pelzl, 2010) Outline Review: Basic Mathematical

More information

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya BBM 205 Discrete Mathematics Hacettepe University http://web.cs.hacettepe.edu.tr/ bbm205 Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya Resources: Kenneth Rosen,

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 11 February 21, 2013 CPSC 467b, Lecture 11 1/27 Discrete Logarithm Diffie-Hellman Key Exchange ElGamal Key Agreement Primitive Roots

More information

One can use elliptic curves to factor integers, although probably not RSA moduli.

One can use elliptic curves to factor integers, although probably not RSA moduli. Elliptic Curves Elliptic curves are groups created by defining a binary operation (addition) on the points of the graph of certain polynomial equations in two variables. These groups have several properties

More information

ECE596C: Handout #11

ECE596C: Handout #11 ECE596C: Handout #11 Public Key Cryptosystems Electrical and Computer Engineering, University of Arizona, Loukas Lazos Abstract In this lecture we introduce necessary mathematical background for studying

More information

Classical Cryptography

Classical Cryptography Classical Cryptography CSG 252 Fall 2006 Riccardo Pucella Goals of Cryptography Alice wants to send message X to Bob Oscar is on the wire, listening to communications Alice and Bob share a key K Alice

More information

Cosc 412: Cryptography and complexity Lecture 7 (22/8/2018) Knapsacks and attacks

Cosc 412: Cryptography and complexity Lecture 7 (22/8/2018) Knapsacks and attacks 1 Cosc 412: Cryptography and complexity Lecture 7 (22/8/2018) Knapsacks and attacks Michael Albert michael.albert@cs.otago.ac.nz 2 This week Arithmetic Knapsack cryptosystems Attacks on knapsacks Some

More information

2. Cryptography 2.5. ElGamal cryptosystems and Discrete logarithms

2. Cryptography 2.5. ElGamal cryptosystems and Discrete logarithms CRYPTOGRAPHY 19 Cryptography 5 ElGamal cryptosystems and Discrete logarithms Definition Let G be a cyclic group of order n and let α be a generator of G For each A G there exists an uniue 0 a n 1 such

More information

MODULAR ARITHMETIC KEITH CONRAD

MODULAR ARITHMETIC KEITH CONRAD MODULAR ARITHMETIC KEITH CONRAD. Introduction We will define the notion of congruent integers (with respect to a modulus) and develop some basic ideas of modular arithmetic. Applications of modular arithmetic

More information

Ma/CS 6a Class 2: Congruences

Ma/CS 6a Class 2: Congruences Ma/CS 6a Class 2: Congruences 1 + 1 5 (mod 3) By Adam Sheffer Reminder: Public Key Cryptography Idea. Use a public key which is used for encryption and a private key used for decryption. Alice encrypts

More information

ECE 646 Lecture 5. Mathematical Background: Modular Arithmetic

ECE 646 Lecture 5. Mathematical Background: Modular Arithmetic ECE 646 Lecture 5 Mathematical Background: Modular Arithmetic Motivation: Public-key ciphers RSA as a trap-door one-way function PUBLIC KEY message ciphertext M C = f(m) = M e mod N C M = f -1 (C) = C

More information

3 The fundamentals: Algorithms, the integers, and matrices

3 The fundamentals: Algorithms, the integers, and matrices 3 The fundamentals: Algorithms, the integers, and matrices 3.4 The integers and division This section introduces the basics of number theory number theory is the part of mathematics involving integers

More information

Introduction to Cryptography k. Lecture 5. Benny Pinkas k. Requirements. Data Integrity, Message Authentication

Introduction to Cryptography k. Lecture 5. Benny Pinkas k. Requirements. Data Integrity, Message Authentication Common Usage of MACs for message authentication Introduction to Cryptography k Alice α m, MAC k (m) Isα= MAC k (m)? Bob k Lecture 5 Benny Pinkas k Alice m, MAC k (m) m,α Got you! α MAC k (m )! Bob k Eve

More information

Public Key Cryptography

Public Key Cryptography Public Key Cryptography Introduction Public Key Cryptography Unlike symmetric key, there is no need for Alice and Bob to share a common secret Alice can convey her public key to Bob in a public communication:

More information

Public Key Cryptography. All secret key algorithms & hash algorithms do the same thing but public key algorithms look very different from each other.

Public Key Cryptography. All secret key algorithms & hash algorithms do the same thing but public key algorithms look very different from each other. Public Key Cryptography All secret key algorithms & hash algorithms do the same thing but public key algorithms look very different from each other. The thing that is common among all of them is that each

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 9 February 6, 2012 CPSC 467b, Lecture 9 1/53 Euler s Theorem Generating RSA Modulus Finding primes by guess and check Density of

More information

For your quiz in recitation this week, refer to these exercise generators:

For your quiz in recitation this week, refer to these exercise generators: Monday, Oct 29 Today we will talk about inverses in modular arithmetic, and the use of inverses to solve linear congruences. For your quiz in recitation this week, refer to these exercise generators: GCD

More information

Lecture Notes, Week 6

Lecture Notes, Week 6 YALE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE CPSC 467b: Cryptography and Computer Security Week 6 (rev. 3) Professor M. J. Fischer February 15 & 17, 2005 1 RSA Security Lecture Notes, Week 6 Several

More information

MEETING 6 - MODULAR ARITHMETIC AND INTRODUCTORY CRYPTOGRAPHY

MEETING 6 - MODULAR ARITHMETIC AND INTRODUCTORY CRYPTOGRAPHY MEETING 6 - MODULAR ARITHMETIC AND INTRODUCTORY CRYPTOGRAPHY In this meeting we go through the foundations of modular arithmetic. Before the meeting it is assumed that you have watched the videos and worked

More information

CSE 20 DISCRETE MATH. Winter

CSE 20 DISCRETE MATH. Winter CSE 20 DISCRETE MATH Winter 2017 http://cseweb.ucsd.edu/classes/wi17/cse20-ab/ Today's learning goals Determine whether a relation is an equivalence relation by determining whether it is Reflexive Symmetric

More information

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank University of Florida Dept. of Computer & Information Science & Engineering COT 3100 Applications of Discrete Structures Dr. Michael P. Frank Slides for a Course Based on the Text Discrete Mathematics

More information

MATH 158 FINAL EXAM 20 DECEMBER 2016

MATH 158 FINAL EXAM 20 DECEMBER 2016 MATH 158 FINAL EXAM 20 DECEMBER 2016 Name : The exam is double-sided. Make sure to read both sides of each page. The time limit is three hours. No calculators are permitted. You are permitted one page

More information

Ma/CS 6a Class 2: Congruences

Ma/CS 6a Class 2: Congruences Ma/CS 6a Class 2: Congruences 1 + 1 5 (mod 3) By Adam Sheffer Reminder: Public Key Cryptography Idea. Use a public key which is used for encryption and a private key used for decryption. Alice encrypts

More information

Part V. Chapter 19. Congruence of integers

Part V. Chapter 19. Congruence of integers Part V. Chapter 19. Congruence of integers Congruence modulo m Let m be a positive integer. Definition. Integers a and b are congruent modulo m if and only if a b is divisible by m. For example, 1. 277

More information

CSE 311 Lecture 28: Undecidability of the Halting Problem. Emina Torlak and Kevin Zatloukal

CSE 311 Lecture 28: Undecidability of the Halting Problem. Emina Torlak and Kevin Zatloukal CSE 311 Lecture 28: Undecidability of the Halting Problem Emina Torlak and Kevin Zatloukal 1 Topics Final exam Logistics, format, and topics. Countability and uncomputability A quick recap of Lecture 27.

More information

Lecture 19: Public-key Cryptography (Diffie-Hellman Key Exchange & ElGamal Encryption) Public-key Cryptography

Lecture 19: Public-key Cryptography (Diffie-Hellman Key Exchange & ElGamal Encryption) Public-key Cryptography Lecture 19: (Diffie-Hellman Key Exchange & ElGamal Encryption) Recall In private-key cryptography the secret-key sk is always established ahead of time The secrecy of the private-key cryptography relies

More information

Public-key Cryptography and elliptic curves

Public-key Cryptography and elliptic curves Public-key Cryptography and elliptic curves Dan Nichols nichols@math.umass.edu University of Massachusetts Oct. 14, 2015 Cryptography basics Cryptography is the study of secure communications. Here are

More information

Notes. Number Theory: Applications. Notes. Number Theory: Applications. Notes. Hash Functions I

Notes. Number Theory: Applications. Notes. Number Theory: Applications. Notes. Hash Functions I Number Theory: Applications Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Fall 2007 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 3.4 3.7 of Rosen cse235@cse.unl.edu

More information

The RSA public encryption scheme: How I learned to stop worrying and love buying stuff online

The RSA public encryption scheme: How I learned to stop worrying and love buying stuff online The RSA public encryption scheme: How I learned to stop worrying and love buying stuff online Anthony Várilly-Alvarado Rice University Mathematics Leadership Institute, June 2010 Our Goal Today I will

More information

CIS 551 / TCOM 401 Computer and Network Security

CIS 551 / TCOM 401 Computer and Network Security CIS 551 / TCOM 401 Computer and Network Security Spring 2008 Lecture 15 3/20/08 CIS/TCOM 551 1 Announcements Project 3 available on the web. Get the handout in class today. Project 3 is due April 4th It

More information

COMP Intro to Logic for Computer Scientists. Lecture 15

COMP Intro to Logic for Computer Scientists. Lecture 15 COMP 1002 Intro to Logic for Computer Scientists Lecture 15 B 5 2 J Puzzle: better than nothing Nothing is better than eternal bliss A burger is better than nothing ------------------------------------------------

More information

4 Number Theory and Cryptography

4 Number Theory and Cryptography 4 Number Theory and Cryptography 4.1 Divisibility and Modular Arithmetic This section introduces the basics of number theory number theory is the part of mathematics involving integers and their properties.

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 10 February 19, 2013 CPSC 467b, Lecture 10 1/45 Primality Tests Strong primality tests Weak tests of compositeness Reformulation

More information

U.C. Berkeley CS276: Cryptography Luca Trevisan February 5, Notes for Lecture 6

U.C. Berkeley CS276: Cryptography Luca Trevisan February 5, Notes for Lecture 6 U.C. Berkeley CS276: Cryptography Handout N6 Luca Trevisan February 5, 2009 Notes for Lecture 6 Scribed by Ian Haken, posted February 8, 2009 Summary The encryption scheme we saw last time, based on pseudorandom

More information

Solutions to the Midterm Test (March 5, 2011)

Solutions to the Midterm Test (March 5, 2011) MATC16 Cryptography and Coding Theory Gábor Pete University of Toronto Scarborough Solutions to the Midterm Test (March 5, 2011) YOUR NAME: DO NOT OPEN THIS BOOKLET UNTIL INSTRUCTED TO DO SO. INSTRUCTIONS:

More information

Lecture 1: Perfect Secrecy and Statistical Authentication. 2 Introduction - Historical vs Modern Cryptography

Lecture 1: Perfect Secrecy and Statistical Authentication. 2 Introduction - Historical vs Modern Cryptography CS 7880 Graduate Cryptography September 10, 2015 Lecture 1: Perfect Secrecy and Statistical Authentication Lecturer: Daniel Wichs Scribe: Matthew Dippel 1 Topic Covered Definition of perfect secrecy One-time

More information

Simple Math: Cryptography

Simple Math: Cryptography 1 Introduction Simple Math: Cryptography This section develops some mathematics before getting to the application. The mathematics that I use involves simple facts from number theory. Number theory is

More information

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 18 November 6, 2017 CPSC 467, Lecture 18 1/52 Authentication While Preventing Impersonation Challenge-response authentication protocols

More information

Cryptography. P. Danziger. Transmit...Bob...

Cryptography. P. Danziger. Transmit...Bob... 10.4 Cryptography P. Danziger 1 Cipher Schemes A cryptographic scheme is an example of a code. The special requirement is that the encoded message be difficult to retrieve without some special piece of

More information

Lecture 7: ElGamal and Discrete Logarithms

Lecture 7: ElGamal and Discrete Logarithms Lecture 7: ElGamal and Discrete Logarithms Johan Håstad, transcribed by Johan Linde 2006-02-07 1 The discrete logarithm problem Recall that a generator g of a group G is an element of order n such that

More information

Linear Congruences. The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence:

Linear Congruences. The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence: Linear Congruences The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence: ax b (mod m), a, b Z, m N +. (1) If x 0 is a solution then so is x k :=

More information

Topics in Cryptography. Lecture 5: Basic Number Theory

Topics in Cryptography. Lecture 5: Basic Number Theory Topics in Cryptography Lecture 5: Basic Number Theory Benny Pinkas page 1 1 Classical symmetric ciphers Alice and Bob share a private key k. System is secure as long as k is secret. Major problem: generating

More information

Ma/CS 6a Class 1. Course Details

Ma/CS 6a Class 1. Course Details Ma/CS 6a Class 1 By Adam Sheffer Course Details Adam Sheffer. adamsh@caltech.edu 1:00 Monday, Wednesday, and Friday. http://www.math.caltech.edu/~2014-15/1term/ma006a/ 1 Course Structure No exam! Grade

More information

Math.3336: Discrete Mathematics. Mathematical Induction

Math.3336: Discrete Mathematics. Mathematical Induction Math.3336: Discrete Mathematics Mathematical Induction Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu Fall 2018

More information

The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }

The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, } Integers and Division 1 The Integers and Division This area of discrete mathematics belongs to the area of Number Theory. Some applications of the concepts in this section include generating pseudorandom

More information

Introduction to Modern Cryptography. Benny Chor

Introduction to Modern Cryptography. Benny Chor Introduction to Modern Cryptography Benny Chor RSA Public Key Encryption Factoring Algorithms Lecture 7 Tel-Aviv University Revised March 1st, 2008 Reminder: The Prime Number Theorem Let π(x) denote the

More information

Intro to Public Key Cryptography Diffie & Hellman Key Exchange

Intro to Public Key Cryptography Diffie & Hellman Key Exchange Introduction to Modern Cryptography Lecture 5 Number Theory: 1. Quadratic residues. 2. The discrete log problem. Intro to Public Key Cryptography Diffie & Hellman Key Exchange Course Summary - Math Part

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security Outline Authentication CPSC 467b: Cryptography and Computer Security Lecture 18 Michael J. Fischer Department of Computer Science Yale University March 29, 2010 Michael J. Fischer CPSC 467b, Lecture 18

More information

Introduction to Number Theory. The study of the integers

Introduction to Number Theory. The study of the integers Introduction to Number Theory The study of the integers of Integers, The set of integers = {... 3, 2, 1, 0, 1, 2, 3,...}. In this lecture, if nothing is said about a variable, it is an integer. Def. We

More information

PERFECT SECRECY AND ADVERSARIAL INDISTINGUISHABILITY

PERFECT SECRECY AND ADVERSARIAL INDISTINGUISHABILITY PERFECT SECRECY AND ADVERSARIAL INDISTINGUISHABILITY BURTON ROSENBERG UNIVERSITY OF MIAMI Contents 1. Perfect Secrecy 1 1.1. A Perfectly Secret Cipher 2 1.2. Odds Ratio and Bias 3 1.3. Conditions for Perfect

More information

Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 1, 2013

Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 1, 2013 RSA Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 1, 2013 Recap Recap Number theory o What is a prime number? o What is prime factorization? o What is a GCD? o What does relatively prime

More information

Adam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course

Adam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course Adam Blank Spring 2017 CSE 311 Foundations of Computing I * All slides are a combined effort between previous instructors of the course HW 3 De-Brief HW 3 De-Brief PROOFS! HW 3 De-Brief Proofs This is

More information

Exam Security January 19, :30 11:30

Exam Security January 19, :30 11:30 Exam Security January 19, 2016. 8:30 11:30 You can score a maximum of 100. Each question indicates how many it is worth. You are NOT allowed to use books or notes, or a (smart) phone. You may answer in

More information

Pseudo-random Number Generation. Qiuliang Tang

Pseudo-random Number Generation. Qiuliang Tang Pseudo-random Number Generation Qiuliang Tang Random Numbers in Cryptography The keystream in the one-time pad The secret key in the DES encryption The prime numbers p, q in the RSA encryption The private

More information

Week 7 An Application to Cryptography

Week 7 An Application to Cryptography SECTION 9. EULER S GENERALIZATION OF FERMAT S THEOREM 55 Week 7 An Application to Cryptography Cryptography the study of the design and analysis of mathematical techniques that ensure secure communications

More information

Elliptic curves: Theory and Applications. Day 4: The discrete logarithm problem.

Elliptic curves: Theory and Applications. Day 4: The discrete logarithm problem. Elliptic curves: Theory and Applications. Day 4: The discrete logarithm problem. Elisa Lorenzo García Université de Rennes 1 14-09-2017 Elisa Lorenzo García (Rennes 1) Elliptic Curves 4 14-09-2017 1 /

More information

Wilson s Theorem and Fermat s Little Theorem

Wilson s Theorem and Fermat s Little Theorem Wilson s Theorem and Fermat s Little Theorem Wilson stheorem THEOREM 1 (Wilson s Theorem): (p 1)! 1 (mod p) if and only if p is prime. EXAMPLE: We have (2 1)!+1 = 2 (3 1)!+1 = 3 (4 1)!+1 = 7 (5 1)!+1 =

More information

Lecture Notes. Advanced Discrete Structures COT S

Lecture Notes. Advanced Discrete Structures COT S Lecture Notes Advanced Discrete Structures COT 4115.001 S15 2015-01-27 Recap ADFGX Cipher Block Cipher Modes of Operation Hill Cipher Inverting a Matrix (mod n) Encryption: Hill Cipher Example Multiple

More information

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 11 October 7, 2015 CPSC 467, Lecture 11 1/37 Digital Signature Algorithms Signatures from commutative cryptosystems Signatures from

More information

Lecture 1: Introduction to Public key cryptography

Lecture 1: Introduction to Public key cryptography Lecture 1: Introduction to Public key cryptography Thomas Johansson T. Johansson (Lund University) 1 / 44 Key distribution Symmetric key cryptography: Alice and Bob share a common secret key. Some means

More information

Tutorial on Quantum Computing. Vwani P. Roychowdhury. Lecture 1: Introduction

Tutorial on Quantum Computing. Vwani P. Roychowdhury. Lecture 1: Introduction Tutorial on Quantum Computing Vwani P. Roychowdhury Lecture 1: Introduction 1 & ) &! # Fundamentals Qubits A single qubit is a two state system, such as a two level atom we denote two orthogonal states

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 8 February 1, 2012 CPSC 467b, Lecture 8 1/42 Number Theory Needed for RSA Z n : The integers mod n Modular arithmetic GCD Relatively

More information

Candidates must show on each answer book the type of calculator used. Only calculators permitted under UEA Regulations may be used.

Candidates must show on each answer book the type of calculator used. Only calculators permitted under UEA Regulations may be used. UNIVERSITY OF EAST ANGLIA School of Mathematics May/June UG Examination 2010 2011 CRYPTOGRAPHY Time allowed: 2 hours Attempt THREE questions. Candidates must show on each answer book the type of calculator

More information

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers Number Theory: Applications Number Theory Applications Computer Science & Engineering 235: Discrete Mathematics Christopher M. Bourke cbourke@cse.unl.edu Results from Number Theory have many applications

More information

Elliptic Curve Cryptography

Elliptic Curve Cryptography Elliptic Curve Cryptography Elliptic Curves An elliptic curve is a cubic equation of the form: y + axy + by = x 3 + cx + dx + e where a, b, c, d and e are real numbers. A special addition operation is

More information

basics of security/cryptography

basics of security/cryptography RSA Cryptography basics of security/cryptography Bob encrypts message M into ciphertext C=P(M) using a public key; Bob sends C to Alice Alice decrypts ciphertext back into M using a private key (secret)

More information

CSCI3390-Lecture 16: Probabilistic Algorithms: Number Theory and Cryptography

CSCI3390-Lecture 16: Probabilistic Algorithms: Number Theory and Cryptography CSCI3390-Lecture 16: Probabilistic Algorithms: Number Theory and Cryptography 1 Two Problems Problem 1. Generate Primes Find a prime number p of between 200 and 1000 decimal digits that has never been

More information

Introduction to Cryptography. Lecture 6

Introduction to Cryptography. Lecture 6 Introduction to Cryptography Lecture 6 Benny Pinkas page 1 Public Key Encryption page 2 Classical symmetric ciphers Alice and Bob share a private key k. System is secure as long as k is secret. Major problem:

More information

Notes 10: Public-key cryptography

Notes 10: Public-key cryptography MTH6115 Cryptography Notes 10: Public-key cryptography In this section we look at two other schemes that have been proposed for publickey ciphers. The first is interesting because it was the earliest such

More information

Introduction to Modern Cryptography. Benny Chor

Introduction to Modern Cryptography. Benny Chor Introduction to Modern Cryptography Benny Chor RSA: Review and Properties Factoring Algorithms Trapdoor One Way Functions PKC Based on Discrete Logs (Elgamal) Signature Schemes Lecture 8 Tel-Aviv University

More information

then the hard copy will not be correct whenever your instructor modifies the assignments.

then the hard copy will not be correct whenever your instructor modifies the assignments. Assignments for Math 2030 then the hard copy will not be correct whenever your instructor modifies the assignments. exams, but working through the problems is a good way to prepare for the exams. It is

More information

Lecture 3.1: Public Key Cryptography I

Lecture 3.1: Public Key Cryptography I Lecture 3.1: Public Key Cryptography I CS 436/636/736 Spring 2015 Nitesh Saxena Today s Informative/Fun Bit Acoustic Emanations http://www.google.com/search?source=ig&hl=en&rlz=&q=keyboard+acoustic+em

More information

17.1 Binary Codes Normal numbers we use are in base 10, which are called decimal numbers. Each digit can be 10 possible numbers: 0, 1, 2, 9.

17.1 Binary Codes Normal numbers we use are in base 10, which are called decimal numbers. Each digit can be 10 possible numbers: 0, 1, 2, 9. ( c ) E p s t e i n, C a r t e r, B o l l i n g e r, A u r i s p a C h a p t e r 17: I n f o r m a t i o n S c i e n c e P a g e 1 CHAPTER 17: Information Science 17.1 Binary Codes Normal numbers we use

More information