@leocuvee/wrkzcoin-multi-hashing 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +5 -0
- package/LICENSE +674 -0
- package/README.md +87 -0
- package/appveyor.yml +12 -0
- package/argon2/.gitattributes +10 -0
- package/argon2/.travis.yml +25 -0
- package/argon2/Argon2.sln +160 -0
- package/argon2/CHANGELOG.md +32 -0
- package/argon2/CMakeLists.txt +87 -0
- package/argon2/LICENSE +314 -0
- package/argon2/Makefile +196 -0
- package/argon2/README.md +297 -0
- package/argon2/appveyor.yml +40 -0
- package/argon2/argon2-specs.pdf +0 -0
- package/argon2/export.sh +7 -0
- package/argon2/include/argon2.h +427 -0
- package/argon2/latex/CMakeLists.txt +34 -0
- package/argon2/latex/IEEEtran.cls +6347 -0
- package/argon2/latex/Makefile +18 -0
- package/argon2/latex/argon2-specs.tex +920 -0
- package/argon2/latex/pics/argon2-par.pdf +0 -0
- package/argon2/latex/pics/compression.pdf +0 -0
- package/argon2/latex/pics/generic.pdf +0 -0
- package/argon2/latex/pics/power-distribution.jpg +0 -0
- package/argon2/latex/tradeoff.bib +822 -0
- package/argon2/libargon2.pc +16 -0
- package/argon2/man/CMakeLists.txt +8 -0
- package/argon2/man/argon2.1 +57 -0
- package/argon2/meson.build +16 -0
- package/argon2/meson_options.txt +1 -0
- package/argon2/src/CMakeLists.txt +147 -0
- package/argon2/src/argon2.c +452 -0
- package/argon2/src/argon2.pc.in +11 -0
- package/argon2/src/blake2/blake2-impl.h +156 -0
- package/argon2/src/blake2/blake2.h +89 -0
- package/argon2/src/blake2/blake2b.c +390 -0
- package/argon2/src/blake2/blamka-round-opt.h +471 -0
- package/argon2/src/blake2/blamka-round-ref.h +56 -0
- package/argon2/src/core.c +634 -0
- package/argon2/src/core.h +228 -0
- package/argon2/src/encoding.c +467 -0
- package/argon2/src/encoding.h +57 -0
- package/argon2/src/genkat.h +51 -0
- package/argon2/src/meson.build +68 -0
- package/argon2/src/opt.c +283 -0
- package/argon2/src/optimization/CMakeLists.txt +10 -0
- package/argon2/src/ref.c +194 -0
- package/argon2/src/thread.c +57 -0
- package/argon2/src/thread.h +67 -0
- package/argon2/tests/CMakeLists.txt +43 -0
- package/argon2/tests/bench.c +111 -0
- package/argon2/tests/genkat.c +207 -0
- package/argon2/tests/kats/argon2d +12304 -0
- package/argon2/tests/kats/argon2d.shasum +1 -0
- package/argon2/tests/kats/argon2d_v16 +12304 -0
- package/argon2/tests/kats/argon2d_v16.shasum +1 -0
- package/argon2/tests/kats/argon2i +12304 -0
- package/argon2/tests/kats/argon2i.shasum +1 -0
- package/argon2/tests/kats/argon2i_v16 +12304 -0
- package/argon2/tests/kats/argon2i_v16.shasum +1 -0
- package/argon2/tests/kats/argon2id +12304 -0
- package/argon2/tests/kats/argon2id.shasum +1 -0
- package/argon2/tests/kats/argon2id_v16 +12304 -0
- package/argon2/tests/kats/argon2id_v16.shasum +1 -0
- package/argon2/tests/kats/check-sums.ps1 +48 -0
- package/argon2/tests/kats/check-sums.sh +16 -0
- package/argon2/tests/kats/test.ps1 +132 -0
- package/argon2/tests/kats/test.sh +117 -0
- package/argon2/tests/meson.build +34 -0
- package/argon2/tests/test.c +289 -0
- package/argon2/tool/CMakeLists.txt +7 -0
- package/argon2/tool/main.c +339 -0
- package/argon2/tool/meson.build +8 -0
- package/argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj +226 -0
- package/argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj +226 -0
- package/argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj +225 -0
- package/argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj.filters +66 -0
- package/argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj +239 -0
- package/argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj.filters +72 -0
- package/argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj +227 -0
- package/argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj +226 -0
- package/argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj +226 -0
- package/argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj.filters +69 -0
- package/argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj +225 -0
- package/argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj.filters +66 -0
- package/argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj +227 -0
- package/argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj.filters +72 -0
- package/argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj +226 -0
- package/argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj.filters +69 -0
- package/bcrypt.c +566 -0
- package/bcrypt.h +14 -0
- package/binding.gyp +93 -0
- package/blake.c +17 -0
- package/blake.h +16 -0
- package/boolberry.cc +11 -0
- package/boolberry.h +6 -0
- package/build/Makefile +354 -0
- package/build/Release/.deps/Release/multihashing.node.d +1 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/argon2.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/blake2/blake2b.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/core.o.d +10 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/encoding.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/ref.o.d +14 -0
- package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/thread.o.d +5 -0
- package/build/Release/.deps/Release/obj.target/multihashing/bcrypt.o.d +4 -0
- package/build/Release/.deps/Release/obj.target/multihashing/blake.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/boolberry.o.d +12 -0
- package/build/Release/.deps/Release/obj.target/multihashing/c11.o.d +20 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/aesb.o.d +3 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_blake256.o.d +5 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_groestl.o.d +10 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_jh.o.d +9 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_keccak.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_skein.o.d +10 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/hash.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/oaes_lib.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/crypto/wild_keccak.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_dark.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_dark_lite.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_fast.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_lite.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_soft_shell.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_turtle.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_turtle_lite.o.d +18 -0
- package/build/Release/.deps/Release/obj.target/multihashing/fresh.o.d +10 -0
- package/build/Release/.deps/Release/obj.target/multihashing/fugue.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/groestl.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/hefty1.o.d +12 -0
- package/build/Release/.deps/Release/obj.target/multihashing/keccak.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/multihashing.o.d +155 -0
- package/build/Release/.deps/Release/obj.target/multihashing/nist5.o.d +12 -0
- package/build/Release/.deps/Release/obj.target/multihashing/quark.o.d +14 -0
- package/build/Release/.deps/Release/obj.target/multihashing/qubit.o.d +12 -0
- package/build/Release/.deps/Release/obj.target/multihashing/scryptjane.o.d +30 -0
- package/build/Release/.deps/Release/obj.target/multihashing/scryptn.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha1.o.d +24 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/aes_helper.o.d +5 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/hamsi.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_blake.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_bmw.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_cubehash.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_echo.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_fugue.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_groestl.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_hefty1.o.d +5 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_jh.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_keccak.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_luffa.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_shabal.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_shavite.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_simd.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_skein.o.d +6 -0
- package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_whirlpool.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/shavite3.o.d +7 -0
- package/build/Release/.deps/Release/obj.target/multihashing/skein.o.d +8 -0
- package/build/Release/.deps/Release/obj.target/multihashing/x11.o.d +20 -0
- package/build/Release/.deps/Release/obj.target/multihashing/x13.o.d +23 -0
- package/build/Release/.deps/Release/obj.target/multihashing/x15.o.d +26 -0
- package/build/Release/.deps/Release/obj.target/multihashing.node.d +1 -0
- package/build/Release/multihashing.node +0 -0
- package/build/binding.Makefile +6 -0
- package/build/multihashing.target.mk +255 -0
- package/c11.c +85 -0
- package/c11.h +17 -0
- package/crypto/aesb.c +177 -0
- package/crypto/c_blake256.c +326 -0
- package/crypto/c_blake256.h +43 -0
- package/crypto/c_groestl.c +360 -0
- package/crypto/c_groestl.h +56 -0
- package/crypto/c_jh.c +367 -0
- package/crypto/c_jh.h +20 -0
- package/crypto/c_keccak.c +112 -0
- package/crypto/c_keccak.h +26 -0
- package/crypto/c_skein.c +2036 -0
- package/crypto/c_skein.h +45 -0
- package/crypto/crypto.h +186 -0
- package/crypto/cryptonote_core/account.cpp +50 -0
- package/crypto/cryptonote_core/account.h +61 -0
- package/crypto/cryptonote_core/cryptonote_basic_impl.cpp +186 -0
- package/crypto/cryptonote_core/cryptonote_basic_impl.h +65 -0
- package/crypto/cryptonote_core/cryptonote_format_utils.cpp +766 -0
- package/crypto/cryptonote_core/cryptonote_format_utils.h +30 -0
- package/crypto/cryptonote_protocol/cryptonote_protocol_defs.h +152 -0
- package/crypto/groestl_tables.h +38 -0
- package/crypto/hash-ops.h +57 -0
- package/crypto/hash.c +24 -0
- package/crypto/hash.h +22 -0
- package/crypto/int-util.h +230 -0
- package/crypto/oaes_config.h +50 -0
- package/crypto/oaes_lib.c +1468 -0
- package/crypto/oaes_lib.h +215 -0
- package/crypto/skein_port.h +190 -0
- package/crypto/variant2_int_sqrt.h +168 -0
- package/crypto/wild_keccak.cpp +119 -0
- package/crypto/wild_keccak.h +168 -0
- package/cryptonight.c +300 -0
- package/cryptonight.h +17 -0
- package/cryptonight_dark.c +300 -0
- package/cryptonight_dark.h +17 -0
- package/cryptonight_dark_lite.c +300 -0
- package/cryptonight_dark_lite.h +17 -0
- package/cryptonight_fast.c +300 -0
- package/cryptonight_fast.h +17 -0
- package/cryptonight_lite.c +300 -0
- package/cryptonight_lite.h +17 -0
- package/cryptonight_soft_shell.c +298 -0
- package/cryptonight_soft_shell.h +17 -0
- package/cryptonight_turtle.c +300 -0
- package/cryptonight_turtle.h +17 -0
- package/cryptonight_turtle_lite.c +300 -0
- package/cryptonight_turtle_lite.h +17 -0
- package/fresh.c +42 -0
- package/fresh.h +16 -0
- package/fugue.c +12 -0
- package/fugue.h +16 -0
- package/groestl.c +40 -0
- package/groestl.h +17 -0
- package/hefty1.c +63 -0
- package/hefty1.h +16 -0
- package/index.js +1 -0
- package/keccak.c +14 -0
- package/keccak.h +16 -0
- package/leocuvee-wrkzcoin-multi-hashing-0.0.20.tgz +0 -0
- package/multihashing.cc +699 -0
- package/nist5.c +46 -0
- package/nist5.h +16 -0
- package/package.json +56 -0
- package/quark.c +210 -0
- package/quark.h +16 -0
- package/qubit.c +45 -0
- package/qubit.h +16 -0
- package/scryptjane/scrypt-jane-chacha.h +132 -0
- package/scryptjane/scrypt-jane-hash.h +48 -0
- package/scryptjane/scrypt-jane-hash_keccak.h +168 -0
- package/scryptjane/scrypt-jane-hash_sha256.h +135 -0
- package/scryptjane/scrypt-jane-mix_chacha-avx.h +340 -0
- package/scryptjane/scrypt-jane-mix_chacha-sse2.h +371 -0
- package/scryptjane/scrypt-jane-mix_chacha-ssse3.h +348 -0
- package/scryptjane/scrypt-jane-mix_chacha.h +69 -0
- package/scryptjane/scrypt-jane-mix_salsa-avx.h +381 -0
- package/scryptjane/scrypt-jane-mix_salsa-sse2.h +443 -0
- package/scryptjane/scrypt-jane-mix_salsa.h +70 -0
- package/scryptjane/scrypt-jane-pbkdf2.h +112 -0
- package/scryptjane/scrypt-jane-portable-x86.h +364 -0
- package/scryptjane/scrypt-jane-portable.h +281 -0
- package/scryptjane/scrypt-jane-romix-basic.h +67 -0
- package/scryptjane/scrypt-jane-romix-template.h +118 -0
- package/scryptjane/scrypt-jane-romix.h +27 -0
- package/scryptjane/scrypt-jane-salsa.h +106 -0
- package/scryptjane/scrypt-jane-test-vectors.h +261 -0
- package/scryptjane.c +223 -0
- package/scryptjane.h +36 -0
- package/scryptn.c +258 -0
- package/scryptn.h +16 -0
- package/sha1.c +65 -0
- package/sha1.h +16 -0
- package/sha256.h +440 -0
- package/sha3/aes_helper.c +392 -0
- package/sha3/hamsi.c +867 -0
- package/sha3/hamsi_helper.c +39648 -0
- package/sha3/md_helper.c +347 -0
- package/sha3/sph_blake.c +1114 -0
- package/sha3/sph_blake.h +327 -0
- package/sha3/sph_bmw.c +965 -0
- package/sha3/sph_bmw.h +328 -0
- package/sha3/sph_cubehash.c +723 -0
- package/sha3/sph_cubehash.h +292 -0
- package/sha3/sph_echo.c +1031 -0
- package/sha3/sph_echo.h +320 -0
- package/sha3/sph_fugue.c +1208 -0
- package/sha3/sph_fugue.h +81 -0
- package/sha3/sph_groestl.c +3119 -0
- package/sha3/sph_groestl.h +329 -0
- package/sha3/sph_hamsi.h +321 -0
- package/sha3/sph_hefty1.c +378 -0
- package/sha3/sph_hefty1.h +66 -0
- package/sha3/sph_jh.c +1116 -0
- package/sha3/sph_jh.h +298 -0
- package/sha3/sph_keccak.c +1824 -0
- package/sha3/sph_keccak.h +293 -0
- package/sha3/sph_luffa.c +1426 -0
- package/sha3/sph_luffa.h +296 -0
- package/sha3/sph_shabal.c +806 -0
- package/sha3/sph_shabal.h +344 -0
- package/sha3/sph_shavite.c +1764 -0
- package/sha3/sph_shavite.h +314 -0
- package/sha3/sph_simd.c +1799 -0
- package/sha3/sph_simd.h +309 -0
- package/sha3/sph_skein.c +1254 -0
- package/sha3/sph_skein.h +298 -0
- package/sha3/sph_types.h +1976 -0
- package/sha3/sph_whirlpool.c +3480 -0
- package/sha3/sph_whirlpool.h +209 -0
- package/shavite3.c +24 -0
- package/shavite3.h +16 -0
- package/skein.c +26 -0
- package/skein.h +16 -0
- package/stdint.h +259 -0
- package/tests/argon2-tests.js +16 -0
- package/tests/benchmark.js +36 -0
- package/tests/cryptonight-tests.js +189 -0
- package/tests/cryptonight_monero.js +53 -0
- package/tests/test.js +16 -0
- package/x11.c +85 -0
- package/x11.h +16 -0
- package/x13.c +97 -0
- package/x13.h +5 -0
- package/x15.c +106 -0
- package/x15.h +16 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
// Copyright (c) 2012-2013 The Cryptonote developers
|
|
2
|
+
// Distributed under the MIT/X11 software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
// Portions Copyright (c) 2018 The Monero developers
|
|
5
|
+
// Portions Copyright (c) 2018 The TurtleCoin Developers
|
|
6
|
+
|
|
7
|
+
#include <stdio.h>
|
|
8
|
+
#include <stdlib.h>
|
|
9
|
+
#include "crypto/oaes_lib.h"
|
|
10
|
+
#include "crypto/c_keccak.h"
|
|
11
|
+
#include "crypto/c_groestl.h"
|
|
12
|
+
#include "crypto/c_blake256.h"
|
|
13
|
+
#include "crypto/c_jh.h"
|
|
14
|
+
#include "crypto/c_skein.h"
|
|
15
|
+
#include "crypto/int-util.h"
|
|
16
|
+
#include "crypto/hash-ops.h"
|
|
17
|
+
#include "crypto/variant2_int_sqrt.h"
|
|
18
|
+
|
|
19
|
+
#if defined(_MSC_VER)
|
|
20
|
+
#include <malloc.h>
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
#define MEMORY 262144 /* 256KB - 2^18 */
|
|
24
|
+
#define ITER 131072 /* 2^17 */
|
|
25
|
+
#define ITER_DIV 65536 /* 2^16 */
|
|
26
|
+
#define AES_BLOCK_SIZE 16
|
|
27
|
+
#define AES_KEY_SIZE 32 /*16*/
|
|
28
|
+
#define INIT_SIZE_BLK 8
|
|
29
|
+
#define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE)
|
|
30
|
+
#define CN_INIT (MEMORY / INIT_SIZE_BYTE)
|
|
31
|
+
#define CN_AES_INIT (MEMORY / AES_BLOCK_SIZE) / 2
|
|
32
|
+
|
|
33
|
+
#define VARIANT1_1(p) \
|
|
34
|
+
do if (variant == 1) \
|
|
35
|
+
{ \
|
|
36
|
+
const uint8_t tmp = ((const uint8_t*)(p))[11]; \
|
|
37
|
+
static const uint32_t table = 0x75310; \
|
|
38
|
+
const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; \
|
|
39
|
+
((uint8_t*)(p))[11] = tmp ^ ((table >> index) & 0x30); \
|
|
40
|
+
} while(0)
|
|
41
|
+
|
|
42
|
+
#define VARIANT1_2(p) \
|
|
43
|
+
do if (variant == 1) \
|
|
44
|
+
{ \
|
|
45
|
+
((uint64_t*)p)[1] ^= tweak1_2; \
|
|
46
|
+
} while(0)
|
|
47
|
+
|
|
48
|
+
#define VARIANT1_INIT() \
|
|
49
|
+
if (variant == 1 && len < 43) \
|
|
50
|
+
{ \
|
|
51
|
+
fprintf(stderr, "Cryptonight variant 1 needs at least 43 bytes of data"); \
|
|
52
|
+
_exit(1); \
|
|
53
|
+
} \
|
|
54
|
+
const uint64_t tweak1_2 = (variant == 1) ? *(const uint64_t*)(((const uint8_t*)input)+35) ^ ctx->state.hs.w[24] : 0
|
|
55
|
+
|
|
56
|
+
#define U64(p) ((uint64_t*)(p))
|
|
57
|
+
|
|
58
|
+
#define VARIANT2_INIT(b, state) \
|
|
59
|
+
uint64_t division_result; \
|
|
60
|
+
uint64_t sqrt_result; \
|
|
61
|
+
do if (variant >= 2) \
|
|
62
|
+
{ \
|
|
63
|
+
U64(b)[2] = state.hs.w[8] ^ state.hs.w[10]; \
|
|
64
|
+
U64(b)[3] = state.hs.w[9] ^ state.hs.w[11]; \
|
|
65
|
+
division_result = state.hs.w[12]; \
|
|
66
|
+
sqrt_result = state.hs.w[13]; \
|
|
67
|
+
} while (0)
|
|
68
|
+
|
|
69
|
+
#define VARIANT2_SHUFFLE_ADD(base_ptr, offset, a, b) \
|
|
70
|
+
do if (variant >= 2) \
|
|
71
|
+
{ \
|
|
72
|
+
uint64_t* chunk1 = U64((base_ptr) + ((offset) ^ 0x10)); \
|
|
73
|
+
uint64_t* chunk2 = U64((base_ptr) + ((offset) ^ 0x20)); \
|
|
74
|
+
uint64_t* chunk3 = U64((base_ptr) + ((offset) ^ 0x30)); \
|
|
75
|
+
\
|
|
76
|
+
const uint64_t chunk1_old[2] = { chunk1[0], chunk1[1] }; \
|
|
77
|
+
\
|
|
78
|
+
chunk1[0] = chunk3[0] + U64(b + 16)[0]; \
|
|
79
|
+
chunk1[1] = chunk3[1] + U64(b + 16)[1]; \
|
|
80
|
+
\
|
|
81
|
+
chunk3[0] = chunk2[0] + U64(a)[0]; \
|
|
82
|
+
chunk3[1] = chunk2[1] + U64(a)[1]; \
|
|
83
|
+
\
|
|
84
|
+
chunk2[0] = chunk1_old[0] + U64(b)[0]; \
|
|
85
|
+
chunk2[1] = chunk1_old[1] + U64(b)[1]; \
|
|
86
|
+
} while (0)
|
|
87
|
+
|
|
88
|
+
#define VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr) \
|
|
89
|
+
((uint64_t*)(b))[0] ^= division_result ^ (sqrt_result << 32); \
|
|
90
|
+
{ \
|
|
91
|
+
const uint64_t dividend = ((uint64_t*)(ptr))[1]; \
|
|
92
|
+
const uint32_t divisor = (((uint32_t*)(ptr))[0] + (uint32_t)(sqrt_result << 1)) | 0x80000001UL; \
|
|
93
|
+
division_result = ((uint32_t)(dividend / divisor)) + \
|
|
94
|
+
(((uint64_t)(dividend % divisor)) << 32); \
|
|
95
|
+
} \
|
|
96
|
+
const uint64_t sqrt_input = ((uint64_t*)(ptr))[0] + division_result
|
|
97
|
+
|
|
98
|
+
#define VARIANT2_INTEGER_MATH(b, ptr) \
|
|
99
|
+
do if (variant >= 2) \
|
|
100
|
+
{ \
|
|
101
|
+
VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr); \
|
|
102
|
+
VARIANT2_INTEGER_MATH_SQRT_STEP_FP64(); \
|
|
103
|
+
VARIANT2_INTEGER_MATH_SQRT_FIXUP(sqrt_result); \
|
|
104
|
+
} while (0)
|
|
105
|
+
|
|
106
|
+
#define VARIANT2_2() \
|
|
107
|
+
do if (variant >= 2) { \
|
|
108
|
+
((uint64_t*)(ctx->long_state + ((j * AES_BLOCK_SIZE) ^ 0x10)))[0] ^= hi; \
|
|
109
|
+
((uint64_t*)(ctx->long_state + ((j * AES_BLOCK_SIZE) ^ 0x10)))[1] ^= lo; \
|
|
110
|
+
hi ^= ((uint64_t*)(ctx->long_state + ((j * AES_BLOCK_SIZE) ^ 0x20)))[0]; \
|
|
111
|
+
lo ^= ((uint64_t*)(ctx->long_state + ((j * AES_BLOCK_SIZE) ^ 0x20)))[1]; \
|
|
112
|
+
} while (0)
|
|
113
|
+
|
|
114
|
+
#pragma pack(push, 1)
|
|
115
|
+
union cn_slow_hash_state {
|
|
116
|
+
union hash_state hs;
|
|
117
|
+
struct {
|
|
118
|
+
uint8_t k[64];
|
|
119
|
+
uint8_t init[INIT_SIZE_BYTE];
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
#pragma pack(pop)
|
|
123
|
+
|
|
124
|
+
static void do_turtle_lite_blake_hash(const void* input, size_t len, char* output) {
|
|
125
|
+
blake256_hash((uint8_t*)output, input, len);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
void do_turtle_lite_groestl_hash(const void* input, size_t len, char* output) {
|
|
129
|
+
groestl(input, len * 8, (uint8_t*)output);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static void do_turtle_lite_jh_hash(const void* input, size_t len, char* output) {
|
|
133
|
+
int r = jh_hash(HASH_SIZE * 8, input, 8 * len, (uint8_t*)output);
|
|
134
|
+
assert(SUCCESS == r);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
static void do_turtle_lite_skein_hash(const void* input, size_t len, char* output) {
|
|
138
|
+
int r = c_skein_hash(8 * HASH_SIZE, input, 8 * len, (uint8_t*)output);
|
|
139
|
+
assert(SKEIN_SUCCESS == r);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static void (* const extra_hashes[4])(const void *, size_t, char *) = {
|
|
143
|
+
do_turtle_lite_blake_hash, do_turtle_lite_groestl_hash, do_turtle_lite_jh_hash, do_turtle_lite_skein_hash
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
extern int aesb_single_round(const uint8_t *in, uint8_t*out, const uint8_t *expandedKey);
|
|
147
|
+
extern int aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *expandedKey);
|
|
148
|
+
|
|
149
|
+
static inline size_t e2i(const uint8_t* a) {
|
|
150
|
+
return (*((uint64_t*) a) / AES_BLOCK_SIZE) & (CN_AES_INIT - 1);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static void mul(const uint8_t* a, const uint8_t* b, uint8_t* res) {
|
|
154
|
+
((uint64_t*) res)[1] = mul128(((uint64_t*) a)[0], ((uint64_t*) b)[0], (uint64_t*) res);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
static void sum_half_blocks(uint8_t* a, const uint8_t* b) {
|
|
158
|
+
uint64_t a0, a1, b0, b1;
|
|
159
|
+
|
|
160
|
+
a0 = SWAP64LE(((uint64_t*) a)[0]);
|
|
161
|
+
a1 = SWAP64LE(((uint64_t*) a)[1]);
|
|
162
|
+
b0 = SWAP64LE(((uint64_t*) b)[0]);
|
|
163
|
+
b1 = SWAP64LE(((uint64_t*) b)[1]);
|
|
164
|
+
a0 += b0;
|
|
165
|
+
a1 += b1;
|
|
166
|
+
((uint64_t*) a)[0] = SWAP64LE(a0);
|
|
167
|
+
((uint64_t*) a)[1] = SWAP64LE(a1);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
static inline void copy_block(uint8_t* dst, const uint8_t* src) {
|
|
171
|
+
((uint64_t*) dst)[0] = ((uint64_t*) src)[0];
|
|
172
|
+
((uint64_t*) dst)[1] = ((uint64_t*) src)[1];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
static void swap_blocks(uint8_t* a, uint8_t* b) {
|
|
176
|
+
size_t i;
|
|
177
|
+
uint8_t t;
|
|
178
|
+
for (i = 0; i < AES_BLOCK_SIZE; i++) {
|
|
179
|
+
t = a[i];
|
|
180
|
+
a[i] = b[i];
|
|
181
|
+
b[i] = t;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
static inline void xor_blocks(uint8_t* a, const uint8_t* b) {
|
|
186
|
+
((uint64_t*) a)[0] ^= ((uint64_t*) b)[0];
|
|
187
|
+
((uint64_t*) a)[1] ^= ((uint64_t*) b)[1];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static inline void xor_blocks_dst(const uint8_t* a, const uint8_t* b, uint8_t* dst) {
|
|
191
|
+
((uint64_t*) dst)[0] = ((uint64_t*) a)[0] ^ ((uint64_t*) b)[0];
|
|
192
|
+
((uint64_t*) dst)[1] = ((uint64_t*) a)[1] ^ ((uint64_t*) b)[1];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
struct cryptonightturtlelite_ctx {
|
|
196
|
+
uint8_t long_state[MEMORY];
|
|
197
|
+
union cn_slow_hash_state state;
|
|
198
|
+
uint8_t text[INIT_SIZE_BYTE];
|
|
199
|
+
uint8_t a[AES_BLOCK_SIZE];
|
|
200
|
+
uint8_t b[AES_BLOCK_SIZE * 2];
|
|
201
|
+
uint8_t c[AES_BLOCK_SIZE];
|
|
202
|
+
uint8_t aes_key[AES_KEY_SIZE];
|
|
203
|
+
oaes_ctx* aes_ctx;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
void cryptonightturtlelite_hash(const char* input, char* output, uint32_t len, int variant) {
|
|
207
|
+
#if defined(_MSC_VER)
|
|
208
|
+
struct cryptonightturtlelite_ctx *ctx = _malloca(sizeof(struct cryptonightturtlelite_ctx));
|
|
209
|
+
#else
|
|
210
|
+
struct cryptonightturtlelite_ctx *ctx = alloca(sizeof(struct cryptonightturtlelite_ctx));
|
|
211
|
+
#endif
|
|
212
|
+
hash_process(&ctx->state.hs, (const uint8_t*) input, len);
|
|
213
|
+
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
|
|
214
|
+
memcpy(ctx->aes_key, ctx->state.hs.b, AES_KEY_SIZE);
|
|
215
|
+
ctx->aes_ctx = (oaes_ctx*) oaes_alloc();
|
|
216
|
+
size_t i, j;
|
|
217
|
+
|
|
218
|
+
VARIANT1_INIT();
|
|
219
|
+
VARIANT2_INIT(ctx->b, ctx->state);
|
|
220
|
+
|
|
221
|
+
oaes_key_import_data(ctx->aes_ctx, ctx->aes_key, AES_KEY_SIZE);
|
|
222
|
+
for (i = 0; i < CN_INIT; i++) {
|
|
223
|
+
for (j = 0; j < INIT_SIZE_BLK; j++) {
|
|
224
|
+
aesb_pseudo_round(&ctx->text[AES_BLOCK_SIZE * j],
|
|
225
|
+
&ctx->text[AES_BLOCK_SIZE * j],
|
|
226
|
+
ctx->aes_ctx->key->exp_data);
|
|
227
|
+
}
|
|
228
|
+
memcpy(&ctx->long_state[i * INIT_SIZE_BYTE], ctx->text, INIT_SIZE_BYTE);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
for (i = 0; i < 16; i++) {
|
|
232
|
+
ctx->a[i] = ctx->state.k[i] ^ ctx->state.k[32 + i];
|
|
233
|
+
ctx->b[i] = ctx->state.k[16 + i] ^ ctx->state.k[48 + i];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
for (i = 0; i < ITER_DIV; i++) {
|
|
237
|
+
/* Dependency chain: address -> read value ------+
|
|
238
|
+
* written value <-+ hard function (AES or MUL) <+
|
|
239
|
+
* next address <-+
|
|
240
|
+
*/
|
|
241
|
+
/* Iteration 1 */
|
|
242
|
+
j = e2i(ctx->a);
|
|
243
|
+
aesb_single_round(&ctx->long_state[j * AES_BLOCK_SIZE], ctx->c, ctx->a);
|
|
244
|
+
VARIANT2_SHUFFLE_ADD(ctx->long_state, j * AES_BLOCK_SIZE, ctx->a, ctx->b);
|
|
245
|
+
xor_blocks_dst(ctx->c, ctx->b, &ctx->long_state[j * AES_BLOCK_SIZE]);
|
|
246
|
+
VARIANT1_1((uint8_t*)&ctx->long_state[j * AES_BLOCK_SIZE]);
|
|
247
|
+
/* Iteration 2 */
|
|
248
|
+
j = e2i(ctx->c);
|
|
249
|
+
|
|
250
|
+
uint64_t* dst = (uint64_t*)&ctx->long_state[j * AES_BLOCK_SIZE];
|
|
251
|
+
|
|
252
|
+
uint64_t t[2];
|
|
253
|
+
t[0] = dst[0];
|
|
254
|
+
t[1] = dst[1];
|
|
255
|
+
|
|
256
|
+
VARIANT2_INTEGER_MATH(t, ctx->c);
|
|
257
|
+
|
|
258
|
+
uint64_t hi;
|
|
259
|
+
uint64_t lo = mul128(((uint64_t*)ctx->c)[0], t[0], &hi);
|
|
260
|
+
|
|
261
|
+
VARIANT2_2();
|
|
262
|
+
VARIANT2_SHUFFLE_ADD(ctx->long_state, j * AES_BLOCK_SIZE, ctx->a, ctx->b);
|
|
263
|
+
|
|
264
|
+
((uint64_t*)ctx->a)[0] += hi;
|
|
265
|
+
((uint64_t*)ctx->a)[1] += lo;
|
|
266
|
+
|
|
267
|
+
dst[0] = ((uint64_t*)ctx->a)[0];
|
|
268
|
+
dst[1] = ((uint64_t*)ctx->a)[1];
|
|
269
|
+
|
|
270
|
+
((uint64_t*)ctx->a)[0] ^= t[0];
|
|
271
|
+
((uint64_t*)ctx->a)[1] ^= t[1];
|
|
272
|
+
|
|
273
|
+
VARIANT1_2((uint8_t*)&ctx->long_state[j * AES_BLOCK_SIZE]);
|
|
274
|
+
copy_block(ctx->b + AES_BLOCK_SIZE, ctx->b);
|
|
275
|
+
copy_block(ctx->b, ctx->c);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
|
|
279
|
+
oaes_key_import_data(ctx->aes_ctx, &ctx->state.hs.b[32], AES_KEY_SIZE);
|
|
280
|
+
for (i = 0; i < CN_INIT; i++) {
|
|
281
|
+
for (j = 0; j < INIT_SIZE_BLK; j++) {
|
|
282
|
+
xor_blocks(&ctx->text[j * AES_BLOCK_SIZE],
|
|
283
|
+
&ctx->long_state[i * INIT_SIZE_BYTE + j * AES_BLOCK_SIZE]);
|
|
284
|
+
aesb_pseudo_round(&ctx->text[j * AES_BLOCK_SIZE],
|
|
285
|
+
&ctx->text[j * AES_BLOCK_SIZE],
|
|
286
|
+
ctx->aes_ctx->key->exp_data);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
memcpy(ctx->state.init, ctx->text, INIT_SIZE_BYTE);
|
|
290
|
+
hash_permutation(&ctx->state.hs);
|
|
291
|
+
/*memcpy(hash, &state, 32);*/
|
|
292
|
+
extra_hashes[ctx->state.hs.b[0] & 3](&ctx->state, 200, output);
|
|
293
|
+
oaes_free((OAES_CTX **) &ctx->aes_ctx);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
void cryptonightturtlelite_fast_hash(const char* input, char* output, uint32_t len) {
|
|
297
|
+
union hash_state state;
|
|
298
|
+
hash_process(&state, (const uint8_t*) input, len);
|
|
299
|
+
memcpy(output, &state, HASH_SIZE);
|
|
300
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#ifndef CRYPTONIGHTTURTLELITE_H
|
|
2
|
+
#define CRYPTONIGHTTURTLELITE_H
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
|
|
10
|
+
void cryptonightturtlelite_hash(const char* input, char* output, uint32_t len, int variant);
|
|
11
|
+
void cryptonightturtlelite_fast_hash(const char* input, char* output, uint32_t len);
|
|
12
|
+
|
|
13
|
+
#ifdef __cplusplus
|
|
14
|
+
}
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#endif
|
package/fresh.c
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#include "fresh.h"
|
|
2
|
+
#include <stdlib.h>
|
|
3
|
+
#include <stdint.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
|
|
7
|
+
#include "sha3/sph_shavite.h"
|
|
8
|
+
#include "sha3/sph_simd.h"
|
|
9
|
+
#include "sha3/sph_echo.h"
|
|
10
|
+
|
|
11
|
+
void fresh_hash(const char* input, char* output, uint32_t len)
|
|
12
|
+
{
|
|
13
|
+
sph_shavite512_context ctx_shavite1;
|
|
14
|
+
sph_simd512_context ctx_simd1;
|
|
15
|
+
sph_echo512_context ctx_echo1;
|
|
16
|
+
|
|
17
|
+
//these uint512 in the c++ source of the client are backed by an array of uint32
|
|
18
|
+
uint32_t hashA[16], hashB[16];
|
|
19
|
+
|
|
20
|
+
sph_shavite512_init (&ctx_shavite1);
|
|
21
|
+
sph_shavite512 (&ctx_shavite1, input, len);
|
|
22
|
+
sph_shavite512_close(&ctx_shavite1, hashA);
|
|
23
|
+
|
|
24
|
+
sph_simd512_init (&ctx_simd1);
|
|
25
|
+
sph_simd512 (&ctx_simd1, hashA, 64);
|
|
26
|
+
sph_simd512_close(&ctx_simd1, hashB);
|
|
27
|
+
|
|
28
|
+
sph_shavite512_init (&ctx_shavite1);
|
|
29
|
+
sph_shavite512 (&ctx_shavite1, hashB, 64);
|
|
30
|
+
sph_shavite512_close(&ctx_shavite1, hashA);
|
|
31
|
+
|
|
32
|
+
sph_simd512_init (&ctx_simd1);
|
|
33
|
+
sph_simd512 (&ctx_simd1, hashA, 64);
|
|
34
|
+
sph_simd512_close(&ctx_simd1, hashB);
|
|
35
|
+
|
|
36
|
+
sph_echo512_init (&ctx_echo1);
|
|
37
|
+
sph_echo512 (&ctx_echo1, hashB, 64);
|
|
38
|
+
sph_echo512_close(&ctx_echo1, hashA);
|
|
39
|
+
|
|
40
|
+
memcpy(output, hashA, 32);
|
|
41
|
+
|
|
42
|
+
}
|
package/fresh.h
ADDED
package/fugue.c
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#include "fugue.h"
|
|
2
|
+
|
|
3
|
+
#include "sha3/sph_fugue.h"
|
|
4
|
+
|
|
5
|
+
void fugue_hash(const char* input, char* output, uint32_t len)
|
|
6
|
+
{
|
|
7
|
+
sph_fugue256_context ctx_fugue;
|
|
8
|
+
sph_fugue256_init(&ctx_fugue);
|
|
9
|
+
sph_fugue256(&ctx_fugue, input, len);
|
|
10
|
+
sph_fugue256_close(&ctx_fugue, output);
|
|
11
|
+
}
|
|
12
|
+
|
package/fugue.h
ADDED
package/groestl.c
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#include "groestl.h"
|
|
2
|
+
#include <stdlib.h>
|
|
3
|
+
#include <stdint.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
|
|
7
|
+
#include "sha3/sph_groestl.h"
|
|
8
|
+
#include "sha256.h"
|
|
9
|
+
|
|
10
|
+
void groestl_hash(const char* input, char* output, uint32_t len)
|
|
11
|
+
{
|
|
12
|
+
char hash1[64];
|
|
13
|
+
char hash2[64];
|
|
14
|
+
|
|
15
|
+
sph_groestl512_context ctx_groestl;
|
|
16
|
+
sph_groestl512_init(&ctx_groestl);
|
|
17
|
+
sph_groestl512(&ctx_groestl, input, len);
|
|
18
|
+
sph_groestl512_close(&ctx_groestl, &hash1);
|
|
19
|
+
|
|
20
|
+
sph_groestl512(&ctx_groestl, hash1, 64);
|
|
21
|
+
sph_groestl512_close(&ctx_groestl, &hash2);
|
|
22
|
+
|
|
23
|
+
memcpy(output, &hash2, 32);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
void groestlmyriad_hash(const char* input, char* output, uint32_t len)
|
|
27
|
+
{
|
|
28
|
+
char temp[64];
|
|
29
|
+
|
|
30
|
+
sph_groestl512_context ctx_groestl;
|
|
31
|
+
sph_groestl512_init(&ctx_groestl);
|
|
32
|
+
sph_groestl512(&ctx_groestl, input, len);
|
|
33
|
+
sph_groestl512_close(&ctx_groestl, &temp);
|
|
34
|
+
|
|
35
|
+
SHA256_CTX ctx_sha256;
|
|
36
|
+
SHA256_Init(&ctx_sha256);
|
|
37
|
+
SHA256_Update(&ctx_sha256, &temp, 64);
|
|
38
|
+
SHA256_Final((unsigned char*) output, &ctx_sha256);
|
|
39
|
+
}
|
|
40
|
+
|
package/groestl.h
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#ifndef GROESTL_H
|
|
2
|
+
#define GROESTL_H
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
|
|
10
|
+
void groestl_hash(const char* input, char* output, uint32_t len);
|
|
11
|
+
void groestlmyriad_hash(const char* input, char* output, uint32_t len);
|
|
12
|
+
|
|
13
|
+
#ifdef __cplusplus
|
|
14
|
+
}
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#endif
|
package/hefty1.c
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#include "hefty1.h"
|
|
2
|
+
|
|
3
|
+
#include "sha3/sph_hefty1.h"
|
|
4
|
+
#include "sha3/sph_keccak.h"
|
|
5
|
+
#include "sha3/sph_groestl.h"
|
|
6
|
+
#include "sha3/sph_blake.h"
|
|
7
|
+
#include "sha256.h"
|
|
8
|
+
|
|
9
|
+
void hefty1_hash(const char* input, char* output, uint32_t len)
|
|
10
|
+
{
|
|
11
|
+
HEFTY1_CTX ctx_hefty1;
|
|
12
|
+
SHA256_CTX ctx_sha256;
|
|
13
|
+
sph_keccak512_context ctx_keccak;
|
|
14
|
+
sph_groestl512_context ctx_groestl;
|
|
15
|
+
sph_blake512_context ctx_blake;
|
|
16
|
+
|
|
17
|
+
char hash32_1[32];
|
|
18
|
+
char hash32_2[32];
|
|
19
|
+
char hash64_3[64];
|
|
20
|
+
char hash64_4[64];
|
|
21
|
+
char hash64_5[64];
|
|
22
|
+
|
|
23
|
+
HEFTY1_Init(&ctx_hefty1);
|
|
24
|
+
HEFTY1_Update(&ctx_hefty1, (const void*) input, len);
|
|
25
|
+
HEFTY1_Final((unsigned char*) &hash32_1, &ctx_hefty1); // 1
|
|
26
|
+
|
|
27
|
+
SHA256_Init(&ctx_sha256);
|
|
28
|
+
SHA256_Update(&ctx_sha256, (const void*) input, len);
|
|
29
|
+
SHA256_Update(&ctx_sha256, (unsigned char*) &hash32_1, 32); // 1
|
|
30
|
+
SHA256_Final((unsigned char*) &hash32_2, &ctx_sha256); // 2
|
|
31
|
+
|
|
32
|
+
sph_keccak512_init(&ctx_keccak);
|
|
33
|
+
sph_keccak512(&ctx_keccak, (const void*) input, len);
|
|
34
|
+
sph_keccak512(&ctx_keccak, (unsigned char*) &hash32_1, 32); //1
|
|
35
|
+
sph_keccak512_close(&ctx_keccak, (void*) &hash64_3); // 3
|
|
36
|
+
|
|
37
|
+
sph_groestl512_init(&ctx_groestl);
|
|
38
|
+
sph_groestl512(&ctx_groestl, (const void*) input, len);
|
|
39
|
+
sph_groestl512(&ctx_groestl, (unsigned char*) &hash32_1, 32); // 1
|
|
40
|
+
sph_groestl512_close(&ctx_groestl, (void*) &hash64_4); // 4
|
|
41
|
+
|
|
42
|
+
sph_blake512_init(&ctx_blake);
|
|
43
|
+
sph_blake512(&ctx_blake, (const void*) input, len);
|
|
44
|
+
sph_blake512(&ctx_blake, (unsigned char*) &hash32_1, 32); // 1
|
|
45
|
+
sph_blake512_close(&ctx_blake, (void*) &hash64_5); // 5
|
|
46
|
+
|
|
47
|
+
memset(output, 0, 32);
|
|
48
|
+
|
|
49
|
+
char* hash[4] = { hash32_2, hash64_3, hash64_4, hash64_5 };
|
|
50
|
+
|
|
51
|
+
uint32_t i;
|
|
52
|
+
uint32_t j;
|
|
53
|
+
|
|
54
|
+
#define OUTPUT_BIT (i * 4 + j)
|
|
55
|
+
|
|
56
|
+
for(i = 0; i < 64; i++) {
|
|
57
|
+
for(j = 0; j < 4; j++) {
|
|
58
|
+
if((*(hash[j] + (i / 8)) & (0x80 >> (i % 8))) != 0)
|
|
59
|
+
*(output + (OUTPUT_BIT / 8)) |= 0x80 >> (OUTPUT_BIT % 8);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
package/hefty1.h
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('bindings')('multihashing.node')
|
package/keccak.c
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#include "keccak.h"
|
|
2
|
+
|
|
3
|
+
#include "sha3/sph_types.h"
|
|
4
|
+
#include "sha3/sph_keccak.h"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
void keccak_hash(const char* input, char* output, uint32_t size)
|
|
8
|
+
{
|
|
9
|
+
sph_keccak256_context ctx_keccak;
|
|
10
|
+
sph_keccak256_init(&ctx_keccak);
|
|
11
|
+
sph_keccak256 (&ctx_keccak, input, size);//80);
|
|
12
|
+
sph_keccak256_close(&ctx_keccak, output);
|
|
13
|
+
}
|
|
14
|
+
|
package/keccak.h
ADDED
|
Binary file
|