<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Alice and Bob in Cryptoland &#187; RSA</title>
	<atom:link href="http://alicebob.cryptoland.net/tag/rsa/feed/" rel="self" type="application/rss+xml" />
	<link>http://alicebob.cryptoland.net</link>
	<description></description>
	<lastBuildDate>Mon, 14 Feb 2011 13:29:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Visualizing group structure with colored addition/multiplication tables</title>
		<link>http://alicebob.cryptoland.net/visualizing-group-structure-with-colored-additionmultiplication-tables/</link>
		<comments>http://alicebob.cryptoland.net/visualizing-group-structure-with-colored-additionmultiplication-tables/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 04:32:51 +0000</pubDate>
		<dc:creator>Conrado</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[elliptic curve]]></category>
		<category><![CDATA[field]]></category>
		<category><![CDATA[group]]></category>
		<category><![CDATA[RSA]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://alicebob.cryptoland.net/?p=70</guid>
		<description><![CDATA[When working with finite fields, if the number of elements is a prime power with m &#62; 1, you can represent the elements as polynomials with degree m-1 and do the field addition and multiplication modulo a irreducible polynomial with degree m. The field GF(5) is composed by the numbers 0 to 4. We don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>When working with finite fields, if the number of elements is a prime power <img src='http://s.wordpress.com/latex.php?latex=p%5Em&#038;bg=T&#038;fg=000000&#038;s=0' alt='p^m' title='p^m' class='latex' /> with m &gt; 1, you can represent the elements as polynomials with degree m-1 and do the field addition and multiplication modulo a irreducible polynomial with degree m.</p>
<p>The field GF(5) is composed by the numbers 0 to 4. We don&#8217;t need to represent its elements as polynomials since m=1. Addition is done modulo 5 and multiplication also modulo 5. So 2 + 3 = 0; 4 * 2 = 3; and so on. This is the addition table for GF(5):</p>
<p class="aligncenter">
<a href="http://alicebob.cryptoland.net/files/z5m.png"><img src="http://alicebob.cryptoland.net/files/z5m.png" alt="Multiplicative table of integers modulo 5" width="100" height="100" class="size-full wp-image-74" /></a></p>
<p>The rows, top down, represent 0 to 4. The columns, right to left, represent 0 to 4. Each square is the result of the addition of the respective numbers in the row / column it belongs to. Black is 0, purple is 1, red is 2, orange is 3, yellow is 4.</p>
<p>In the field GF(25) = GF(5²), as I said, you represent each element as a polynomial. So we have 25 elements: 0 to 4; x, x+ 1, &#8230;, x + 4; 2x, 2x + 1, &#8230;; 3x, 3x + 1, &#8230;; 4x, 4x + 1, &#8230;, 4x + 4.</p>
<p>In order to add two elements, add them as you would add two polynomials, but remember that the coefficients are in GF(5); for example, in GF(5²), we have (3x + 2) + (4x + 4) = (2x + 1). In order to multiply two elements, multiply them as usual but then take the result modulo an irreducible polynomial. So, with GF(5²) modulo <img src='http://s.wordpress.com/latex.php?latex=x%5E2%20%2B%204x%20%2B%202&#038;bg=T&#038;fg=000000&#038;s=0' alt='x^2 + 4x + 2' title='x^2 + 4x + 2' class='latex' />, you have (2x + 5) * (3x + 4) = (4x + 3).</p>
<p>I always wondered what would happen when you changed the modulus. Obviously the group &#8220;changes&#8221;, but in order to actually see it, I&#8217;ve built the multiplication table for GF(5²) modulus <img src='http://s.wordpress.com/latex.php?latex=x%5E2%20%2B%204x%20%2B%202&#038;bg=T&#038;fg=000000&#038;s=0' alt='x^2 + 4x + 2' title='x^2 + 4x + 2' class='latex' /> and <img src='http://s.wordpress.com/latex.php?latex=x%5E2%20%2B%203x%20%2B%203&#038;bg=T&#038;fg=000000&#038;s=0' alt='x^2 + 3x + 3' title='x^2 + 3x + 3' class='latex' />:</p>
<p class="aligncenter">
<img src="http://alicebob.cryptoland.net/files/gf25m_x2_4x_2.png" alt="Multiplicative table for GF(5^2)/(x^2+4x+2)" width="200" height="200" class="size-medium wp-image-76" /><img src="http://alicebob.cryptoland.net/files/gf25m_x2_3x_3.png" alt="Multiplicative table for GF(5^2)/(x^2+3x+3)" width="200" height="200" class="size-medium wp-image-85" />
</p>
<p>Yep, they&#8217;re different <img src='http://alicebob.cryptoland.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Of course, both are isomorphic, so you&#8217;re free to pick your favorite modulus.</p>
<h3>Multiplicative group of integers modulo n vs group of points in a elliptic curve</h3>
<p>Then I got curious: how would the multiplication table of integers modulo n look like? This group is the group used in many cryptographic schemes, like RSA. This is the multiplication table for integers modulo 509:</p>
<p class="aligncenter">
<img src="http://alicebob.cryptoland.net/files/z509m.png" alt="Multiplicative table for integers modulo 509" width="508" height="508" class="size-full wp-image-78" />
</p>
<p>Pretty (and trippy)!</p>
<p>What about the group of points on a elliptic curve over a finite field, which is also a group used in cryptographic schemes? This is the additive table for the points on <img src='http://s.wordpress.com/latex.php?latex=y%5E2%20%3D%20x%5E3%20%2B%204x%20%2B%201&#038;bg=T&#038;fg=000000&#038;s=0' alt='y^2 = x^3 + 4x + 1' title='y^2 = x^3 + 4x + 1' class='latex' /> over GF(503):</p>
<p class="aligncenter">
<img src="http://alicebob.cryptoland.net/files/e_4_1_503.png" alt="Additive table for points in y^2 = x^3 +4x + 1 over GF(503)" width="516" height="516" class="size-full wp-image-79" />
</p>
<p>The difference between them is striking; the elliptic group seems almost random. This is (intuitively speaking! I’m not being formal here) the reason why this group is used in cryptography in the first place: since the group structure is more “messed up”, you can get away with using groups of much smaller size (no smaller than <img src='http://s.wordpress.com/latex.php?latex=2%5E%7B160%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='2^{160}' title='2^{160}' class='latex' /> elements) than with multiplicative groups of integers modulo n (no smaller than <img src='http://s.wordpress.com/latex.php?latex=2%5E%7B1024%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='2^{1024}' title='2^{1024}' class='latex' /> elements). This is not set in stone though; maybe someday someone will come up with a better method to crack this seemingly random structure (for now the best method to solve the discrete log problem for elliptic groups is exponential, while the best method for integers modulo n is sub-exponential).</p>
<p>It’s worth mentioning that even this elliptic group is not that extraordinary: it is isomorphic to the very simple additive group of integers modulo 506:</p>
<p class="aligncenter"><img src="http://alicebob.cryptoland.net/files/z506a.png" alt="Additive table of integers modulo 516" width="506" height="506" class="size-full wp-image-89" />
</p>
<p>The big problem is to find the isomorphism! You can see this better with a small example. This is the elliptic group of <img src='http://s.wordpress.com/latex.php?latex=y%5E2%20%3D%20x%5E3%20%2B%203x%20%2B%202&#038;bg=T&#038;fg=000000&#038;s=0' alt='y^2 = x^3 + 3x + 2' title='y^2 = x^3 + 3x + 2' class='latex' /> over GF(5) (left) which is isomorphic to the additive group modulo 5 (right):</p>
<p class="aligncenter">
<img src="http://alicebob.cryptoland.net/files/e_3_2_5.png" alt="Additive table of points on y^2 = x^3 + 3x + 2 over GF(5)" width="100" height="100" class="size-full wp-image-81" /><img src="http://alicebob.cryptoland.net/files/z5a.png" alt="Additive table for integers modulo 5" width="100" height="100" class="size-full wp-image-83" />
</p>
<p>(OK, it&#8217;s not that easy to see)</p>
<h3>Software</h3>
<p>To generate those images, I&#8217;ve used Python with <a href="http://www.pythonware.com/products/pil/">PIL</a> and <a href="http://www.sagemath.org/">Sage</a>. Sage aims to be a open source replacement for (expensive) software like Magma, Maple, Mathematica and Matlab. Since I&#8217;ve never used those, I can&#8217;t really say how it is going in its mission, but it&#8217;s really awesome. If you&#8217;re a Windows user you&#8217;ll probably be scared by the fact that the Windows version of Sage is actually an entire Linux virtual machine! They&#8217;re working to port it natively, but even until then, it&#8217;s worth it (and you&#8217;ll have an excuse to try Linux <img src='http://alicebob.cryptoland.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<h3>Update</h3>
<p>Someone asked for the source code used to generate those. It&#8217;s ugly (I&#8217;ve added comments at least) but you can download it here: the <a href="http://alicebob.cryptoland.net/files/gentable.sage">sage script</a> and the <a href="http://alicebob.cryptoland.net/files/plottable.py">python script</a>. In the sage script, uncomment the lines representing what you want to plot, then run <code>./sage gentable.sage</code> (or whichever path to were sage is). It will generate a data.txt in the same folder. Now run <code>python plottable.py img.png</code> to plot it on the img.png file (or omit it to show on the screen). You&#8217;ll need to have PIL installed.</p>
<p>If you don&#8217;t want to plot fancy stuff as elliptic groups, you can easily transform the gentable.sage into a normal Python script and write the addition/multiplication yourself (like a + b % n). Have fun, and feel free to ask anything.</p>
]]></content:encoded>
			<wfw:commentRss>http://alicebob.cryptoland.net/visualizing-group-structure-with-colored-additionmultiplication-tables/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

