<?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>Intrepid Blog</title>
	<atom:link href="http://blog.affien.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.affien.com</link>
	<description>A few thoughts</description>
	<lastBuildDate>Tue, 23 Apr 2013 21:02:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Simple Elliptic Curve Cryptography in Python compatible with seccure</title>
		<link>http://blog.affien.com/archives/2013/04/16/simple-elliptic-curve-cryptography-in-python-compatible-with-seccure/</link>
		<comments>http://blog.affien.com/archives/2013/04/16/simple-elliptic-curve-cryptography-in-python-compatible-with-seccure/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 14:12:46 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[Computer Science]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=553</guid>
		<description><![CDATA[Instead of RSA, you can use an Elliptic Curve algorithm [...]]]></description>
			<content:encoded><![CDATA[<p>Instead of RSA, you can use an Elliptic Curve algorithm for public/private key cryptography. The main advantage is that keys are a lot smaller. With RSA you need keyservers to distribute public keys. With Elliptic Curves, you can just write: my public key is <code>*jMVCU^[QC&#038;q*v_8C1ZAFBAgD</code>.</p>
<p>There are two drawbacks: first, Elliptic Curve cryptography is even harder to understand than plain RSA <em>and</em> secondly, there are only a few implementation of Elliptic Curve cryptography.  In fact: I did not find any maintained Elliptic Curve package for Python.</p>
<p>Thus I wrote a <a href="https://github.com/bwesterb/py-seccure">Python package</a> compatible with the excellent commandline utility <a href="http://point-at-infinity.org/seccure/">seccure</a> written by Poettering. Here are some examples of how to use the original commandline <code>seccure</code> and how to do the same thing in Python.</p>
<p>For a private key, you just pick a (long!) password.  You can <strong>derive the public key</strong> with <code>seccure</code> as follows:</p>
<blockquote><p><code>$ <strong>seccure-key</strong><br />
Assuming curve p160.<br />
Enter private key: <strong>my private key</strong><br />
The public key is: 8W;&gt;i^H0qi|J&#038;$coR5MFpR*Vn<br />
</code></p></blockquote>
<p>In Python</p>
<blockquote><p><code>&gt;&gt;&gt; <strong>import seccure</strong><br />
&gt;&gt;&gt; <strong>str(seccure.passphrase_to_pubkey('my private key'))</strong><br />
'8W;&gt;i^H0qi|J&#038;$coR5MFpR*Vn'</code></p></blockquote>
<p>Now, to <strong>encrypt</strong> a message for the public key:</p>
<blockquote><p><code>$ <strong>seccure-encrypt -o private.msg '8W;&gt;i^H0qi|J&#038;$coR5MFpR*Vn'</strong><br />
Assuming MAC length of 80 bits.<br />
Go ahead and type your message ...<br />
<strong>This is a very secret message!<br />
^D</strong></code></p></blockquote>
<p>In Python:</p>
<blockquote><p><code>&gt;&gt;&gt; <strong>ciphertext = seccure.encrypt('This is a very secret message\n', '8W;&gt;i^H0qi|J&#038;$coR5MFpR*Vn')</strong><br />
&gt;&gt;&gt; <strong>ciphertext</strong><br />
'\x00\x146\x17\xe9\xc1\x1a\x7fkX\xec\xa0n,h</code>&#8230;</p></blockquote>
<p>To <strong>decrypt</strong> the encrypted message:</p>
<blockquote><p><code>$ <strong>seccure-decrypt -i private.msg</strong><br />
Assuming MAC length of 80 bits.<br />
Assuming curve p160.<br />
Enter private key: <strong>my private key</strong><br />
This is a very secret message!<br />
Integrity check successful, message unforged!</code></p></blockquote>
<p>In Python:</p>
<blockquote><p><code>&gt;&gt;&gt; <strong>seccure.decrypt(ciphertext, 'my private key')</strong><br />
'This is a very secret message\n'</code></p></blockquote>
<p>To create a <strong>signature</strong></p>
<blockquote><p><code>$ <strong>seccure-sign</strong><br />
Assuming curve p160.<br />
Enter private key: <strong>my private key</strong><br />
Go ahead and type your message ...<br />
<strong>This message will be signed<br />
^D</strong><br />
Signature: $HPI?t(I*1vAYsl$|%21WXND=6Br*[&gt;k(OR9B!GOwHqL0s+3Uq</code></p></blockquote>
<p>In Python:</p>
<blockquote><p><code>&gt;&gt;&gt; <strong>seccure.sign('This message will be signed\n', 'my private key')</strong><br />
'$HPI?t(I*1vAYsl$|%21WXND=6Br*[&gt;k(OR9B!GOwHqL0s+3Uq'</code></p></blockquote>
<p>And to <strong>verify a signature</strong>:</p>
<blockquote><p><code>$ <strong>seccure-verify '8W;&gt;i^H0qi|J&#038;$coR5MFpR*Vn' '$HPI?t(I*1vAYsl$|%21WXND=6Br*[&gt;k(OR9B!GOwHqL0s+3Uq'</strong><br />
Go ahead and type your message ...<br />
<strong>This message will be signed<br />
^D</strong><br />
Signature successfully verified!</code></p></blockquote>
<p>In Python:</p>
<blockquote><p><code>&gt;&gt;&gt; <strong>seccure.verify('This message will be signed\n', '$HPI?t(I*1vAYsl$|%21WXND=6Br*[&gt;k(OR9B!GOwHqL0s+3Uq', '8W;&gt;i^H0qi|J&#038;$coR5MFpR*Vn')</strong><br />
True</code></p></blockquote>
<p>You can find <a href="https://github.com/bwesterb/py-seccure">the Python library on Github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2013/04/16/simple-elliptic-curve-cryptography-in-python-compatible-with-seccure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>msgpack for pypy</title>
		<link>http://blog.affien.com/archives/2013/01/29/msgpack-for-pypy/</link>
		<comments>http://blog.affien.com/archives/2013/01/29/msgpack-for-pypy/#comments</comments>
		<pubDate>Tue, 29 Jan 2013 22:24:38 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=535</guid>
		<description><![CDATA[msgpack is a fast and small binary format for json.  Th [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msgpack.org">msgpack</a> is a fast and small binary format for <a href="http://json.org">json</a>.  The Python <code>msgpack</code> module is even a drop-in replacement for the <code>json</code> module.</p>
<p><a href="http://pypy.org">PyPy</a> is an implementation of Python in Python with a <a href="http://en.wikipedia.org/wiki/Tracing_just-in-time_compilation">tracing JIT</a>.  If your Python script runs for more than 1 second, it will probably be <a href="http://speed.pypy.org">quite faster</a> on PyPy.</p>
<p>PyPy is almost a drop-in replacement for Python.  Only extensions modules written in C can be a problem &#8212; for instance the <code>msgpack</code> module.</p>
<p>Thus I wrote a pure Python fallback for the msgpack module, which <a href="https://github.com/msgpack/msgpack-python/pull/42">has been merged upstream</a>. As a rough benchmark, I measured the pack and unpack time of a 30MB msgpack-object from the wild.</p>
<p><a href="http://w-nz.com/~bas/images/msgpack-chart1.png"><img src="http://w-nz.com/~bas/images/msgpack-chart1.png" /></a></p>
<p>Note that:</p>
<ul>
<li>The execution times for the fallback with normal Python are all off the chart (15.4s, 15.1s, 10.1s, 10.0s).</li>
<li>PyPy is faster on the second run: it had time to trace and optimize at runtime.</li>
<li>For packing, PyPy (nightly) is almost as fast as the original C extension.</li>
<li>For unpacking, PyPy (nightly) is 340% slower.  Yet it more than 10 times faster than normal Python.</li>
</ul>
<p><strong>This code should be in the next official release of <code>msgpack-python</code>.  If you want to use it already, check out the <a href="https://github.com/msgpack/msgpack-python">git repository</a>.</strong></p>
<p>The first version did not run this fast on PyPy.  With PyPy&#8217;s <a href="https://bitbucket.org/pypy/jitviewer">jitviewer</a> the compiled code and assumptions of PyPy can be examined.  These are the tweaks I used in descending order of impact.</p>
<ul>
<li>Instead of <code>StringIO</code>, the fallback uses PyPy&#8217;s own <code>StringBuilder</code>.  <code>StringIO</code> allows writing, reading, seeking and what more.  <code>StringBuilder</code> only allows appending and thus it is easier for PyPy to optimize.  This increased performance of packing by an order of magnitude.</li>
<li>Using constant format strings for <code>struct.unpack</code> allows PyPy to optimize it.  Thus <code>struct.unpack("I", f.read(4)); f.read(n)</code> instead of <code>struct.unpack("I%ds"%n, f.read(4+n))</code></li>
<li>Using <code>stream.write(a); stream.write(b)</code> instead of <code>stream.write(a+b)</code> increased performance.</li>
<li>Adding an explicit fastpath</li>
<li>PyPy usually specializes a function well for its most common path, however in <a href="https://github.com/msgpack/msgpack-python/commit/4cde7f080c16fd396d758930faf9ebf15b138047">some cases</a> it needs help. In this case a function returns a concatenation of several strings.  However: in the most common case it only does one: <code>ret=''; ret+=something; return ret</code>.  PyPy does not recognize that <code>ret</code> is not needed at all in this case, so I added an if-statement before initializing it for the case where there is only one concatenation.</li>
</ul>
<p>Clearly the unpacking code could be faster, if anyone with expertise on PyPy&#8217;s JIT would look at it, that would be great.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2013/01/29/msgpack-for-pypy/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>PyPy 2.0-beta1 for Debian Squeeze amd64</title>
		<link>http://blog.affien.com/archives/2013/01/26/pypy-2-0-beta1-for-debian-squeeze-amd64/</link>
		<comments>http://blog.affien.com/archives/2013/01/26/pypy-2-0-beta1-for-debian-squeeze-amd64/#comments</comments>
		<pubDate>Sat, 26 Jan 2013 10:57:47 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=529</guid>
		<description><![CDATA[I compiled PyPy 2.0-beta1 for Debian Squeeze amd64. [...]]]></description>
			<content:encoded><![CDATA[<p>I compiled <a href="http://westerbaan.name/~bas/builds/pypy/pypy-2.0-beta1-squeeze-amd64.tar.bz2">PyPy 2.0-beta1 for Debian Squeeze amd64</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2013/01/26/pypy-2-0-beta1-for-debian-squeeze-amd64/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FTL .dat packer and unpacker</title>
		<link>http://blog.affien.com/archives/2012/09/14/ftl-dat-packer-and-unpacker/</link>
		<comments>http://blog.affien.com/archives/2012/09/14/ftl-dat-packer-and-unpacker/#comments</comments>
		<pubDate>Fri, 14 Sep 2012 16:04:25 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=518</guid>
		<description><![CDATA[I wrote a simple Python script to pack and unpack the d [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a simple Python script to pack and unpack the data files of the indie game <a href="http://www.ftlgame.com">FTL</a>, which is by the way quite enjoyable.  You can find it <a href="https://github.com/bwesterb/ftldat">here</a> on github.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2012/09/14/ftl-dat-packer-and-unpacker/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fix excessive disk usage of Sparrow for Mac</title>
		<link>http://blog.affien.com/archives/2012/08/12/fix-excessive-disk-usage-of-sparrow-for-mac/</link>
		<comments>http://blog.affien.com/archives/2012/08/12/fix-excessive-disk-usage-of-sparrow-for-mac/#comments</comments>
		<pubDate>Sun, 12 Aug 2012 14:43:25 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=509</guid>
		<description><![CDATA[It may happen that Sparrow for Mac uses an excessive am [...]]]></description>
			<content:encoded><![CDATA[<p>It may happen that <a href="http://sprw.me">Sparrow for Mac</a> uses an excessive amount of disk space.  For only the headers of my 9GB of e-mail, Sparrow used 39GB.  I found a work-around.</p>
<p><strong>The problem</strong><br />
Sparrow uses a <a href="http://fallabs.com/tokyocabinet/">Tokyo Cabinet</a>, called <code>data.tch</code>, as storage.  Mine was 39GB. What could eat up all that space?  I only have 9GB of e-mail in total.  With <a href="https://gist.github.com/3332093">a simple script</a> I looked into the cabinet and found it actually contained less than 1GB of data.  The cabinet was wasting a lot of space by not being packed tightly.</p>
<p><strong>The work-around</strong><br />
To repack the Tokyo Cabinet, run:</p>
<blockquote><p><code>tchmgr optimize "~/Library/Containers/com.sparrowmailapp.sparrow/Data/Library/Application Support/Sparrow/<strong>(your-email@gmail.com)</strong>.sparrowdb/data.db/data.tch"</code></p></blockquote>
<p>Replace <strong>(your-email@gmail.com)</strong> with your e-mail address.  You can install the <code>tchmgr</code> program using <code>sudo port install tokyocabinet</code>, if you are a <a href="http://www.macports.org">MacPorts</a> user.</p>
<p>This reduced the size of the cabinet to 1.1GB!</p>
<p><strong>Cause?</strong><br />
It is odd that the cabinet became so loosely packed.  It may happen if Sparrow adds and removes a lot of entries, but there seems no reason for Sparrow to do this. There might be an underlying bug.  I reported this issue to the developers, but they have yet to respond.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2012/08/12/fix-excessive-disk-usage-of-sparrow-for-mac/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bachelor thesis: on effective undecidability and Post&#8217;s problem</title>
		<link>http://blog.affien.com/archives/2012/07/11/bachelor-thesis-on-effective-undecidability-and-posts-problem/</link>
		<comments>http://blog.affien.com/archives/2012/07/11/bachelor-thesis-on-effective-undecidability-and-posts-problem/#comments</comments>
		<pubDate>Wed, 11 Jul 2012 10:49:48 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[Maths]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=507</guid>
		<description><![CDATA[This is my bachelor thesis on effective undecidability  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://westerbaan.name/~bas/math/bachelor.pdf" title="On effective undecidability and Post's problem">This is my bachelor thesis on effective undecidability and Post&#8217;s problem.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2012/07/11/bachelor-thesis-on-effective-undecidability-and-posts-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Henk Westerbaan</title>
		<link>http://blog.affien.com/archives/2012/06/09/henk-westerbaan/</link>
		<comments>http://blog.affien.com/archives/2012/06/09/henk-westerbaan/#comments</comments>
		<pubDate>Sat, 09 Jun 2012 14:45:03 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=502</guid>
		<description><![CDATA[
 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://henk.westerbaan.name"><img src="http://w-nz.com/~bas/images/rouwkaart-henk.png" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2012/06/09/henk-westerbaan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Could not open audio device for playback. with GStreamer on Rapsberry Pi</title>
		<link>http://blog.affien.com/archives/2012/05/13/could-not-open-audio-device-for-playback-with-gstreamer-on-rapsberry-pi/</link>
		<comments>http://blog.affien.com/archives/2012/05/13/could-not-open-audio-device-for-playback-with-gstreamer-on-rapsberry-pi/#comments</comments>
		<pubDate>Sun, 13 May 2012 14:17:23 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=482</guid>
		<description><![CDATA[You can fix this error by explicitly setting the defaul [...]]]></description>
			<content:encoded><![CDATA[<p>You can fix this error by explicitly setting the default audio device.  For instance, put this:</p>
<blockquote><p><code>pcm.!default {<br />
	&nbsp;type hw<br />
	&nbsp;card 0<br />
}</p>
<p>ctl.!default {<br />
	&nbsp;type hw<br />
	&nbsp;card 0<br />
}<br />
</code></p></blockquote>
<p>in <code>$HOME/.asoundrc</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2012/05/13/could-not-open-audio-device-for-playback-with-gstreamer-on-rapsberry-pi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Split ape/flac with cue into oggs on Linux</title>
		<link>http://blog.affien.com/archives/2011/10/08/split-apeflac-with-cue-into-oggs-on-linux/</link>
		<comments>http://blog.affien.com/archives/2011/10/08/split-apeflac-with-cue-into-oggs-on-linux/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 14:56:02 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=477</guid>
		<description><![CDATA[$ shnsplit -o 'cust ext=ogg oggenc - -o %f' \
&#160;&#038;n [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><code><strong>$</strong> shnsplit -o 'cust ext=ogg oggenc - -o %f' \<br />
&nbsp;&nbsp;-f CDImage.cue -t "%n.%p - %a - %t" \<br />
&nbsp;&nbsp;CDImage.ape<br />
<strong>$</strong> cuetag CDImage.cue *.ogg</code></p></blockquote>
<p>If you&#8217;re on Ubuntu, you&#8217;ll need to install <code>cuetools</code> and <code>shntool</code>.  To split <code>ape</code>, compile and install <a href="http://etree.org/shnutils/shntool/support/formats/ape/unix/3.99-u4-b5-s7/mac-3.99-u4-b5-s7.tar.gz">this port</a> of <code>mac</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2011/10/08/split-apeflac-with-cue-into-oggs-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Radboud Universiteit Nieuws</title>
		<link>http://blog.affien.com/archives/2011/06/06/radboud-universiteit-nieuws/</link>
		<comments>http://blog.affien.com/archives/2011/06/06/radboud-universiteit-nieuws/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 14:50:24 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.affien.com/?p=466</guid>
		<description><![CDATA[De Radboud Universiteit censuurt onder het mom van een  [...]]]></description>
			<content:encoded><![CDATA[<p>De Radboud Universiteit censuurt onder het mom van <a href="http://www.ru.nl/actueel/nieuws-0/?ActItmIdt=811729&#038;ActLbl=nieuwsplatform">een duidelijke scheiding tussen intern en extern nieuws</a> sinds kort het niet-meer-onafhankelijke blad de <a href="http://voxlog.nl">Vox</a>.</p>
<p>Gelukkig kunt u het nieuws alsnog lezen op <a href="http://runieuws.nl">RU Nieuws</a>.  Op deze site wordt al het interne nieuws gelekt.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2011/06/06/radboud-universiteit-nieuws/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
