Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x@gmail.com committed Mar 30, 2014
1 parent 5e96997 commit 29010cc
Show file tree
Hide file tree
Showing 28 changed files with 3,914 additions and 7 deletions.
@@ -0,0 +1,32 @@
cmd_Release/obj.target/multihashing/multihashing.o := g++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/root/.node-gyp/0.10.26/src -I/root/.node-gyp/0.10.26/deps/uv/include -I/root/.node-gyp/0.10.26/deps/v8/include -fPIC -Wall -Wextra -Wno-unused-parameter -pthread -m64 -O2 -fno-strict-aliasing -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/multihashing/multihashing.o.d.raw -c -o Release/obj.target/multihashing/multihashing.o ../multihashing.cc
Release/obj.target/multihashing/multihashing.o: ../multihashing.cc \
/root/.node-gyp/0.10.26/src/node.h \
/root/.node-gyp/0.10.26/deps/uv/include/uv.h \
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/uv-unix.h \
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/ngx-queue.h \
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/uv-linux.h \
/root/.node-gyp/0.10.26/deps/v8/include/v8.h \
/root/.node-gyp/0.10.26/deps/v8/include/v8stdint.h \
/root/.node-gyp/0.10.26/src/node_object_wrap.h \
/root/.node-gyp/0.10.26/src/node.h \
/root/.node-gyp/0.10.26/src/node_buffer.h ../bcrypt.h ../keccak.h \
../quark.h ../scrypt.h ../scryptjane.h ../scryptn.h ../skein.h ../x11.h
../multihashing.cc:
/root/.node-gyp/0.10.26/src/node.h:
/root/.node-gyp/0.10.26/deps/uv/include/uv.h:
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/uv-unix.h:
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/ngx-queue.h:
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/uv-linux.h:
/root/.node-gyp/0.10.26/deps/v8/include/v8.h:
/root/.node-gyp/0.10.26/deps/v8/include/v8stdint.h:
/root/.node-gyp/0.10.26/src/node_object_wrap.h:
/root/.node-gyp/0.10.26/src/node.h:
/root/.node-gyp/0.10.26/src/node_buffer.h:
../bcrypt.h:
../keccak.h:
../quark.h:
../scrypt.h:
../scryptjane.h:
../scryptn.h:
../skein.h:
../x11.h:
@@ -0,0 +1,4 @@
cmd_Release/obj.target/multihashing/scrypt.o := cc '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/root/.node-gyp/0.10.26/src -I/root/.node-gyp/0.10.26/deps/uv/include -I/root/.node-gyp/0.10.26/deps/v8/include -fPIC -Wall -Wextra -Wno-unused-parameter -pthread -m64 -O2 -fno-strict-aliasing -fno-tree-vrp -fno-omit-frame-pointer -MMD -MF ./Release/.deps/Release/obj.target/multihashing/scrypt.o.d.raw -c -o Release/obj.target/multihashing/scrypt.o ../scrypt.c
Release/obj.target/multihashing/scrypt.o: ../scrypt.c ../scrypt.h
../scrypt.c:
../scrypt.h:
30 changes: 30 additions & 0 deletions build/Release/.deps/Release/obj.target/multihashing/scryptjane.o.d
@@ -0,0 +1,30 @@
cmd_Release/obj.target/multihashing/scryptjane.o := cc '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/root/.node-gyp/0.10.26/src -I/root/.node-gyp/0.10.26/deps/uv/include -I/root/.node-gyp/0.10.26/deps/v8/include -fPIC -Wall -Wextra -Wno-unused-parameter -pthread -m64 -O2 -fno-strict-aliasing -fno-tree-vrp -fno-omit-frame-pointer -MMD -MF ./Release/.deps/Release/obj.target/multihashing/scryptjane.o.d.raw -c -o Release/obj.target/multihashing/scryptjane.o ../scryptjane.c
Release/obj.target/multihashing/scryptjane.o: ../scryptjane.c \
../scryptjane.h ../scryptjane/scrypt-jane-portable.h \
../scryptjane/scrypt-jane-portable-x86.h \
../scryptjane/scrypt-jane-hash.h ../scryptjane/scrypt-jane-hash_keccak.h \
../scryptjane/scrypt-jane-pbkdf2.h ../scryptjane/scrypt-jane-romix.h \
../scryptjane/scrypt-jane-chacha.h \
../scryptjane/scrypt-jane-romix-basic.h \
../scryptjane/scrypt-jane-mix_chacha-avx.h \
../scryptjane/scrypt-jane-mix_chacha-ssse3.h \
../scryptjane/scrypt-jane-mix_chacha-sse2.h \
../scryptjane/scrypt-jane-mix_chacha.h \
../scryptjane/scrypt-jane-romix-template.h \
../scryptjane/scrypt-jane-test-vectors.h
../scryptjane.c:
../scryptjane.h:
../scryptjane/scrypt-jane-portable.h:
../scryptjane/scrypt-jane-portable-x86.h:
../scryptjane/scrypt-jane-hash.h:
../scryptjane/scrypt-jane-hash_keccak.h:
../scryptjane/scrypt-jane-pbkdf2.h:
../scryptjane/scrypt-jane-romix.h:
../scryptjane/scrypt-jane-chacha.h:
../scryptjane/scrypt-jane-romix-basic.h:
../scryptjane/scrypt-jane-mix_chacha-avx.h:
../scryptjane/scrypt-jane-mix_chacha-ssse3.h:
../scryptjane/scrypt-jane-mix_chacha-sse2.h:
../scryptjane/scrypt-jane-mix_chacha.h:
../scryptjane/scrypt-jane-romix-template.h:
../scryptjane/scrypt-jane-test-vectors.h:
Binary file not shown.
Binary file added build/Release/obj.target/multihashing/scrypt.o
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions multihashing.cc
Expand Up @@ -193,8 +193,8 @@ Handle<Value> scryptjane(const Arguments& args) {
Local<Number> num = args[1]->ToNumber();
int timestamp = num->Value();

Local<Number> num = args[2]->ToNumber();
int nChainStarTime = num->Value();
Local<Number> num2 = args[2]->ToNumber();
int nChainStarTime = num2->Value();


char * input = Buffer::Data(target);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -15,7 +15,7 @@
},
"keywords": [
"scrypt",
"scrypt-jane",
"scryptjane",
"script-n",
"x11",
"quark",
Expand Down
132 changes: 132 additions & 0 deletions scryptjane/scrypt-jane-chacha.h
@@ -0,0 +1,132 @@
#define SCRYPT_MIX_BASE "ChaCha20/8"

typedef uint32_t scrypt_mix_word_t;

#define SCRYPT_WORDTO8_LE U32TO8_LE
#define SCRYPT_WORD_ENDIAN_SWAP U32_SWAP

#define SCRYPT_BLOCK_BYTES 64
#define SCRYPT_BLOCK_WORDS (SCRYPT_BLOCK_BYTES / sizeof(scrypt_mix_word_t))

/* must have these here in case block bytes is ever != 64 */
#include "scrypt-jane-romix-basic.h"

#include "scrypt-jane-mix_chacha-avx.h"
#include "scrypt-jane-mix_chacha-ssse3.h"
#include "scrypt-jane-mix_chacha-sse2.h"
#include "scrypt-jane-mix_chacha.h"

#if defined(SCRYPT_CHACHA_AVX)
#define SCRYPT_CHUNKMIX_FN scrypt_ChunkMix_avx
#define SCRYPT_ROMIX_FN scrypt_ROMix_avx
#define SCRYPT_MIX_FN chacha_core_avx
#define SCRYPT_ROMIX_TANGLE_FN scrypt_romix_nop
#define SCRYPT_ROMIX_UNTANGLE_FN scrypt_romix_nop
#include "scrypt-jane-romix-template.h"
#endif

#if defined(SCRYPT_CHACHA_SSSE3)
#define SCRYPT_CHUNKMIX_FN scrypt_ChunkMix_ssse3
#define SCRYPT_ROMIX_FN scrypt_ROMix_ssse3
#define SCRYPT_MIX_FN chacha_core_ssse3
#define SCRYPT_ROMIX_TANGLE_FN scrypt_romix_nop
#define SCRYPT_ROMIX_UNTANGLE_FN scrypt_romix_nop
#include "scrypt-jane-romix-template.h"
#endif

#if defined(SCRYPT_CHACHA_SSE2)
#define SCRYPT_CHUNKMIX_FN scrypt_ChunkMix_sse2
#define SCRYPT_ROMIX_FN scrypt_ROMix_sse2
#define SCRYPT_MIX_FN chacha_core_sse2
#define SCRYPT_ROMIX_TANGLE_FN scrypt_romix_nop
#define SCRYPT_ROMIX_UNTANGLE_FN scrypt_romix_nop
#include "scrypt-jane-romix-template.h"
#endif

/* cpu agnostic */
#define SCRYPT_ROMIX_FN scrypt_ROMix_basic
#define SCRYPT_MIX_FN chacha_core_basic
#define SCRYPT_ROMIX_TANGLE_FN scrypt_romix_convert_endian
#define SCRYPT_ROMIX_UNTANGLE_FN scrypt_romix_convert_endian
#include "scrypt-jane-romix-template.h"

#if !defined(SCRYPT_CHOOSE_COMPILETIME)
static scrypt_ROMixfn
scrypt_getROMix() {
size_t cpuflags = detect_cpu();

#if defined(SCRYPT_CHACHA_AVX)
if (cpuflags & cpu_avx)
return scrypt_ROMix_avx;
else
#endif

#if defined(SCRYPT_CHACHA_SSSE3)
if (cpuflags & cpu_ssse3)
return scrypt_ROMix_ssse3;
else
#endif

#if defined(SCRYPT_CHACHA_SSE2)
if (cpuflags & cpu_sse2)
return scrypt_ROMix_sse2;
else
#endif

return scrypt_ROMix_basic;
}
#endif


#if defined(SCRYPT_TEST_SPEED)
static size_t
available_implementations() {
size_t flags = 0;

#if defined(SCRYPT_CHACHA_AVX)
flags |= cpu_avx;
#endif

#if defined(SCRYPT_CHACHA_SSSE3)
flags |= cpu_ssse3;
#endif

#if defined(SCRYPT_CHACHA_SSE2)
flags |= cpu_sse2;
#endif

return flags;
}
#endif

static int
scrypt_test_mix() {
static const uint8_t expected[16] = {
0x48,0x2b,0x2d,0xb8,0xa1,0x33,0x22,0x73,0xcd,0x16,0xc4,0xb4,0xb0,0x7f,0xb1,0x8a,
};

int ret = 1;
size_t cpuflags = detect_cpu();

#if defined(SCRYPT_CHACHA_AVX)
if (cpuflags & cpu_avx)
ret &= scrypt_test_mix_instance(scrypt_ChunkMix_avx, scrypt_romix_nop, scrypt_romix_nop, expected);
#endif

#if defined(SCRYPT_CHACHA_SSSE3)
if (cpuflags & cpu_ssse3)
ret &= scrypt_test_mix_instance(scrypt_ChunkMix_ssse3, scrypt_romix_nop, scrypt_romix_nop, expected);
#endif

#if defined(SCRYPT_CHACHA_SSE2)
if (cpuflags & cpu_sse2)
ret &= scrypt_test_mix_instance(scrypt_ChunkMix_sse2, scrypt_romix_nop, scrypt_romix_nop, expected);
#endif

#if defined(SCRYPT_CHACHA_BASIC)
ret &= scrypt_test_mix_instance(scrypt_ChunkMix_basic, scrypt_romix_convert_endian, scrypt_romix_convert_endian, expected);
#endif

return ret;
}

48 changes: 48 additions & 0 deletions scryptjane/scrypt-jane-hash.h
@@ -0,0 +1,48 @@
#if defined(SCRYPT_BLAKE512)
#include "scrypt-jane-hash_blake512.h"
#elif defined(SCRYPT_BLAKE256)
#include "scrypt-jane-hash_blake256.h"
#elif defined(SCRYPT_SHA512)
#include "scrypt-jane-hash_sha512.h"
#elif defined(SCRYPT_SHA256)
#include "scrypt-jane-hash_sha256.h"
#elif defined(SCRYPT_SKEIN512)
#include "scrypt-jane-hash_skein512.h"
#elif defined(SCRYPT_KECCAK512) || defined(SCRYPT_KECCAK256)
#include "scrypt-jane-hash_keccak.h"
#else
#define SCRYPT_HASH "ERROR"
#define SCRYPT_HASH_BLOCK_SIZE 64
#define SCRYPT_HASH_DIGEST_SIZE 64
typedef struct scrypt_hash_state_t { size_t dummy; } scrypt_hash_state;
typedef uint8_t scrypt_hash_digest[SCRYPT_HASH_DIGEST_SIZE];
static void scrypt_hash_init(scrypt_hash_state *S) {}
static void scrypt_hash_update(scrypt_hash_state *S, const uint8_t *in, size_t inlen) {}
static void scrypt_hash_finish(scrypt_hash_state *S, uint8_t *hash) {}
static const uint8_t scrypt_test_hash_expected[SCRYPT_HASH_DIGEST_SIZE] = {0};
#error must define a hash function!
#endif

#include "scrypt-jane-pbkdf2.h"

#define SCRYPT_TEST_HASH_LEN 257 /* (2 * largest block size) + 1 */

static int
scrypt_test_hash() {
scrypt_hash_state st;
scrypt_hash_digest hash, final;
uint8_t msg[SCRYPT_TEST_HASH_LEN];
size_t i;

for (i = 0; i < SCRYPT_TEST_HASH_LEN; i++)
msg[i] = (uint8_t)i;

scrypt_hash_init(&st);
for (i = 0; i < SCRYPT_TEST_HASH_LEN + 1; i++) {
scrypt_hash(hash, msg, i);
scrypt_hash_update(&st, hash, sizeof(hash));
}
scrypt_hash_finish(&st, final);
return scrypt_verify(final, scrypt_test_hash_expected, SCRYPT_HASH_DIGEST_SIZE);
}

0 comments on commit 29010cc

Please sign in to comment.