Skip to content

Commit 29010cc

Browse files
more
1 parent 5e96997 commit 29010cc

28 files changed

+3914
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
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
2+
Release/obj.target/multihashing/multihashing.o: ../multihashing.cc \
3+
/root/.node-gyp/0.10.26/src/node.h \
4+
/root/.node-gyp/0.10.26/deps/uv/include/uv.h \
5+
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/uv-unix.h \
6+
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/ngx-queue.h \
7+
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/uv-linux.h \
8+
/root/.node-gyp/0.10.26/deps/v8/include/v8.h \
9+
/root/.node-gyp/0.10.26/deps/v8/include/v8stdint.h \
10+
/root/.node-gyp/0.10.26/src/node_object_wrap.h \
11+
/root/.node-gyp/0.10.26/src/node.h \
12+
/root/.node-gyp/0.10.26/src/node_buffer.h ../bcrypt.h ../keccak.h \
13+
../quark.h ../scrypt.h ../scryptjane.h ../scryptn.h ../skein.h ../x11.h
14+
../multihashing.cc:
15+
/root/.node-gyp/0.10.26/src/node.h:
16+
/root/.node-gyp/0.10.26/deps/uv/include/uv.h:
17+
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/uv-unix.h:
18+
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/ngx-queue.h:
19+
/root/.node-gyp/0.10.26/deps/uv/include/uv-private/uv-linux.h:
20+
/root/.node-gyp/0.10.26/deps/v8/include/v8.h:
21+
/root/.node-gyp/0.10.26/deps/v8/include/v8stdint.h:
22+
/root/.node-gyp/0.10.26/src/node_object_wrap.h:
23+
/root/.node-gyp/0.10.26/src/node.h:
24+
/root/.node-gyp/0.10.26/src/node_buffer.h:
25+
../bcrypt.h:
26+
../keccak.h:
27+
../quark.h:
28+
../scrypt.h:
29+
../scryptjane.h:
30+
../scryptn.h:
31+
../skein.h:
32+
../x11.h:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
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
2+
Release/obj.target/multihashing/scrypt.o: ../scrypt.c ../scrypt.h
3+
../scrypt.c:
4+
../scrypt.h:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
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
2+
Release/obj.target/multihashing/scryptjane.o: ../scryptjane.c \
3+
../scryptjane.h ../scryptjane/scrypt-jane-portable.h \
4+
../scryptjane/scrypt-jane-portable-x86.h \
5+
../scryptjane/scrypt-jane-hash.h ../scryptjane/scrypt-jane-hash_keccak.h \
6+
../scryptjane/scrypt-jane-pbkdf2.h ../scryptjane/scrypt-jane-romix.h \
7+
../scryptjane/scrypt-jane-chacha.h \
8+
../scryptjane/scrypt-jane-romix-basic.h \
9+
../scryptjane/scrypt-jane-mix_chacha-avx.h \
10+
../scryptjane/scrypt-jane-mix_chacha-ssse3.h \
11+
../scryptjane/scrypt-jane-mix_chacha-sse2.h \
12+
../scryptjane/scrypt-jane-mix_chacha.h \
13+
../scryptjane/scrypt-jane-romix-template.h \
14+
../scryptjane/scrypt-jane-test-vectors.h
15+
../scryptjane.c:
16+
../scryptjane.h:
17+
../scryptjane/scrypt-jane-portable.h:
18+
../scryptjane/scrypt-jane-portable-x86.h:
19+
../scryptjane/scrypt-jane-hash.h:
20+
../scryptjane/scrypt-jane-hash_keccak.h:
21+
../scryptjane/scrypt-jane-pbkdf2.h:
22+
../scryptjane/scrypt-jane-romix.h:
23+
../scryptjane/scrypt-jane-chacha.h:
24+
../scryptjane/scrypt-jane-romix-basic.h:
25+
../scryptjane/scrypt-jane-mix_chacha-avx.h:
26+
../scryptjane/scrypt-jane-mix_chacha-ssse3.h:
27+
../scryptjane/scrypt-jane-mix_chacha-sse2.h:
28+
../scryptjane/scrypt-jane-mix_chacha.h:
29+
../scryptjane/scrypt-jane-romix-template.h:
30+
../scryptjane/scrypt-jane-test-vectors.h:
Binary file not shown.
12.6 KB
Binary file not shown.
Binary file not shown.

