switch to gyp, add tests and more methods#5
Open
warner wants to merge 18 commits intothejh:masterfrom
Open
Conversation
This includes the C++ wrappers, which throw exceptions upon error.
The new binding.gyp re-enables C++ exceptions, since the NACL C++ wrappers throw them to signal errors like "bad signature". index.js was updated to require the right thing (build/Release/nacl)
beforenm/afternm tests are disabled until there is C++ code for them
Collaborator
Author
|
Two other notes:
|
Owner
|
Oh, wow. That is great! However, I haven't touched any nodejs stuff in months, so all my node-related work is currently pretty much abandoned. In case you want to take over package ownership in npm, just ask. Also, it doesn't seem to build on my machine: |
Collaborator
Author
|
Hm, it should be using gyp, not waf (I deleted the wscript file entirely). I've only tested it on node-0.8.15 (on OS-X, via homebrew) though, maybe 0.8.10 behaves differently? I'll ask some more-node-experienced coworkers to review it. I'd be happy to take it over. My npm user name is |
Owner
|
I did a |
These take a few minutes to run, we might want to run just a subset.
The failing tests were modifying a random byte and then confirming that authenticators were invalid. But with Math.round() they were sometimes modifying a byte off the end of the Buffer, hence not modifying the buffer at all, so the authenticator was still valid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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