-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use optimized implementations from XKCP (#8)
* src/libkeccak: Use XKCP's optimized implementations It looks like we were using the reference C implementation, which is not designed for good performance. Switch to using either the 32-bit or 64-bit optimized C implementations, depending on the Node "arch" variable. * Remove submodule KeccakCodePackage * Bump minimum node version to 6.0.0 * Small improvements in src/README.md * Add preprocessor in src/addon.cc * Add submodle github.com/XKCP/XKCP for test vectors
- Loading branch information
Showing
35 changed files
with
3,950 additions
and
784 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "keccak-src"] | ||
path = util/KeccakCodePackage | ||
url = https://github.com/gvanas/KeccakCodePackage.git | ||
[submodule "util/XKCP"] | ||
path = util/XKCP | ||
url = https://github.com/XKCP/XKCP.git |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Importing Keccak C code | ||
|
||
The XKCP project contains various implementations of Keccak-related algorithms. These are the steps to select a specific implementation and import the code into our project. | ||
|
||
First, generate the source bundles in XKCP: | ||
|
||
``` | ||
git clone https://github.com/XKCP/XKCP.git | ||
cd XKCP | ||
git checkout 58b20ec | ||
# Edit "Makefile.build". After all the <fragment> tags, add the following two <target> tags: | ||
<target name="node32" inherits="KeccakSpongeWidth1600 inplace1600bi"/> | ||
<target name="node64" inherits="KeccakSpongeWidth1600 optimized1600ufull"/> | ||
make node32.pack node64.pack | ||
``` | ||
|
||
The source files we need are now under XKCP's "bin/.pack/npm32/" and "bin/.pack/npm64/". | ||
- Copy those to our repo under "src/libkeccak-32" and "src/libkeccak-64". | ||
- Update our "binding.gyp" to point to the correct ".c" files. | ||
- Run `npm run rebuild`. | ||
|
||
## Implementation Choice | ||
|
||
Currently, we're using two of XKCP KeccakP[1600] implementations -- the generic 32-bit-optimized one and the generic 64-bit-optimized one. | ||
|
||
XKCP has implementations that use CPU-specific instructions (e.g. Intel AVR) and are likely much faster. It might be worth using those. |
This file contains 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
This file contains 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
Oops, something went wrong.