Skip to content

Commit 10a08b7

Browse files
authored
Merge pull request fancoder#1 from brandonlehmann/complete_rebase
I Throw My Hands Up In The Air Sometimes
2 parents a4e2394 + 2ec97a1 commit 10a08b7

23 files changed

+1116
-769
lines changed

.travis.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
language: node_js
22
node_js:
3-
- '0.10'
4-
- '4'
5-
- '5'
6-
- '6'
7-
- '7'
8-
- '8'
9-
#deploy:
10-
# provider: npm
11-
# email: zone117x@gmail.com
12-
# api_key:
13-
# secure: D9lpUDAx1OudPBji3mapnAhOug3wcEBqFrNgWaFh5XiYesa/f/X0gMOJggLlvzyhLHKs8VdTHShdu3XzlC3EDwr5wCdgYO1JSOyDo93FG7Y/qhPDVFnzdtsKmr813Qtj2UDKIh2ZP+JnjKaITrvUwRmdi/8+B9Enr5o9ulFb/a0=
3+
- '0.10'
4+
- '4'
5+
- '5'
6+
- '6'
7+
- '7'
8+
- '8'
9+
- '9'

README.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
node-multi-hashing
2-
===============
1+
# turtlecoin-multi-hashing
32

4-
[![Travis build status](https://travis-ci.org/codebling/node-multi-hashing-windows.png?branch=windows-compatibility)](https://travis-ci.org/codebling/node-multi-hashing-windows) [![Appveyor build status](https://ci.appveyor.com/api/projects/status/xixm3n1fprcyr96y/branch/windows-compatibility)](https://ci.appveyor.com/project/codebling/node-multi-hashing/branch/windows-compatibility)
3+
[![Build Status](https://travis-ci.org/brandonlehmann/node8-multi-hashing.png?branch=master)](https://travis-ci.org/brandonlehmann/node8-multi-hashing) [![Build Status](https://ci.appveyor.com/api/projects/status/github/brandonlehmann/node8-multi-hashing?branch=master&svg=true)](https://ci.appveyor.com/project/brandonlehmann/node8-multi-hashing/branch/master)
54

6-
[![NPM](https://nodei.co/npm/multi-hashing.png?downloads=true&stars=true)](https://nodei.co/npm/multi-hashing/)
5+
[![NPM](https://nodei.co/npm/turtlecoin-multi-hashing.png?downloads=true&stars=true)](https://nodei.co/npm/turtlecoin-multi-hashing/)
76

8-
Cryptocurrency hashing functions for node.js.
7+
Cryptocurrency hashing functions for NodeJS
98

9+
***Now with Windows support***
10+
11+
## Algorithms
1012

11-
Algorithms
12-
----------
1313
* quark
1414
* x11
1515
* x13
@@ -27,49 +27,48 @@ Algorithms
2727
* hefty1
2828
* shavite3
2929
* cryptonight
30+
* cryptonight-fast
31+
* cryptonight-lite
3032
* boolberry
3133

32-
Usage
33-
-----
34+
## Usage
3435

35-
Install on Ubuntu 16.04
36+
### Install
3637

3738
```bash
3839
sudo apt-get nodejs nodejs-dev node-gyp npm
3940
sudo ln -s /usr/bin/nodejs /usr/bin/node
40-
npm install git+https://github.com/sumlnoether/node-multi-hashing-node8.git
41+
npm install turtlecoin-multi-hashing
4142
```
4243

43-
So far this native Node.js addon can do the following hashing algos
44+
So far this native NodeJS addon can do the following hashing algorithms.
4445

4546
```javascript
46-
var multiHashing = require('multi-hashing');
47-
48-
var algorithms = ['quark', 'x11', 'scrypt', 'scryptn', 'scryptjane', 'keccak', 'bcrypt', 'skein', 'blake'];
47+
var multiHashing = require('turtlecoin-multi-hashing')
48+
var Buffer = require('safe-buffer').Buffer
4949

50-
var data = new Buffer("7000000001e980924e4e1109230383e66d62945ff8e749903bea4336755c00000000000051928aff1b4d72416173a8c3948159a09a73ac3bb556aa6bfbcad1a85da7f4c1d13350531e24031b939b9e2b", "hex");
50+
var algorithms = ['quark', 'x11', 'scrypt', 'scryptn', 'scryptjane', 'keccak', 'bcrypt', 'skein', 'blake']
5151

52-
var hashedData = algorithms.map(function(algo){
53-
if (algo === 'scryptjane'){
54-
//scryptjane needs block.nTime and nChainStartTime (found in coin source)
55-
var yaCoinChainStartTime = 1367991200;
56-
var nTime = Math.round(Date.now() / 1000);
57-
return multiHashing[algo](data, nTime, yaCoinChainStartTime);
58-
}
59-
else{
60-
return multiHashing[algo](data);
61-
}
62-
});
52+
var data = new Buffer('7000000001e980924e4e1109230383e66d62945ff8e749903bea4336755c00000000000051928aff1b4d72416173a8c3948159a09a73ac3bb556aa6bfbcad1a85da7f4c1d13350531e24031b939b9e2b', 'hex')
6353

54+
var hashedData = algorithms.map(function (algo) {
55+
if (algo === 'scryptjane') {
56+
// scryptjane needs block.nTime and nChainStartTime (found in coin source)
57+
var yaCoinChainStartTime = 1367991200
58+
var nTime = Math.round(Date.now() / 1000)
59+
return multiHashing[algo](data, nTime, yaCoinChainStartTime)
60+
} else {
61+
return multiHashing[algo](data)
62+
}
63+
})
6464

65-
console.log(hashedData);
65+
console.log(hashedData)
6666
//<SlowBuffer 0b de 16 ef 2d 92 e4 35 65 c6 6c d8 92 d9 66 b4 3d 65 ..... >
67+
```
6768

6869

69-
```
70+
## Credits
7071

71-
Credits
72-
-------
7372
* [NSA](http://www.nsa.gov/) and [NIST](http://www.nist.gov/) for creation or sponsoring creation of SHA2 and SHA3 algos
7473
* [Keccak](http://en.wikipedia.org/wiki/Keccak) - Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche
7574
* [Skein](http://en.wikipedia.org/wiki/Skein_(hash_function)) - Bruce Schneier, Stefan Lucks, Niels Ferguson, Doug Whiting, Mihir Bellare, Tadayoshi Kohno, Jon Callas and Jesse Walker.
@@ -83,3 +82,4 @@ Credits
8382
* [PhearZero](https://github.com/PhearZero) Michael J Feher
8483
* [codebling](https://github.com/codebling) CodeBling
8584
* [Monero](https://github.com/monero-project/monero) The Monero Project
85+
* [TurtleCoin](https://github.com/turtlecoin) TurtleCoin Developers

bcrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static void _crypt_blowfish_rn(const char *key, const char *salt, char *output)
558558
clean(&data, sizeof(data));
559559
}
560560

561-
void bcrypt_hash(const char *in, char *out)
561+
void bcrypt_hash(const char *in, char *out, uint32_t len)
562562
{
563563
_crypt_blowfish_rn(&in[0 * BF_N], &in[1 * BF_N], &out[0 * BF_N]);
564564
_crypt_blowfish_rn(&in[2 * BF_N], &in[3 * BF_N], &out[1 * BF_N]);

bcrypt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
extern "C" {
66
#endif
77

8-
void bcrypt_hash(const char *input, char *output);
8+
void bcrypt_hash(const char *input, char *output, uint32_t len);
99

1010
#ifdef __cplusplus
1111
}

binding.gyp

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,30 @@
33
{
44
"target_name": "multihashing",
55
"sources": [
6-
"multihashing.cpp",
7-
"scryptjane.c",
8-
"scryptn.c",
9-
"keccak.c",
10-
"skein.c",
11-
"x11.c",
12-
"quark.c",
6+
"multihashing.cc",
137
"bcrypt.c",
14-
"groestl.c",
158
"blake.c",
9+
"boolberry.cc",
10+
"c11.c",
11+
"cryptonight.c",
12+
"cryptonight_fast.c",
13+
"cryptonight_lite.c",
14+
"fresh.c",
1615
"fugue.c",
17-
"qubit.c",
16+
"groestl.c",
1817
"hefty1.c",
19-
"shavite3.c",
20-
"cryptonight.c",
21-
"x13.c",
22-
"boolberry.cc",
18+
"keccak.c",
2319
"nist5.c",
20+
"quark.c",
21+
"qubit.c",
22+
"scryptjane.c",
23+
"scryptn.c",
2424
"sha1.c",
25+
"shavite3.c",
26+
"skein.c",
27+
"x11.c",
28+
"x13.c",
2529
"x15.c",
26-
"fresh.c",
2730
"sha3/sph_hefty1.c",
2831
"sha3/sph_fugue.c",
2932
"sha3/aes_helper.c",
@@ -53,11 +56,26 @@
5356
],
5457
"include_dirs": [
5558
"crypto",
56-
"<!(node -e \"require('nan')\")"
5759
],
5860
"cflags_cc": [
59-
"-std=c++0x"
61+
"-std=c++0x",
62+
"-Wno-missing-field-initializers",
63+
"-Wno-unused-function",
64+
"-Wno-unused-const-variable",
65+
"-Wno-unused-private-field",
66+
"-Wno-unused-function",
67+
"-Wno-unused-but-set-variable"
6068
],
69+
"xcode_settings": {
70+
"OTHER_CFLAGS": [
71+
"-Wno-missing-field-initializers",
72+
"-Wno-unused-function",
73+
"-Wno-unused-const-variable",
74+
"-Wno-unused-private-field",
75+
"-Wno-unused-function",
76+
"-Wno-unused-but-set-variable"
77+
],
78+
}
6179
}
6280
]
6381
}

c11.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include "c11.h"
2+
#include <stdlib.h>
3+
#include <stdint.h>
4+
#include <string.h>
5+
#include <stdio.h>
6+
7+
#include "sha3/sph_blake.h"
8+
#include "sha3/sph_bmw.h"
9+
#include "sha3/sph_groestl.h"
10+
#include "sha3/sph_jh.h"
11+
#include "sha3/sph_keccak.h"
12+
#include "sha3/sph_skein.h"
13+
#include "sha3/sph_luffa.h"
14+
#include "sha3/sph_cubehash.h"
15+
#include "sha3/sph_shavite.h"
16+
#include "sha3/sph_simd.h"
17+
#include "sha3/sph_echo.h"
18+
19+
20+
void c11_hash(const char* input, char* output, uint32_t len)
21+
{
22+
sph_blake512_context ctx_blake;
23+
sph_bmw512_context ctx_bmw;
24+
sph_groestl512_context ctx_groestl;
25+
sph_skein512_context ctx_skein;
26+
sph_jh512_context ctx_jh;
27+
sph_keccak512_context ctx_keccak;
28+
29+
sph_luffa512_context ctx_luffa1;
30+
sph_cubehash512_context ctx_cubehash1;
31+
sph_shavite512_context ctx_shavite1;
32+
sph_simd512_context ctx_simd1;
33+
sph_echo512_context ctx_echo1;
34+
35+
//these uint512 in the c++ source of the client are backed by an array of uint32
36+
uint32_t hashA[16], hashB[16];
37+
38+
sph_blake512_init(&ctx_blake);
39+
sph_blake512 (&ctx_blake, input, 80);
40+
sph_blake512_close (&ctx_blake, hashA);
41+
42+
sph_bmw512_init(&ctx_bmw);
43+
sph_bmw512 (&ctx_bmw, hashA, 64);
44+
sph_bmw512_close(&ctx_bmw, hashB);
45+
46+
sph_groestl512_init(&ctx_groestl);
47+
sph_groestl512 (&ctx_groestl, hashB, 64);
48+
sph_groestl512_close(&ctx_groestl, hashA);
49+
50+
sph_jh512_init(&ctx_jh);
51+
sph_jh512 (&ctx_jh, hashA, 64);
52+
sph_jh512_close(&ctx_jh, hashB);
53+
54+
sph_keccak512_init(&ctx_keccak);
55+
sph_keccak512 (&ctx_keccak, hashB, 64);
56+
sph_keccak512_close(&ctx_keccak, hashA);
57+
58+
sph_skein512_init(&ctx_skein);
59+
sph_skein512 (&ctx_skein, hashA, 64);
60+
sph_skein512_close (&ctx_skein, hashB);
61+
62+
sph_luffa512_init (&ctx_luffa1);
63+
sph_luffa512 (&ctx_luffa1, hashB, 64);
64+
sph_luffa512_close (&ctx_luffa1, hashA);
65+
66+
sph_cubehash512_init (&ctx_cubehash1);
67+
sph_cubehash512 (&ctx_cubehash1, hashA, 64);
68+
sph_cubehash512_close(&ctx_cubehash1, hashB);
69+
70+
sph_shavite512_init (&ctx_shavite1);
71+
sph_shavite512 (&ctx_shavite1, hashB, 64);
72+
sph_shavite512_close(&ctx_shavite1, hashA);
73+
74+
sph_simd512_init (&ctx_simd1);
75+
sph_simd512 (&ctx_simd1, hashA, 64);
76+
sph_simd512_close(&ctx_simd1, hashB);
77+
78+
sph_echo512_init (&ctx_echo1);
79+
sph_echo512 (&ctx_echo1, hashB, 64);
80+
sph_echo512_close(&ctx_echo1, hashA);
81+
82+
memcpy(output, hashA, 32);
83+
84+
}
85+

c11.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef C11_H
2+
#define C11_H
3+
4+
5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif
8+
9+
#include <stdint.h>
10+
11+
void c11_hash(const char* input, char* output, uint32_t len);
12+
13+
#ifdef __cplusplus
14+
}
15+
#endif
16+
17+
#endif // C11_H

crypto/c_blake256.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void blake256_update(state *S, const uint8_t *data, uint64_t datalen) {
148148

149149
if (datalen > 0) {
150150
memcpy((void *) (S->buf + left), (void *) data, datalen >> 3);
151-
S->buflen = (left << 3) + datalen;
151+
S->buflen = (left << 3) + (int)datalen;
152152
} else {
153153
S->buflen = 0;
154154
}

crypto/oaes_lib.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@
2727
* POSSIBILITY OF SUCH DAMAGE.
2828
* ---------------------------------------------------------------------------
2929
*/
30+
3031
static const char _NR[] = {
3132
0x4e,0x61,0x62,0x69,0x6c,0x20,0x53,0x2e,0x20,
32-
0x41,0x6c,0x20,0x52,0x61,0x6d,0x6c,0x69,0x00 };
33-
33+
0x41,0x6c,0x20,0x52,0x61,0x6d,0x6c,0x69,0x00
34+
};
35+
3436
#include <stddef.h>
3537
#include <time.h>
3638
#include <sys/timeb.h>
39+
#ifdef __APPLE__
40+
#include <malloc/malloc.h>
41+
#else
3742
#include <malloc.h>
43+
#endif
3844
#include <string.h>
3945
#include <stdlib.h>
4046
#include <stdio.h>
@@ -486,9 +492,9 @@ static uint32_t oaes_get_seed(void)
486492
ftime (&timer);
487493
gmTimer = gmtime( &timer.time );
488494
_test = (char *) calloc( sizeof( char ), timer.millitm );
489-
_ret = gmTimer->tm_year + 1900 + gmTimer->tm_mon + 1 + gmTimer->tm_mday +
495+
_ret = (uint32_t)(gmTimer->tm_year + 1900 + gmTimer->tm_mon + 1 + gmTimer->tm_mday +
490496
gmTimer->tm_hour + gmTimer->tm_min + gmTimer->tm_sec + timer.millitm +
491-
(uintptr_t) ( _test + timer.millitm ) + getpid();
497+
(uintptr_t) ( _test + timer.millitm ) + getpid());
492498

493499
if( _test )
494500
free( _test );
@@ -669,7 +675,7 @@ OAES_RET oaes_key_export( OAES_CTX * ctx,
669675
// header
670676
memcpy( data, oaes_header, OAES_BLOCK_SIZE );
671677
data[5] = 0x01;
672-
data[7] = _ctx->key->data_len;
678+
data[7] = (uint8_t)_ctx->key->data_len;
673679
memcpy( data + OAES_BLOCK_SIZE, _ctx->key->data, _ctx->key->data_len );
674680

675681
return OAES_RET_SUCCESS;
@@ -1262,7 +1268,7 @@ OAES_RET oaes_encrypt( OAES_CTX * ctx,
12621268

12631269
// insert pad
12641270
for( _j = 0; _j < OAES_BLOCK_SIZE - _block_size; _j++ )
1265-
_block[ _block_size + _j ] = _j + 1;
1271+
_block[ _block_size + _j ] = (uint8_t)(_j + 1);
12661272

12671273
// CBC
12681274
if( _ctx->options & OAES_OPTION_CBC )

0 commit comments

Comments
 (0)