<?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>Modulo Errors &#187; Complexity</title>
	<atom:link href="http://maths.straylight.co.uk/archives/category/complexity/feed" rel="self" type="application/rss+xml" />
	<link>http://maths.straylight.co.uk</link>
	<description>for when the margin is too small</description>
	<lastBuildDate>Thu, 12 Jan 2012 16:36:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>iSquared: The limits of Computation</title>
		<link>http://maths.straylight.co.uk/archives/124</link>
		<comments>http://maths.straylight.co.uk/archives/124#comments</comments>
		<pubDate>Sat, 13 Dec 2008 12:14:26 +0000</pubDate>
		<dc:creator>Graeme</dc:creator>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[CM10020]]></category>
		<category><![CDATA[Complexity]]></category>
		<category><![CDATA[Pop.Maths]]></category>

		<guid isPermaLink="false">http://maths.straylight.co.uk/?p=124</guid>
		<description><![CDATA[The cover article of this quarter's iSquared magazine is by me!]]></description>
			<content:encoded><![CDATA[<p>The winter issue of <a href="http://isquaredmagazine.co.uk">iSquared magazine</a> is now available, with the cover article &#8216;The limits of Computation&#8217; being by, well, me! I discuss Turing Machines, undecidability, intractability, and (briefly) Artificial Intelligence. </p>
<p>I&#8217;ve not received my own copy so can&#8217;t comment on the other articles yet, although I&#8217;ve attended a talk by interviewee Keith Briggs <a href="http://maths.straylight.co.uk/archives/50">before</a> which was very good, so I expect the interview will be interesting too. So I hope you&#8217;ll pick up a copy- it&#8217;s a venture well worth supporting!</p>
]]></content:encoded>
			<wfw:commentRss>http://maths.straylight.co.uk/archives/124/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geometry Club Talk: Computational aspects of ECDLP</title>
		<link>http://maths.straylight.co.uk/archives/118</link>
		<comments>http://maths.straylight.co.uk/archives/118#comments</comments>
		<pubDate>Wed, 23 Apr 2008 09:05:35 +0000</pubDate>
		<dc:creator>Graeme</dc:creator>
				<category><![CDATA[Algebraic Geometry]]></category>
		<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Complexity]]></category>
		<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Group Theory]]></category>
		<category><![CDATA[PhD]]></category>
		<category><![CDATA[Talks]]></category>

		<guid isPermaLink="false">http://maths.straylight.co.uk/?p=118</guid>
		<description><![CDATA[Notes from my geometry club talk given April 18th, 2008.]]></description>
			<content:encoded><![CDATA[<p>On Friday I gave a <a href="http://www.maths.ed.ac.uk/~s0198576/gc/">geometry club</a> seminar, speaking about some of the computational aspects of discrete-logarithm cryptography in general and as implemented for elliptic curves.  <a href="http://www.maths.ed.ac.uk/~s0677951/gc_apr_08.pdf">My notes</a> supplement rather than completely describe the talk, being heavier on the formalities and lighter on the narrative. </p>
<p>The topics covered are: Diffie-Hellman and one-way functions for key exchange; the generic Discrete Logarithm Problem and BSGS algorithm; scalar multiplication- addition chains, fast exponentiation, m-ary methods and windowing; group law implementations, Side-channel attacks and the Edwards form. </p>
<p>I&#8217;ve discussed several of these ideas elsewhere on this blog, as well as the cryptanalysis ideas I mentioned on the day but which are not in the notes. I also refered to a recent real-world example of a side-channel attack; see <a href="http://www.theregister.co.uk/2008/04/03/keeloq_master_key_found/">this</a> story from The Register for details.</p>
]]></content:encoded>
			<wfw:commentRss>http://maths.straylight.co.uk/archives/118/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Addition Chains</title>
		<link>http://maths.straylight.co.uk/archives/106</link>
		<comments>http://maths.straylight.co.uk/archives/106#comments</comments>
		<pubDate>Thu, 29 Nov 2007 12:04:12 +0000</pubDate>
		<dc:creator>Graeme</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Complexity]]></category>
		<category><![CDATA[Number Theory]]></category>
		<category><![CDATA[PhD]]></category>

		<guid isPermaLink="false">http://maths.straylight.co.uk/?p=106</guid>
		<description><![CDATA[Fast addition (or exponentiation) via addition chains.]]></description>
			<content:encoded><![CDATA[<p>Suppose you have a rule for addition of some objects (most generally, elements of a <em>semigroup</em>), and you wish to compute the sum of <em>n</em> copies of the same object. How could you achieve this?</p>
<p>The primary school answer is to do just that: given <em>g</em>, compute <em>2g=g+g</em>; then compute <em>3g=2g+g</em> and so on, for <em>n</em> steps. But this rapidly becomes tedious, and isn&#8217;t (I hope) how we&#8217;d perform such a calculation in our heads: instead, we&#8217;d try to take bigger jumps. For instance, to compute the number <em>16g</em>, we can find <em>2g</em>, add that to itself to reach <em>4g</em>, and again for <em>8g</em>, hitting <em>16g</em> after just 4 steps. Had we wanted 17, we&#8217;d then just add <em>g</em> again. </p>
<p>The sequence of intermediate values correspond to an <em>addition chain</em> for <em>n</em>: this is a sequence starting at <em>a<sub>0</sub>=1</em> and ending at <em>a<sub>l</sub>=n</em> with the property that for any term <em>a<sub>k</sub></em> there exist terms <em>a<sub>i</sub></em>,<em>a<sub>j</sub></em> with <em>a<sub>k</sub>=a<sub>i</sub>+a<sub>j</sub></em>. That is, every term is the sum of two earlier terms (not necessarily distinct), so we can reach <em>ng</em> by computing each <em>a<sub>k</sub>g</em> in turn without needing anything fancier than our addition law.</p>
<p>As a side effect, an addition chain also tells us how to exponentiate if we know how to multiply, since <em>x<sup>a+b</sup>=x<sup>a</sup>x<sup>b</sup></em> so we can build up to <em>x<sup>n</sup></em> by finding the powers <em>x<sup>a<sub>k</sub></sup></em> in turn.</p>
<p>Thus our tedious sequence for 16 is 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, with the more sophisticated one being 1,2,4,8,16. If I asked you to compute 16x for a number x, you&#8217;d probably do something different: compute 10x (easy in base 10!) and 6x, then add those. With access to a multiplication procedure, this is definitely more efficient: but without that luxury it can still be used to give an addition chain for 16, by finding chains for 10 and 6. These are 1,2,4,5,10 and 1,2,3,6 respectively, so we can merge them into the chain 1,2,3,4,5,6,10,16.</p>
<p>We describe the length of the chain as <em>l</em>: that is, there are <em>l</em> terms after the 1. Notice that at worst, therefore, we need <em>n-1</em> terms. If we move as quickly as possible by taking <em>a<sub>k+1</sub>=a<sub>k</sub>+a<sub>k</sub>=2a<sub>k</sub></em> then the greatest value we can reach after <em>m</em> terms is 2<sup>m</sup>, as demonstrated with the chain for 2<sup>4</sup>=16. However, if we can compute <em>n</em> and <em>m</em> in l<sub>n</sub>,l<sub>m</sub> terms, it needn&#8217;t take as many as <em>l<sub>n</sub>+l<sub>m</sub>+1</em> terms to compute <em>n+m</em>, since there may be common terms in the chains. Finally, as defined an addition chain needn&#8217;t make use of all it&#8217;s terms: for example, 1,2,4,6,8,16 is still a chain for 16, although the 6 isn&#8217;t needed. We will obviously be interested in chains without any such wasted terms.</p>
<p>The observation for powers of two motivates a first attempt at an efficient algorithm for building addition chains. if <em>n</em> is 1, then we have nothing to do: the chain 1 suffices. Otherwise, we can work recursively: for an even number <em>n=2k</em>, we ask for the chain for <em>k</em> and then add <em>2k</em> to the end; whereas for an odd number <em>n=2k+1</em>, we ask for the chain for <em>k</em> and add <em>2k</em><em> then </em><em>2k+1</em> to the end. This will require at most log<sub>2</sub>n calls, and each step adds 1 or 2 entries to the chain. </p>
<p>This can also be captured by considering the binary representation of <em>n</em>, which will also indicate whether we hit an even or odd number at each stage. Suppose <em>n</em> is of the form
<p align=center><img src="http://straylight.co.uk/cgi-bin/mimetex.cgi?n=\sum_{i=0}^k d_i 2^i=(d_kd_{k-1} d_{k-2}\ldots d_1d_0)_2"/></p>
<p> where each <em>d<sub>i</sub></em> is either 0 or 1, and <em>d<sub>k</sub>=1</em> so there are no leading zeros. Then we start the chain with 1, and read from left to right, ignoring the leading 1: if we see a 0, then we double the last term of the chain; if we see a 1, add 1 to this new term as well. More formally:</p>
<p>Input: the binary expansion <img src="http://straylight.co.uk/cgi-bin/mimetex.cgi?(d_kd_{k-1} d_{k-2}\ldots d_1d_0)_2"/> of n.<br />
<br />Output: an addition chain for n.</p>
<p>Set a<sub>0</sub>=1<br />
Set t=1<br />
for i from k-1 down to 0:<br />
&nbsp;&nbsp;&nbsp;&nbsp;Set a<sub>t</sub>=2a<sub>t-1</sub> and t=t+1.<br />
&nbsp;&nbsp;&nbsp;&nbsp;If d_i=1:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set a<sub>t</sub>=a<sub>t-1</sub>+1 and t=t+1<br />
return a<sub>0</sub>&#8230;a<sub>t</sub></p>
<p>For instance, with <em>n</em> a power of 2 we will see only a run of zeros, and thus perform the appropriate number of doublings, for a chain of length <em>log<sub>2</sub>n</em>. For <em>n</em> one less than a power of two, the expansion consists entirely of 1s, costing <em>2log<sub>2</sub>n</em>. For an &#8216;average&#8217; number where each digit has around a 50% chance of being a 1 or a 0, the chain will therefore be of approximate length <em>(3/2)log<sub>2</sub>n</em>. More formally, we can define the <em>Hamming Weight v(n)</em> to be the number of 1s in the binary expansion of <em>n</em>; then the chain will have length <em>floor(log<sub>2</sub>n) + v(n) -1</em>. </p>
<p>Is this optimal? A counterexample suffices to show it is not, the first being 15, which is 1111 in binary. Using the binary expansion we get the sequence 1,2,3,6,7,14,15 of length 6 (=3+4-1 as claimed). But the sequence would be 1,2,3,5,10,15 of length 5 and hence 1 shorter.</p>
<p>Nonetheless, our binary chain gives a much better upper bound than the naive chain of <em>(n-1)</em> steps, and is very simple to implement both in logic and memory. The idea also generalises to arbitrary bases, as follows.</p>
<p>Suppose <em>n</em> is of the form
<p align=center><img src="http://straylight.co.uk/cgi-bin/mimetex.cgi?n=\sum_{i=0}^k d_i m^i=(d_kd_{k-1} d_{k-2}\ldots d_1d_0)_m"/></p>
<p> where each d<sub>i</sub> is in the range 0&#8230;m-1, d<sub>k</sub> non-zero. Then we can compute an <em>m-ary addition chain</em> for n:</p>
<p>Input: the m-ary expansion <img src="http://straylight.co.uk/cgi-bin/mimetex.cgi?(d_kd_{k-1} d_{k-2}\ldots d_1d_0)_m"/> of n.<br />
<br />Output: an addition chain for n.</p>
<p>Set a=0<br />
Start the chain with 1,2,3,&#8230;,m-1.<br />
for i from k down to 0:<br />
&nbsp;&nbsp;&nbsp;&nbsp;Extend the chain to m*a (if not already present) and set a=m*a.<br />
&nbsp;&nbsp;&nbsp;&nbsp;Add a+d<sub>i</sub> to the chain (if not already present), and set a=a+d<sub>i</sub>.<br />
return chain.</p>
<p>Notice that <em>a</em> tracks the last term computed, and that extending the chain to <em>m*a</em> is itself an addition chain problem: this makes some 2<sup>k</sup> a good choice for <em>m</em>, since this extension can then be accomplished in <em>k</em> additions. </p>
<p>The shorter chain for 15 arises from its ternary expansion: considered as (120)<sub>3</sub> 1*9+2*3+0*1, we have an initial chain of 1,2 then apply the loop. With a=0,d<sub>2</sub>=1 we set a=3a=0 then a=a+1=1; neither of these need to be added to the chain; for a=1, d<sub>1</sub>=2 we set a=3a=3 which requires the addition of 3 to the chain; then a=a+2=5 which extends the chain to 1,2,3,5; finally for a=5,d<sub>2</sub>=0 we set a=3a=15, adding first 10 then 15 to the chain; then a=a+0=15 so we terminate with chain 1,2,3,5,10,15.</p>
<p>The optimal choice of <em>m</em> depends on <em>n</em>, since although there will be less steps (<em>log<sub>m</sub>n</em>) for greater <em>m</em>, each step will require more additions in the computation of <em>m*a</em>. Nor are m-ary expansions the end of the story- there are various other tricks available to finesse addition chains. However, there is no known algorithm for finding shortest addition chains- and a generalisation of the problem to finding shortest addition sequences (chains that contain a desired list of values n<sub>1</sub>,n<sub>2</sub>,&#8230;,n<sub>k</sub>) is NP-complete. Searching for short chains is therefore an interesting challenge, and is constrained by the fact that unless you are precomputing them for future use, any shorter chain must offer a speedup in computation greater than the time taken to find it.</p>
<p>There are, however, bounds for the length of the chain: </p>
<p align=center><img src="http://straylight.co.uk/cgi-bin/mimetex.cgi?log_2 n +log_2 v(n) \leq l(n) \leq log_2 n + v(n) -1"/></p>
<p>Where <em>v(n)</em> is the Hamming weight as before.</p>
<p><strong>References/Further Reading</strong><br />
<br />Knuth- <em>The Art of Computer Programming Vol. 2: Seminumerical Algorithms</em>.<br />
<br />Bos and Coster- <em>Addition Chain Heuristics</em> in Advances in Cryptology- Crypto&#8217;89 (Lecture Notes in Computer Science) (Available via <a href="http://www.springerlink.com/content/hc5a5p31deeypu94/">SpringerLink</a>.)<br />
<br />Gordon- <em>A Survey of Fast Exponentiation Methods.</em> (Available via <a href="http://citeseer.ist.psu.edu/gordon97survey.html">citeseer</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://maths.straylight.co.uk/archives/106/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Secrecy Problem</title>
		<link>http://maths.straylight.co.uk/archives/84</link>
		<comments>http://maths.straylight.co.uk/archives/84#comments</comments>
		<pubDate>Thu, 03 May 2007 14:48:50 +0000</pubDate>
		<dc:creator>Graeme</dc:creator>
				<category><![CDATA[Complexity]]></category>
		<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Logic]]></category>

		<guid isPermaLink="false">http://maths.straylight.co.uk/archives/84</guid>
		<description><![CDATA[Link to an E2 writeup on reducing the secrecy problem to Post's Correspondence Problem.]]></description>
			<content:encoded><![CDATA[<p>I took a number of interesting modules in formal logic as an undergraduate, and I&#8217;m often fascinated by ideas in this field. There are natural connections between cryptographic protocol analysis and string rewriting, and with enough freedom one can emulate general models of computation such as Turing machines by protocols. One particularly neat side effect of this is that it allows an elegant proof of the undecidability of the secrecy problem: namely, given a protocol and a secret message, is there a decision procedure to establish whether an intruder can learn the secret? By reducing to Post&#8217;s Correspondence Problem, it can be shown that the answer is no! Of course, this raises issues of intruder strength and &#8216;honest&#8217; protocols; I&#8217;ve written up some of these ideas (along with the proof and an outline of PCP) <a href="http://www.everything2.com/index.pl?node_id=1883122">over on e2</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://maths.straylight.co.uk/archives/84/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hard problems in graph theory</title>
		<link>http://maths.straylight.co.uk/archives/50</link>
		<comments>http://maths.straylight.co.uk/archives/50#comments</comments>
		<pubDate>Tue, 13 Jun 2006 20:21:59 +0000</pubDate>
		<dc:creator>Graeme</dc:creator>
				<category><![CDATA[Complexity]]></category>
		<category><![CDATA[Graph Theory]]></category>

		<guid isPermaLink="false">http://maths.straylight.co.uk/archives/50</guid>
		<description><![CDATA[BICS Seminar by Keith Briggs.]]></description>
			<content:encoded><![CDATA[<p>Despite my usual resistance to applied maths, yesterday&#8217;s <a href="http://www.bath.ac.uk/math-sci/bics/index.html">BICS</a> seminar sounded worthwhile, and turned out to be very good- <a href="http://keithbriggs.info/">Keith Briggs</a> of BT gave a talk entitled <a href="http://keithbriggs.info/documents/hard_graph_problems_Bath_2006_Jun_12.pdf"><em>Some practical experiences of hard graph problems</em></a>. Graph Theory isn&#8217;t part of our syllabus, which seems a shame, as the concepts are simple- colouring, cliques etc. &#8211; but the questions difficult. </p>
<p>
Much of the talk discussed the validity of results on infinite graphs when applied to smaller (and hence computationally feasible) ones: in particular, obtaining good bounds on clique and chromatic numbers. Towards the end, the reduction of graph problems to the satisfiability problem in propositional logic was mentioned. Obviously, the possibility of such reductions is a defining characteristic of NP-hard problems (and one I&#8217;ve <a href="http ://maths.straylight.co.uk/archives/49">recently</a> been studying), but it&#8217;s good to see that this is of practical merit rather than simply theoretical interest.</p>
]]></content:encoded>
			<wfw:commentRss>http://maths.straylight.co.uk/archives/50/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NP vs Co-NP</title>
		<link>http://maths.straylight.co.uk/archives/49</link>
		<comments>http://maths.straylight.co.uk/archives/49#comments</comments>
		<pubDate>Sat, 13 May 2006 20:19:24 +0000</pubDate>
		<dc:creator>Graeme</dc:creator>
				<category><![CDATA[CM30071]]></category>
		<category><![CDATA[Complexity]]></category>
		<category><![CDATA[Logic]]></category>

		<guid isPermaLink="false">http://maths.straylight.co.uk/archives/49</guid>
		<description><![CDATA[Notes from a talk on complexity theory and logic.]]></description>
			<content:encoded><![CDATA[<p>
<a HREF="http://aleph.straylight.co.uk/coNP.pdf"><img SRC="http://www.straylight.co.uk/images/pdf.jpg" alt="view as PDF"/></a>
</p>
<p>The NP vs co-NP problem is related to the more famous P vs NP question. As part of <i>CM30071:Logic and its applications</i> (University of Bath Computer Science), my group gave a presentation on this topic, and its connections to propostional logic (through the satisfiability and validity problems). The attached file contains a two page summary of the main ideas from the talk.</p>
]]></content:encoded>
			<wfw:commentRss>http://maths.straylight.co.uk/archives/49/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