multihashing.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ Handle<Value> scryptjane(const Arguments& args) {
193193
Local<Number> num = args[1]->ToNumber();
194194
int timestamp = num->Value();
195195

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

199199

200200
char * input = Buffer::Data(target);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"keywords": [
1717
"scrypt",
18-
"scrypt-jane",
18+
"scryptjane",
1919
"script-n",
2020
"x11",
2121
"quark",

scryptjane/scrypt-jane-chacha.h

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#define SCRYPT_MIX_BASE "ChaCha20/8"
2+
3+
typedef uint32_t scrypt_mix_word_t;
4+
5+
#define SCRYPT_WORDTO8_LE U32TO8_LE
6+
#define SCRYPT_WORD_ENDIAN_SWAP U32_SWAP
7+
8+
#define SCRYPT_BLOCK_BYTES 64
9+
#define SCRYPT_BLOCK_WORDS (SCRYPT_BLOCK_BYTES / sizeof(scrypt_mix_word_t))
10+
11+
/* must have these here in case block bytes is ever != 64 */
12+
#include "scrypt-jane-romix-basic.h"
13+
14+
#include "scrypt-jane-mix_chacha-avx.h"
15+
#include "scrypt-jane-mix_chacha-ssse3.h"
16+
#include "scrypt-jane-mix_chacha-sse2.h"
17+
#include "scrypt-jane-mix_chacha.h"
18+
19+
#if defined(SCRYPT_CHACHA_AVX)
20+
#define SCRYPT_CHUNKMIX_FN scrypt_ChunkMix_avx
21+
#define SCRYPT_ROMIX_FN scrypt_ROMix_avx
22+
#define SCRYPT_MIX_FN chacha_core_avx
23+
#define SCRYPT_ROMIX_TANGLE_FN scrypt_romix_nop
24+
#define SCRYPT_ROMIX_UNTANGLE_FN scrypt_romix_nop
25+
#include "scrypt-jane-romix-template.h"
26+
#endif
27+
28+
#if defined(SCRYPT_CHACHA_SSSE3)
29+
#define SCRYPT_CHUNKMIX_FN scrypt_ChunkMix_ssse3
30+
#define SCRYPT_ROMIX_FN scrypt_ROMix_ssse3
31+
#define SCRYPT_MIX_FN chacha_core_ssse3
32+
#define SCRYPT_ROMIX_TANGLE_FN scrypt_romix_nop
33+
#define SCRYPT_ROMIX_UNTANGLE_FN scrypt_romix_nop
34+
#include "scrypt-jane-romix-template.h"
35+
#endif
36+
37+
#if defined(SCRYPT_CHACHA_SSE2)
38+
#define SCRYPT_CHUNKMIX_FN scrypt_ChunkMix_sse2
39+
#define SCRYPT_ROMIX_FN scrypt_ROMix_sse2
40+
#define SCRYPT_MIX_FN chacha_core_sse2
41+
#define SCRYPT_ROMIX_TANGLE_FN scrypt_romix_nop
42+
#define SCRYPT_ROMIX_UNTANGLE_FN scrypt_romix_nop
43+
#include "scrypt-jane-romix-template.h"
44+
#endif
45+
46+
/* cpu agnostic */
47+
#define SCRYPT_ROMIX_FN scrypt_ROMix_basic
48+
#define SCRYPT_MIX_FN chacha_core_basic
49+
#define SCRYPT_ROMIX_TANGLE_FN scrypt_romix_convert_endian
50+
#define SCRYPT_ROMIX_UNTANGLE_FN scrypt_romix_convert_endian
51+
#include "scrypt-jane-romix-template.h"
52+
53+
#if !defined(SCRYPT_CHOOSE_COMPILETIME)
54+
static scrypt_ROMixfn
55+
scrypt_getROMix() {
56+
size_t cpuflags = detect_cpu();
57+
58+
#if defined(SCRYPT_CHACHA_AVX)
59+
if (cpuflags & cpu_avx)
60+
return scrypt_ROMix_avx;
61+
else
62+
#endif
63+
64+
#if defined(SCRYPT_CHACHA_SSSE3)
65+
if (cpuflags & cpu_ssse3)
66+
return scrypt_ROMix_ssse3;
67+
else
68+
#endif
69+
70+
#if defined(SCRYPT_CHACHA_SSE2)
71+
if (cpuflags & cpu_sse2)
72+
return scrypt_ROMix_sse2;
73+
else
74+
#endif
75+
76+
return scrypt_ROMix_basic;
77+
}
78+
#endif
79+
80+
81+
#if defined(SCRYPT_TEST_SPEED)
82+
static size_t
83+
available_implementations() {
84+
size_t flags = 0;
85+
86+
#if defined(SCRYPT_CHACHA_AVX)
87+
flags |= cpu_avx;
88+
#endif
89+
90+
#if defined(SCRYPT_CHACHA_SSSE3)
91+
flags |= cpu_ssse3;
92+
#endif
93+
94+
#if defined(SCRYPT_CHACHA_SSE2)
95+
flags |= cpu_sse2;
96+
#endif
97+
98+
return flags;
99+
}
100+
#endif
101+
102+
static int
103+
scrypt_test_mix() {
104+
static const uint8_t expected[16] = {
105+
0x48,0x2b,0x2d,0xb8,0xa1,0x33,0x22,0x73,0xcd,0x16,0xc4,0xb4,0xb0,0x7f,0xb1,0x8a,
106+
};
107+
108+
int ret = 1;
109+
size_t cpuflags = detect_cpu();
110+
111+
#if defined(SCRYPT_CHACHA_AVX)
112+
if (cpuflags & cpu_avx)
113+
ret &= scrypt_test_mix_instance(scrypt_ChunkMix_avx, scrypt_romix_nop, scrypt_romix_nop, expected);
114+
#endif
115+
116+
#if defined(SCRYPT_CHACHA_SSSE3)
117+
if (cpuflags & cpu_ssse3)
118+
ret &= scrypt_test_mix_instance(scrypt_ChunkMix_ssse3, scrypt_romix_nop, scrypt_romix_nop, expected);
119+
#endif
120+
121+
#if defined(SCRYPT_CHACHA_SSE2)
122+
if (cpuflags & cpu_sse2)
123+
ret &= scrypt_test_mix_instance(scrypt_ChunkMix_sse2, scrypt_romix_nop, scrypt_romix_nop, expected);
124+
#endif
125+
126+
#if defined(SCRYPT_CHACHA_BASIC)
127+
ret &= scrypt_test_mix_instance(scrypt_ChunkMix_basic, scrypt_romix_convert_endian, scrypt_romix_convert_endian, expected);
128+
#endif
129+
130+
return ret;
131+
}
132+

scryptjane/scrypt-jane-hash.h

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#if defined(SCRYPT_BLAKE512)
2+
#include "scrypt-jane-hash_blake512.h"
3+
#elif defined(SCRYPT_BLAKE256)
4+
#include "scrypt-jane-hash_blake256.h"
5+
#elif defined(SCRYPT_SHA512)
6+
#include "scrypt-jane-hash_sha512.h"
7+
#elif defined(SCRYPT_SHA256)
8+
#include "scrypt-jane-hash_sha256.h"
9+
#elif defined(SCRYPT_SKEIN512)
10+
#include "scrypt-jane-hash_skein512.h"
11+
#elif defined(SCRYPT_KECCAK512) || defined(SCRYPT_KECCAK256)
12+
#include "scrypt-jane-hash_keccak.h"
13+
#else
14+
#define SCRYPT_HASH "ERROR"
15+
#define SCRYPT_HASH_BLOCK_SIZE 64
16+
#define SCRYPT_HASH_DIGEST_SIZE 64
17+
typedef struct scrypt_hash_state_t { size_t dummy; } scrypt_hash_state;
18+
typedef uint8_t scrypt_hash_digest[SCRYPT_HASH_DIGEST_SIZE];
19+
static void scrypt_hash_init(scrypt_hash_state *S) {}
20+
static void scrypt_hash_update(scrypt_hash_state *S, const uint8_t *in, size_t inlen) {}
21+
static void scrypt_hash_finish(scrypt_hash_state *S, uint8_t *hash) {}
22+
static const uint8_t scrypt_test_hash_expected[SCRYPT_HASH_DIGEST_SIZE] = {0};
23+
#error must define a hash function!
24+
#endif
25+
26+
#include "scrypt-jane-pbkdf2.h"
27+
28+
#define SCRYPT_TEST_HASH_LEN 257 /* (2 * largest block size) + 1 */
29+
30+
static int
31+
scrypt_test_hash() {
32+
scrypt_hash_state st;
33+
scrypt_hash_digest hash, final;
34+
uint8_t msg[SCRYPT_TEST_HASH_LEN];
35+
size_t i;
36+
37+
for (i = 0; i < SCRYPT_TEST_HASH_LEN; i++)
38+
msg[i] = (uint8_t)i;
39+
40+
scrypt_hash_init(&st);
41+
for (i = 0; i < SCRYPT_TEST_HASH_LEN + 1; i++) {
42+
scrypt_hash(hash, msg, i);
43+
scrypt_hash_update(&st, hash, sizeof(hash));
44+
}
45+
scrypt_hash_finish(&st, final);
46+
return scrypt_verify(final, scrypt_test_hash_expected, SCRYPT_HASH_DIGEST_SIZE);
47+
}
48+

0 commit comments

Comments
 (0)