<?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>Brian Warner</title>
	<atom:link href="http://blog.mozilla.org/warner/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mozilla.org/warner</link>
	<description>Just another Blog.mozilla.com site</description>
	<lastBuildDate>Sat, 11 Feb 2012 21:12:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>New Ed25519 &#8220;ref10&#8243; implementation available: 20x faster</title>
		<link>http://blog.mozilla.org/warner/2012/02/11/new-ed25519-ref10-implementation-available-20x-faster/</link>
		<comments>http://blog.mozilla.org/warner/2012/02/11/new-ed25519-ref10-implementation-available-20x-faster/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 21:12:35 +0000</pubDate>
		<dc:creator>warner</dc:creator>
				<category><![CDATA[Cryptography]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/warner/?p=165</guid>
		<description><![CDATA[&#8220;Dcoder&#8221; on the #tahoe-lafs IRC channel was kind enough to point me at the latest SUPERCOP benchmark-suite release: http://hyperelliptic.org/ebats/supercop-20120210.tar.bz2 , which includes a new portable-C reference version of the Ed25519 signature code named &#8220;ref10&#8243;. I added this into python-ed25519 in the &#8220;ref10&#8243; branch (at https://github.com/warner/python-ed25519/tree/ref10) and did some quick speed comparisons. I&#8217;m delighted to see [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Dcoder&#8221; on the #tahoe-lafs IRC channel was kind enough to point me at the latest SUPERCOP benchmark-suite release: <a title="http://hyperelliptic.org/ebats/supercop-20120210.tar.bz2" href="http://hyperelliptic.org/ebats/supercop-20120210.tar.bz2">http://hyperelliptic.org/ebats/supercop-20120210.tar.bz2</a> , which includes a new portable-C reference version of the Ed25519 signature code named &#8220;ref10&#8243;. I added this into python-ed25519 in the &#8220;ref10&#8243; branch (at <a title="https://github.com/warner/python-ed25519/tree/ref10" href="https://github.com/warner/python-ed25519/tree/ref10">https://github.com/warner/python-ed25519/tree/ref10</a>) and did some quick speed comparisons.</p>
<p>I&#8217;m delighted to see that the new code is roughly 20x faster than the previous version, without using processor-specific non-portable assembly language. The old &#8220;ref&#8221; code, on my 2008 laptop (2.53GHz Core2Duo), makes signatures in 2ms and verifies them in 7ms. The &#8220;ref10&#8243; code signs in 120us and verifies in 307us. That&#8217;s over 8300 signature per second! The ref10 version also includes the batch-verification function, which (thanks to some tricks in the design of Ed25519) makes it faster to verify many signatures at once. Interestingly, this requires random numbers on the *verification* side (since it&#8217;s doing statistical verification: if the attacker knew which random numbers you were going to use, they could craft a set of message that would appear valid when checked by the batch verifier, but were invalid when checked individually).</p>
<p>Naturally, this release came exactly one day after I finally published python-ed25519 1.0 <img src='http://blog.mozilla.org/warner/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . But 1.1 will have the speedups.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/warner/2012/02/11/new-ed25519-ref10-implementation-available-20x-faster/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Version String Management in Python: Introducing python-versioneer</title>
		<link>http://blog.mozilla.org/warner/2012/01/31/version-string-management-in-python-introducing-python-versioneer/</link>
		<comments>http://blog.mozilla.org/warner/2012/01/31/version-string-management-in-python-introducing-python-versioneer/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 02:08:14 +0000</pubDate>
		<dc:creator>warner</dc:creator>
				<category><![CDATA[Jetpack]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/warner/?p=147</guid>
		<description><![CDATA[What&#8217;s a good way to manage version numbers in a Python project? I don&#8217;t mean: where should it be stored, so that other code can find it. PEP 8 tells us to use __version__, and distutils tells us to call setup() with a version= argument. The embedded string is particularly useful to report or record [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s a good way to manage version numbers in a Python project? I don&#8217;t mean:</p>
<ul>
<li>where should it be stored, so that other code can find it. PEP 8 tells us to use __version__, and distutils tells us to call setup() with a version= argument. The embedded string is particularly useful to report or record a version in bug reports.</li>
<li>what format it should take: PEP 386 describes a format (N.N[.N]+[{a|b|c|rc}N[.N]+][.postN][.devN]) that enables comparison, so packaging tools can evaluate things like &#8220;dependency &gt; 1.2.0&#8243;. (I happen to find this format really limiting, and this tool doesn&#8217;t necessarily produce PEP386-compliant strings, but that&#8217;s not what this post is about)</li>
</ul>
<p>What I do mean is:</p>
<ul>
<li>how does the right version string get into the code?</li>
<li>what does a release manager need to do when it&#8217;s time to make a new release?</li>
</ul>
<p>The traditional approach, ages old, is to have a static string embedded in the code. Each time you&#8217;re about to make a new release, you make a commit which updates this string. It&#8217;s nice and simple, but has some problems:<span id="more-147"></span></p>
<ul>
<li>Confusing intermediate versions: users/developers who work from revision control, between releases, will get a stale version, causing confusing bug reports (&#8220;it says 1.2! Oh, but I pulled from SVN last tuesday, maybe it&#8217;s closer to 1.3&#8243;). I got into the habit of commiting a &#8220;1.2+&#8221; version just after making the 1.2 release, which fixes the confusion, but doesn&#8217;t remove the ambiguity (&#8220;it says 1.2+ .. when did you last update?&#8221;)</li>
<li>Post-RC code changes: projects large enough to have release candidates must accept (small) code changes between the last release-candidate and the final release, to update the embedded version string one last time. This makes QA nervous.</li>
<li>Merge conflicts: embedded version strings work fine for linear histories, but modern DVCS systems make it easy to have extended release branches, so larger projects usually have parallel lines of development (dev, stabilization, release). It&#8217;s frequently a good idea to merge your release branch back into your main trunk, to make sure you don&#8217;t lose any of the fixes made during the release effort. But then you get merge conflicts between the version string on trunk (which now says something like 1.3-dev or 1.3+) and the older version on the release branch (maybe 1.2), every single release. Resolving this correctly each time (generally in favor of the trunk version) is a source of errors.</li>
<li>It adds an extra step to the release process (two if you use the &#8220;1.2+&#8221; approach), discouraging developers from releasing early and often.</li>
</ul>
<p>Over the years, I&#8217;ve built a couple of ad-hoc mechanisms for updating the embedded version string just before each commit, or to add an &#8220;update version&#8221; command/script that checks with the version-control tool for information. Tahoe uses setup.cfg to prepend an update-versions command in front of any setup.py command that might care. And I&#8217;ve had setup.py code which greps a _version.py for the current string (rather than import, to avoid committing to an unusably old dependency, also for speed). But none of these have been very satisfying.</p>
<p>Thinking about how I use git these days, I realized that I want my release process to have one step: &#8220;git tag&#8221; (well, and a &#8220;git push&#8221; to tell the world about it). Everything else should be automated: building tarballs, uploading them to a release server, updating a web page, sending an announcement email, pypi registration, etc. What really matters is the release manager making the decision to bless some well-tested revision id with a public name of some sort.</p>
<p>So I finally built a tool to accomplish this. It&#8217;s called &#8220;Versioneer&#8221;, and is available at <a title="https://github.com/warner/python-versioneer" href="https://github.com/warner/python-versioneer">https://github.com/warner/python-versioneer</a> . It&#8217;s still pretty early, but seems to do the right thing. Here&#8217;s how it works:</p>
<ul>
<li>To install, you copy versioneer.py into your tree and follow the instructions in the docstring. These will have you edit your setup.py to &#8220;import versioneer&#8221;, set a few variables to tell it about your tag-naming convention (PROJECT-VER or just VER) and where the _version.py ought to live. It also has you add a cmdclass= to your setup() arguments, which hooks into the &#8220;build&#8221; and &#8220;sdist&#8221; commands, and adds an &#8220;update_files&#8221; command. Then you run &#8220;setup.py update_files&#8221;, which creates your _version.py and modifies your __init__.py to include it (and define the PEP 8 __version__ variable). It also creates a .gitattributes file to arrange for variable-expansion during git-archive, described below. Then it does &#8216;git add&#8217; on the relevant files and asks you to commit the changes.</li>
<li>When setup.py needs a version (such as for building an sdist tarball, or registering with pypi), it calls versioneer.get_versions().</li>
<li>At runtime, __init__.py calls _version.get_versions() to populate __version__</li>
<li>If either is called in a checked out source tree, they invoke &#8220;git describe&#8221; (with &#8211;tags &#8211;always &#8211;dirty) to come up with a fine-grained version string. If you&#8217;re sitting on a tag, you get just &#8220;1.4&#8243;. If you&#8217;re after a tag, you&#8217;ll get something like &#8220;1.4-8-gf7283c2&#8243;, which means there are 8 commits after the 1.4 tag, and the abbreviated SHA1 revision ID is f7283c2. And if your tree has uncommitted changes, you&#8217;ll get &#8220;1.4-8-gf7283c2-dirty&#8221;.</li>
<li>Using &#8220;git archive&#8221; to create a tarball or zipfile will expand some magic variables in _version.py, capturing the SHA1 revision id, and any tags that point to it. When unpacked, these strings are parsed to extract the most likely tag name. This allows tarballs generated by gitweb and GitHub&#8217;s &#8220;Download A Tarball&#8221; button to get useful version strings.</li>
<li>Using &#8220;setup.py dist&#8221; to make a tarball, or &#8220;setup.py build&#8221; to copy code into build/, will compute the version and replace _version.py with a short form that just has the computed strings.</li>
</ul>
<p>The result is that you get a useful fine-grained version string, updated every time you run your program, embedded into release products via the most common tarball-generation tools (setup.py sdist and git-archive). Developers will get detailed version information in their test logs (assuming you record __version__ in them, which you should), so other developers can reproduce their tree. Bug reports from end users will contain enough data (assuming they emit the version string) to reproduce their code, and to learn if they have local modifications or not. Release managers only need to run &#8220;git tag&#8221; when they decide to make a new release. And development/stabilization/release branches can be merged freely without worrying about what will happen to embedded version strings.</p>
<p>There are a few gotchas:</p>
<ul>
<li>the tool only handles git so far. I plan to add support for other systems in the future. Git is nice because git-describe is so fast. The &#8211;dirty flag does require that it stat every file (and possibly hash the contents), but that&#8217;s still pretty fast (25ms on my laptop for the jetpack tree). Other VCSes should be similarly fast, except for Darcs for which there is no concise version string except for specific tags.</li>
<li>The git-archive expanded variables are abbreviated, and don&#8217;t distinguish between branch names and tag names, so sometimes we have to guess. Also you might have multiple tags pointing at the current revision (very common when your last release candidate gets promoted to final: the code sees both &#8220;1.3rc2&#8243; and &#8220;1.3&#8243; and picks the shorter one). It works pretty well when you build a tarball from a release tag, but building from something between-releases only gets you the full SHA1 (not the 1.4-8-gREVID form).</li>
<li>if you wind up in a git checkout but either /usr/bin/git or .git is unavailable (maybe your git is named something else, or you&#8217;ve deleted the .git directory, or something), then the code will report a version of &#8220;unknown&#8221;. This happened on the Flightdeck (aka Add-On Builder) site, where it turned out they were getting the Jetpack code in a git submodule and then copying everything but the .git directory to a deployment server. This also happens if you&#8217;re bridging the code into a different VC system (e.g. using hg_git or git-svn or something) and using the result. This happens on the git-to-hg bridged version of the jetpack trunk, which is still used by some RelEng automation.</li>
<li>&#8220;1.4-8-gREVID&#8221; is not PEP386-compliant: it can tolerate an &#8220;-rNNN&#8221; suffix (for SVN-style revision IDs), but not the more general &#8220;-gHEX&#8221; suffix that git-describe provides, nor the &#8220;-8&#8243; revision counter. You may need to mangle the result if PEP386-compatibility of between-release version strings is important to you.</li>
</ul>
<p>Jetpack uses Versioneer as of addon-sdk-1.4, with only a few stumbles so far. I&#8217;ve also switched <a title="python-ed25519" href="https://github.com/warner/python-ed25519">python-ed25519</a> to use Versioneer. Let me know what you think!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/warner/2012/01/31/version-string-management-in-python-introducing-python-versioneer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Improving the pynacl build process</title>
		<link>http://blog.mozilla.org/warner/2012/01/19/improving-the-pynacl-build-process/</link>
		<comments>http://blog.mozilla.org/warner/2012/01/19/improving-the-pynacl-build-process/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 01:21:33 +0000</pubDate>
		<dc:creator>warner</dc:creator>
				<category><![CDATA[Cryptography]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/warner/?p=134</guid>
		<description><![CDATA[I&#8217;ve been hacking on my copy of pynacl this week. pynacl is a set of Python bindings to the NaCl cryptography library (by djb and friends). The bindings, first written by Sean Lynch and then picked up by &#8220;k3d3&#8243;, are great. They even support py2.6 through py3.2. But actually building them is a hassle, because [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been hacking on <a href="https://github.com/warner/pynacl">my copy of pynacl</a> this week. pynacl is a set of Python bindings to the <a href="http://nacl.cr.yp.to/">NaCl cryptography library</a> (by djb and friends). The bindings, first written by <a href="https://github.com/seanlynch/pynacl">Sean Lynch</a> and then picked up by <a href="https://github.com/k3d3/pynacl">&#8220;k3d3&#8243;</a>, are great. They even support py2.6 through py3.2.</p>
<p>But actually building them is a hassle, because the NaCl build process is so idiosyncratic. It consists of a 500-line undocumented shell script named &#8220;do&#8221;, and running it gets you 25 minutes of 100% CPU that executes in stony silence (all progress messages are redirected to a logfile). If you can wait that long, and think to explore the directory afterwards, you&#8217;ll be rewarded with a build/HOSTNAME/ directory that contains a libnacl.a and a set of header files that are pretty easy to use. What&#8217;s actually going on behind the scenes is that the script is exhaustively compiling and testing a large matrix of compiler flags (-O vs -O3 vs -O3 -funroll-loops), ABI variants, and alternative implementations. The goal is apparently to:</p>
<ul>
<li>select the fastest possible implementation and compiler options, using any assembly-language tricks specific to the processor (SSE3, etc)</li>
<li>make sure the unit tests pass</li>
<li>construct a performance report to send back to the authors</li>
</ul>
<p>Unfortunately, this doesn&#8217;t play well with other build systems that might want to embed a copy, such as Python&#8217;s distutils, because:</p>
<ul>
<li>some compiler flags (-fPIC) are needed to build the .so files that python can load at runtime: distutils knows what these are, &#8220;do&#8221; doesn&#8217;t</li>
<li>when building e.g. debian packages, the results will be used on other machines, so processor-specific optimizations aren&#8217;t ok (you might build your packages on a machine with some feature that&#8217;s not present on the machines that use those packages, so stick with least-common-denominator).</li>
<li>running &#8220;do&#8221; requires a Bourne Shell interpreter, standard on unix systems but not so obvious on windows. distutils knows how to compile things on windows, but you have to tell it the source files, and it will run the compiler itself.</li>
<li>having a separate &#8220;./do&#8221; compile step means that &#8220;setup.py build&#8221; is not enough, which means that easy_install won&#8217;t work, making it hard to use pynacl as a dependency in virtualenv or pip environments.</li>
</ul>
<p>In addition, waiting 25 minutes for an otherwise small and elegant library to build is just a drag.</p>
<p><span id="more-134"></span></p>
<p>So I&#8217;ve pursued two projects this week. The first is to simply embed a mostly-unmodified (I did add -fPIC) copy of the latest nacl release into the pynacl source tree, and modify pynacl&#8217;s setup.py to use it. The build process becomes &#8220;cd nacl-*; ./do; cd ..; python setup.py build&#8221;. This is way easier than downloading+building an external copy and then pointing environment variables at the result. Takes just as long, but is easier to run. This work is in my <a href="https://github.com/warner/pynacl/tree/embed-nacl">&#8220;embed-nacl&#8221;</a> branch (don&#8217;t be surprised if the branch is gone by the time you read this.. it may get merged to trunk). I also have a subset of &#8220;do&#8221;, named &#8220;dont&#8221;, which cuts out some of the unused pieces (like the C++ bindings and the large performance benchmarks), and runs in about 8 minutes.</p>
<p>The second is to embed a modified subset of the nacl sources in pynacl, making it look much more like a normal python extension module. This is in my <a href="https://github.com/warner/pynacl/tree/minimal">&#8220;minimal&#8221;</a> branch (again, this branch may get merged and be deleted).</p>
<p>This turned out to be pretty hard: the nacl &#8220;do&#8221; script synthesizes different versions of the same header file for each algorithm, and deletes many of them just after compilation. Also, the C code for e.g. crypto_hash_sha256 uses the same function name crypto_hash() as the code for crypto_hash_sha512, and depends upon #defines in the header file to prevent them from colliding. (the goal here is to let users call short function names and get the recommended algorithm, like crypto_box() instead of crypto_box_curve25519xsalsa20poly1305(), which is frequently a good idea, but not always).</p>
<p>So I had to modify the .c files to have non-colliding names, and write new header files to provide the recommended-algorithm mapping. I only copied in the portable implementations (leaving out the non-portable asm speedups). I also left out the multiple-ABI support, the try-different-compiler-flags speedups, the automatic performance tests, and the unit tests (although I hope to bring those back). But the result is something that compiles in <strong>13 seconds</strong>, a 100x speedup, and which can be built with easy_install.</p>
<p>How does performance suffer without the specialized implementations and compiler flags? Here&#8217;s a comparison of the time it takes to call the various python functions (using 1000-byte messages, where applicable) in the two versions, on my 2010 MacBookPro (2.8GHz Core2Duo). The results are tolerable. The biggest victim is the Curve25519 scalar multiplication functions, since the whole algorithm was specifically designed to take advantage of 64-bit operations not available to the generic version (which needs to run on 32-bit machines). This slowdown also hits the high-level box()/box_open() functions, bringing them up to 5ms on my laptop. crypto_sign uses an early version of Ed25519, and nacl does not yet have an optimized version, so it takes 6ms in both branches. The next version of nacl will include the same carefully optimized version of Ed25519 as the SUPERCOP benchmark suite, in which signing takes about 19us, so this will also become a noticeable slowdown.</p>
<table style="border: 1px solid #CCC;" cellspacing="0">
<tbody>
<tr>
<th style="padding-left: 10px; padding-right: 10px;">name</th>
<th style="padding-left: 10px; padding-right: 10px;">ref</th>
<th style="padding-left: 10px; padding-right: 10px;">optimized</th>
<th style="padding-left: 10px; padding-right: 10px;">slowdown</th>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_auth</td>
<td style="border: 1px solid #CCC; text-align: right;">8.50 us</td>
<td style="border: 1px solid #CCC; text-align: right;">7.95 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #afa;">1.1x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_auth_verify</td>
<td style="border: 1px solid #CCC; text-align: right;">8.49 us</td>
<td style="border: 1px solid #CCC; text-align: right;">7.87 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #afa;">1.1x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_box</td>
<td style="border: 1px solid #CCC; text-align: right;">4.64 ms</td>
<td style="border: 1px solid #CCC; text-align: right;">198.61 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #faa;">23.3x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_box_keypair</td>
<td style="border: 1px solid #CCC; text-align: right;">4.57 ms</td>
<td style="border: 1px solid #CCC; text-align: right;">198.84 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #faa;">23.0x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_box_open</td>
<td style="border: 1px solid #CCC; text-align: right;">4.65 ms</td>
<td style="border: 1px solid #CCC; text-align: right;">199.33 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #faa;">23.3x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_hash_sha256</td>
<td style="border: 1px solid #CCC; text-align: right;">898.93 ns</td>
<td style="border: 1px solid #CCC; text-align: right;">855.99 ns</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #afa;">1.1x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_hash_sha512</td>
<td style="border: 1px solid #CCC; text-align: right;">1.54 us</td>
<td style="border: 1px solid #CCC; text-align: right;">1.25 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #afa;">1.2x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_onetimeauth</td>
<td style="border: 1px solid #CCC; text-align: right;">49.06 us</td>
<td style="border: 1px solid #CCC; text-align: right;">2.40 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #faa;">20.4x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_onetimeauth_verify</td>
<td style="border: 1px solid #CCC; text-align: right;">67.07 us</td>
<td style="border: 1px solid #CCC; text-align: right;">2.42 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #faa;">27.7x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_scalarmult</td>
<td style="border: 1px solid #CCC; text-align: right;">4.57 ms</td>
<td style="border: 1px solid #CCC; text-align: right;">191.88 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #faa;">23.8x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_scalarmult_base</td>
<td style="border: 1px solid #CCC; text-align: right;">4.69 ms</td>
<td style="border: 1px solid #CCC; text-align: right;">192.76 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #faa;">24.3x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_secretbox</td>
<td style="border: 1px solid #CCC; text-align: right;">58.02 us</td>
<td style="border: 1px solid #CCC; text-align: right;">5.09 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #faa;">11.4x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_secretbox_open</td>
<td style="border: 1px solid #CCC; text-align: right;">58.59 us</td>
<td style="border: 1px solid #CCC; text-align: right;">5.64 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #faa;">10.4x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_sign</td>
<td style="border: 1px solid #CCC; text-align: right;">6.28 ms</td>
<td style="border: 1px solid #CCC; text-align: right;">5.95 ms</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #afa;">1.1x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_sign_keypair_fromseed</td>
<td style="border: 1px solid #CCC; text-align: right;">6.26 ms</td>
<td style="border: 1px solid #CCC; text-align: right;">5.96 ms</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #afa;">1.1x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_sign_open</td>
<td style="border: 1px solid #CCC; text-align: right;">16.58 ms</td>
<td style="border: 1px solid #CCC; text-align: right;">15.67 ms</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #afa;">1.1x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_stream</td>
<td style="border: 1px solid #CCC; text-align: right;">5.53 us</td>
<td style="border: 1px solid #CCC; text-align: right;">2.66 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #ffa;">2.1x</td>
</tr>
<tr>
<td style="border: 1px solid #CCC; text-align: left;">crypto_stream_xor</td>
<td style="border: 1px solid #CCC; text-align: right;">6.80 us</td>
<td style="border: 1px solid #CCC; text-align: right;">2.27 us</td>
<td style="border: 1px solid #CCC; text-align: right; background-color: #ffa;">3.0x</td>
</tr>
</tbody>
</table>
<p>But I think the result is still pretty good: for many applications where you&#8217;re using Python, 5ms is just as good as 200us. And this branch makes it <strong>much</strong> easier to depend upon pynacl than the others.</p>
<p>My next steps are to clean up the branch a bit, talk to k3d3 about which approach seems the best, get it merged upstream, and then hopefully get it copied to PyPI. And then investigate how hard it&#8217;d be to build the alternative implementations: maybe with some distutils hacking, we could build all the variants (and see which ones actually work), do some quick performance tests, then call setup() again &#8220;for real&#8221; with just the fastest ones. That should shave off most of the slowdown (leaving the compiler-flag gains), but still give us something that compiles easily.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/warner/2012/01/19/improving-the-pynacl-build-process/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ed25519 Keys</title>
		<link>http://blog.mozilla.org/warner/2011/11/29/ed25519-keys/</link>
		<comments>http://blog.mozilla.org/warner/2011/11/29/ed25519-keys/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 01:24:07 +0000</pubDate>
		<dc:creator>warner</dc:creator>
				<category><![CDATA[Cryptography]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/warner/?p=124</guid>
		<description><![CDATA[How do Ed5519 keys work? There are several different implementations of the Ed25519 signature system, and they each use slightly different key formats. While writing python-ed25519, I wanted to validate it against the upstream known-answer-tests, so I had to figure out how to convert those keys into a format that my code could use. The [...]]]></description>
			<content:encoded><![CDATA[<h1>How do Ed5519 keys work?</h1>
<p>There are several different implementations of the <a href="http://ed25519.cr.yp.to/">Ed25519</a> signature system, and they each use slightly different key formats. While writing <a href="https://github.com/warner/python-ed25519">python-ed25519</a>, I wanted to validate it against the upstream known-answer-tests, so I had to figure out how to convert those keys into a format that my code could use.</p>
<p><span id="more-124"></span><br />
The best reference is the <a href="http://ed25519.cr.yp.to/ed25519-20110926.pdf">original paper</a>, which explains everything you need to know to implement the basic algorithm. I currently know of three or four implementations (many of which are on the Ed25519 <a href="http://ed25519.cr.yp.to/software.html">software page</a>):</p>
<ul>
<li>a portable C &#8220;reference&#8221; version</li>
<li>a 10x faster AMD64-optimized C/assembly version (in two flavors, with different speed/memory tradeoffs)</li>
<li>an educational (but unusably slow) pure-python module</li>
<li>my Python binding to the C reference version</li>
</ul>
<p>djb&#8217;s <a href="http://nacl.cr.yp.to/">NaCl</a> library (as of version 20110221) includes an <del>older copy</del> prototype of the portable C version, in nacl-20110221/crypto_sign/edwards5519sha512batch/ref/ (as far as I can tell, it doesn&#8217;t implement quite the same algorithm: it doesn&#8217;t include the pubkey in the hash when computing S. UPDATE: djb told me that nacl-20110221&#8242;s code is just a prototype, and will be replaced with the real Ed25519 in the next release). The <a href="http://bench.cr.yp.to/supercop.html">SUPERCOP</a> benchmark suite includes both the portable C and the two AMD64-specific flavors (in supercop-20110704/crypto_sign/ed25519/, under the ref, amd64-51-30k, and amd64-64-24k subdirectories). The pedagogical pure-python implementation is referenced by the <a href="http://ed25519.cr.yp.to/software.html">ed25519 web page</a>, but since it takes tens of seconds to compute each signature, it&#8217;s really only useful for validating the output of other implementations.</p>
<p>My <a href="https://github.com/warner/python-ed25519">python-ed25519</a> library provides Python bindings to the portable C version, using code taken from the SUPERCOP suite.</p>
<p>These different implementations all arrange the keys and signatures slightly differently. NaCl&#8217;s goal is to provide safe high-level box/unbox functions, so the only interface it offers will copy the entire message into the output and append a signature to it (not so convenient for building into other protocols). SUPERCOP&#8217;s goal is to measure the speed of each operation, so its interface isn&#8217;t so convenient for general use either. I&#8217;ve tried to give python-ed25519 a good interface for use in other projects.</p>
<p>To remind myself about how these different implementations handle keys, here&#8217;s an overview.</p>
<p>Ed25519 keys start life as a 32-byte (256-bit) uniformly random binary seed (e.g. the output of SHA256 on some random input). The seed is then hashed using SHA512, which gets you 64 bytes (512 bits), which is then split into a &#8220;left half&#8221; (the first 32 bytes) and a &#8220;right half&#8221;. The left half is massaged into a curve25519 private scalar &#8220;a&#8221; by setting and clearing a few high/low-order bits. The pubkey is generated by multiplying this secret scalar by &#8220;B&#8221; (the generator), which yields a 32-byte/256-bit group element &#8220;A&#8221;.</p>
<p>When signatures are made, two values result: R and S (both 32-bytes, so the overall signature is 64 bytes long). R depends upon the right half of the expanded seed and on the message. (In traditional DSA, R is randomly generated, and the security of the private key depends upon the quality of that randomness, leading to some high-profile failures). S is the real meat of the signature, and is a function of everything (including the pubkey).</p>
<p>Private signing keys can be generated from just the 32-byte seed, but require additional work before you can make signatures (SHA512-based expansion, the bit setting/clearing massage step, and pubkey exponentiation). Likewise public verifying keys can be derived from either the private seed or the private exponent. (note that it&#8217;s the multiplications that take the most time: everything else is trivial by comparison).</p>
<p>If you care more about the speed of operations than storage space, you&#8217;d want to store the expanded versions. Or, you might want to store as little information as possible, and accept the performance penalty of re-deriving things when necessary. Different implementations choose different tradeoffs.</p>
<p>With that background, here&#8217;s what the different implementations do:</p>
<ul>
<li>slow pure-python &#8220;ed25519.py&#8221; implementation, with Known-Answer-Tests in sign.py and sign.input:
<ul>
<li>publickey(sk) takes the seed, returns the 32-byte pubkey</li>
<li>signature() takes the message to be signed, the seed, and the pubkey, returns the 64-byte signature</li>
<li>checkvalid() takes the signature, the message, and the 32-byte pubkey</li>
<li>each line of the test data contains four fields (joined by colons):</li>
<li>seed+pubkey (64 bytes)</li>
<li>just the pubkey (32 bytes)</li>
<li>the message (variable length)</li>
<li>the signature concatenated with the message (R+S+msg)</li>
</ul>
</li>
<li>NaCl-20110221 implementation:
<ul>
<li>keypair() returns two values. The first (signing key) is the private scalar (32 bytes) concatenated with the &#8220;right half&#8221; (also 32 bytes). The second is the pubkey (32 bytes)</li>
<li>sign() takes the signing key and message. The NaCl version doesn&#8217;t take the pubkey, and thus diverges from the ed25519.py implementation: S=H(r+msg), not H(r+pubkey+msg). ed25519.py matches the paper, as does SUPERCOP, but NaCl does not. sign() returns R+msg+S</li>
</ul>
</li>
<li>SUPERCOP-20110704 implementation:
<ul>
<li>keypair() returns two values. The first (signing key) is the seed (32 bytes) concatenated with the generated pubkey (32 bytes). The second is the pubkey (32 bytes).</li>
<li>sign() returns R+S+msg</li>
</ul>
</li>
<li>python-ed25519 (using the SUPERCOP code but changing the output):
<ul>
<li>ed25519.create_keypair() returns a SigningKey object and a VerifyingKey object</li>
<li>SigningKeys can be serialized with to_bytes() (which returns the same 64 bytes as the SUPERCOP code that it wraps: the seed concatenated with the pubkey A), or with to_seed() (which returns just the 32-byte seed).</li>
<li>VerifyingKeys can be serialized with to_bytes(), which returns the<br />
32-byte pubkey A.</li>
<li>sk.sign() returns a 64-byte signature (the concatenation of R and S) without returning a copy of the message too. (internally, this invokes SUPERCOP&#8217;s crypto_sign() function with an output buffer large enough to hold R+S+msg, then discards the message).</li>
</ul>
</li>
</ul>
<p>This is summarized in the following diagram:</p>
<p><a href="http://blog.mozilla.org/warner/files/2011/11/key-formats.png"><img class="alignnone size-large wp-image-116" title="key-formats" src="http://blog.mozilla.org/warner/files/2011/11/key-formats-757x1024.png" alt="" width="757" height="1024" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/warner/2011/11/29/ed25519-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing python-ed25519</title>
		<link>http://blog.mozilla.org/warner/2011/11/21/introducing-python-ed25519/</link>
		<comments>http://blog.mozilla.org/warner/2011/11/21/introducing-python-ed25519/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 00:40:21 +0000</pubDate>
		<dc:creator>warner</dc:creator>
				<category><![CDATA[Cryptography]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/warner/?p=98</guid>
		<description><![CDATA[Ed25519 is an implementation of Schnorr Signatures in a particular elliptic curve (Curve25519) that enables very high speed operations. It also has a few nice features to make the algorithm safer and easier to use. I&#8217;ve published some MIT-licensed Python bindings to djb++&#8217;s portable C implementation of this signature scheme. They&#8217;re available here: https://github.com/warner/python-ed25519 or [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ed25519.cr.yp.to/">Ed25519</a> is an implementation of Schnorr Signatures in a particular elliptic curve (Curve25519) that enables very high speed operations. It also has a few nice features to make the algorithm safer and easier to use.</p>
<p>I&#8217;ve published some MIT-licensed Python bindings to djb++&#8217;s portable C implementation of this signature scheme. They&#8217;re available here:</p>
<ul>
<li><a href="https://github.com/warner/python-ed25519">https://github.com/warner/python-ed25519</a></li>
<li>or <tt>easy_install ed25519</tt></li>
</ul>
<p>Some highlights:</p>
<ul>
<li>signing keys and verifing keys are both just 32 bytes</li>
<li>signatures are 64 bytes</li>
<li>key generation and signing each take about 2ms on my 2010 MacBookPro</li>
<li>signature verification takes about 6ms</li>
<li>128-bit security level, comparable to AES-128, SHA256, and 3072-bit RSA</li>
<li>No entropy needed during signing (signatures are deterministic)</li>
</ul>
<p>There are amd64-specific assembly versions that run even faster, in just a few hundred microseconds, and for bulk operations you can do batch verification faster than one-at-a-time verification. So you can perform thousands of operations per second with this algorithm (and hundreds with this particular implementation).</p>
<p>It&#8217;s very exciting to finally have short+fast signatures (and also, through <a href="http://code.google.com/p/curve25519-donna/">Curve25519</a>, key-agreement and encryption): it opens up a lot of new possibilities. When public-key encryption was first invented, keys took so long to generate that folks assumed that each human would have just one: all sorts of mental baggage was built up around this restriction (ideas like never sharing signing keys, keys representing people, and the need to distribute keys separately from fingerprints). When you can easily generate a new key for each message or object or operation, we can let go of some of those psychological fetters and build something new.</p>
<p>(Note that &#8220;<a href="http://cr.yp.to/ecdh.html">Curve25519</a>&#8221; uses the same basic curve equation, but only provides Diffie-Hellman key agreement [and, by extension, public-key encryption]. It can&#8217;t be used to create signatures that can be verified by third parties: for that you need Ed25519. A portable Curve25519 implementation can be found in <a href="http://code.google.com/p/curve25519-donna/">curve25519-donna</a>, and includes a Python binding that I wrote too)</p>
<p>Take a look and let me know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/warner/2011/11/21/introducing-python-ed25519/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cryptographic Invitation Protocols</title>
		<link>http://blog.mozilla.org/warner/2011/10/28/cryptographic-invitation-protocols/</link>
		<comments>http://blog.mozilla.org/warner/2011/10/28/cryptographic-invitation-protocols/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 15:47:51 +0000</pubDate>
		<dc:creator>warner</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Tahoe-LAFS]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/warner/?p=64</guid>
		<description><![CDATA[For a while now, I&#8217;ve been noodling around with a cryptographically-secure &#34;invitation protocol&#34; of sorts. I want something that can start with Alice sending an Invitation Message to Bob, and end with fully secure bidirectional communication. The use cases I have so far are: secure file-transfer tools, as a browser plugin or standalone application. The [...]]]></description>
			<content:encoded><![CDATA[<div class="document" id="an-invitation-protocol">
<p>For a while now, I&#8217;ve been noodling around with a cryptographically-secure &quot;invitation protocol&quot; of sorts. I want something that can start with Alice sending an <cite>Invitation Message</cite> to Bob, and end with fully secure bidirectional communication.</p>
<p>The use cases I have so far are:</p>
<ul class="simple">
<li>secure file-transfer tools, as a browser plugin or standalone application. The program would have an address-book, each entry would have an &quot;Inbox&quot; for that person, you would send them a file by drag-and-dropping it onto the Inbox. This invitation protocol would be used to populate the address book.</li>
<li>secure communication tools, like <a class="reference external" href="http://petmail.lothar.com/">Petmail</a> or an encrypted email/IM client, in which you want to add address-book entries so you can later exchange messages with the right correspondent.</li>
<li><a class="reference external" href="http://tahoe-lafs.org/">Tahoe</a> grid membership tools: you would use an Invitation to securely add another person&#8217;s client/server node to your grid, maintaining enough information to perform Accounting and server-selection properly.</li>
</ul>
<p>but there are lots of others. Most applications with any sort of social component need a way to add &quot;buddies&quot; or correspondents. There are plenty of centralized systems (like IM networks, where the namespace is controlled by a single company), and a handful of insecure decentralized systems (like email addresses). I want this protocol for secure decentralized systems, in which the primary identifier for each participant is a public key of some sort.</p>
<p>Read on if you&#8217;re interested in cryptographic protocols..</p>
<p><span id="more-64"></span></p>
<p>A big usability-barrier for such systems is the bootstrapping problem: getting from a casual (insecure) everyday channel to the persistent secure long-term channel. A lot of tools punt on this and assume the keys are distributed ahead of time, or managed by some administrator. I&#8217;m interested in systems for which the only mode is &quot;secure&quot; mode, and which are as easy to use as traditional insecure systems. The usability standard is that the humans do not need to do anything more than they&#8217;re already doing: the system would look no simpler if you ripped out the security, so we might as well leave it in.</p>
<p>Imagine you&#8217;re chatting with someone at a conference, or at lunch, or in an IRC channel, and you want to send them a file, or pick up the conversation later, or whatever. You want your user agent to learn about their user agent, so that you can use it to send them a message later on. I&#8217;d like this to be properly secure, so every message is signed and encrypted, which means the agents need to learn each other&#8217;s keys. What can the two humans exchange that will let their agents establish that cryptographic connection?</p>
<p>The usual (worst case) pattern, with something like PGP, is that both people must pre-arrange for some common server to hold copies of their public keys, indexed by an email address, and to have secure hashes of those keys on something transferrable in their pocket (frequently printed on business cards). They can exchange business cards and type in their contents later (downloading the keys, computing the hashes, and comparing against the cards). Or, if they have an online connection already, they can paste large key files to each other, and perhaps paste+compare fingerprints. But we have plenty of experience showing that these schemes aren&#8217;t sufficiently usable, and needing to type in all that material discourages casual real-time use.</p>
<p>In the protocol I have in mind, one of these people sends an &quot;Invitation&quot; to the other, and the second person accepts it. Alice, the inviter, asks her computer for the invitation object (a file or a short string), and she somehow hands it to Bob: maybe she emails it to him, or pastes it to him over an IM channel, or recites it to him in person or over the phone. Bob drags or pastes or types this invitation into his computer. Then the two computers talk to each other, exchange keys, and at the end of the process, each computer has an address-book entry for the other. Later, their applications can use these keys to perform secure message exchanges with each other.</p>
<p>The ground rules for this protocol (including some assumptions and basic engineering tradeoffs) are:</p>
<ul class="simple">
<li>Alice has a &quot;secure-enough&quot; channel to Bob already. &quot;secure-enough&quot; means we&#8217;re comfortable pretending that whatever she emails or pastes or speaks to him will remain secret and intact (not modified by an attacker) long enough for Bob to use it. Alice and Bob can take extra steps to make it more secure, if they want.</li>
<li>The channel isn&#8217;t long-term secure: we assume that the contents will become public eventually, so we aren&#8217;t allowed to put any long-term secrets in it</li>
<li>The channel is one-way and one-shot: if Alice sends her invitation via email, the protocol isn&#8217;t allowed to use email to get the response back. (this would impose burdens on the users, and require more complex interaction between the protocol implementation and existing tools)</li>
<li>The Invitation is thus single-use and only valid for a limited time, maybe 24 hours. We&#8217;re comfortable with a &quot;Trust On First Use&quot; policy: an attacker who both learns and acts upon the invitation early can impersonate Bob. But there will be a way to do an out-of-band comparison later, to completely rule out a man-in-the-middle.</li>
<li>Since the Internet is no longer a network of computers that can all talk to each other, we assume that either agent may be behind a NAT box. We allow applications to bake-in the address a publically-reachable &quot;Relay Service&quot;, which helps them exchange messages for the duration of the protocol. We don&#8217;t allow this service to affect the security of the system: it could mount a DoS attack, but otherwise is no more powerful than any other MitM.</li>
<li>The goal of the protocol is to securely get Alice&#8217;s address-book entry into Bob&#8217;s address-book, under a petname for &quot;Alice&quot; that Bob picks when he accepts the invitation: we call this entry <tt class="docutils literal">Ealice</tt>. We also need symmetry: to get Bob&#8217;s entry into Alice&#8217;s address-book under a petname that Alice picks when she sends the invitation, which we call <tt class="docutils literal">Ebob</tt>. Part of these entries is the address of a relay-service or other helper to exchange subsequent application-specific messages.</li>
<li>All these address-book entries are public knowledge: no need to keep them confidential during the protocol (this turns out to affect the protocol in significant ways)</li>
<li>We have a secure/fast/short public-key signature scheme: <a class="reference external" href="http://ed25519.cr.yp.to/">Ed25519</a>. We want a 128-bit security level.</li>
</ul>
<p>I&#8217;ll post more later about the protocol I&#8217;m building to satisfy these constraints. Let me know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/warner/2011/10/28/cryptographic-invitation-protocols/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>London Jetpack Workshop coming up: September 29th</title>
		<link>http://blog.mozilla.org/warner/2011/09/06/london-jetpack-workshop-coming-up-september-29th/</link>
		<comments>http://blog.mozilla.org/warner/2011/09/06/london-jetpack-workshop-coming-up-september-29th/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 00:16:55 +0000</pubDate>
		<dc:creator>warner</dc:creator>
				<category><![CDATA[Jetpack]]></category>
		<category><![CDATA[jetpack]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/warner/?p=3</guid>
		<description><![CDATA[If you&#8217;re in the London area, check out the free workshop we&#8217;re hosting on writing addons with Jetpack. It&#8217;s happening on a Thursday night (September 29th) at City University. See Jeff&#8217;s blog post for details and signup. We&#8217;re also setting one up for the San Francisco area in October.. stay tuned. I&#8217;ll be leading a [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re in the London area, check out the free workshop we&#8217;re hosting on writing addons with Jetpack. It&#8217;s happening on a Thursday night (September 29th) at City University. See <a href="http://blog.mozilla.org/addons/2011/08/25/add-on-sdk-workshop-coming-to-london-sept-29th/">Jeff&#8217;s blog post</a> for details and signup. We&#8217;re also setting one up for the San Francisco area in October.. stay tuned.</p>
<p>I&#8217;ll be leading a session on using modules. See you there!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/warner/2011/09/06/london-jetpack-workshop-coming-up-september-29th/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introductions</title>
		<link>http://blog.mozilla.org/warner/2011/08/25/hello-world/</link>
		<comments>http://blog.mozilla.org/warner/2011/08/25/hello-world/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 01:03:02 +0000</pubDate>
		<dc:creator>warner</dc:creator>
				<category><![CDATA[Jetpack]]></category>
		<category><![CDATA[Tahoe-LAFS]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/warner/?p=1</guid>
		<description><![CDATA[Hi! My name is Brian Warner. Welcome to my blog! I&#8217;ve been working at Mozilla for about a year and a half. Before Mozilla I was at a startup (now gone) named AllMyData.com, which ran an online backup service aimed at home users and small businesses. For the backend, we developed an open-source encrypted distributed [...]]]></description>
			<content:encoded><![CDATA[<p>Hi! My name is Brian Warner. Welcome to my blog!</p>
<p>I&#8217;ve been working at Mozilla for about a year and a half. Before Mozilla I was at a startup (now gone) named AllMyData.com, which ran an online backup service aimed at home users and small businesses. For the backend, we developed an open-source encrypted distributed filesystem named <a href="http://tahoe-lafs.org/">Tahoe-LAFS</a> (still thriving), with the relatively-unique feature of &#8220;provider-independent security&#8221;: the servers hold ciphertext, and only your client (and anyone you choose to share them with) holds the decryption key. By relying upon the servers for availability but <strong>not</strong> security, you can use servers that you wouldn&#8217;t trust otherwise. The system is designed with &#8220;POLA&#8221; in mind, the Principle Of Least Authority, which improves safety by giving each component as little power as possible; just enough to do its one job.</p>
<p>Mozilla&#8217;s <a href="http://www.mozilla.org/en-US/mobile/sync/">Sync</a> system, which helps keep your bookmarks and other browser data synchronized between multiple browsers, uses the same principle. The data is encrypted before it leaves your computer, and our servers don&#8217;t get to see the key. The similarity in philosophy between Sync and Tahoe was a big part of the reason I joined Mozilla: I had found a bunch of like-minded people with whom I could promote these ideas, with a wider audience (400 million users and counting!) than anything our tiny startup could reach. Shortly after joining, I helped build the credential-exchange protocol that Sync uses to add a new computer to your account (the &#8220;copy this code&#8221; J-PAKE-based dialog panel).</p>
<p>But most of what I&#8217;ve been doing for the last 18 months is <a href="https://wiki.mozilla.org/Jetpack">Jetpack</a>, now better known as the <strong>Add-On SDK</strong>. It&#8217;s a new way to tackle the admittedly painful process of writing add-ons for Firefox (and eventually other XUL-based programs, like Thunderbird).</p>
<p>Add-ons in Firefox have always been a bit.. organic. There&#8217;s an awful lot of internal interfaces, and add-ons authors have had to dig through a lot of that to find a useful point to attach or override some code. It&#8217;s messy, and fragile: it&#8217;s difficult for the Firefox developers to keep those internals stable while making large-scale improvements to the browser, so add-on authors are fighting an uphill battle to maintain compatibility with newer releases. With our new faster release cadence (every couple months!), the problem becomes even more challenging.</p>
<p>Jetpack was intended to make the simple things simple. It has a library of interface modules for doing common add-on tasks, like creating a UI, and modifying web pages. We, the SDK authors, will keep updating these modules to match the Firefox internals, so add-on authors won&#8217;t have to. One of the promises of Jetpack is that the high-level add-on code doesn&#8217;t need to change much at all to keep up with newer browsers.</p>
<p>The SDK has two parts: this library of modules, and a program that assembles your code with the right set of modules and produces the XPI file, ready for installation or upload to <a href="https://addons.mozilla.org/en-US/firefox/">AMO</a>. If you think about it in terms of gcc and other compilers, this program is a linker: it figures out which modules are required and combines them into an executable bundle.</p>
<p>The linker is written in Python, and since that&#8217;s been my dominant language for the last ten years, most of my Jetpack work has been on the linker side. I&#8217;ve also been heavily involved in developing the security model, to make Jetpack-based addons safer in the face of bugs and compromises. I&#8217;ll be explaining a lot more about the security model in this blog over the coming months.</p>
<p>And no description of Jetpack is complete without also mentioning Flightdeck, better known as the <a href="https://builder.addons.mozilla.org/">Add-On Builder</a>. This is an online IDE for writing add-ons. On the backend, it runs a copy of the SDK to generate the XPIs. It allows folks to get into the add-on writing business without downloading or installing an SDK: just start writing the code! A big goal of Jetpack is to make add-on writing accessible to a wider developer community, leveraging Javascript skills that web-devs already have, and an online tool like Builder removes a lot of the unnecessary hurdles for that audience.</p>
<p>Welcome!<br />
-Brian</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/warner/2011/08/25/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

