<?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; field</title>
	<atom:link href="http://alicebob.cryptoland.net/tag/field/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>The Frobenius endomorphism with finite fields</title>
		<link>http://alicebob.cryptoland.net/the-frobenius-endomorphism-with-finite-fields/</link>
		<comments>http://alicebob.cryptoland.net/the-frobenius-endomorphism-with-finite-fields/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 03:17:29 +0000</pubDate>
		<dc:creator>Conrado</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[field]]></category>
		<category><![CDATA[frobenius]]></category>
		<category><![CDATA[sage]]></category>

		<guid isPermaLink="false">http://alicebob.cryptoland.net/?p=153</guid>
		<description><![CDATA[The Frobenius endomorphism is defined as: where p is the characteristic of the ring you&#8217;re working with. Simple, right? If you&#8217;re working with a field with prime order, then Frobenius is actually the identity map. Since the order of the multiplicative subgroup is p, when you raise to the power of p you get back [...]]]></description>
			<content:encoded><![CDATA[<p>The Frobenius endomorphism is defined as:</p>
<img src='http://s.wordpress.com/latex.php?latex=%5CPhi%28x%29%3Dx%5Ep&#038;bg=T&#038;fg=000000&#038;s=0' alt='\Phi(x)=x^p' title='\Phi(x)=x^p' class='latex' />
<p>where p is the characteristic of the ring you&#8217;re working with. Simple, right?</p>
<p>If you&#8217;re working with a field with prime order, then Frobenius is actually the identity map. Since the order of the multiplicative subgroup is p, when you raise to the power of p you get back to x due to <a href="http://en.wikipedia.org/wiki/Fermat%27s_little_theorem">Fermat&#8217;s little theorem</a>. Things get more interesting when you&#8217;re working with a extension field (i.e. a field which order is a prime power).</p>
<p>I&#8217;m studying <a href="http://en.wikipedia.org/wiki/Pairing#Pairings_in_Cryptography">pairings</a> for my master&#8217;s degree and the Frobenius endomorphism appears all the time in their computation. For example, you need to do a &#8220;final exponentation&#8221; which can be split in multiple exponentiations, and some of them are to the power of p. This is good because powering to p is &#8220;easy&#8221; due to Frobenius, or at least all the papers I read said so. But for a while I couldn&#8217;t see why, and that&#8217;s the reason I&#8217;m posting this. It&#8217;s really easy; it&#8217;s just not that obvious to see why.</p>
<h3>Why Frobenius is easy?</h3>
<p>Say you&#8217;re working with a quadratic extension, that is, with a field <img src='http://s.wordpress.com/latex.php?latex=GF%28p%5E2%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='GF(p^2)' title='GF(p^2)' class='latex' /> where p is a prime. You can represent this group with polynomials of degree 1 which can be added the usual way and multiplied taking the result modulo a irreducible polynomial of degree 2. To understand why this makes sense, I recommend <a href="http://everything2.com/index.pl?node_id=1674246">this excellent write-up at Everything2</a>. Assume that you pick a irreducible polynomial in the form <img src='http://s.wordpress.com/latex.php?latex=X%5E2-%5Cbeta&#038;bg=T&#038;fg=000000&#038;s=0' alt='X^2-\beta' title='X^2-\beta' class='latex' />. Working modulo this polynomial is the same thing as working in a &#8220;world&#8221; where <img src='http://s.wordpress.com/latex.php?latex=X%5E2%20%3D%20%5Cbeta&#038;bg=T&#038;fg=000000&#038;s=0' alt='X^2 = \beta' title='X^2 = \beta' class='latex' />. (You could of course work with a polynomial in the form <img src='http://s.wordpress.com/latex.php?latex=X%5E2%20%2B%20aX%20%2B%20b&#038;bg=T&#038;fg=000000&#038;s=0' alt='X^2 + aX + b' title='X^2 + aX + b' class='latex' /> but that would complicate things.)</p>
<p>So every element of <img src='http://s.wordpress.com/latex.php?latex=GF%28p%5E2%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='GF(p^2)' title='GF(p^2)' class='latex' /> can be written as <img src='http://s.wordpress.com/latex.php?latex=a%20%2B%20bX&#038;bg=T&#038;fg=000000&#038;s=0' alt='a + bX' title='a + bX' class='latex' />. What happens when you apply the Frobenius endomorphism? Let&#8217;s see:</p>
<img src='http://s.wordpress.com/latex.php?latex=%28a%20%2B%20bX%29%5Ep%20%3D%20%28a%5Ep%20%2B%20b%5EpX%5Ep%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='(a + bX)^p = (a^p + b^pX^p)' title='(a + bX)^p = (a^p + b^pX^p)' class='latex' />
<p>Why is that so? That&#8217;s a known fact about the Frobenius, check the <a href="http://en.wikipedia.org/wiki/Frobenius_automorphism">explanation at Wikipedia</a> for more details. But basically, the expansion of <img src='http://s.wordpress.com/latex.php?latex=%28a%20%2B%20bX%29%5Ep&#038;bg=T&#038;fg=000000&#038;s=0' alt='(a + bX)^p' title='(a + bX)^p' class='latex' /> has many terms, but only the first <img src='http://s.wordpress.com/latex.php?latex=%28a%5Ep%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='(a^p)' title='(a^p)' class='latex' /> and the last <img src='http://s.wordpress.com/latex.php?latex=%28b%5EpX%5Ep%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='(b^pX^p)' title='(b^pX^p)' class='latex' /> survive because all others are multiples of p. Since we&#8217;re working with coefficients modulo p, they are all zero.</p>
<p>Let&#8217;s continue. Since <img src='http://s.wordpress.com/latex.php?latex=a%2C%20b%20%5Cin%20GF%28p%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='a, b \in GF(p)' title='a, b \in GF(p)' class='latex' />, then raising to the power of p won&#8217;t change them (yep, that&#8217;s Frobenius again). So we have:</p>
<img src='http://s.wordpress.com/latex.php?latex=%28a%20%2B%20bX%29%5Ep%20%3D%20%28a%5Ep%20%2B%20b%5EpX%5Ep%29%20%3D%20%28a%20%2B%20bX%5Ep%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='(a + bX)^p = (a^p + b^pX^p) = (a + bX^p)' title='(a + bX)^p = (a^p + b^pX^p) = (a + bX^p)' class='latex' />
<p>There&#8217;s only <img src='http://s.wordpress.com/latex.php?latex=X%5Ep&#038;bg=T&#038;fg=000000&#038;s=0' alt='X^p' title='X^p' class='latex' /> left to bother us. If p is odd (not 2), then you can rearrange this as:</p>
<img src='http://s.wordpress.com/latex.php?latex=%28a%20%2B%20bX%29%5Ep%20%3D%20%28a%20%2B%20bX%5Ep%29%20%3D%20%28a%20%2B%20b%28X%5E2%29%5E%7B%28p-1%29%2F2%7DX%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='(a + bX)^p = (a + bX^p) = (a + b(X^2)^{(p-1)/2}X)' title='(a + bX)^p = (a + bX^p) = (a + b(X^2)^{(p-1)/2}X)' class='latex' />
<p>Now remember that we&#8217;re working in a &#8220;world&#8221; where <img src='http://s.wordpress.com/latex.php?latex=X%5E2%20%3D%20%5Cbeta&#038;bg=T&#038;fg=000000&#038;s=0' alt='X^2 = \beta' title='X^2 = \beta' class='latex' />. Then we get:</p>
<img src='http://s.wordpress.com/latex.php?latex=%28a%20%2B%20bX%29%5Ep%20%3D%20%28a%20%2B%20b%28X%5E2%29%5E%7B%28p-1%29%2F2%7DX%5Ep%29%20%3D%20%28a%20%2B%20b%5Cbeta%5E%7B%28p-1%29%2F2%7DX%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='(a + bX)^p = (a + b(X^2)^{(p-1)/2}X^p) = (a + b\beta^{(p-1)/2}X)' title='(a + bX)^p = (a + b(X^2)^{(p-1)/2}X^p) = (a + b\beta^{(p-1)/2}X)' class='latex' />
<p>That&#8217;s why Frobenius is easy: &#8220;a&#8221; stays the same, all you need to do is multiply &#8220;b&#8221; with <img src='http://s.wordpress.com/latex.php?latex=%5Cbeta%5E%7B%28p-1%29%2F2%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\beta^{(p-1)/2}' title='\beta^{(p-1)/2}' class='latex' />. But according to <a href="http://en.wikipedia.org/wiki/Euler%27s_criterion">Euler&#8217;s criterion</a>, since <img src='http://s.wordpress.com/latex.php?latex=%5Cbeta&#038;bg=T&#038;fg=000000&#038;s=0' alt='\beta' title='\beta' class='latex' /> is not a square (if it were, <img src='http://s.wordpress.com/latex.php?latex=X%5E2-%5Cbeta&#038;bg=T&#038;fg=000000&#038;s=0' alt='X^2-\beta' title='X^2-\beta' class='latex' /> wouldn&#8217;t be irreducible), we have <img src='http://s.wordpress.com/latex.php?latex=%5Cbeta%5E%7B%28p-1%29%2F2%7D%20%5Cequiv%20-1%20%5Cpmod%7Bp%7D&#038;bg=T&#038;fg=000000&#038;s=0' alt='\beta^{(p-1)/2} \equiv -1 \pmod{p}' title='\beta^{(p-1)/2} \equiv -1 \pmod{p}' class='latex' />. Then the formula gets much simpler:</p>
<img src='http://s.wordpress.com/latex.php?latex=%28a%20%2B%20bX%29%5Ep%20%3D%20%28a-bX%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='(a + bX)^p = (a-bX)' title='(a + bX)^p = (a-bX)' class='latex' />
<h3>A concrete example</h3>
<p>Just for the sake of concreteness, let&#8217;s work out an example. I&#8217;ll use <a href="http://www.sagemath.org/">Sage</a> for that, but I&#8217;ll explain what each command does.</p>
<pre>
sage: K = GF(7)
</pre>
<p>We create a field with 7 elements (that&#8217;s actually integers modulo 7).</p>
<pre>
sage: K(5)^7
5
</pre>
<p>We take the element 5 and power to 7. We get 5 again. If you don&#8217;t believe it works for all elements:</p>
<pre>
sage: [(x,x^7) for x in K]
[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)]
</pre>
<p>Let&#8217;s create <img src='http://s.wordpress.com/latex.php?latex=GF%287%5E2%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='GF(7^2)' title='GF(7^2)' class='latex' />.</p>
<pre>
sage: KR. = GF(7)[]
</pre>
<p>This creates a polynomial ring with the X variable and coefficients in <img src='http://s.wordpress.com/latex.php?latex=GF%287%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='GF(7)' title='GF(7)' class='latex' />, just to allow us to specify the modulus in the next step:</p>
<pre>
sage: K2. = GF(7^2, modulus=X^2+1)
</pre>
<p>We create the <img src='http://s.wordpress.com/latex.php?latex=GF%287%5E2%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='GF(7^2)' title='GF(7^2)' class='latex' /> field using the variable X (I&#8217;m overwriting the X used in the ring, you could use other name) and modulus <img src='http://s.wordpress.com/latex.php?latex=X%5E2%2B1&#038;bg=T&#038;fg=000000&#038;s=0' alt='X^2+1' title='X^2+1' class='latex' /> (so <img src='http://s.wordpress.com/latex.php?latex=%5Cbeta%20%3D%20-1&#038;bg=T&#038;fg=000000&#038;s=0' alt='\beta = -1' title='\beta = -1' class='latex' />). Let&#8217;s take an arbitrary element to the power of 7:</p>
<pre>
sage: (3*X + 2)^7
4*X + 2
</pre>
<p>Remeber when <img src='http://s.wordpress.com/latex.php?latex=%5Cbeta%20%3D%20-1&#038;bg=T&#038;fg=000000&#038;s=0' alt='\beta = -1' title='\beta = -1' class='latex' /> then <img src='http://s.wordpress.com/latex.php?latex=%28a%20%2B%20bX%29%5Ep%20%3D%20%28a-bX%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='(a + bX)^p = (a-bX)' title='(a + bX)^p = (a-bX)' class='latex' />. And modulo 7, -3 is actually 4, so the result is correct (of course!). Again, if you don&#8217;t believe it works for all elements:</p>
<pre>
sage: all(x^7 == (x.vector()[0] - x.vector()[1]*X) for x in K2)
True
</pre>
<p>This checks, for all elements in the field K2, if the element raised to the power of 7 is equal to the element built with our special formula. The method <code>vector()</code> returns the coefficients of the polynomial as a list. The <code>all</code> function is a relatively unknown function of Python that returns True if all the elements of the iterable passed to it evaluate to True (there&#8217;s <code>any(iter)</code> too).</p>
<h3>Extensions of higher degree</h3>
<p>The trick to calculate the Frobenius endomorphism also works for extensions of higher degree. When implementing them, usually using a tower of extensions is more efficient then using a direct extension. For example, when working with <img src='http://s.wordpress.com/latex.php?latex=GF%28p%5E%7B12%7D%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='GF(p^{12})' title='GF(p^{12})' class='latex' />, you can represent it as a quadratic extension of <img src='http://s.wordpress.com/latex.php?latex=GF%28p%5E6%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='GF(p^6)' title='GF(p^6)' class='latex' />, which can be represented as a cubic extension of <img src='http://s.wordpress.com/latex.php?latex=GF%28p%5E2%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='GF(p^2)' title='GF(p^2)' class='latex' />, which can be represented as a quadratic extension of <img src='http://s.wordpress.com/latex.php?latex=GF%28p%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='GF(p)' title='GF(p)' class='latex' />.</p>
<p>For example, for <img src='http://s.wordpress.com/latex.php?latex=%28a%20%2B%20bX%29%20%5Cin%20GF%28p%5E%7B12%7D%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='(a + bX) \in GF(p^{12})' title='(a + bX) \in GF(p^{12})' class='latex' /> built this way, with <img src='http://s.wordpress.com/latex.php?latex=a%2C%20b%20%5Cin%20GF%28p%5E6%29&#038;bg=T&#038;fg=000000&#038;s=0' alt='a, b \in GF(p^6)' title='a, b \in GF(p^6)' class='latex' />, you just apply the same trick explained above. The only difference is that a and b to the power of p aren&#8217;t a and b themselves, but that&#8217;s not a problem, you just apply the same trick recursively.</p>
]]></content:encoded>
			<wfw:commentRss>http://alicebob.cryptoland.net/the-frobenius-endomorphism-with-finite-fields/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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>

