Pranav Prasad Phatak EE19B105 Electrical Engineering pranav541 ee19b105@smail.iitm.ac.in Module 1 Assignment Version 2 CS 6858 : Jul – Nov, 2022 : John Augustine Due : 2 PM on Friday, September 16, 2022 (Submission via turnitin) 1 Pranav Prasad Phatak Figure 1: Turnitin Details. CS 6858: Module 1 Assignment Version 2 Page 2 of 21 Pranav Prasad Phatak Contents Problem 1. Tossing Random Coins With PKI Part 1. Using the Dolev-Strong Byzantine Broadcast protocol. . . . . . . . . . Part 2. Relying on b + 1 signatures . . . . . . . . . . . . . . . . . . . . . . . . Problem 2. Leader Part 1. Analysis – Part 2. Analysis – Part 3. Analysis – Part 4. Analysis – Election by Passing Consistency . . . . . Byzantine Strategy . Via Experimentation Conjecture . . . . . . a Token . . . . . . . . . . . . . . . . . . . . . . . . 4 4 5 . . . . 7 7 7 8 10 Problem 3. Incorrect Implementations of the Dolev-Strong Protocol Part 1. Lanie’s Mistake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Part 2. Elanna’s Mistake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 12 13 Problem 4. Randomized Lower Bound Part 1. Reading Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . Part 2. Randomized Lower Bound . . . . . . . . . . . . . . . . . . . . . . . . . 14 14 15 Problem 5. Going Viral Part 1. Experimental Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . Part 2. Randomized Lower Bound . . . . . . . . . . . . . . . . . . . . . . . . . 17 17 19 . . . . . . . . . . . . . . . . . . . . CS 6858: Module 1 Assignment Version 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Page 3 of 21 Pranav Prasad Phatak Problem 1. Tossing Random Coins With PKI In this problem, we will design attack strategies to foil protocols for tossing global coins. Consider a synchronous message passing complete network with n nodes {1, 2, . . . , n}; you may assume PKI. Nodes can perform any required computation instantaneously at any time and this includes tossing coins to generate uniformly random bits. Up to b nodes are Byzantine for some b < n; b is common knowledge among the nodes. Time runs synchronously starting from round 1. Within each round, each node can send a finite-sized message to every other node during the first half of the round; nodes can also refrain from sending anything. Any good node must send the same message to all other nodes (within a round) whereas bad nodes can send different messages to different nodes. In the second half of the round, the messages will be delivered. We are exploring the challenges in designing algorithms that guarantees that (agreement) all good nodes output the same bit r and (valid randomness) the probability that r = 1 is exactly 1/2. You can imagine the output bit at each node to be a “write-once” bit that cannot be edited after the first (and only) write operation. Your goal is to design attack strategies for the following algorithms. The attack strategies must be simple, precise and succeed with the smallest possible value for b. Part 1. Using the Dolev-Strong Byzantine Broadcast protocol. be exploited to break this protocol is the fact that valid randomness is an extra requirement for the problem (over and beyond agreement, validity and termination which are always true for the Dolev-Strong Byzantine Broadcast). This gives us the idea that randomness is something which can be broken. Now note that, each node will accept messages from other nodes as valid in the k th round only if it has a k-1 signature chain on it. Therefore if we have a single byzantine node, he can never change his message since it won’t have a k-1 signature chain on it because all the other nodes are honest and therefore it basically cannot change its bit at any time in the algorithm, if he sends distinct messages in the first round then in the second round everyone will take his message bit as a ⊥ which in our case is 0, so he cannot affect the output at all. Therefore to break this algorithm we will use 2 byzantine nodes. In the first round, both will broadcast a 1 to all other nodes. At the end of the first round, they now know the parity of the input bits of all nodes. Now the idea is to ensure that this parity always turns up to 0. If it is already 0 then these nodes will act as honest nodes since they have nothing to do. If the parity of all the nodes at the end of the first round is 1 however, what the Byzantine nodes will do is the 2nd Byzantine node will change the input bit of 1st Byzantine node to 0 and then put CS 6858: Module 1 Assignment Version 2 Page 4 of 21 Pranav Prasad Phatak the signatures of both the byzantine nodes. (Note that since both are Byzantine they can do this forgery of signatures). Because of this, in the 3rd round all nodes will get a 2 signature chain with 0 as input bit of 1st Byzantine node from the 2nd Byzantine node and from all other honest nodes they will get a 1 as input thus making the input bit of 1st Byzantine node as ⊥ which is 0. Because of this, now the parity again became 0. After this both nodes will behave as honest nodes since their work is done because the output is now 0. This method successfully breaks the valid randomness condition since these 2 Byzantine nodes can ensure that the output of the algorithm is always 0. Part 2. Relying on b + 1 signatures In this case, each bit in the final message always has a 2 signature chain on it since there are only 2 rounds. The first is the signature of the node whose input the bit is and the second signature corresponds to the sender of the vector of inputs from first round in the second round. Note that the algorithm removes any entries and returns it as a ⊥ if there is a 1 entry and a 0 entry both corresponding to the same node in the output vector. The final output is the XOR of the output vector. Since there are just 2 rounds in this algorithm, we can also break the agreement condition and so I will explain a attack which does this. We will need a single Byzantine node for this purpose. This node will send a 1 to all nodes in the first round. Now in the second round, it will change its own bit in the vector to 0 and send this to one honest node, to all the other nodes it will again send the 1. Because of this, the node that received the 1 and 0 in the 2 rounds, will return the bit of the Byzantine node as ⊥ while all the other nodes will return this Byzantine node’s bit as 1, therefore the parity of the one honest node which received 2 different values will be different from all other nodes. Thus this attack breaks the agreement condition. Let us look at another scenario just to be curious. Suppose the honest nodes are smart and ignore the message bit corresponding to the sender in the second round and will only consider the other n-1 bits to confirm. Basically what this does is ensures a single Byzantine node cannot change its bit in the second round and get away with it since all the honest nodes will ignore this change and stick with its original bit in the first round, however if the Byzantine node sends distinct bits in the first round itself then each other node will get 2 different values of that node in other nodes’ messages so all will return the Byzantine node’s bit as ⊥. CS 6858: Module 1 Assignment Version 2 Page 5 of 21 Pranav Prasad Phatak In this case however, if we have 2 Byzantine nodes, the same attack can work out. What the Byzantine nodes will do now is, the 2nd Byzantine node will change the bit of the 1st Byzantine node for a single honest node and keep it same for all other nodes. Again the same scenario as the one in the previous case has been successfully generated. To stop breaking the agreement condition we will need at least b+1 round therefore since all messages must be signed by at least 1 honest node for agreement to go through. CS 6858: Module 1 Assignment Version 2 Page 6 of 21 Pranav Prasad Phatak Problem 2. Leader Election by Passing a Token Part 1. Analysis – Consistency It is mentioned clearly that all good nodes will always take record of the position where the token is passed in each round and in each round the token is always passed to a valid node (one that has not held the token before). Since the Byzantine nodes cannot send different messages to different nodes, all nodes will always record the same move. At the end of each round, each node will have a move recorded which will correspond to the position of the node which is currently holding the token. All the Byzantine nodes can do is pass the token to any one of their choice instead of passing it randomly. This also, however will be always recorded correctly i.e even if the honest do not know what the Byzantine node does it will record the move made by the node corresponding to which node got the token now. Because of this, all good nodes will always make record of the same node at the end of each round (corresponding to the node who has the token now) and therefore at the end of the nth round, all good nodes will declare the same node as the leader and since b < n2 − 1 this will also be declared as the leader overall by majority. Part 2. Analysis – Byzantine Strategy Since the Byzantine nodes have to broadcast the same message to all the other nodes and the honest nodes are in a majority since it is given that b < n2 − 1 , the Byzantine nodes can never ensure that the leader at the end of the rounds is a Byzantine node. They can however do something to increase the chances that the leader is Byzantine. First of all what they will do is that they will ensure the first node is never Byzantine so initially always an honest node will have the token. Further, every time a Byzantine node gets the token, the node should pass it to a honest node instead of doing the random generation since it does not want to pass the token to a Byzantine node because that decreases the chances that a Byzantine node gets the token after the nth round. This is the best strategy and the only thing that the Byzantine nodes can do to increase the chances of the chosen leader be a Byzantine node. CS 6858: Module 1 Assignment Version 2 Page 7 of 21 Pranav Prasad Phatak Part 3. Analysis – Via Experimentation I wrote a code which does the exact same simulation as mentioned above, everytime a random number is generated in between the range 0 to k-1 if k-1 nodes are yet to get the token, and if this generated number is less than the number of Byzantine nodes yet to get the token, then the token is passed to a token and otherwise it is given to a honest node. If ever b > n2 then we break the while loop and start next experiment since in this scenario the byzantine node will always be the leader since whenever the Byzantine will get the token it will pass it to a honest node thus ensuring that whenever a Byzantine node gets the token, an honest node gets it immediately and b > h if h is the number of honest nodes and so finally a Byzantine will always get it. One thing which can be observed from small experiments is that for b = n3 , taking b = 1 and n = 3, the probability that Byzantine leader is chosen is 12 clearly since the first node is honest and if he chooses honest node as next then the leader becomes Byzantine. If we consider a slightly bigger experiment with b = 2 and n = 6; this probability becomes around 0.6 and this should increase ideally upto a certain point, since the probability of the first node choosing a honest node next is higher and then it comes towards 21 eventually ( which was the probability of b = 1 and n = 3 case ) therefore it can be inferred that this will increase a till some value. I did total such 10000 iterations to statistically get a probability as to who will be the chosen leader for a given b and n. I used n = 100 and varied b from 1 to CS 6858: Module 1 Assignment Version 2 Page 8 of 21 Pranav Prasad Phatak 100 ( clearly for b > 50 we have probability that chosen leader is Byzantine = 1 ). From the graph it seems that probability that a Byzantine leader is chosen comes very close to 0.8 as b ≈ n3 and from there onwards it quickly reaches 1 ( becomes exact 1 at b = n2 ). This also confirms the initial conjecture mentioned that the probability at b = n3 will increase to some value ( here it went to 0.8 ) however 100 is a large enough number so it may not increase much further. The code used for simulating the experiment is as follows : import numpy as np import m a t p l o t l i b . p y p l o t as p l t n = 100 B = [ x for x in range ( 1 , n ) ] Byz win prob = [ ] Honest win prob = [ ] for b in B : Byz count = 0 for i in range ( 1 0 0 0 0 ) : b copy = b n copy = n−1 while ( True ) : i f ( b copy>n copy / 2 ) : Byz count += 1 break i f ( n copy == 1 ) : i f ( b copy == 1 ) : Byz count += 1 break i f ( n copy == 2 ) : i f ( b copy == 1 ) : i f ( np . random . rand ( ) > 0 . 5 ) : Byz count += 1 break num = np . random . r a n d i n t ( n copy ) CS 6858: Module 1 Assignment Version 2 Page 9 of 21 Pranav Prasad Phatak i f (num<b b copy n copy else : n copy copy ) : −= 1 −= 2 −= 1 Byz win prob . append ( Byz count /10000) H o n e s t w i n p r o b . append (1 −( Byz count ) / 1 0 0 0 0 ) p l t . p l o t (B, Byz win prob , l a b e l= ’ Byzantine l e a d e r chosen ’ ) p l t . p l o t (B, Honest win prob , l a b e l= ’ Honest l e a d e r chosen ’ ) plt . legend () p l t . x l a b e l ( ” Byzantine nodes ” ) plt . ylabel (” Probability ”) p l t . t i t l e ( ” Varying number o f Byzantine nodes k e e p i n g n f i x e d ” ) p l t . show ( ) Part 4. Analysis – Conjecture Using the above algorithm mentioned, one can get a recursion relation solving which also gives similar values as we got from the simulation experiment. Let us say C(n, b) is the scenario that the final leader is Byzantine. Then we can say that b C(n, b) = n−b−1 ∗ C(n − 1, b) + n−1 ∗ C(n − 2, b − 1). n−1 n−b−1 Since n−1 is the probability that the current node chooses a honest node next and in which case we have reduced the problem to a C(n − 1, b) problem. The b and if this is current leader can choose a Byzantine node next with probability n−1 done, the Byzantine will pass it a non-Byzantine node ( since this is the algorithm ) therefore reducing it to a C(n − 2, b − 1) problem. Let us see some observations now. After doing a few experiments with small n,b values and large as well one main point became very much visible. So as the total number of nodes in the system increases, we need b to be as less as n5 to have a probability of around 0.5 that the leader chosen is honest. For smaller total number of nodes, we have a better probability that a honest leader is chosen. Basically we can say that we want absolute number of Byzantine nodes to be small and not the fraction because a larger n with same fraction of b will always give higher probability that the leader is Byzantine. This is because the honest nodes are always behaving fully randomly whereas the Byzantine nodes have more CS 6858: Module 1 Assignment Version 2 Page 10 of 21 Pranav Prasad Phatak control over their actions so they will control the fact as to who is the chosen leader more than the honest ones for large values of n. In large graphs with a lot of nodes, having around even 10 − 15% will give a good probability ( for eg with n = 200 and b = 30 we get probability ≈ 0.38 whereas for n = 20 and b = 3 we had that probability ≈ 0.21 which is quite significant. So it can be concluded that in large graphs to get an honest node ( probability ¿ 0.7 ) we need the Byzantine node % close to 5-10. CS 6858: Module 1 Assignment Version 2 Page 11 of 21 Pranav Prasad Phatak Problem 3. Incorrect Implementations of the DolevStrong Protocol In this problem, you are asked to help analyze two buggy implementations of the DolevStrong protocol. You must provide specific examples (and attack strategies) illustrating the mistake. Your example in each case must be small and the attack strategy must be as simple as possible. (This problem is taken from the book by Elaine Shi – Exercise 6 on Page 19). Part 1. Lanie’s Mistake There are 2 possible interpretations, I will suggest ways to break both the protocol for both interpretations. First interpretation is that Lanie’s mistake in her implementation is that in the rth round, all nodes get a r signature chain message from other nodes, however these nodes do not check the leader’s signature and its legitimacy (forgets to check that the batch of r signatures must contain the signature from the designated sender) since the designated sender of the message bit is the leader and all other nodes simply add their signature and pass it on to each other. If this is the case, let us assume we have a single Byzantine node, now what this node will do is receive the message from the leader who is honest in round 1. Since the leader is honest, he will send the same message to all the nodes in the first round. Let this bit be v. Now what the Byzantine node will do is also send a message in the first round to all the nodes with the bit v’ ( such that v’ is the opposite bit of v ). Because of this, all the nodes will output as ⊥ since they received 2 distinct messages. Therefore validity is broken since we had a honest leader and his input bit has not been decided as the output bit. There could be a slightly different interpretation of the question statement, let us consider that and give an attack strategy for that one too. It is very much possible that ’She forgot to check that the batch of r signatures expected in round r must contain the signature from the designated send’ means that the most recent signature is missed by all the nodes during checking for signatures ( as designated sender could mean the node that has just sent the message which has been received ). This case can also be attacked, in this case assume that we have a single Byzantine node but this time this node is the leader. Now what the Byzantine node will do is send a 0 bit to one single honest node and not send any message to all the other nodes. In the second round, he will now send a 1 to that same node and sign it himself twice. Since the node will not check the most recent signature, the honest node will think it has gotten a 0 originally and a 1 in the second round so he will output ⊥ at the end of the 2nd and last round. CS 6858: Module 1 Assignment Version 2 Page 12 of 21 Pranav Prasad Phatak However all the nodes only got a 0 ( from that one honest node ) and therefore they will output 0. Again as it is visible the agreement has been broken since one honest node gave an output different from the other honest ones. The message that broke this protocol is : < v ′ , sign < v ′ , 1 >, sign < v ′ , 1 > since the latest sign is not checked, this is considered as a valid message. Here v’ is the bit opposite to the one sent by the Byzantine leader in the first round and 1 is the Byzantine node. Part 2. Elanna’s Mistake In this buggy implementation there are multiple ways to break the protocol. Either validity or agreement can be broken. Let us look at how to break validity first. Let us assume we have a Byzantine non-leader node ( a single one ). In the first round, the honest leader will send a message bit to all the nodes. In the second round, what the Byzantine node can do is send the other bit ( a 0 if the leader had sent 1 and vice versa ). by forging the leader’s signature and then signing it using his own signature. Because of this, this will be a valid message ( 2 signature chain ) and because of this, all the nodes will receive 2 different values and hence all the nodes will return a ⊥. Now since all the honest nodes are indeed returning the same value, agreement is intact however validity is broken because the honest leader’s input bit is not the output bit of the honest nodes. The second way to break this protocol is by attacking the agreement. To do this, again we need a single Byzantine non-leader node. Again, the honest leader will send a message bit to all the honest. What the Byzantine node will do now is forge the leader’s signature, append his own signature to the message and then send the opposite bit of what the leader sent only to one single honest node and behave like a honest node to all the other nodes. Because of this, the one honest node who got 2 different values will output a ⊥ however all the other nodes will output the bit that was sent by the leader in the first round. Hence agreement has been breached in this way. In both the cases the message which was used to break the protocol was of this form : < v ′ , f orged sign < v ′ , 1 >, sign < v ′ , j > where v’ is the bit which is the opposite of the bit sent by the leader and j is the Byzantine node. CS 6858: Module 1 Assignment Version 2 Page 13 of 21 Pranav Prasad Phatak Problem 4. Randomized Lower Bound Part 1. Reading Assignment To show this, we have to simulate a 3 node system with 1 Byzantine node and show that it is impossible to get a working protocol. If we are able to do that then we can further use a sort of inductive argument or say that n can be divided into 3 subnodes of size n3 and then use the argument to show that the protocol does not work. Task therefore is : showing a n = 3 and b = 1 will not have a protocol in this system. Instead of 3 nodes, let us simulate a 6 node system which is similar to our 3 node system with the nodes as - F, M, L, F’, M and L as in the figure below. From the point of view of any respective node, it is just like a 3-node system ( each node has 2 neighbours with direct links ). Thus the experiment is well-defined. Note: Image taken from Elaine Shi’s book. To prove, we will use the method of contradiction. So let us assume some protocol P exists for Byzantine Broadcast with n3 Byzantine nodes, we will run the protocol P on all nodes. The nodes F and F act as honest senders, each receiving the input bit 0 and 1 respectively. The other nodes will run as honest receivers. Let us now consider the 3 possible scenarios at hand here, where one of the three nodes is Byzantine but is unknown to the honest nodes which one is Byzantine (obviously). Since we have assumed that protocol P is resistant to n/3 failures, it should work on this system. Because basically we are conducting the same experiment and the 3 scenarios are hypothetical situation that arose because of not knowing the Byzantine node, the conclusions we reach should be internally consistent, if such a protocol P exists. • Interpretation 1: The actual 3 nodes are F , L, and M. F is corrupt and is imagining all the nodes F, L, M, and F in its head so it can start an attack CS 6858: Module 1 Assignment Version 2 Page 14 of 21 Pranav Prasad Phatak on the protocol P. Whereas L and M are honest. Therefore, we can conclude by agreement that L and M must output the same bit in this experiment. • Interpretation 2: The actual 3 nodes are F , L, and M. L is corrupt and is imagining all the nodes L, F, M, and L in its head so it can start an attack on the protocol P. Whereas F and M are honest. Therefore, we can conclude by validity that M should output F’s input bit, that is 0 in this experiment, which implies that M = 0. • Interpretation 3: The actual 3 nodes are F, L, and M. M is corrupt and is imagining all the nodes M, F, L, and M in its head so it can start an attack on the protocol P. Whereas F and L are honest. Therefore, we can conclude by validity that L should output the input bit of F , that is 1 in this experiment, which implies that L = 1. We have a clear contradiction as it is visible. From interpretation 2, we got that the output of M = 0, and from interpretation 3 we got that the output of L = 1 ( both of which came from validity). However, from agreement in interpretation 1, we must have the output bit of M and L to be same, which is clearly not the case since M is outputting 0 and L is outputting 1. So we can say that we cannot have any protocol which can achieve Byzantine Broadcast in a plain pairwise authenticated channel model any setup assumptions like PKI. Part 2. Randomized Lower Bound Instead of having a foolproof Byzantine Broadcast protocol ( with probability 1 ) it is now asked to prove that there does not even exist any protocol P that will achieve Byzantine Broadcast with probability greater than 32 . Again, we will prove it by the method of contradiction. We will also use the same setup as in the previous question. Attaching the figure here so it is easy to imagine the solution. Note : Image taken from Elaine Shis book. CS 6858: Module 1 Assignment Version 2 Page 15 of 21 Pranav Prasad Phatak Let us assume that the protocol P achieves Byzantine Broadcast with probability 2 . Again we will have a similar hypothetical experiment. The nodes F and F 3 act as honest senders, each receiving the input bit 0 and 1 respectively. The other nodes will run as honest receivers. Let us now consider the 3 possible scenarios at hand here, where one of the three nodes is Byzantine but is unknown to the honest nodes which one is Byzantine (obviously). Since we have assumed that protocol P is resistant to n/3 failures, it should work on this system. Because basically we are conducting the same experiment and the 3 scenarios are hypothetical situation that arose because of not knowing the Byzantine node, the conclusions we reach should be internally consistent, if such a protocol P exists. • Interpretation 1: The actual 3 nodes are F , L, and M. F is corrupt and is imagining all the nodes F, L, M, and F in its head so it can start an attack on the protocol P. Whereas L and M are honest. Therefore, we can conclude by agreement that L and M will output the same bit with a probability of atleast 23 in this experiment since this is our threshold. • Interpretation 2: The actual 3 nodes are F , L, and M. L is corrupt and is imagining all the nodes L, F, M, and L in its head so it can start an attack on the protocol P. Whereas F and M are honest. Therefore, we can conclude by validity that M should output F’s input bit, that is 0 with a probability of atleast 23 in this experiment since this is our threshold. • Interpretation 3: The actual 3 nodes are F, L, and M. M is corrupt and is imagining all the nodes M, F, L, and M in its head so it can start an attack on the protocol P. Whereas F and L are honest. Therefore, we can conclude by validity that L should output the input bit of F, that is 1 with a probability of atleast 23 in this experiment since this is our threshold. Let us now do some probability on these possible outcomes of the events and try to find a contradiction. Let event A be the case that M = 0 and let event B be the case that L = 1. Noting down the observations from the interpretations we have that P (A) > 23 , P (B) > 23 and P (A ∩ B)′ > 23 . Using basic probability, we can rewrite P (A ∩ B)′ as P (A′ ∪ B ′ ) ≤ P (A′ ) + P (B ′ ) = 2 − P (A) − P (B) < 2 − 32 − 32 = 23 Therefore, we have 2 equations, one stating that P (A∩B)′ > 23 and another stating that P (A ∩ B)′ < 23 . And we have our contradiction. So we can say that we cannot have any protocol which can achieve Byzantine Broadcast with probability > 23 in a plain pairwise authenticated channel model any setup assumptions like PKI. CS 6858: Module 1 Assignment Version 2 Page 16 of 21 Pranav Prasad Phatak Problem 5. Going Viral Part 1. Experimental Setup I used the python language, I made a single array of n elements, with value 0 corresponding to the node being infected and 1 corresponding to it being healthy. I initialized the array with first b values as 0 and rest as 1. I wrote a while loop which terminated whenever either all became 1 or all became 0. In each iteration, I made a copy of the initial state and then spread the virus first where all infected ones could spread the virus to a random node ( copy because we do not want the ones who got the infection in this round to spread it further ) and in the second part, the healthy ones got to recover a random person ( again used a copy of the array for the same reason as above ). The code is attached here : import numpy as np import m a t p l o t l i b . p y p l o t as p l t n = 100 B = [ x for x in range ( 0 , 1 0 0 , 1 ) ] people = [ 0 ] ∗ n p e o p l e c o p y = p e o p l e . copy ( ) prob virus wins = [ ] counter = [ ] for b in B : healthy wins = 0 virus wins = 0 count = 0 for i in range ( 1 0 0 0 ) : for k in range ( b ) : people [ k ] = 0 for k in range ( b , n ) : people [ k ] = 1 p e o p l e c o p y = p e o p l e . copy ( ) while ( True ) : count += 1 i f ( p e o p l e . count (1)==0): CS 6858: Module 1 Assignment Version 2 Page 17 of 21 Pranav Prasad Phatak v i r u s w i n s += 1 break i f ( p e o p l e . count (1)==n ) : h e a l t h y w i n s += 1 break #Round 1 where i n f e c t e d ones s p r e a d t h e v i r u s for j in range ( n ) : i f ( p e o p l e [ j ]==0): num = np . random . r a n d i n t ( n−1) i f (num == j ) : p e o p l e c o p y [ n−1] = 0 else : p e o p l e c o p y [ num ] = 0 p e o p l e = p e o p l e c o p y . copy ( ) #Round 2 which i s t h e h e a l i n g round for j j in range ( n ) : i f ( p e o p l e [ j j ]==1): num = np . random . r a n d i n t ( n−1) i f (num == j j ) : p e o p l e c o p y [ n−1] = 1 else : p e o p l e c o p y [ num ] = 1 p e o p l e = p e o p l e c o p y . copy ( ) p r o b v i r u s w i n s . append ( v i r u s w i n s /1000) c o u n t e r . append ( count /1000) p l t . p l o t (B, p r o b v i r u s w i n s ) p l t . x l a b e l ( ” I n i t i a l i n f e c t e d nodes ” ) p l t . y l a b e l ( ” P r o b a b i l i t y t h a t a l l nodes g e t i n f e c t e d ” ) p l t . t i t l e ( ” Varying t he number o f i n i t i a l i n f e c t e d nodes ” ) p l t . show ( ) p l t . p l o t (B, c o u n t e r ) p l t . x l a b e l ( ” I n i t i a l i n f e c t e d nodes ” ) CS 6858: Module 1 Assignment Version 2 Page 18 of 21 Pranav Prasad Phatak p l t . y l a b e l ( ” I t e r a t i o n s taken f o r i t t o c o n v e r g e ” ) p l t . t i t l e ( ” Varying t he number o f i n i t i a l i n f e c t e d nodes ” ) p l t . show ( ) Part 2. Randomized Lower Bound The first graph is depicting the probability that all nodes get infected as b is varied from 0 to n. It starts showing a fast increase as b ≈ 0.3n and around b = 0.5n it almost reaches 1. This can be explained by the fact the first infection is spread and then healing is done. As b goes slight ahead of n3 , around 0.4n – running this algorithm should take the most time, which is also observed in the second figure. This is because of the fact the at this value, the infections will be nullified by healing and both the number of infected ones and healed ones per round will be close to each other due to the randomness of the nature however, it will eventually converge. As expected, the time taken is most when the probability of infections spreading to all is 0.5 ( since here in some cases it converged to 0 and in some it converged to 1 ) meaning that the infecting and healing went on for the most time till finally the randomness tilted it in one direction. CS 6858: Module 1 Assignment Version 2 Page 19 of 21 Pranav Prasad Phatak The expected results were observed pretty closely in the experiment as can be seen from the graphs above. CS 6858: Module 1 Assignment Version 2 Page 20 of 21 Pranav Prasad Phatak Acknowledgments I would like to thank the following people with whom I discussed ideas. • Bartakke Prasanna ( EE19B106 ) : exchanged ideas for the 4th question part 2 • Chougule Atharva ( CS19B016 ) • Pansambal Shone ( CS19B042 ) • Shah Kshitij ( CS19B027 ) : exchanged ideas for 4th question part 2 I had a group discussion with Atharva, Shone and Kshitj in class regarding the first question and we came up with the idea of breaking agreement for the question 1 part 2 together. CS 6858: Module 1 Assignment Version 2 Page 21 of 21