<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Miguel  on Medium]]></title>
        <description><![CDATA[Stories by Miguel  on Medium]]></description>
        <link>https://medium.com/@macworks?source=rss-d187cdb8c939------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_4HJ9mRH_ABTtQmg.jpeg</url>
            <title>Stories by Miguel  on Medium</title>
            <link>https://medium.com/@macworks?source=rss-d187cdb8c939------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:43:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@macworks/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Chord]]></title>
            <link>https://medium.com/@macworks/chord-52c452808a60?source=rss-d187cdb8c939------2</link>
            <guid isPermaLink="false">https://medium.com/p/52c452808a60</guid>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Miguel ]]></dc:creator>
            <pubDate>Mon, 10 Dec 2018 04:14:22 GMT</pubDate>
            <atom:updated>2018-12-10T04:14:22.437Z</atom:updated>
            <content:encoded><![CDATA[<p>From a high-level perspective, the processes that constitute a peer-to-peer system are all equal. This means that the functions that need to be carried out are represented by every process that constitutes the distributed system.</p><p>Two types of overlay networks exist: those that are structured and those that are not.</p><h4>Structured peer-to-peer systems</h4><p>As its name suggests, in a structured peer-to-peer system the nodes (i.e., processes) are organized in an overlay that adheres to a specific, deterministic topology: a ring, a binary tree, a grid, etc. This topology is used to efficiently look up data. Characteristic for structured peer-to-peer systems, is that they are generally based on using a so-called semantic-free index. What this means is that each data item that is to be maintained by the system, is uniquely associated with a key, and that this key is subsequently used as an index.</p><p>The peer-to-peer system as a whole is now responsible for storing (key,value) pairs. To this end, each node is assigned an identifier from the same set of all possible hash values, and each node is made responsible for storing data associated with a specific subset of keys. In essence, the system is thus seen to implement a distributed hash table, generally abbreviated to a DHT [Balakrishnan et al., 2003].</p><p>Following this approach now reduces the essence of structured peer-topeer systems to being able to look up a data item by means of its key. That is, the system provides an efficient implementation of a function lookup that maps a key to an existing node.</p><p>This is where the topology of a structured peer-to-peer system plays a crucial role. Any node can be asked to look up a given key, which then boils down to efficiently <em>routing</em> that lookup request to the node responsible for storing the data associated with the given key.</p><p>In the Chord system [Stoica et al., 2003] the nodes are logically organized in a ring such that a data item with an m-bit key k is mapped to the node with the smallest (again, also m bit) identifier id ≥ k. This node is referred to as the successor of key k and denoted as succ(k). Keys and identifiers are typically 128 or 160 bits long.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iRGXcQzuxsPOYaNPHJylxQ.png" /><figcaption>A Chord ring, where m = 5 and with nine nodes {1, 4, 9, 11, 14, 18, 20, 21, 28}.</figcaption></figure><p>The successor of key 7 is equal to 9. Likewise, succ(5) = 9, but also succ(9) = 9. Likewise, succ(5) = 9, but also succ(9) = 9. In Chord, each node maintains shortcuts to other nodes. A shortcut appears as a directed edge from one node to another.</p><p>To look up a key, a node will try to forward the request “as far as possible,” but without passing it beyond the node responsible for that key. To clarify, suppose that in our example Chord ring, node 9 is asked to look up the node responsible for key 3 (which is node 4). Node 9 has four shortcuts: to nodes 11, 14, 18, and 28, respectively. As node 28 is the farthest node 9 knows about and still preceding the one responsible for key 3, it will get the lookup request. Node 28 has three shortcuts: to nodes 1, 4, and 14, respectively. Note that node 28 has no knowledge about the existence of nodes between nodes 1 and 4. For this reason, the best what it can do is forward the request to node 1. The latter knows that its successor in the ring is node 4, and thus that this is the node responsible for key 3, to which it will subsequently forward the request.</p><p>Now suppose that a node, with the unique identifier u, wants to join a Chord overlay. To that end, it contacts an arbitrary node and requests it to look up u, that is, return the value v= succ(u). At that point, node u will simply need to insert itself between the predecessor of v and v itself, thus becoming the new predecessor of v. During this process, shortcuts from u to other nodes will be established, but also some existing ones previously directed toward v will now be adjusted to point to u (again, details are deferred until later chapters). Obviously, any data item with key k stored at v but for which succ(k) is now equal to u is transferred from v to u.</p><p>For example, node24 wants to join the chord, so we have u=24, succ(24) = v=28. Suppose the node contacts node1. Node1 will forward the request to node21 because it is the farthest node node1 knows about and still preceding the one responsible for key 24. Node21 knows that its successor in the ring is node 24, and thus that this is the node responsible for key 24, to which it will subsequently forward the request.</p><p>Leaving is just as simple: node u informs its departure to its predecessor and successor, and transfers its data items to succ(u).</p><p>How these shortcuts are constructed? When new nodes join, shortcuts from u to other nodes will be established, but also some existing ones previously directed toward v will now be adjusted to point to u.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52c452808a60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Distributed commit]]></title>
            <link>https://medium.com/@macworks/distributed-commit-66c866975fb6?source=rss-d187cdb8c939------2</link>
            <guid isPermaLink="false">https://medium.com/p/66c866975fb6</guid>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Miguel ]]></dc:creator>
            <pubDate>Sun, 09 Dec 2018 15:57:59 GMT</pubDate>
            <atom:updated>2018-12-09T15:57:59.693Z</atom:updated>
            <content:encoded><![CDATA[<p>The atomic multicasting problem discussed in the previous section is an example of a more general problem, known as <strong>distributed commit</strong>. The distributed commit problem involves having an operation being performed by each member of a process group, or none at all. In the case of reliable multicasting, the operation is the delivery of a message.</p><p>Distributed commit is often established by means of a coordinator. In a simple scheme, this coordinator tells all other processes that are also involved, called participants, whether or not to (locally) perform the operation in question. This scheme is referred to as a <strong>one-phase commit protocol</strong>. It has the obvious drawback that if one of the participants cannot actually perform the operation, there is no way to tell the coordinator. For example, in the case of distributed transactions, a local commit may not be possible because this would violate concurrency control constraints.</p><p>In practice, more sophisticated schemes are needed, the most common one being the two-phase commit protocol, which we discuss in detail below. The main drawback of this protocol is that it cannot generally efficiently handle the failure of the coordinator.</p><p>The original two-phase commit protocol (2PC) is due to Gray [1978]. Without loss of generality, consider a distributed transaction involving the participation of a number of processes each running on a different machine. Assuming that no failures occur, the protocol consists of the following two phases, each consisting of two steps</p><ol><li>The coordinator sends a vote-request message to all participants.</li><li>When a participant receives a vote-request message, it returns either a vote-commit message to the coordinator telling the coordinator that it is prepared to locally commit its part of the transaction, or otherwise a vote-abort message.</li><li>The coordinator collects all votes from the participants. If all participants have voted to commit the transaction, then so will the coordinator. In that case, it sends a global-commit message to all participants. However, if one participant had voted to abort the transaction, the coordinator will also decide to abort the transaction and multicasts a global-abort message.</li><li>Each participant that voted for a commit waits for the final reaction by the coordinator. If a participant receives a global-commit message, it locally commits the transaction. Otherwise, when receiving a global-abort message, the transaction is locally aborted as well.</li></ol><p>The first phase is the voting phase, and consists of steps 1 and 2. The second phase is the decision phase, and consists of steps 3 and 4. These four steps are shown as finite state diagrams below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_wA3QgtVQChdE-UsgG6Wg.png" /><figcaption>The finite state machine for the coordinator in 2PC.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvoptt9FuH6QNj4LaxFw-w.png" /><figcaption>The finite state machine for a participant.</figcaption></figure><p>Several problems arise when this basic 2PC protocol is used in a system where failures occur. First, note that the coordinator as well as the participants have states in which they block waiting for incoming messages. Consequently, the protocol can easily fail when a process crashes for other processes may be indefinitely waiting for a message from that process. For this reason, timeout mechanisms are used.</p><p>When taking a look at the finite state machines above, it can be seen that there are a total of three states in which either a coordinator or participant is blocked waiting for an incoming message. First, a participant may be waiting in its INIT state for a vote-request message from the coordinator. If that message is not received after some time, the participant will simply decide to locally abort the transaction, and thus send a vote-abort message to the coordinator.</p><p>Likewise, the coordinator can be blocked in state WAIT, waiting for the votes of each participant. If not all votes have been collected after a certain period of time, the coordinator should vote for an abort as well, and subsequently send global-abort to all participants.</p><p>Finally, a participant can be blocked in state READY, waiting for the global vote as sent by the coordinator. <strong>If that message is not received within a given time, the participant cannot simply decide to abort the transaction. Instead, it must find out which message the coordinator actually sent.</strong> The simplest solution to this problem is to let each participant block until the coordinator recovers again.</p><p>A better solution is to let a participant P contact another participant Q to see if it can decide from Q’s current state what it should do. For example, suppose that Q had reached state COMMIT. This is possible only if the coordinator had sent a global-commit message to Q just before crashing. Apparently, this message had not yet been sent to P. Consequently, P may now also decide to locally commit. Likewise, if Q is in state ABORT, P can safely abort as well.</p><p>Now suppose that Q is still in state INIT. This situation can occur when the coordinator has sent vote-request to all participants, but this message has reached P (which subsequently responded with a vote-commit message), but has not reached Q. In other words, the coordinator had crashed while multicasting vote-request. In this case, it is safe to abort the transaction: both P and Q can make a transition to state ABORT.</p><p>The most difficult situation occurs when Q is also in state READY, waiting for a response from the coordinator. In particular, if it turns out that all participants are in state READY, no decision can be taken. The problem is that although all participants are willing to commit, they still need the coordinator’s vote to reach the final decision. Consequently, the protocol blocks until the coordinator recovers.</p><p>To ensure that a process can actually recover, it is necessary that it saves its state to persistent storage. For example, if a participant was in state INIT, it can safely decide to locally abort the transaction when it recovers, and then inform the coordinator. Likewise, when it had already taken a decision such as when it crashed while being in either state COMMIT or ABORT, it is in order to recover to that state again, and retransmit its decision to the coordinator.</p><p>Problems arise when a participant crashed while residing in state READY. In that case, <strong>when recovering, it cannot decide on its own what it should do next</strong>, that is, commit or abort the transaction. Consequently, it is forced to contact other participants to find what it should do, analogous to the situation when it times out while residing in state READY as described above.</p><p>The coordinator has only two critical states it needs to keep track of. When it starts the 2PC protocol, it should record that it is entering state WAIT so that it can possibly retransmit the vote-request message to all participants after recovering. Likewise, if it had come to a decision in the second phase, it is sufficient if that decision has been recorded so that it can be retransmitted when recovering.</p><p>It may thus be possible that a participant will need to block until the coordinator recovers. This situation occurs when all participants have received and processed the vote-request message from the coordinator, while in the meantime, the coordinator crashed. In that case, participants cannot cooperatively decide on the final action to take. For this reason, 2PC is also referred to as a <strong>blocking commit protocol</strong>.</p><p>There are several solutions to avoid blocking. One solution is to use a multicast primitive by which a receiver immediately multicasts a received message to all other processes [Babaoglu and Toueg, 1993]. It can be shown that this approach allows a participant to reach a final decision, even if the coordinator has not yet recovered. Another solution is to use three instead of two phases.</p><p>Notes from Distributed Systems 3rd edition (2017), <a href="https://www.distributed-systems.net/">https://www.distributed-systems.net</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66c866975fb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Message Ordering]]></title>
            <link>https://medium.com/@macworks/message-ordering-16011fce95e1?source=rss-d187cdb8c939------2</link>
            <guid isPermaLink="false">https://medium.com/p/16011fce95e1</guid>
            <category><![CDATA[messaging]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Miguel ]]></dc:creator>
            <pubDate>Sat, 08 Dec 2018 22:37:35 GMT</pubDate>
            <atom:updated>2018-12-08T22:37:35.721Z</atom:updated>
            <content:encoded><![CDATA[<p>Virtual synchrony allows an application developer to think about multicasts as taking place in epochs that are separated by group membership changes. However, nothing has yet been said concerning the ordering of multicasts. In general, four different orderings are distinguished:</p><ol><li>Unordered multicasts</li><li>FIFO-ordered multicasts</li><li>Causally ordered multicasts</li><li>Totally ordered multicasts</li></ol><p>A <strong>reliable, unordered multicast</strong> is a virtually synchronous multicast in which no guarantees are given concerning the order in which received messages are delivered by different processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yIleP358DjaoZBCFazzl0w.png" /><figcaption>unordered multicast</figcaption></figure><p>P1 multicasts two messages to a group while two other processes in that group are waiting for messages to arrive. It is possible that the message-handling component at P2 first receives message m1 and then m2. Because there are no message ordering constraints, the messages may be delivered in the order that they are received. In contrast, the message-handling component at P3 may first receive message m2 followed by m1, and delivers these two in this same order to the higher-level application of P3.</p><p>In the case of <strong>reliable FIFO-ordered multicasts</strong>, the message-handling component layer is forced to <strong>deliver incoming messages from the same process in the same order as they have been sent.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TdjonU3O7KSnNsbe-64BWw.png" /><figcaption>FIFO-ordered multicasts</figcaption></figure><p>With FIFO ordering, the only thing that matters is that message m1 is always delivered before m2, and, likewise, that message m3 is always delivered before m4. This rule has to be obeyed by all processes in the group.</p><p><strong>Reliable causally ordered multicast</strong> delivers messages so that potential causality between different messages is preserved. In other words, if a message m1 causally precedes another message m2, regardless of whether they were multicast by the same sender, then the communication layer at each receiver will always deliver m2 after it has received and delivered m1. Note that causally ordered multicasts can be implemented using <strong>vector timestamps</strong>.</p><p><strong>Total-ordered delivery</strong> means that regardless of whether message delivery is unordered, FIFO ordered, or causally ordered, it is required additionally that when messages are delivered, they are delivered in the same order to all group members.</p><p>For example, with the combination of FIFO and totally ordered multicast, processes P2 and P3 in Figure 8.27 may both first deliver message m3 and then message m1. However, if P2 delivers m1 before m3, while P3 delivers m3 before delivering m1, they would violate the total-ordering constraint. Note that FIFO ordering should still be respected. In other words, m2 should be delivered after m1 and, accordingly, m4 should be delivered after m3.</p><p><a href="https://medium.com/@macworks/virtual-synchrony-575219a01252">Virtually synchronous</a> reliable multicasting offering total-ordered delivery of messages is called atomic multicasting.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16011fce95e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Virtual Synchrony]]></title>
            <link>https://medium.com/@macworks/virtual-synchrony-575219a01252?source=rss-d187cdb8c939------2</link>
            <guid isPermaLink="false">https://medium.com/p/575219a01252</guid>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Miguel ]]></dc:creator>
            <pubDate>Sat, 08 Dec 2018 17:32:31 GMT</pubDate>
            <atom:updated>2018-12-08T22:38:23.201Z</atom:updated>
            <content:encoded><![CDATA[<p>Virtual Synchrony is a mechanism or algorithm tackling the <strong>atomic<br>multicast problem</strong>. Similar to atomic transaction, atomic multicast refers to the scenario that a message is delivered to either all group members or to none at all. It is named virtual synchrony because operations are often performed concurrently and multicasts are often issued asynchronously, but algorithms can still be developed and reasoned about using simply, synchronous model.</p><p>Why atomicity is so important? consider a distributed database, all the nodes are replications of each other and form a group. Assume a client contacts a replica P and requests it to perform an update. The replica does so by multicasting the update to the other group members. Unfortunately, before the multicast completes, P crashes, leaving the rest of the group in a difficult position: some group members will have received the update request; others will not. If the members who have received the request deliver it to the database, then obviously we will have an inconsistent replicated database. This situation needs to be avoided and we should either have that the update is delivered to all nonfaulty members, or to none at all.</p><p>So we need a way to do <strong>reliable multicast</strong> in the presence of process failures. To achieve this, we make a distinction between <em>receiving</em> and <em>delivering</em> a message. In particular, we adopt a model in which the distributed system consists of message-handling components (middleware)as was shown in below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8FIobTdbgF81oFdgVL1yPQ.png" /></figure><p>This provides us another abstraction layer so that we can have finer control of how to deliver the message to the application. When we define atomic multicast, we restrict it happens at a particular <strong>group view</strong>. Group view is a list of processes that a multicast message m is uniquely associated with. Within this group view, the message should be delivered to all group view members, or to none at all. The sender bundles this group view (list) at the time message m was multicast. An important observation is that each process on that list has the same view. In other words, they should all agree that m should be delivered by each one of them and by no other process.</p><p>Now suppose that message m is multicast at the time its sender, say P, has group view <strong>G</strong>. Furthermore, assume that while the multicast is taking place, another process <strong>Q</strong> joins or leaves the group. This change in group membership is naturally announced to all processes in G. Stated somewhat differently, a view change takes place by multicasting a message <em>vc</em> announcing the joining or leaving of <strong>Q</strong>. We now have two multicast messages simultaneously in transit: <em>m</em> and <em>vc</em>. <strong>What we need to guarantee is that m is either delivered by all processes in G before any one executes the view change as specified by vc, or m is not delivered at all.</strong></p><p>Virtually synchrony guarantees that a message multicast to group view G is delivered by each nonfaulty process in G. If the sender of the message crashes during the multicast, the message is either delivered to all remaining processes, or ignored by each of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-MbkmJijAV2iSH6Q50FYg.png" /></figure><p>To illustrate these matters, consider the four processes shown above. At a certain point in time, we have a group consisting of S1, S2, S3, and S4. After some messages have been multicast, S3 crashes. However, before crashing, it succeeded in multicasting a message to processes S2 and S4, but not to S1. However, virtual synchrony in this case guarantees that the message is not delivered at all, effectively establishing the situation that the message was never sent before S3 crashed.</p><p>After S3 has been removed from the group, communication proceeds between the remaining group members. Later, when S3 recovers, it can join the group again, after its state has been brought up to date.</p><p>The principle of virtual synchrony comes from the fact that all multicasts take place between view changes. Put somewhat differently, a view change acts as a barrier across which no multicast can pass. All multicasts that are in transit while a view change takes place are completed before the view change comes into effect.</p><h4>Implementing virtual synchrony</h4><p>We use TCP as the point-to-point communication protocol. So multicasting a message m to a group of processes is implemented by reliably sending m to each group member. Note that although each transmission is guaranteed to succeed, this by no means guarantees that all group members receive m because the sender may fail before having transmitted m to each member. We also assumes that messages from the same source are received by a communication layer in the order they were sent by that source. In practice, this requirement is solved by using TCP connections for point-to-point communication.</p><p>The main problem that needs to be solved is to guarantee that all messages sent to view G are delivered to all nonfaulty processes in G before the next group membership change takes place. The first issue that needs to be taken care of is making sure that each process in G has received all messages that were sent to G. Note that because the sender of a message m to G may have failed before completing its multicast, there may indeed be processes in G that will never receive m. Because the sender has crashed, these processes should get m from somewhere else.</p><p>The solution to this problem is to let every process in G keep m until it knows for sure that all members in G have received it. If m has been received by all members in G, m is said to be <strong>stable</strong>. Only stable messages are allowed to be delivered. To ensure stability, it is sufficient to select an arbitrary live process in G and request it to send m to all other processes in G.</p><p>To be more specific, assume the current view is G, but that it is necessary to install the next view G’. Without loss of generality, we assume that G and G’ differ by at most one process. A process P notices the view change when it receives a view-change message. Such a message may come from the process wanting to join or leave the group, or from a process that had detected the failure of a process in G that is now to be removed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*KnlBpU2rJhcwrQRmgjdTyA.png" /><figcaption>Process 4 notices that process 7 has crashed and sends a view change.</figcaption></figure><p>When a process P receives the view-change message for G’ , it first forwards a copy of any unstable message from G it still has to every process in G’ , and subsequently marks it as being stable. Recall that we assumes point-to-point communication is reliable, so that forwarded messages are never lost. <strong>Such forwarding guarantees that all messages in G that have been received by at least one process are received by all nonfaulty processes in G’.</strong> Note that it would also have been sufficient to elect a single coordinator to forward unstable messages.</p><p>To indicate that P no longer has any unstable messages and that <strong>it is prepared to install G’ as soon as the other processes can do that as well</strong>, it multicasts a <strong>flush message</strong> for G’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*xgO3s7O0C3LCY65W-Sm5Gw.png" /><figcaption>Process 6 sends out all its unstable messages, followed by a flush message.</figcaption></figure><p>After P has received a flush message for G’ from each other process, it can safely install the new view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*9-Dc1P5SaKXSMGTbP44TMg.png" /><figcaption>Process 6 installs the new view when it has received a flush message from everyone else.</figcaption></figure><p>When a process Q receives a message m while Q still believes the current view is G , it delivers m taking any additional message-ordering constraints into account. If it had already received m, it considers the message to be a duplicate and discards it.</p><p>Because process Q will eventually receive the view-change message for G’ , it will also first forward any of its unstable messages and subsequently wrap things up by sending a flush message for G’ . Note that due to the assumed FIFO-<a href="https://medium.com/@macworks/message-ordering-16011fce95e1">message ordering</a> as provided by the underlying communication layer, a flush message from a process is always received after the receipt of an unstable message from that same process.</p><p>The major flaw in the protocol described so far is that it cannot deal with process failures while a new view change is being announced. In particular, it assumes that until the new view G’ has been installed by each member in G’ , no process in G’ will fail (which would lead to a next view G’’ ). This problem is solved by announcing view changes for any view Gi+k even while previous changes have not yet been installed by all processes. The details are rather intricate, yet the principle should be clear.</p><p>Notes from Distributed Systems 3rd edition (2017), <a href="https://www.distributed-systems.net/">https://www.distributed-systems.net</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=575219a01252" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Public Key Certification]]></title>
            <link>https://medium.com/@macworks/public-key-certification-14a70b6bf542?source=rss-d187cdb8c939------2</link>
            <guid isPermaLink="false">https://medium.com/p/14a70b6bf542</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[network-security]]></category>
            <dc:creator><![CDATA[Miguel ]]></dc:creator>
            <pubDate>Wed, 28 Nov 2018 04:38:17 GMT</pubDate>
            <atom:updated>2018-11-28T05:10:35.087Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@macworks/digital-signatures-9b21148db928">Previously</a> we mentioned that one important application of digital signatures is Public key certification. It is used in many popular secure networking protocols, including IPsec and SSL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*MDuemq-8KxNX27f3oOm1Qg.png" /></figure><p>Let’s consider Alice runs a pizza delivery business and Bob send Alice an order including his home address, the type of pizza he wants. He also includes a digital signature to prove to Alice that he’s the true source of the order. To verify the order, Alice obtains Bob’s public key (perhaps from a public key server or from the e-mail message) and checks the signature. In this manner, she rule of the possibility of prankster, and confirms the order.</p><p>The procedure is flawed in that Trudy could pretend to be Bob, send Alice the order with the digital signature and the public key to verify the signature all belong to Bob. Under this circumstance, Alice cannot verify the public key indeed belongs to Bob.</p><p>In order for the digital signature, public private key verification to work, we need to be able to verify that the actual public key we are using to communicate is indeed belong to the entity.</p><p>Binding a public key to a particular entity is typically done by a Certification Authority (CA), whose job is to validate identities and issues certificates. A CA has the following roles:</p><ol><li>A CA verifies that an entity (a person, a router, and so on) is who it says it is. However, there are no mandated procedures for how certification is done, therefore one might (or might not!) be more willing to trust a CA that is part of a federal or state program. <strong>You can trust the identity associated with a public key only to the extent to which you can trust a CA and its identity verification technique.</strong></li><li>Once the CA verifies the identity of the entity, the CA create certificate that binds the public key of the entity to the identity. The certificate contains the public key and globally unique identifying information about the owner of the public key (for example, a human name or an IP address). The certificate is digitally signed by the CA.</li></ol><p>How certificates can be used to combat pizza-ordering pranksters? When Bob places his order, he also sends his CA-signed certificate. Alice use the CA’s public key to check the validity of Bob’s certificate and extract Bob’s public key.</p><p>You can check more about CA at <a href="https://en.wikipedia.org/wiki/Certificate_authority">https://en.wikipedia.org/wiki/Certificate_authority</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14a70b6bf542" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digital Signatures]]></title>
            <link>https://medium.com/@macworks/digital-signatures-9b21148db928?source=rss-d187cdb8c939------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b21148db928</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[network-security]]></category>
            <dc:creator><![CDATA[Miguel ]]></dc:creator>
            <pubDate>Wed, 28 Nov 2018 03:46:52 GMT</pubDate>
            <atom:updated>2018-11-28T03:46:52.034Z</atom:updated>
            <content:encoded><![CDATA[<p>Previously we talked about <a href="https://medium.com/@macworks/message-integrity-92ef0493f398">Message Integrity</a> in network communication, now we introduce Digital Signatures.</p><p>Similar to the signature you sign checks or legal documents. In digital world, we also need a way to indicate the owner or creator of a document, or to signify one’s agreement with a document’s content. A <strong>digital signature</strong> is a cryptographic technique for achieving these goals. Digital signing should satisfy:</p><ol><li>The signature must be verifiable. To prove that a document signed by an individual was indeed signed by that individual.</li><li>The signature cannot be forged. Only that individual could have signed the document.</li></ol><p>How can we design such a digital signature scheme. When Bob signs a message, he must put something unique to him on this message. You may say that <a href="https://en.wikipedia.org/wiki/Message_authentication_code">MAC</a> is an option. But for Alice to verify the signature, she must also have the copy of the shared secret <em>s</em>, in which case the <em>s </em>would not be unique to Bob.</p><p>Recall that with public-key cryptography, Bob has both a public and private key, both are unique to him. It seems to be an excellent choice for providing digital signatures. Let’s see what can we do using public-key cryptography.</p><p>Suppose Bob wants to digitally sign a document, <em>m</em>. Bob can use his private key to compute the signature. (Note, here we do not use the private key to do encryption, because encryption and decryption are simply mathematical operations).</p><p>With message <em>m </em>and<em> </em>the<em> </em>digital signature of Bob, how can Alice prove that Bob had indeed signed the message and was the only person who could have possibly signed the message? She takes Bob’s public key and applies it to the digital signature, if she produces <em>m</em>, she can prove that only Bob could have signed the document for the following reasons:</p><ul><li>Whoever signed the message must have used the private key in computing the signature.</li><li>The only person who could have known the private key is Bob. (Knowing the public key is of no help in learning the private key. Therefore the only person who could know the private key is the person who generate the pair of keys in the first place, assuming Bob does not give anyone his private key, nor anyone stolen his private key)</li></ul><p>We also notice that using this method, once the original message is modified, the signature of Bob will be invalid for the new message. So digital signatures also provide message integrity.</p><p>Since signing and checking message using private and public key is expensive, a more efficient approach is to sign <em>H(m)</em> and then use private key to calculate <em>H(m)</em> as the signature for <em>m</em>.</p><p>For Alice to verify, she will use the public key to get H(m) first, then use the same hash function to compute and compare whether the two H(m) are the same.</p><p>Next, we will talk about one important application of digital signature, <strong>public key certification</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b21148db928" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Message Integrity]]></title>
            <link>https://medium.com/@macworks/message-integrity-92ef0493f398?source=rss-d187cdb8c939------2</link>
            <guid isPermaLink="false">https://medium.com/p/92ef0493f398</guid>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Miguel ]]></dc:creator>
            <pubDate>Wed, 28 Nov 2018 01:51:28 GMT</pubDate>
            <atom:updated>2018-11-28T01:53:14.009Z</atom:updated>
            <content:encoded><![CDATA[<p>Encryption, Message Integrity and Digital Signatures go hand in hand in our daily communication. Here we talk about <strong>message integrity</strong>.</p><p>If Bob receives a message (either be encrypted or be in plaintext) from Alice, he needs to verify:</p><ol><li>The message indeed originated from Alice.</li><li>The message was not tempered with on its way to Bob.</li></ol><p>Before talking about how to achieve the above goals, we need to introduce cryptographic hash functions.</p><p>A hash function takes an input, <em>m</em>, and computes a fixed-size string <em>H(m)</em>. A cryptographic hash function also needs to satisfy an additional property:</p><ul><li>It is computationally infeasible to find any two different messages <em>x</em> and <em>y</em> such that <em>H(x) = H(y)</em>.</li></ul><p>Common hash algorithms are MD5 [RFC 1321] and SHA-1 [FIPS 1995].</p><p>After we having the cryptographic hash function. A naive step to perform message integrity would be:</p><ol><li>Alice creates message m and send Bob <em>(m, H(m))</em>.</li><li>After Bob receives <em>(m, H(m))</em>, he uses the same hash function to check whether after hashing m, the result is equal to the <em>H(m)</em> he received from Alice.</li></ol><p>The approach is flawed because other party can also send message to bob (<em>m’, H(m’))</em> claiming that this is from Alice, and Bob has no way to tell even the hash result is correct.</p><p>In order to prove the message is indeed from Alice, Alice and Bob should have a shared secret <em>s</em>. This shared secret is called <strong>authentication key</strong>. Using this shared secret, message integrity can be performed as:</p><ol><li>Alice creates message <em>m</em>, concatenates <em>s</em> to <em>m</em>, calculates <em>H(m+s)</em>, sends Bob <em>(m, H(m+s))</em>. <em>H(m+s)</em> here is called the <strong>message authentication code (MAC)</strong>.</li><li>Bob receives <em>(m, H(m+s))</em>, calculates the MAC using his <em>s</em>, check whether it is the same <em>H(m+s)</em> he received from the message.</li></ol><p>Note that <strong>message integrity</strong> does not imply or require encrypting the message between Alice and Bob. However, a remaining issue is, how do we distribute the shared authentication key between Alice and Bob? We will discuss it in another article.</p><p>This is a notes from Chapter 8.3, Computer Networking: A Top-Down Approach, 7th Edition</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92ef0493f398" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[shadowsocks作者在警方压力下删除项目]]></title>
            <link>https://medium.com/@macworks/shadowsocks%E4%BD%9C%E8%80%85%E5%9C%A8%E8%AD%A6%E6%96%B9%E5%8E%8B%E5%8A%9B%E4%B8%8B%E5%88%A0%E9%99%A4%E9%A1%B9%E7%9B%AE-5f707ee79b4d?source=rss-d187cdb8c939------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f707ee79b4d</guid>
            <category><![CDATA[shadowsocks]]></category>
            <dc:creator><![CDATA[Miguel ]]></dc:creator>
            <pubDate>Sat, 22 Aug 2015 13:54:45 GMT</pubDate>
            <atom:updated>2015-09-02T15:42:18.686Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/shadowsocks/shadowsocks-iOS/issues/124#issuecomment-133630294">https://github.com/shadowsocks/shadowsocks-iOS/issues/124#issuecomment-133630294</a></p><blockquote>Two days ago the police came to me and wanted me to stop working on this. Today they asked me to delete all the code from GitHub. I have no choice but to obey.</blockquote><blockquote>I hope one day I’ll live in a country where I have freedom to write any code I like without fearing.</blockquote><blockquote>I believe you guys will make great stuff with Network Extensions.</blockquote><blockquote>Cheers!</blockquote><p>BBC记者，请问你有孩子吗的故事依然萦绕在耳边。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f707ee79b4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>