<?xml version="1.0" encoding="ISO-8859-1" ?>
  <resource>
  <id>2200</id>
  <path>/www/nrich/html/content/04/03/article4/</path>
  <resourceTypeID>3</resourceTypeID>
  <last_published>2011-02-01T00:00:01</last_published>
  <indexXML>&lt;mdoxml version=&quot;1.0&quot;&gt;&lt;br&gt;&lt;/br&gt;
&lt;p&gt;&lt;mdo:image width=&quot;264&quot; height=&quot;92&quot; src=&quot;key_export.png&quot; alt=&quot;Key&quot;&gt;&lt;/mdo:image&gt;&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
The idea of Public Key Cryptography is to send messages in such a way that only the person who receives them can understand them even if the method of encryption is discovered by 'an enemy' who intercepts the messages. The person who sends the message &lt;span style=&quot;font-style: italic;&quot;&gt;encodes&lt;/span&gt; it; the person who receives the message &lt;span style=&quot;font-style: italic;&quot;&gt;decodes&lt;/span&gt; it
(puts it back into a readable form). &lt;span style=&quot;font-style: italic;&quot;&gt;Public Key Cryptography&lt;/span&gt; was discovered (or invented?) by R. Rivest, A. Shamir and L.Adleman about 1970. This method has been widely used to ensure security and secrecy in electronic communication and particularly where financial transactions are involved.&lt;/p&gt;
&lt;p&gt;The method depends on the fact that while it is easy to calculate the product of two large prime numbers (particularly with the help of a computer) it is, for all practical purposes, impossible to find the factors of a large number if it has only very large prime factors. This is because all methods of finding such factors would take many many thousands of years by even the fastest modern
computers.&lt;/p&gt;
&lt;p&gt;In order to understand this article you need to know that two numbers are said to be congruent in modulus arithmetic if their difference is divisible by the modulus. For example 23 is congruent to 2 modulus 7 because the difference between 2 and 23 is divisible by 7. Another way of expressing this is to say $a\equiv b \pmod{m}$ if and only if $a=pm+b$ where $p$ is an integer. Everything else
you need to know is explained in the article.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;The Basic Idea&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bob wants to receive a coded message from Alice&lt;/li&gt;
&lt;li&gt;EVERYBODY knows how to write the message in code.&lt;/li&gt;
&lt;li&gt;Bob is the ONLY person who knows how to decode the coded message.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;The idea is that Bob chooses two (very large) prime numbers $p$ and $q$, and then writes $n=p q$. Then $n$ is used to code the message, but $p$ and $q$ are needed to decode the message.&lt;/div&gt;
&lt;br&gt;&lt;/br&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;The Details&lt;/div&gt;
&lt;ol&gt;
&lt;li style=&quot;font-weight: 400;&quot;&gt;Bob chooses two very large (distinct) prime numbers $p$ and $q$;&lt;/li&gt;
&lt;li style=&quot;font-weight: 400;&quot;&gt;$n = pq$, $\quad m =$ $lcm$ {$p-1$, $q-1$} (lcm is the &lt;span style=&quot;font-style: italic;&quot;&gt;least common multiple&lt;/span&gt; );&lt;/li&gt;
&lt;li style=&quot;font-weight: 400;&quot;&gt;Bob chooses $r$, where $r &amp;gt; 1$ and $r$ is coprime with $m$ (i.e. $r$ and $m$ have no factors in common);&lt;/li&gt;
&lt;li style=&quot;font-weight: 400;&quot;&gt;Bob then finds the &lt;span style=&quot;font-style: italic;&quot;&gt;unique&lt;/span&gt; $s$ such that $rs \equiv 1 \pmod{m}$&lt;/li&gt;
&lt;li style=&quot;font-weight: 400;&quot;&gt;Bob now tells everyone what $n$ and $r$ are, but does NOT say what $p$, $q$ or $s$ are.&lt;/li&gt;
&lt;li style=&quot;font-weight: 400;&quot;&gt;Alice wants to send the message $M$ (a single number) where $M$ and $n$ are coprime and $0&amp;lt; M&amp;lt; n$.&lt;/li&gt;
&lt;li style=&quot;font-weight: 400;&quot;&gt;Alice finds $M_c$, where $M_c \equiv M^r \pmod{n}$, and sends the message $M_c$ to Bob.&lt;/li&gt;
&lt;li style=&quot;font-weight: 400;&quot;&gt;Bob receives the message $M_c$ from Alice and decodes it.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now Bob knows $p,q,m,n,r,s$, and he uses these to decode the message $M_c$ from Alice so as to find $M$. To do this Bob uses the theorem that $(M_c)^s \equiv M \pmod n$&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
In the following example we use small numbers so that you can work through it using a calculator. In practice the numbers would be &lt;span style=&quot;font-weight: bold;&quot;&gt;very&lt;/span&gt; big.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;An example&lt;/span&gt;&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(1)&lt;/span&gt; Alice wishes to send the message $M$ to Bob&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(2)&lt;/span&gt; Bob chooses $p=17$, $q=23$; so $n=391$, $m=176$, $r=3$ and $s=59$.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(3)&lt;/span&gt; Bob then tells Alice that $n=391$ and $r=3$.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(4)&lt;/span&gt; Note: It does not matter how many people have this information, they still won't be able to find $s$.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(5)&lt;/span&gt; Alice computes $M_c$ and finds that $M_c=180$.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(5)&lt;/span&gt; Bob receives the coded message $180$ from Alice&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(6)&lt;/span&gt; Bob now calculates $M \equiv 180^{59} \pmod {391}$, and finds Alice's secret message $M$. Can you find it?&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
In order to find Alice's message you may need some help from the following section.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Working with modulus arithmetic&lt;/span&gt;&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
You need to use the following facts:&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(1)&lt;/span&gt; If $a\equiv b \pmod n$ then $a c\equiv b c \pmod n$&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(2)&lt;/span&gt; If $a\equiv b \pmod n$ then $a^k\equiv b^k \pmod n$.&lt;br&gt;&lt;/br&gt;
The proofs of these results are simple.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(1)&lt;/span&gt; If $a\equiv b \pmod n$ then $n$ divides $a-b$ and if $n$ divides $a-b$ then $n$ divides $(a-b)c=a c-b c$ which is the same as saying $a c\equiv b c \pmod n$.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;(2)&lt;/span&gt; As $a^k-b^k$ always has a factor $a-b$ for all k it follows that if $n$ divides $a-b$ then $n$ divides $a^k-b^k$ so if $a\equiv b \pmod n$ then $a^k\equiv b^k \pmod n$.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
In order to find the secret number that Alice sent to Bob as described above you will need to use the same sort of method as in the following example. Suppose you want to find $x$ where ($0\leq x\leq 100$) and $17^{13}\equiv x \pmod {101}$. As $17^{13}$ is too large for most calculators to show exactly we start with $17^6=24137569$ and, first dividing this by 101, we find that
$17^6=(238985)(101)+84$ so we now know that $17^6\equiv 84 \pmod{101}.$ The next step is to use this to tackle $17^{13}$. $$\eqalign{ 17^{13}&amp;amp;=(17^6)^2 \times 17 \\ &amp;amp;\equiv 84^2 \times 17 \equiv 119952 \pmod {101} \\ 119952 &amp;amp;=1187\times 101 + 65 \\ &amp;amp;\equiv 65 \pmod{101}.}$$ Hence $x=65$.&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
Finally we prove the theorem that $(M_c)^s = M^{rs} \equiv M \pmod n$, where $M$ and $n$ are coprime, given that \+(i) $rs\equiv 1 \pmod m$ \\ \+(ii) $m= {\rm lcm}\ [(p-1), (q-1)]$ \\ \+(iii) $n=pq$ \\&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-style: italic;&quot;&gt;Proof&lt;/span&gt;&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
As $M$ and $n$ are coprime we know that $M$ and $p$ are coprime and $M$ and $q$ are coprime. By Fermat's Little Theorem it follows that $$\eqalign{ M^{p-1}&amp;amp;\equiv 1 \pmod p \\ M^{q-1}&amp;amp;\equiv 1 \pmod q }.$$ Also $(p-1)$ and $(q-1)$ divide $m$ so say $m=j(p-1)=k(q-1)$, then $$M^m={(M^{p-1})}^j\equiv 1^j \equiv 1 \pmod p.$$ Similarly $$M^m={(M^{q-1})}^k\equiv 1^k \equiv 1 \pmod q.$$ So both
$p$ and $q$ divide $M^m-1$ and, as $n=p q$, it follows that $M^m\equiv 1 \pmod n$. We know that $rs\equiv 1 \pmod m$ so $rs=1+mt$ for some integer $t$. Putting all this together we have $$M^{r s}=(M^1)(M^{m t})\equiv M \pmod{n}.$$&lt;br&gt;&lt;/br&gt;
&lt;br&gt;&lt;/br&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;For Further Reading&lt;/span&gt;&lt;br&gt;&lt;/br&gt;
Singh, Simon (1999) 'The Code Book - The Science of Secrecy from Ancient Egypt to Quantum Cryptography', The Fourth Estate, London ISBN 1 85702 879 1&lt;br&gt;&lt;/br&gt;
Flannery, Sarah (2000) 'In Code - A Mathematical Journey' Profile Books, ISBN 1 86197 222 9 This is a unique book, written by a teenager, and highly recommended for all young people interested in mathematics.&lt;/p&gt;
&lt;br&gt;&lt;/br&gt;&lt;/mdoxml&gt;</indexXML>
  <solutionXML/>
  <noteXML/>
  <clueXML/>
  <canonXML/>
  <end_user_role>2</end_user_role>
  <difficulty>5</difficulty>
  <keystage1>0</keystage1>
  <keystage2>0</keystage2>
  <keystage3>0</keystage3>
  <keystage4>0</keystage4>
  <keystage4plus>1</keystage4plus>
  <title>Public Key Cryptography</title>
  <description>An introduction to the ideas of public key cryptography using small
numbers to explain the process. In practice the numbers used are
too large to factorise in a reasonable time.</description>
  <spec_group>Using, Applying and Reasoning about Mathematics
    <specifier>Real world</specifier>
  </spec_group>
  <spec_group>Numbers and the Number System
    <specifier>Factors and multiples</specifier>
  </spec_group>
  <spec_group>Numbers and the Number System
    <specifier>Divisibility</specifier>
  </spec_group>
  <spec_group>Numbers and the Number System
    <specifier>Prime factors</specifier>
  </spec_group>
  <spec_group>Algebra
    <specifier>Index notation/Indices</specifier>
  </spec_group>
</resource>