Created by Steven Baltakatei Sandoval on 2019-08-15T06:46:35Z under a CC BY-SA 4.0 license and last updated on 2019-08-15T20:16:52Z.
It is possible to determine how far two computers are from eachother using the speed of light and ping time. The physical distance is, at most, the ping time multiplied by the speed of light. This documents explains the Hancke-Kuhn protocol that can calculate this upper bound for the distance between a Verifier V and a Prover P through the sending and receiving of certain bit sequences. This calculation is useful for location-based authentication technology (ex: RFID, contactless payment) defending against man-in-the middle attacks.
I have written this explanation in order to help solidify my own understanding of the protocol before I write my own implementation of it at my GitLab repository. It is an explanation in my own words. Any errors or misrepresentations are entirely my own.
A more detailed summary with references to academic papers was published by Cristina Onete which may be found here on her website's publication page.
This document makes use of MathML for displaying equations. Firefox 60.0 esr should render MathML symbols correctly.
In 2005, Gerhard P. Hancke and Markus G. Kuhn proposed a distance-bounding protocol as a defense against man-in-the-middle attacks for people who use RFID tokens in order to automatically authenticate themselves for a location-based service such as the opening of a door or purchase at a specific point-of-sale device.
An example of a man-in-the-middle attack for such a building access-control could be two attackers maliciously forwarding radio traffic between an RFID token and a building RFID reader without the RFID token owner's knowledge even in the case where the token is located at a great distance from the reader. The idea to strengthen an RFID token against such an attack is to equip the building RFID reader with some means of proving the token is physically located within a specific distance.
The goal of this project is to apply this concept to the ping time between two computers in order to prove how close the computers are from eachother. A distance-bounding protocol proof uses the distance, speed, and time equation solved for distance.
The speed is set to the speed of light since one conclusion from the theory of special relativity is that no information signal or material can travel faster than light in a vacuum. The time is set to half the ping time (round trip time divided by .
In the protocol, a verifier, V, and a prover, P, create a pair of one-time-use pseudorandom bit sequences, and , each containing elements. Each element or is a bit whose value is either or . These sequences can be represented like so:
Regarding these bit sequences, V rapidly asks P a stream of questions. A question may take only one of the two forms:
What is the th bit of , ?
What is the th bit of , ?
The stream of questions start with and end with .
In order to decide which question V asks P, V generates a private random bit sequence, , which consists of elements. The rule V follows is that if then V requests that P supply . If then V requests that P supply . In other words, at each round, , V randomly chooses which of the two questions to ask P.
After sending a question to P, V records the exact time and increments by .
Because cause must precede effect, P cannot provide a correct answer to V until after P receives the question. Since the speed of light is the maximum rate at which any information can travel through space, there is a minimum ping time (or "time of flight") for any given distance between V and P which can be used by the protocol to prove an upper bound to the distance between V and P.
Immediately after receiving a question, P sends to V the value which is the requested bit from either or . The set of these responses can be written as .
Upon receiving each response, V records the exact time in order to calculate that particular question-response round-trip time (or "ping time").
To help explain how this process works below is an example that sets and walks you through how to calculate the response bit sequence, .
Verifier V and Prover P assemble and agree upon pseudorandom bit sequences and
Verifier V secretly produces a pseudorandom bit sequence :
V sends each bit of , one at a time, starting from until . V notes the exact time when it sent each value of .
P receives and uses each bit of to determine whether to immediately send the bit or to V in response. If all bits are received and sent without error, P will eventually have sent the set .
V receives and records the arrival time for each response bit, . V calculates the round-trip time for each round. The resulting values of are:
Below is a table illustrating how the example values for these bit sequences correlate. I have bolded the values of and which were sent by P in response to the values sent of sent by V.
At each step V records the round trip time required between the sending of the question and the receiving of the correct answer from P. Given enough correct answers from P, V can then use the average value of the round trip time, , of correct responses in order to calculate with some statistical certainty that P is physically located within a distance, . The distance, can be calculated using the following two equations (pg 68, Hancke 2005).
In the language of the Hancke paper, variables in the two equations are defined as:
is the propagation speed, is the one way propagation time, is the measured total round-trip time, and is the processing delay of the remote device.
A conservative practice defines for the processing delay variable. It is conservative because is a function of the capabilities of the hardware P uses to process requests from V. If both P and V trust eachother to use specific hardware with consistent and accurate estimates for response times then may be specified. However, the Hancke protocol-Kuhn does not provide a means for proving or incentivizing P to accurately measure and report its own hardware capability.
The highest possible propagation speed, , according to the laws of physics is the speed of light in a vacuum. According to section 22.214.171.124 of the 8th edition of the International System of Units, a document published by the International Bureau of Weights and Measures, this speed is .
The statistical certainty that the round-trip time between P and V is less than is where is the "false-accept probability". The value of must be a statistical estimate constrained by the possibility that prover, P, maliciously sends its best guesses before receiving the questions from V. If P dishonestly wishes to convince V that the distance is lower than it really is, then P can achieve a probability of guessing correctly for a given round without having yet received that round's value of . This is because, on average, half of the rounds do not require guessing at all since half the time . The other half of the time P's best strategy, assuming V generated securely, is to guess or at random.
The false acceptance probability, or "False-Acceptance Rate", , of V accepting the distance-bounding protocol proof of P can be calculated using the following equation found on the sixth page of the Hancke paper. This equation calculates assuming V judges that receiving correct responses out of total rounds is acceptable.
The equation states that is equal to the sum of each individual probability where P guessed correctly or more times (for example: one outcome exists where P guesses perfectly, some outcomes where P makes only one mistake, some outcomes where P makes two mistakes, etc.). The total number of terms in the sum is of .
In other words, the final term (the 'th term) of the sum is the probability that P guesses correctly in exactly every single response (one very rare possibility). The penultimate term (the 'th term) is the probability that P guesses correctly every single time except for exactly one mistake somewhere (a slightly less rare possibility). The 'th term is the probability that P guesses all responses correctly but with two errors somewhere. The 'th term is the probability that P guesses all responses correctly but with three errors somewhere, and so forth. The first term of the sum is the probability that P guesses correctly exactly times out of responses and therefore provided incorrect responses exactly times. Each term of the sum is the binomial probability function (a.k.a. "binomial distribution formula" or "probability mass function") which should be part of the syllabus for any a typical Statistics course.
Since no factor of the equation for can be made exactly equal to zero it is impossible for Verifier V to completely eliminate the possibility that P could forge this distance-bounding proof. The best V can do to strengthen confidence in the proof's validity is to set the parameters and to values that produce an acceptably low value for , the probability of falsely accepting a maliciously constructed proof by Prover P.
Below is a copy of the previous example table but with values of and bolded when . From inspection it should be clear that P does not have to guess roughly half of the rounds since a quarter of the time and a quarter of the time .
Side note: I believe the inefficiency of allowing the protocol to have instances where is due to Hancke designing the protocol to be simple in order to accomodate implementation in RFID tags with limited computatioinal ability and over noisy communication channels. The scope of my [Proof of Ping project][glbk2019pypop] doesn't include attempting to improve the protocol but to simply implement it as described in the Hancke paper.
In order to illustrate how the False-Acceptance Rate, , is calculated, let us say that V was programmed to accept correct responses out of (, ). For this case the calculation of is detailed in this spreadsheet file (in ODS format) as well directly below.
The binomial coefficient factor in the equation can be expanded out, with signifying the factorial operation (for example, ).
The sum consists consist of a total of terms.
The last term () is:
The penultimate term () is:
The first term () is:
The sum of these three terms is:
Therefore, the False-Acceptance Rate, can be written as:
In other words, if V decides to accept only or more correct bits from from P out of a possible bits in the bit sequences they exchange, then there is about a chance that P could fool V into accepting that the distance between them was lower than it physically is. P could do this by completely disregarding V's questions, , and sending only best guesses for bit sequence given the structure of and .