thejh/node-nacl — pull request #5 by warner (2012-12-14 00:35:15+00:00)
Title: switch to gyp, add tests and more methods

Hi! Thanks for writing node-nacl! I've got some improvements for you.

First off, this switches from waf to gyp, which (I'm told) is the preferred modern node-0.8.x extension mechanism. It bypasses the upstream "do" script, instead it imports a modified copy of nacl (via the "import.py" script). This copy puts real .c and .h files in the "subnacl/" directory, so gyp can use all its own compiler flags and build process. I think this ought to fix the 32-vs-64-bit problems you were having. It also speeds up the build time immensely. The downside is that it always uses the portable "ref" version of the code, so you don't get the super-fast assembly versions (see https://blog.mozilla.org/warner/2012/01/19/improving-the-pynacl-build-process/ for my speed comparison of ref-vs-asm variants).

I also added a "raw" interface, `require("nacl").nacl`, which should map directly to the upstream C/C++ API. Personally I favor a more OOP-ish interface (like in my python-ed25519 package), since that makes it harder to accidentally swap the public and private keys, but I figure it's most useful to provide the same API as djb's library does, and then write separate wrappers on top of that.

I added access to some other nacl functions (secretbox, onetimeauth, stream). And I added some unit tests for most of them (copied from djb's papers on xsalsa20 and poly1305), using the "tap" test runner.

I'm new to node.js and gyp, so please let me know what could be improved.

thanks!
-Brian