├── res ├── icon.rc ├── cpuminer.rc ├── resource.h ├── setup.ico └── cpuminer.ico ├── algo ├── groestl │ ├── aes_ni │ │ ├── architectures │ │ ├── api.h │ │ ├── implementors │ │ ├── groestl-version.h │ │ └── README │ ├── myrgr-gate.c │ └── myrgr-gate.h ├── blake │ ├── sse2 │ │ └── blake │ │ │ └── sse41 │ │ │ ├── architectures │ │ │ ├── api.h │ │ │ ├── implementors │ │ │ ├── config.h │ │ │ └── hash.h │ ├── pentablake-gate.c │ ├── blake2b-gate.c │ ├── blake-gate.h │ ├── pentablake-gate.h │ ├── blake2b-gate.h │ ├── blake-gate.c │ ├── blake2s-gate.c │ ├── blake2b-hash-4way.h │ ├── blakecoin-gate.h │ ├── blake2s-gate.h │ ├── sph_blake2b.h │ ├── blakecoin-gate.c │ ├── decred-gate.h │ ├── blake2b.c │ ├── blake2b-4way.c │ ├── blake.c │ └── blake2s.c ├── echo │ └── aes_ni │ │ ├── api.h │ │ └── hash_api.h ├── yespower │ ├── insecure_memzero.h │ └── TESTS-OK ├── yescrypt │ └── yescrypt-best.c ├── hodl │ ├── hodl-gate.h │ ├── wolf-aes.h │ ├── hodl-wolf.h │ ├── sha512-avx.h │ └── hodl-endian.h ├── x17 │ ├── x17-gate.c │ ├── sonoa-gate.c │ ├── x17-gate.h │ ├── xevan-gate.c │ ├── xevan-gate.h │ └── sonoa-gate.h ├── nist5 │ ├── nist5-gate.c │ └── nist5-gate.h ├── x15 │ ├── x15-gate.c │ └── x15-gate.h ├── qubit │ ├── deep-gate.c │ ├── qubit-gate.c │ ├── deep-gate.h │ └── qubit-gate.h ├── quark │ ├── anime-gate.c │ ├── quark-gate.c │ ├── hmq1725-gate.c │ ├── anime-gate.h │ ├── quark-gate.h │ └── hmq1725-gate.h ├── whirlpool │ ├── whirlpool-gate.c │ ├── whirlpool-gate.h │ └── whirlpoolx.c ├── x11 │ ├── c11-gate.c │ ├── x11-gate.c │ ├── x11gost-gate.c │ ├── tribus-gate.c │ ├── tribus-gate.h │ ├── c11-gate.h │ ├── x11-gate.h │ ├── x11gost-gate.h │ ├── x11evo-gate.h │ ├── timetravel-gate.h │ ├── timetravel10-gate.h │ ├── timetravel-gate.c │ ├── timetravel10-gate.c │ └── x11evo-gate.c ├── x12 │ ├── x12-gate.c │ └── x12-gate.h ├── x13 │ ├── x13-gate.c │ ├── phi1612-gate.c │ ├── skunk-gate.c │ ├── x13-gate.h │ ├── skunk-gate.h │ ├── phi1612-gate.h │ ├── x13sm3-gate.c │ └── x13sm3-gate.h ├── x14 │ ├── x14-gate.c │ ├── polytimos-gate.c │ ├── veltor-gate.c │ ├── x14-gate.h │ ├── polytimos-gate.h │ ├── veltor-gate.h │ └── axiom.c ├── jh │ ├── jha-gate.c │ └── jha-gate.h ├── skein │ ├── skein2-gate.c │ ├── skein-gate.c │ ├── skein2-gate.h │ ├── skein-gate.h │ ├── skein.c │ ├── skein2.c │ └── skein2-4way.c ├── bmw │ ├── bmw512-gate.c │ ├── bmw512-gate.h │ ├── bmw512.c │ ├── bmw256.c │ ├── bmw512-4way.c │ └── sse2 │ │ └── sph_bmw.h ├── scryptjane │ ├── scrypt-conf.h │ ├── scrypt-jane-mix_salsa64.h │ ├── scrypt-jane-romix.h │ ├── scrypt-jane-mix_chacha.h │ ├── scrypt-jane-mix_salsa.h │ └── scrypt-jane-hash.h ├── keccak │ ├── keccak-gate.h │ ├── keccak.c │ ├── keccak-gate.c │ └── keccak-4way.c ├── sha │ ├── sha3-defs.h │ ├── sha3_common.h │ ├── sha256t-gate.c │ └── sha256t-gate.h ├── shavite │ └── shavite-hash-2way.h ├── simd │ ├── simd-hash-2way.h │ ├── simd_iv.h │ └── nist.h ├── argon2 │ ├── argon2a │ │ └── ar2 │ │ │ ├── sj │ │ │ ├── scrypt-jane-mix_salsa64.h │ │ │ ├── scrypt-jane-romix.h │ │ │ ├── scrypt-jane-test-vectors.h │ │ │ └── scrypt-jane-hash.h │ │ │ ├── ar2-scrypt-jane.h │ │ │ ├── genkat.h.hide │ │ │ ├── ref.h.hide │ │ │ ├── opt.h │ │ │ └── blake2 │ │ │ ├── blamka-round-ref.h │ │ │ └── blake2.h │ └── argon2d │ │ ├── argon2d-gate.h │ │ └── argon2d │ │ ├── argon2d_thread.c │ │ └── encoding.h ├── x20 │ ├── x20r-gate.c │ └── x20r-gate.h ├── cubehash │ ├── cube-hash-2way.h │ └── cubehash_sse2.h ├── ripemd │ ├── ripemd-hash-4way.h │ └── lbry-gate.h ├── luffa │ └── luffa.c ├── cryptonight │ └── cryptonight.h ├── fugue │ └── sph_fugue.h └── lyra2 │ └── lyra2h.c ├── compat ├── inttypes.h ├── unistd.h ├── jansson │ ├── .gitignore │ ├── util.h │ ├── Makefile.am │ ├── strbuffer.h │ ├── LICENSE │ ├── utf.h │ ├── memory.c │ ├── jansson_config.h │ └── error.c ├── Makefile.am ├── stdbool.h ├── pthreads │ ├── x64 │ │ ├── libpthreadGC2.a │ │ └── pthreadVC2.lib │ └── x86 │ │ └── pthreadVC2.lib ├── sys │ └── time.h ├── winansi.h └── gettimeofday.c ├── ChangeLog ├── .gitattributes ├── m4 └── .gitignore ├── LICENSE ├── crypto ├── hash.h ├── c_keccak.h ├── hash.c ├── c_jh.h ├── c_blake256.h ├── magimath.h ├── c_groestl.h ├── hash-ops.h ├── magimath.cpp ├── c_skein.h └── oaes_config.h ├── autogen.sh ├── .travis.yml ├── AUTHORS ├── cpuminer-conf.json ├── asm ├── aesb-x86.S └── aesb-x64.S ├── .gitignore ├── Dockerfile ├── uint256.cpp ├── mingw64.sh ├── nomacro.pl ├── cpuminer.sln ├── README.txt ├── api └── websocket.htm ├── Android.mk └── compat.h /res/icon.rc: -------------------------------------------------------------------------------- 1 | 0 ICON cpuminer.ico 2 | -------------------------------------------------------------------------------- /algo/groestl/aes_ni/architectures: -------------------------------------------------------------------------------- 1 | amd64 2 | -------------------------------------------------------------------------------- /algo/blake/sse2/blake/sse41/architectures: -------------------------------------------------------------------------------- 1 | amd64 2 | x86 -------------------------------------------------------------------------------- /compat/inttypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | -------------------------------------------------------------------------------- /compat/unistd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "getopt/getopt.h" -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | See git repository ('git log') for full changelog. 2 | -------------------------------------------------------------------------------- /algo/blake/sse2/blake/sse41/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 64 2 | 3 | -------------------------------------------------------------------------------- /compat/jansson/.gitignore: -------------------------------------------------------------------------------- 1 | *.h.in 2 | *.h.in~ 3 | libtool 4 | libjansson.a 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto -------------------------------------------------------------------------------- /algo/echo/aes_ni/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 64 2 | #define CRYPTO_VERSION "1.208" -------------------------------------------------------------------------------- /algo/yespower/insecure_memzero.h: -------------------------------------------------------------------------------- 1 | #define insecure_memzero(buf, len) /* empty */ 2 | -------------------------------------------------------------------------------- /algo/blake/sse2/blake/sse41/implementors: -------------------------------------------------------------------------------- 1 | Jean-Philippe Aumasson 2 | Samuel Neves 3 | -------------------------------------------------------------------------------- /algo/groestl/aes_ni/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 64 2 | #define CRYPTO_VERSION "2.2" 3 | -------------------------------------------------------------------------------- /res/cpuminer.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raptor3um/cpuminer-opt/HEAD/res/cpuminer.rc -------------------------------------------------------------------------------- /res/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raptor3um/cpuminer-opt/HEAD/res/resource.h -------------------------------------------------------------------------------- /res/setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raptor3um/cpuminer-opt/HEAD/res/setup.ico -------------------------------------------------------------------------------- /res/cpuminer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raptor3um/cpuminer-opt/HEAD/res/cpuminer.ico -------------------------------------------------------------------------------- /algo/groestl/aes_ni/implementors: -------------------------------------------------------------------------------- 1 | Krystian Matusiewicz 2 | Günther A. Roland 3 | Martin Schläffer 4 | -------------------------------------------------------------------------------- /compat/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | if WANT_JANSSON 3 | SUBDIRS = jansson 4 | else 5 | SUBDIRS = 6 | endif 7 | 8 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /compat/stdbool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define false 0 4 | #define true 1 5 | 6 | #define bool int 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | cpuminer is available under the terms of the GNU Public License version 2. 2 | 3 | See COPYING for details. 4 | -------------------------------------------------------------------------------- /compat/pthreads/x64/libpthreadGC2.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raptor3um/cpuminer-opt/HEAD/compat/pthreads/x64/libpthreadGC2.a -------------------------------------------------------------------------------- /compat/pthreads/x64/pthreadVC2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raptor3um/cpuminer-opt/HEAD/compat/pthreads/x64/pthreadVC2.lib -------------------------------------------------------------------------------- /compat/pthreads/x86/pthreadVC2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raptor3um/cpuminer-opt/HEAD/compat/pthreads/x86/pthreadVC2.lib -------------------------------------------------------------------------------- /algo/yescrypt/yescrypt-best.c: -------------------------------------------------------------------------------- 1 | #ifdef __SSE2__ 2 | #include "yescrypt-simd.c" 3 | #else 4 | #include "yescrypt-opt.c" 5 | #endif 6 | -------------------------------------------------------------------------------- /algo/hodl/hodl-gate.h: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | 3 | extern unsigned char *hodl_scratchbuf; 4 | 5 | bool register_hodl_algo ( algo_gate_t* gate ); 6 | 7 | -------------------------------------------------------------------------------- /algo/blake/sse2/blake/sse41/config.h: -------------------------------------------------------------------------------- 1 | #ifndef __BLAKE512_CONFIG_H__ 2 | #define __BLAKE512_CONFIG_H__ 3 | 4 | #define AVOID_BRANCHING 1 5 | //#define HAVE_XOP 1 6 | 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /crypto/hash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef unsigned char BitSequence; 4 | typedef unsigned long long DataLength; 5 | typedef enum {SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2} HashReturn; 6 | -------------------------------------------------------------------------------- /compat/sys/time.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" 5 | { 6 | #endif 7 | int gettimeofday(struct timeval *tv, struct timezone *tz); 8 | void usleep(__int64 usec); 9 | #ifdef __cplusplus 10 | } 11 | #endif 12 | typedef __int64 useconds_t; 13 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # You need autoconf 2.5x, preferably 2.57 or later 4 | # You need automake 1.7 or later. 1.6 might work. 5 | 6 | set -e 7 | 8 | aclocal 9 | autoheader 10 | automake --foreign --add-missing --force-missing --copy 11 | # automake --gnu --add-missing --copy 12 | autoconf 13 | 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | compiler: 4 | - gcc 5 | 6 | before_install: 7 | - sudo apt-get update -qq 8 | - sudo apt-get install libcurl4-openssl-dev 9 | 10 | before_script: 11 | - ./autogen.sh 12 | 13 | script: 14 | - ./configure --with-crypto --with-curl 15 | - make 16 | - ./cpuminer --cputest 17 | -------------------------------------------------------------------------------- /algo/groestl/aes_ni/groestl-version.h: -------------------------------------------------------------------------------- 1 | // specify assembly or intrinsics implementation 2 | //#define TASM 3 | #define TINTR 4 | 5 | //#define AES_NI 6 | 7 | //#ifdef AES_NI 8 | // specify AES-NI, AVX (with AES-NI) or vector-permute implementation 9 | 10 | //#ifndef NO_AES_NI 11 | 12 | #define VAES 13 | // #define VAVX 14 | // #define VVPERM 15 | 16 | //#endif 17 | -------------------------------------------------------------------------------- /compat/jansson/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2010 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef UTIL_H 9 | #define UTIL_H 10 | 11 | #ifndef max 12 | #define max(a, b) ((a) > (b) ? (a) : (b)) 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Jeff Garzik 2 | 3 | ArtForz 4 | 5 | pooler 6 | 7 | BlueDragon747 8 | 9 | 1gh 10 | 11 | Neisklar 12 | 13 | prettyhatemachine 14 | 15 | LucasJones 16 | 17 | tpruvot@github 18 | 19 | elmad 20 | 21 | djm34 22 | 23 | palmd 24 | 25 | ig0tik3d 26 | 27 | Wolf0 28 | 29 | Optiminer 30 | 31 | Jay D Dee 32 | 33 | xcouiz@gmail.com 34 | 35 | Cryply 36 | -------------------------------------------------------------------------------- /compat/jansson/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_LIBRARIES = libjansson.a 3 | 4 | libjansson_a_SOURCES = \ 5 | config.h \ 6 | dump.c \ 7 | error.c \ 8 | hashtable.c hashtable.h \ 9 | jansson.h \ 10 | jansson_config.h \ 11 | jansson_private.h \ 12 | load.c \ 13 | memory.c \ 14 | pack_unpack.c \ 15 | strbuffer.c strbuffer.h \ 16 | strconv.c \ 17 | utf.c utf.h \ 18 | util.h \ 19 | value.c 20 | 21 | -------------------------------------------------------------------------------- /algo/x17/x17-gate.c: -------------------------------------------------------------------------------- 1 | #include "x17-gate.h" 2 | 3 | bool register_x17_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (X17_4WAY) 6 | gate->scanhash = (void*)&scanhash_x17_4way; 7 | gate->hash = (void*)&x17_4way_hash; 8 | #else 9 | gate->scanhash = (void*)&scanhash_x17; 10 | gate->hash = (void*)&x17_hash; 11 | #endif 12 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 13 | return true; 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /algo/nist5/nist5-gate.c: -------------------------------------------------------------------------------- 1 | #include "nist5-gate.h" 2 | 3 | bool register_nist5_algo( algo_gate_t* gate ) 4 | { 5 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 6 | #if defined (NIST5_4WAY) 7 | gate->scanhash = (void*)&scanhash_nist5_4way; 8 | gate->hash = (void*)&nist5hash_4way; 9 | #else 10 | init_nist5_ctx(); 11 | gate->scanhash = (void*)&scanhash_nist5; 12 | gate->hash = (void*)&nist5hash; 13 | #endif 14 | return true; 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /algo/x15/x15-gate.c: -------------------------------------------------------------------------------- 1 | #include "x15-gate.h" 2 | 3 | bool register_x15_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (X15_4WAY) 6 | init_x15_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x15_4way; 8 | gate->hash = (void*)&x15_4way_hash; 9 | #else 10 | init_x15_ctx(); 11 | gate->scanhash = (void*)&scanhash_x15; 12 | gate->hash = (void*)&x15hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | return true; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /algo/qubit/deep-gate.c: -------------------------------------------------------------------------------- 1 | #include "deep-gate.h" 2 | 3 | bool register_deep_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (DEEP_2WAY) 6 | init_deep_2way_ctx(); 7 | gate->scanhash = (void*)&scanhash_deep_2way; 8 | gate->hash = (void*)&deep_2way_hash; 9 | #else 10 | init_deep_ctx(); 11 | gate->scanhash = (void*)&scanhash_deep; 12 | gate->hash = (void*)&deep_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | return true; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /algo/quark/anime-gate.c: -------------------------------------------------------------------------------- 1 | #include "anime-gate.h" 2 | 3 | bool register_anime_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (ANIME_4WAY) 6 | init_anime_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_anime_4way; 8 | gate->hash = (void*)&anime_4way_hash; 9 | #else 10 | init_anime_ctx(); 11 | gate->scanhash = (void*)&scanhash_anime; 12 | gate->hash = (void*)&anime_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | return true; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /algo/quark/quark-gate.c: -------------------------------------------------------------------------------- 1 | #include "quark-gate.h" 2 | 3 | bool register_quark_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (QUARK_4WAY) 6 | init_quark_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_quark_4way; 8 | gate->hash = (void*)&quark_4way_hash; 9 | #else 10 | init_quark_ctx(); 11 | gate->scanhash = (void*)&scanhash_quark; 12 | gate->hash = (void*)&quark_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | return true; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /algo/qubit/qubit-gate.c: -------------------------------------------------------------------------------- 1 | #include "qubit-gate.h" 2 | 3 | bool register_qubit_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (QUBIT_2WAY) 6 | init_qubit_2way_ctx(); 7 | gate->scanhash = (void*)&scanhash_qubit_2way; 8 | gate->hash = (void*)&qubit_2way_hash; 9 | #else 10 | init_qubit_ctx(); 11 | gate->scanhash = (void*)&scanhash_qubit; 12 | gate->hash = (void*)&qubit_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | return true; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /algo/whirlpool/whirlpool-gate.c: -------------------------------------------------------------------------------- 1 | #include "whirlpool-gate.h" 2 | 3 | bool register_whirlpool_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (WHIRLPOOL_4WAY) 6 | four_way_not_tested(); 7 | gate->optimizations = AVX2_OPT; 8 | gate->scanhash = (void*)&scanhash_whirlpool_4way; 9 | gate->hash = (void*)&whirlpool_hash_4way; 10 | #else 11 | gate->scanhash = (void*)&scanhash_whirlpool; 12 | gate->hash = (void*)&whirlpool_hash; 13 | init_whirlpool_ctx(); 14 | #endif 15 | return true; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /algo/blake/pentablake-gate.c: -------------------------------------------------------------------------------- 1 | #include "pentablake-gate.h" 2 | 3 | bool register_pentablake_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (PENTABLAKE_4WAY) 6 | gate->scanhash = (void*)&scanhash_pentablake_4way; 7 | gate->hash = (void*)&pentablakehash_4way; 8 | #else 9 | gate->scanhash = (void*)&scanhash_pentablake; 10 | gate->hash = (void*)&pentablakehash; 11 | #endif 12 | gate->optimizations = AVX2_OPT; 13 | gate->get_max64 = (void*)&get_max64_0x3ffff; 14 | return true; 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /algo/x11/c11-gate.c: -------------------------------------------------------------------------------- 1 | #include "c11-gate.h" 2 | 3 | bool register_c11_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (C11_4WAY) 6 | init_c11_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_c11_4way; 8 | gate->hash = (void*)&c11_4way_hash; 9 | #else 10 | init_c11_ctx(); 11 | gate->scanhash = (void*)&scanhash_c11; 12 | gate->hash = (void*)&c11_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/x11/x11-gate.c: -------------------------------------------------------------------------------- 1 | #include "x11-gate.h" 2 | 3 | bool register_x11_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (X11_4WAY) 6 | init_x11_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x11_4way; 8 | gate->hash = (void*)&x11_4way_hash; 9 | #else 10 | init_x11_ctx(); 11 | gate->scanhash = (void*)&scanhash_x11; 12 | gate->hash = (void*)&x11_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/x12/x12-gate.c: -------------------------------------------------------------------------------- 1 | #include "x12-gate.h" 2 | 3 | bool register_x12_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (X12_4WAY) 6 | init_x12_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x12_4way; 8 | gate->hash = (void*)&x12_4way_hash; 9 | #else 10 | init_x12_ctx(); 11 | gate->scanhash = (void*)&scanhash_x12; 12 | gate->hash = (void*)&x12hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/x13/x13-gate.c: -------------------------------------------------------------------------------- 1 | #include "x13-gate.h" 2 | 3 | bool register_x13_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (X13_4WAY) 6 | init_x13_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x13_4way; 8 | gate->hash = (void*)&x13_4way_hash; 9 | #else 10 | init_x13_ctx(); 11 | gate->scanhash = (void*)&scanhash_x13; 12 | gate->hash = (void*)&x13hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/x14/x14-gate.c: -------------------------------------------------------------------------------- 1 | #include "x14-gate.h" 2 | 3 | bool register_x14_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (X14_4WAY) 6 | init_x14_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x14_4way; 8 | gate->hash = (void*)&x14_4way_hash; 9 | #else 10 | init_x14_ctx(); 11 | gate->scanhash = (void*)&scanhash_x14; 12 | gate->hash = (void*)&x14hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /cpuminer-conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "_comment1" : "Any long-format command line argument ", 3 | "_comment2" : "may be used in this JSON configuration file", 4 | 5 | "api-bind" : "127.0.0.1:4048", 6 | 7 | "url" : "stratum+tcp://mine.xpool.ca:1131", 8 | "user" : "XeVrkPrWB7pDbdFLfKhF1Z3xpqhsx6wkH3", 9 | "pass" : "cpuminer", 10 | 11 | "algo" : "x11", 12 | "threads" : 0, 13 | "cpu-priority" : 0, 14 | "cpu-affinity" : -1, 15 | 16 | "benchmark" : false, 17 | "debug" : false, 18 | "protocol": false, 19 | "quiet" : false 20 | } 21 | -------------------------------------------------------------------------------- /algo/quark/hmq1725-gate.c: -------------------------------------------------------------------------------- 1 | #include "hmq1725-gate.h" 2 | 3 | bool register_hmq1725_algo( algo_gate_t* gate ) 4 | { 5 | #if defined(HMQ1725_4WAY) 6 | gate->scanhash = (void*)&scanhash_hmq1725_4way; 7 | gate->hash = (void*)&hmq1725_4way_hash; 8 | #else 9 | init_hmq1725_ctx(); 10 | gate->scanhash = (void*)&scanhash_hmq1725; 11 | gate->hash = (void*)&hmq1725hash; 12 | #endif 13 | gate->set_target = (void*)&scrypt_set_target; 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | return true; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /asm/aesb-x86.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if defined(__linux__) && defined(__ELF__) 4 | .section .note.GNU-stack,"",%progbits 5 | #endif 6 | 7 | .text 8 | .p2align 6 9 | .globl fast_aesb_single_round 10 | .globl _fast_aesb_single_round 11 | fast_aesb_single_round: 12 | _fast_aesb_single_round: 13 | ret 14 | 15 | .text 16 | .p2align 6 17 | .globl fast_aesb_pseudo_round_mut 18 | .globl _fast_aesb_pseudo_round_mut 19 | fast_aesb_pseudo_round_mut: 20 | _fast_aesb_pseudo_round_mut: 21 | ret 22 | -------------------------------------------------------------------------------- /algo/groestl/myrgr-gate.c: -------------------------------------------------------------------------------- 1 | #include "myrgr-gate.h" 2 | 3 | bool register_myriad_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (MYRGR_4WAY) 6 | init_myrgr_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_myriad_4way; 8 | gate->hash = (void*)&myriad_4way_hash; 9 | #else 10 | init_myrgr_ctx(); 11 | gate->scanhash = (void*)&scanhash_myriad; 12 | gate->hash = (void*)&myriad_hash; 13 | #endif 14 | gate->optimizations = AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/jh/jha-gate.c: -------------------------------------------------------------------------------- 1 | #include "jha-gate.h" 2 | 3 | 4 | bool register_jha_algo( algo_gate_t* gate ) 5 | { 6 | #if defined (JHA_4WAY) 7 | four_way_not_tested(); 8 | gate->scanhash = (void*)&scanhash_jha_4way; 9 | gate->hash = (void*)&jha_hash_4way; 10 | #else 11 | gate->scanhash = (void*)&scanhash_jha; 12 | gate->hash = (void*)&jha_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->set_target = (void*)&scrypt_set_target; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/x14/polytimos-gate.c: -------------------------------------------------------------------------------- 1 | #include "polytimos-gate.h" 2 | 3 | bool register_polytimos_algo( algo_gate_t* gate ) 4 | { 5 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 6 | #ifdef POLYTIMOS_4WAY 7 | gate->scanhash = (void*)&scanhash_polytimos_4way; 8 | gate->hash = (void*)&polytimos_4way_hash; 9 | #else 10 | init_polytimos_ctx(); 11 | gate->scanhash = (void*)&scanhash_polytimos; 12 | gate->hash = (void*)&polytimos_hash; 13 | #endif 14 | gate->get_max64 = (void*)&get_max64_0x3ffff; 15 | return true; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /algo/x17/sonoa-gate.c: -------------------------------------------------------------------------------- 1 | #include "sonoa-gate.h" 2 | 3 | bool register_sonoa_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (SONOA_4WAY) 6 | // init_sonoa_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_sonoa_4way; 8 | gate->hash = (void*)&sonoa_4way_hash; 9 | #else 10 | init_sonoa_ctx(); 11 | gate->scanhash = (void*)&scanhash_sonoa; 12 | gate->hash = (void*)&sonoa_hash; 13 | #endif 14 | gate->get_max64 = (void*)&get_max64_0x1ffff; 15 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/x14/veltor-gate.c: -------------------------------------------------------------------------------- 1 | #include "veltor-gate.h" 2 | 3 | bool register_veltor_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (VELTOR_4WAY) 6 | init_veltor_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_veltor_4way; 8 | gate->hash = (void*)&veltor_4way_hash; 9 | #else 10 | init_veltor_ctx(); 11 | gate->scanhash = (void*)&scanhash_veltor; 12 | gate->hash = (void*)&veltor_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/x11/x11gost-gate.c: -------------------------------------------------------------------------------- 1 | #include "x11gost-gate.h" 2 | 3 | bool register_x11gost_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (X11GOST_4WAY) 6 | init_x11gost_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x11gost_4way; 8 | gate->hash = (void*)&x11gost_4way_hash; 9 | #else 10 | init_x11gost_ctx(); 11 | gate->scanhash = (void*)&scanhash_x11gost; 12 | gate->hash = (void*)&x11gost_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/x13/phi1612-gate.c: -------------------------------------------------------------------------------- 1 | #include "phi1612-gate.h" 2 | 3 | bool register_phi1612_algo( algo_gate_t* gate ) 4 | { 5 | #if defined(PHI1612_4WAY) 6 | init_phi1612_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_phi1612_4way; 8 | gate->hash = (void*)&phi1612_4way_hash; 9 | #else 10 | init_phi1612_ctx(); 11 | gate->scanhash = (void*)&scanhash_phi1612; 12 | gate->hash = (void*)&phi1612_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/x13/skunk-gate.c: -------------------------------------------------------------------------------- 1 | #include "skunk-gate.h" 2 | 3 | bool register_skunk_algo( algo_gate_t* gate ) 4 | { 5 | gate->optimizations = SSE2_OPT | AVX2_OPT; 6 | #if defined (SKUNK_4WAY) 7 | gate->miner_thread_init = (void*)&skunk_4way_thread_init; 8 | gate->scanhash = (void*)&scanhash_skunk_4way; 9 | gate->hash = (void*)&skunk_4way_hash; 10 | // init_skunk_4way_ctx(); 11 | #else 12 | gate->miner_thread_init = (void*)&skunk_thread_init; 13 | gate->scanhash = (void*)&scanhash_skunk; 14 | gate->hash = (void*)&skunkhash; 15 | #endif 16 | return true; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /algo/skein/skein2-gate.c: -------------------------------------------------------------------------------- 1 | #include "skein2-gate.h" 2 | #include 3 | #include "sph_skein.h" 4 | 5 | int64_t skein2_get_max64 () 6 | { 7 | return 0x7ffffLL; 8 | } 9 | 10 | bool register_skein2_algo( algo_gate_t* gate ) 11 | { 12 | gate->optimizations = AVX2_OPT; 13 | #if defined (SKEIN2_4WAY) 14 | gate->scanhash = (void*)&scanhash_skein2_4way; 15 | gate->hash = (void*)&skein2hash_4way; 16 | #else 17 | gate->scanhash = (void*)&scanhash_skein2; 18 | gate->hash = (void*)&skein2hash; 19 | #endif 20 | gate->get_max64 = (void*)&skein2_get_max64; 21 | return true; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /algo/bmw/bmw512-gate.c: -------------------------------------------------------------------------------- 1 | #include "bmw512-gate.h" 2 | 3 | int64_t bmw512_get_max64() { return 0x7ffffLL; } 4 | 5 | bool register_bmw512_algo( algo_gate_t* gate ) 6 | { 7 | gate->optimizations = AVX2_OPT; 8 | gate->set_target = (void*)&alt_set_target; 9 | gate->get_max64 = (void*)&bmw512_get_max64; 10 | #if defined (BMW512_4WAY) 11 | gate->scanhash = (void*)&scanhash_bmw512_4way; 12 | gate->hash = (void*)&bmw512hash_4way; 13 | #else 14 | gate->scanhash = (void*)&scanhash_bmw512; 15 | gate->hash = (void*)&bmw512hash; 16 | #endif 17 | return true; 18 | }; 19 | 20 | 21 | -------------------------------------------------------------------------------- /algo/skein/skein-gate.c: -------------------------------------------------------------------------------- 1 | #include "skein-gate.h" 2 | #include "sph_skein.h" 3 | #include "skein-hash-4way.h" 4 | 5 | int64_t skein_get_max64() { return 0x7ffffLL; } 6 | 7 | bool register_skein_algo( algo_gate_t* gate ) 8 | { 9 | gate->optimizations = AVX2_OPT | SHA_OPT; 10 | #if defined (SKEIN_4WAY) 11 | gate->scanhash = (void*)&scanhash_skein_4way; 12 | gate->hash = (void*)&skeinhash_4way; 13 | #else 14 | gate->scanhash = (void*)&scanhash_skein; 15 | gate->hash = (void*)&skeinhash; 16 | #endif 17 | gate->get_max64 = (void*)&skein_get_max64; 18 | return true; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /algo/x11/tribus-gate.c: -------------------------------------------------------------------------------- 1 | #include "tribus-gate.h" 2 | 3 | bool register_tribus_algo( algo_gate_t* gate ) 4 | { 5 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 6 | gate->get_max64 = (void*)&get_max64_0x1ffff; 7 | #if defined (TRIBUS_4WAY) 8 | // init_tribus_4way_ctx(); 9 | gate->scanhash = (void*)&scanhash_tribus_4way; 10 | gate->hash = (void*)&tribus_hash_4way; 11 | #else 12 | gate->miner_thread_init = (void*)&tribus_thread_init; 13 | gate->scanhash = (void*)&scanhash_tribus; 14 | gate->hash = (void*)&tribus_hash; 15 | #endif 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/scryptjane/scrypt-conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | pick the best algo at runtime or compile time? 3 | ---------------------------------------------- 4 | SCRYPT_CHOOSE_COMPILETIME (gcc only!) 5 | SCRYPT_CHOOSE_RUNTIME 6 | */ 7 | #define SCRYPT_CHOOSE_RUNTIME 8 | 9 | 10 | /* 11 | hash function to use 12 | ------------------------------- 13 | SCRYPT_BLAKE256 14 | SCRYPT_BLAKE512 15 | SCRYPT_SHA256 16 | SCRYPT_SHA512 17 | SCRYPT_SKEIN512 18 | */ 19 | //#define SCRYPT_SHA256 20 | 21 | 22 | /* 23 | block mixer to use 24 | ----------------------------- 25 | SCRYPT_CHACHA 26 | SCRYPT_SALSA 27 | */ 28 | //#define SCRYPT_SALSA 29 | -------------------------------------------------------------------------------- /algo/blake/blake2b-gate.c: -------------------------------------------------------------------------------- 1 | #include "blake2b-gate.h" 2 | 3 | /* 4 | // changed to get_max64_0x3fffffLL in cpuminer-multi-decred 5 | int64_t blake2s_get_max64 () 6 | { 7 | return 0x7ffffLL; 8 | } 9 | */ 10 | 11 | bool register_blake2b_algo( algo_gate_t* gate ) 12 | { 13 | #if defined(BLAKE2B_4WAY) 14 | gate->scanhash = (void*)&scanhash_blake2b_4way; 15 | gate->hash = (void*)&blake2b_4way_hash; 16 | #else 17 | gate->scanhash = (void*)&scanhash_blake2b; 18 | gate->hash = (void*)&blake2b_hash; 19 | #endif 20 | // gate->get_max64 = (void*)&blake2s_get_max64; 21 | gate->optimizations = AVX2_OPT; 22 | return true; 23 | }; 24 | 25 | 26 | -------------------------------------------------------------------------------- /algo/hodl/wolf-aes.h: -------------------------------------------------------------------------------- 1 | #ifndef __WOLF_AES_H 2 | #define __WOLF_AES_H 3 | 4 | #include 5 | #include 6 | 7 | void ExpandAESKey256(__m128i *keys, const __m128i *KeyBuf); 8 | 9 | #if defined(__SSE4_2__) 10 | //#ifdef __AVX__ 11 | 12 | #define AES_PARALLEL_N 8 13 | #define BLOCK_COUNT 256 14 | 15 | void AES256CBC( __m128i** data, const __m128i** next, __m128i ExpandedKey[][16], 16 | __m128i* IV ); 17 | 18 | #else 19 | 20 | void AES256CBC( __m128i *Ciphertext, const __m128i *Plaintext, 21 | const __m128i *ExpandedKey, __m128i IV, uint32_t BlockCount ); 22 | 23 | #endif 24 | 25 | #endif // __WOLF_AES_H 26 | -------------------------------------------------------------------------------- /algo/blake/blake-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __BLAKE_GATE_H__ 2 | #define __BLAKE_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) 8 | #define BLAKE_4WAY 9 | #endif 10 | 11 | #if defined (BLAKE_4WAY) 12 | void blakehash_4way(void *state, const void *input); 13 | int scanhash_blake_4way( struct work *work, uint32_t max_nonce, 14 | uint64_t *hashes_done, struct thr_info *mythr ); 15 | #endif 16 | 17 | void blakehash( void *state, const void *input ); 18 | int scanhash_blake( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /crypto/c_keccak.h: -------------------------------------------------------------------------------- 1 | // keccak.h 2 | // 19-Nov-11 Markku-Juhani O. Saarinen 3 | 4 | #ifndef KECCAK_H 5 | #define KECCAK_H 6 | 7 | #include 8 | #include 9 | 10 | #ifndef KECCAK_ROUNDS 11 | #define KECCAK_ROUNDS 24 12 | #endif 13 | 14 | #ifndef ROTL64 15 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) 16 | #endif 17 | 18 | // compute a keccak hash (md) of given byte length from "in" 19 | int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen); 20 | 21 | // update the state 22 | void keccakf(uint64_t st[25], int norounds); 23 | 24 | void keccak1600(const uint8_t *in, int inlen, uint8_t *md); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /algo/skein/skein2-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __SKEIN2GATE_H__ 2 | #define __SKEIN2_GATE_H__ 3 | #include "algo-gate-api.h" 4 | #include 5 | 6 | #if defined(__AVX2__) 7 | #define SKEIN2_4WAY 8 | #endif 9 | 10 | #if defined(SKEIN2_4WAY) 11 | void skein2hash_4way( void *output, const void *input ); 12 | int scanhash_skein2_4way( struct work *work, uint32_t max_nonce, 13 | uint64_t* hashes_done, struct thr_info *mythr ); 14 | #endif 15 | 16 | void skein2hash( void *output, const void *input ); 17 | int scanhash_skein2( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /algo/bmw/bmw512-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef BMW512_GATE_H__ 2 | #define BMW512_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) 8 | #define BMW512_4WAY 1 9 | #endif 10 | 11 | #if defined(BMW512_4WAY) 12 | 13 | void bmw512hash_4way( void *state, const void *input ); 14 | int scanhash_bmw512_4way( struct work *work, uint32_t max_nonce, 15 | uint64_t *hashes_done, struct thr_info *mythr ); 16 | 17 | #endif 18 | 19 | void bmw512hash( void *state, const void *input ); 20 | int scanhash_bmw512( struct work *work, uint32_t max_nonce, 21 | uint64_t *hashes_done, struct thr_info *mythr ); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /algo/keccak/keccak-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef KECCAK_GATE_H__ 2 | #define KECCAK_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) 8 | #define KECCAK_4WAY 9 | #endif 10 | 11 | #if defined(KECCAK_4WAY) 12 | 13 | void keccakhash_4way( void *state, const void *input ); 14 | int scanhash_keccak_4way( struct work *work, uint32_t max_nonce, 15 | uint64_t *hashes_done, struct thr_info *mythr ); 16 | 17 | #endif 18 | 19 | void keccakhash( void *state, const void *input ); 20 | int scanhash_keccak( struct work *work, uint32_t max_nonce, 21 | uint64_t *hashes_done, struct thr_info *mythr ); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /algo/skein/skein-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __SKEIN_GATE_H__ 2 | #define __SKEIN_GATE_H__ 3 | #include 4 | #include "algo-gate-api.h" 5 | 6 | #if defined(__AVX2__) 7 | #define SKEIN_4WAY 8 | #endif 9 | 10 | #if defined(SKEIN_4WAY) 11 | 12 | void skeinhash_4way( void *output, const void *input ); 13 | 14 | int scanhash_skein_4way( struct work *work, uint32_t max_nonce, 15 | uint64_t *hashes_done, struct thr_info *mythr ); 16 | #endif 17 | 18 | void skeinhash( void *output, const void *input ); 19 | 20 | int scanhash_skein( struct work *work, uint32_t max_nonce, 21 | uint64_t *hashes_done, struct thr_info *mythr ); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /algo/blake/pentablake-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __PENTABLAKE_GATE_H__ 2 | #define __PENTABLAKE_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) 8 | #define PENTABLAKE_4WAY 9 | #endif 10 | 11 | #if defined(PENTABLAKE_4WAY) 12 | void pentablakehash_4way( void *state, const void *input ); 13 | int scanhash_pentablake_4way( struct work *work, 14 | uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ); 15 | #endif 16 | 17 | void pentablakehash( void *state, const void *input ); 18 | int scanhash_pentablake( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /algo/jh/jha-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef JHA_GATE_H__ 2 | #define JHA_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | 8 | #if defined(__AVX2__) && defined(__AES__) 9 | #define JHA_4WAY 10 | #endif 11 | 12 | #if defined JHA_4WAY 13 | void jha_hash_4way( void *state, const void *input ); 14 | 15 | int scanhash_jha_4way( struct work *work, uint32_t max_nonce, 16 | uint64_t *hashes_done, struct thr_info *mythr ); 17 | #endif 18 | 19 | void jha_hash( void *state, const void *input ); 20 | 21 | int scanhash_jha( struct work *work, uint32_t max_nonce, 22 | uint64_t *hashes_done, struct thr_info *mythr ); 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | minerd* 2 | cpuminer 3 | *.exe 4 | *.o 5 | *.d 6 | gmon.out 7 | 8 | autom4te.cache 9 | .deps 10 | 11 | Makefile 12 | Makefile.in 13 | INSTALL 14 | configure.lineno 15 | depcomp 16 | missing 17 | install-sh 18 | stamp-h1 19 | cpuminer-config.h* 20 | compile 21 | config.log 22 | config.status 23 | config.status.lineno 24 | config.guess 25 | config.sub 26 | 27 | mingw32-config.cache 28 | 29 | */.dirstamp 30 | */*/.dirstamp 31 | */*/*/.dirstamp 32 | *.iml 33 | 34 | *.vcxproj.user 35 | *.opensdf 36 | *.sdf 37 | *.suo 38 | Release/ 39 | Debug/ 40 | x64/Release/ 41 | x64/Debug/ 42 | *.pdb/ 43 | 44 | installer/ 45 | res/cpuminer.aps 46 | res/RC* 47 | sign/ 48 | sign.sh 49 | 50 | compat/curl-for-windows/ 51 | -------------------------------------------------------------------------------- /algo/sha/sha3-defs.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef DEFS_X5_H__ 3 | #define DEFS_X5_H__ 4 | #include 5 | typedef unsigned char BitSequence; 6 | typedef unsigned long long DataLength; 7 | typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHBITLEN = 2} HashReturn; 8 | 9 | typedef unsigned char uint8; 10 | typedef unsigned int uint32; 11 | typedef unsigned long long uint64; 12 | 13 | //typedef struct { 14 | // uint32 buffer[8]; /* Buffer to be hashed */ 15 | // __m128i chainv[10]; /* Chaining values */ 16 | // uint64 bitlen[2]; /* Message length in bits */ 17 | // uint32 rembitlen; /* Length of buffer data to be hashed */ 18 | // int hashbitlen; 19 | //} hashState_luffa; 20 | 21 | typedef unsigned char byte; 22 | #endif 23 | -------------------------------------------------------------------------------- /algo/groestl/aes_ni/README: -------------------------------------------------------------------------------- 1 | This package contains an implementation of the Groestl-512 hash 2 | function optimized for the Intel AES instructions. 3 | 4 | Authors are Krystian Matusiewicz, Günther A. Roland, Martin Schläffer 5 | 6 | There are no known present or future claims by a copyright holder that 7 | the distribution of this software infringes the copyright. In 8 | particular, the author of the software is not making such claims and 9 | does not intend to make such claims. 10 | 11 | Moreover, there are no known present or future claims by a patent 12 | holder that the use of this software infringes the patent. In 13 | particular, the author of the software is not making such claims and 14 | does not intend to make such claims. 15 | -------------------------------------------------------------------------------- /algo/x17/x17-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X17_GATE_H__ 2 | #define X17_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define X17_4WAY 9 | #endif 10 | 11 | bool register_x17_algo( algo_gate_t* gate ); 12 | 13 | #if defined(X17_4WAY) 14 | 15 | void x17_4way_hash( void *state, const void *input ); 16 | int scanhash_x17_4way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | 19 | #endif 20 | 21 | void x17_hash( void *state, const void *input ); 22 | int scanhash_x17( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /algo/nist5/nist5-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __NIST5_GATE_H__ 2 | #define __NIST5_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define NIST5_4WAY 9 | #endif 10 | 11 | #if defined(NIST5_4WAY) 12 | 13 | void nist5hash_4way( void *state, const void *input ); 14 | 15 | int scanhash_nist5_4way( struct work *work, uint32_t max_nonce, 16 | uint64_t *hashes_done, struct thr_info *mythr ); 17 | 18 | #else 19 | 20 | void nist5hash( void *state, const void *input ); 21 | 22 | int scanhash_nist5( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | void init_nist5_ctx(); 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /algo/x17/xevan-gate.c: -------------------------------------------------------------------------------- 1 | #include "xevan-gate.h" 2 | 3 | void xevan_set_target( struct work* work, double job_diff ) 4 | { 5 | work_set_target( work, job_diff / (256.0 * opt_diff_factor) ); 6 | } 7 | 8 | bool register_xevan_algo( algo_gate_t* gate ) 9 | { 10 | #if defined (XEVAN_4WAY) 11 | // init_xevan_4way_ctx(); 12 | gate->scanhash = (void*)&scanhash_xevan_4way; 13 | gate->hash = (void*)&xevan_4way_hash; 14 | #else 15 | init_xevan_ctx(); 16 | gate->scanhash = (void*)&scanhash_xevan; 17 | gate->hash = (void*)&xevan_hash; 18 | #endif 19 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 20 | gate->set_target = (void*)&xevan_set_target; 21 | gate->get_max64 = (void*)&get_max64_0xffffLL; 22 | return true; 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /algo/blake/blake2b-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __BLAKE2B_GATE_H__ 2 | #define __BLAKE2B_GATE_H__ 1 3 | 4 | #include 5 | #include "algo-gate-api.h" 6 | 7 | #if defined(__AVX2__) 8 | #define BLAKE2B_4WAY 9 | #endif 10 | 11 | bool register_blake2b_algo( algo_gate_t* gate ); 12 | 13 | #if defined(BLAKE2B_4WAY) 14 | 15 | void blake2b_4way_hash( void *state, const void *input ); 16 | int scanhash_blake2b_4way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | #else 19 | 20 | void blake2b_hash( void *state, const void *input ); 21 | int scanhash_blake2b( struct work *work, uint32_t max_nonce, 22 | uint64_t *hashes_done, struct thr_info *mythr ); 23 | 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /crypto/hash.c: -------------------------------------------------------------------------------- 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 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "hash-ops.h" 10 | #include "c_keccak.h" 11 | 12 | void hash_permutation(union hash_state *state) { 13 | keccakf((uint64_t*)state, 24); 14 | } 15 | 16 | void hash_process(union hash_state *state, const uint8_t *buf, int count) { 17 | keccak1600(buf, count, (uint8_t*)state); 18 | } 19 | 20 | void cn_fast_hash(const void *data, int len, char *hash) { 21 | union hash_state state; 22 | hash_process(&state, data, len); 23 | memcpy(hash, &state, HASH_SIZE); 24 | } 25 | -------------------------------------------------------------------------------- /algo/blake/blake-gate.c: -------------------------------------------------------------------------------- 1 | #include "blake-gate.h" 2 | 3 | int64_t blake_get_max64 () 4 | { 5 | return 0x7ffffLL; 6 | } 7 | 8 | bool register_blake_algo( algo_gate_t* gate ) 9 | { 10 | gate->optimizations = AVX2_OPT; 11 | gate->get_max64 = (void*)&blake_get_max64; 12 | //#if defined (__AVX2__) && defined (FOUR_WAY) 13 | // gate->optimizations = SSE2_OPT | AVX2_OPT; 14 | // gate->scanhash = (void*)&scanhash_blake_8way; 15 | // gate->hash = (void*)&blakehash_8way; 16 | #if defined(BLAKE_4WAY) 17 | four_way_not_tested(); 18 | gate->scanhash = (void*)&scanhash_blake_4way; 19 | gate->hash = (void*)&blakehash_4way; 20 | #else 21 | gate->scanhash = (void*)&scanhash_blake; 22 | gate->hash = (void*)&blakehash; 23 | #endif 24 | return true; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /algo/sha/sha3_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * file : sha3_common.h 3 | * version : 1.0.208 4 | * date : 14.12.2010 5 | * 6 | * Common declarations 7 | * 8 | * Cagdas Calik 9 | * ccalik@metu.edu.tr 10 | * Institute of Applied Mathematics, Middle East Technical University, Turkey. 11 | * 12 | */ 13 | #include "sha3-defs.h" 14 | #ifndef SHA3_COMMON_H 15 | #define SHA3_COMMON_H 16 | 17 | 18 | #ifdef __GNUC__ 19 | #define MYALIGN __attribute__((aligned(16))) 20 | #else 21 | #define MYALIGN __declspec(align(16)) 22 | #endif 23 | 24 | #define M128(x) *((__m128i*)x) 25 | 26 | 27 | //typedef unsigned char BitSequence; 28 | //typedef unsigned long long DataLength; 29 | //typedef enum {SUCCESS = 0, FAIL = 1, BAD_HASHBITLEN = 2} HashReturn; 30 | 31 | #endif // SHA3_COMMON_H 32 | -------------------------------------------------------------------------------- /algo/blake/blake2s-gate.c: -------------------------------------------------------------------------------- 1 | #include "blake2s-gate.h" 2 | 3 | 4 | // changed to get_max64_0x3fffffLL in cpuminer-multi-decred 5 | int64_t blake2s_get_max64 () 6 | { 7 | return 0x7ffffLL; 8 | } 9 | 10 | bool register_blake2s_algo( algo_gate_t* gate ) 11 | { 12 | #if defined(BLAKE2S_8WAY) 13 | gate->scanhash = (void*)&scanhash_blake2s_8way; 14 | gate->hash = (void*)&blake2s_8way_hash; 15 | #elif defined(BLAKE2S_4WAY) 16 | gate->scanhash = (void*)&scanhash_blake2s_4way; 17 | gate->hash = (void*)&blake2s_4way_hash; 18 | #else 19 | gate->scanhash = (void*)&scanhash_blake2s; 20 | gate->hash = (void*)&blake2s_hash; 21 | #endif 22 | gate->get_max64 = (void*)&blake2s_get_max64; 23 | gate->optimizations = SSE2_OPT | AVX2_OPT; 24 | return true; 25 | }; 26 | 27 | 28 | -------------------------------------------------------------------------------- /algo/x14/x14-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X14_GATE_H__ 2 | #define X14_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define X14_4WAY 9 | #endif 10 | 11 | bool register_x14_algo( algo_gate_t* gate ); 12 | 13 | #if defined(X14_4WAY) 14 | 15 | void x14_4way_hash( void *state, const void *input ); 16 | int scanhash_x14_4way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | void init_x14_4way_ctx(); 19 | 20 | #endif 21 | 22 | void x14hash( void *state, const void *input ); 23 | int scanhash_x14( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_x14_ctx(); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /algo/x15/x15-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X15_GATE_H__ 2 | #define X15_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define X15_4WAY 9 | #endif 10 | 11 | bool register_x15_algo( algo_gate_t* gate ); 12 | 13 | #if defined(X15_4WAY) 14 | 15 | void x15_4way_hash( void *state, const void *input ); 16 | int scanhash_x15_4way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | void init_x15_4way_ctx(); 19 | 20 | #endif 21 | 22 | void x15hash( void *state, const void *input ); 23 | int scanhash_x15( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_x15_ctx(); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /compat/winansi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ANSI emulation wrappers 3 | */ 4 | #ifdef WIN32 5 | #include 6 | #include 7 | #include 8 | 9 | #define isatty(fd) _isatty(fd) 10 | #define fileno(fd) _fileno(fd) 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | int winansi_fputs(const char *str, FILE *stream); 16 | int winansi_printf(const char *format, ...); 17 | int winansi_fprintf(FILE *stream, const char *format, ...); 18 | int winansi_vfprintf(FILE *stream, const char *format, va_list list); 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #undef fputs 24 | #undef fprintf 25 | #undef vfprintf 26 | 27 | #define fputs winansi_fputs 28 | #define printf winansi_printf 29 | #define fprintf winansi_fprintf 30 | #define vfprintf winansi_vfprintf 31 | 32 | #endif -------------------------------------------------------------------------------- /crypto/c_jh.h: -------------------------------------------------------------------------------- 1 | /*This program gives the 64-bit optimized bitslice implementation of JH using ANSI C 2 | 3 | -------------------------------- 4 | Performance 5 | 6 | Microprocessor: Intel CORE 2 processor (Core 2 Duo Mobile T6600 2.2GHz) 7 | Operating System: 64-bit Ubuntu 10.04 (Linux kernel 2.6.32-22-generic) 8 | Speed for long message: 9 | 1) 45.8 cycles/byte compiler: Intel C++ Compiler 11.1 compilation option: icc -O2 10 | 2) 56.8 cycles/byte compiler: gcc 4.4.3 compilation option: gcc -O3 11 | 12 | -------------------------------- 13 | Last Modified: January 16, 2011 14 | */ 15 | #pragma once 16 | 17 | #include "hash.h" 18 | 19 | HashReturn jh_hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval); 20 | -------------------------------------------------------------------------------- /algo/groestl/myrgr-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef MYRGR_GATE_H__ 2 | #define MYRGR_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) && !defined(__SHA__) 8 | #define MYRGR_4WAY 9 | #endif 10 | 11 | #if defined(MYRGR_4WAY) 12 | 13 | void myriad_4way_hash( void *state, const void *input ); 14 | 15 | int scanhash_myriad_4way( struct work *work, uint32_t max_nonce, 16 | uint64_t *hashes_done, struct thr_info *mythr ); 17 | 18 | void init_myrgr_4way_ctx(); 19 | 20 | #endif 21 | 22 | void myriad_hash( void *state, const void *input ); 23 | 24 | int scanhash_myriad( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | 27 | void init_myrgr_ctx(); 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /algo/qubit/deep-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef DEEP_GATE_H__ 2 | #define DEEP_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define DEEP_2WAY 9 | #endif 10 | 11 | bool register_deep_algo( algo_gate_t* gate ); 12 | 13 | #if defined(DEEP_2WAY) 14 | 15 | void deep_2way_hash( void *state, const void *input ); 16 | int scanhash_deep_2way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | void init_deep_2way_ctx(); 19 | 20 | #endif 21 | 22 | void deep_hash( void *state, const void *input ); 23 | int scanhash_deep( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_deep_ctx(); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /algo/whirlpool/whirlpool-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef WHIRLPOOL_GATE_H__ 2 | #define WHIRLPOOL_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | /* 8 | #if defined(FOUR_WAY) && defined(__AVX2__) 9 | #define WHIRLPOOL_4WAY 10 | #endif 11 | */ 12 | 13 | #if defined (WHIRLPOOL_4WAY) 14 | 15 | void whirlpool_hash_4way(void *state, const void *input); 16 | 17 | int scanhash_whirlpool_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | #else 20 | 21 | void whirlpool_hash( void *state, const void *input ); 22 | 23 | int scanhash_whirlpool( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_whirlpool_ctx(); 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /algo/x11/tribus-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef TRIBUS_GATE_H__ 2 | #define TRIBUS_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define TRIBUS_4WAY 9 | #endif 10 | 11 | #if defined(TRIBUS_4WAY) 12 | 13 | //void init_tribus_4way_ctx(); 14 | 15 | void tribus_hash_4way( void *state, const void *input ); 16 | 17 | int scanhash_tribus_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | #else 21 | 22 | void tribus_hash( void *state, const void *input ); 23 | 24 | int scanhash_tribus( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | 27 | bool tribus_thread_init(); 28 | 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /algo/x12/x12-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X12_GATE_H__ 2 | #define X12_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define X12_4WAY 9 | #endif 10 | 11 | bool register_x12_algo( algo_gate_t* gate ); 12 | 13 | #if defined(X12_4WAY) 14 | 15 | void x12_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_x12_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | void init_x12_4way_ctx(); 21 | 22 | #endif 23 | 24 | void x12hash( void *state, const void *input ); 25 | 26 | int scanhash_x12( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | void init_x12_ctx(); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /algo/x13/x13-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X13_GATE_H__ 2 | #define X13_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define X13_4WAY 9 | #endif 10 | 11 | bool register_x13_algo( algo_gate_t* gate ); 12 | 13 | #if defined(X13_4WAY) 14 | 15 | void x13_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_x13_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | void init_x13_4way_ctx(); 21 | 22 | #endif 23 | 24 | void x13hash( void *state, const void *input ); 25 | 26 | int scanhash_x13( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | void init_x13_ctx(); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /algo/quark/anime-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIME_GATE_H__ 2 | #define ANIME_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define ANIME_4WAY 9 | #endif 10 | 11 | bool register_anime_algo( algo_gate_t* gate ); 12 | 13 | #if defined(ANIME_4WAY) 14 | 15 | void anime_4way_hash( void *state, const void *input ); 16 | int scanhash_anime_4way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | void init_anime_4way_ctx(); 19 | 20 | #endif 21 | 22 | void anime_hash( void *state, const void *input ); 23 | int scanhash_anime( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_anime_ctx(); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /algo/quark/quark-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef QUARK_GATE_H__ 2 | #define QUARK_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define QUARK_4WAY 9 | #endif 10 | 11 | bool register_quark_algo( algo_gate_t* gate ); 12 | 13 | #if defined(QUARK_4WAY) 14 | 15 | void quark_4way_hash( void *state, const void *input ); 16 | int scanhash_quark_4way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | void init_quark_4way_ctx(); 19 | 20 | #endif 21 | 22 | void quark_hash( void *state, const void *input ); 23 | int scanhash_quark( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_quark_ctx(); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /algo/qubit/qubit-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef QUBIT_GATE_H__ 2 | #define QUBIT_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define QUBIT_2WAY 9 | #endif 10 | 11 | bool register_qubit_algo( algo_gate_t* gate ); 12 | 13 | #if defined(QUBIT_2WAY) 14 | 15 | void qubit_2way_hash( void *state, const void *input ); 16 | int scanhash_qubit_2way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | void init_qubit_2way_ctx(); 19 | 20 | #endif 21 | 22 | void qubit_hash( void *state, const void *input ); 23 | int scanhash_qubit( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_qubit_ctx(); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /algo/x11/c11-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef C11_GATE_H__ 2 | #define C11_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define C11_4WAY 9 | #endif 10 | 11 | bool register_c11_algo( algo_gate_t* gate ); 12 | 13 | #if defined(C11_4WAY) 14 | 15 | void c11_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_c11_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | void init_c11_4way_ctx(); 21 | 22 | #endif 23 | 24 | void c11_hash( void *state, const void *input ); 25 | 26 | int scanhash_c11( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | void init_c11_ctx(); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /algo/x11/x11-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X11_GATE_H__ 2 | #define X11_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define X11_4WAY 9 | #endif 10 | 11 | bool register_x11_algo( algo_gate_t* gate ); 12 | 13 | #if defined(X11_4WAY) 14 | 15 | void x11_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_x11_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | void init_x11_4way_ctx(); 21 | 22 | #endif 23 | 24 | void x11_hash( void *state, const void *input ); 25 | 26 | int scanhash_x11( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | void init_x11_ctx(); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /algo/x14/polytimos-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef POLYTIMOS_GATE_H__ 2 | #define POLYTIMOS_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define POLYTIMOS_4WAY 9 | #endif 10 | 11 | bool register_polytimos_algo( algo_gate_t* gate ); 12 | 13 | #if defined(POLYTIMOS_4WAY) 14 | 15 | void polytimos_4way_hash( void *state, const void *input ); 16 | int scanhash_polytimos_4way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | 19 | #endif 20 | 21 | void polytimos_hash( void *state, const void *input ); 22 | int scanhash_polytimos( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | void init_polytimos_ctx(); 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /algo/x17/xevan-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef XEVAN_GATE_H__ 2 | #define XEVAN_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define XEVAN_4WAY 9 | #endif 10 | 11 | bool register_xevan_algo( algo_gate_t* gate ); 12 | 13 | #if defined(XEVAN_4WAY) 14 | 15 | void xevan_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_xevan_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | //void init_xevan_4way_ctx(); 21 | 22 | #endif 23 | 24 | void xevan_hash( void *state, const void *input ); 25 | 26 | int scanhash_xevan( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | void init_xevan_ctx(); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /algo/quark/hmq1725-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef HMQ1725_GATE_H__ 2 | #define HMQ1725_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | // #define HMQ1725_4WAY 9 | #endif 10 | 11 | bool register_hmq1725_algo( algo_gate_t* gate ); 12 | 13 | #if defined(HMQ1725_4WAY) 14 | 15 | void hmq1725_4way_hash( void *state, const void *input ); 16 | int scanhash_hmq1725_4way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | 19 | #else 20 | 21 | void hmq1725hash( void *state, const void *input ); 22 | int scanhash_hmq1725( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | void init_hmq1725_ctx(); 25 | 26 | #endif 27 | 28 | #endif // HMQ1725_GATE_H__ 29 | -------------------------------------------------------------------------------- /algo/x17/sonoa-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef SONOA_GATE_H__ 2 | #define SONOA_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define SONOA_4WAY 9 | #endif 10 | 11 | bool register_sonoa_algo( algo_gate_t* gate ); 12 | 13 | #if defined(SONOA_4WAY) 14 | 15 | void sonoa_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_sonoa_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | //void init_sonoa_4way_ctx(); 21 | 22 | #endif 23 | 24 | void sonoa_hash( void *state, const void *input ); 25 | 26 | int scanhash_sonoa( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | void init_sonoa_ctx(); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /algo/x14/veltor-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef VELTOR_GATE_H__ 2 | #define VELTOR_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define VELTOR_4WAY 9 | #endif 10 | 11 | bool register_veltor_algo( algo_gate_t* gate ); 12 | 13 | #if defined(VELTOR_4WAY) 14 | 15 | void veltor_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_veltor_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | void init_veltor_4way_ctx(); 21 | 22 | #endif 23 | 24 | void veltor_hash( void *state, const void *input ); 25 | 26 | int scanhash_veltor( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | void init_veltor_ctx(); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /algo/x13/skunk-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef SKUNK_GATE_H__ 2 | #define SKUNK_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) 8 | #define SKUNK_4WAY 9 | #endif 10 | 11 | bool register_skunk_algo( algo_gate_t* gate ); 12 | 13 | #if defined(SKUNK_4WAY) 14 | 15 | void skunk_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_skunk_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | bool skunk_4way_thread_init(); 21 | //void init_skunk_4way_ctx(); 22 | 23 | #endif 24 | 25 | void skunkhash( void *state, const void *input ); 26 | 27 | int scanhash_skunk( struct work *work, uint32_t max_nonce, 28 | uint64_t *hashes_done, struct thr_info *mythr ); 29 | 30 | bool skunk_thread_init(); 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /algo/x11/x11gost-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X11GOST_GATE_H__ 2 | #define X11GOST_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define X11GOST_4WAY 9 | #endif 10 | 11 | bool register_x11gost_algo( algo_gate_t* gate ); 12 | 13 | #if defined(X11GOST_4WAY) 14 | 15 | void x11gost_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_x11gost_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | void init_x11gost_4way_ctx(); 21 | 22 | #endif 23 | 24 | void x11gost_hash( void *state, const void *input ); 25 | 26 | int scanhash_x11gost( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | void init_x11gost_ctx(); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /algo/shavite/shavite-hash-2way.h: -------------------------------------------------------------------------------- 1 | #ifndef SHAVITE_HASH_2WAY_H__ 2 | #define SHAVITE_HASH_2WAY_H__ 3 | 4 | #if defined(__AVX2__) 5 | 6 | #include "simd-utils.h" 7 | 8 | typedef struct { 9 | unsigned char buf[128<<1]; 10 | uint32_t h[16<<1]; 11 | size_t ptr; 12 | uint32_t count0, count1, count2, count3; 13 | } shavite512_2way_context __attribute__ ((aligned (64))); 14 | 15 | void shavite512_2way_init( shavite512_2way_context *ctx ); 16 | void shavite512_2way_update( shavite512_2way_context *ctx, const void *data, 17 | size_t len ); 18 | void shavite512_2way_close( shavite512_2way_context *ctx, void *dst ); 19 | void shavite512_2way_update_close( shavite512_2way_context *ctx, void *dst, 20 | const void *data, size_t len ); 21 | 22 | #endif // AVX2 23 | 24 | #endif // SHAVITE_HASH_2WAY_H__ 25 | 26 | -------------------------------------------------------------------------------- /algo/x13/phi1612-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef PHI1612_GATE_H__ 2 | #define PHI1612_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define PHI1612_4WAY 9 | #endif 10 | 11 | bool register_phi1612_algo( algo_gate_t* gate ); 12 | 13 | #if defined(PHI1612_4WAY) 14 | 15 | void phi1612_4way_hash( void *state, const void *input ); 16 | 17 | int scanhash_phi1612_4way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | void init_phi1612_4way_ctx(); 21 | 22 | #endif 23 | 24 | void phi1612_hash( void *state, const void *input ); 25 | 26 | int scanhash_phi1612( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | void init_phi1612_ctx(); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /algo/simd/simd-hash-2way.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMD_HASH_2WAY_H__ 2 | #define SIMD_HASH_2WAY_H__ 1 3 | 4 | #include "simd-compat.h" 5 | 6 | #if defined(__AVX2__) 7 | 8 | #include "simd-utils.h" 9 | 10 | typedef struct { 11 | uint32_t A[ 32*2 ] __attribute__((aligned(64))); 12 | uint8_t buffer[ 128*2 ] __attribute__((aligned(64))); 13 | uint64_t count; 14 | unsigned int hashbitlen; 15 | unsigned int blocksize; 16 | unsigned int n_feistels; 17 | 18 | } simd_2way_context; 19 | 20 | int simd_2way_init( simd_2way_context *state, int hashbitlen ); 21 | int simd_2way_update( simd_2way_context *state, const void *data, 22 | int databitlen ); 23 | int simd_2way_close( simd_2way_context *state, void *hashval ); 24 | int simd_2way_update_close( simd_2way_context *state, void *hashval, 25 | const void *data, int databitlen ); 26 | #endif 27 | #endif 28 | -------------------------------------------------------------------------------- /algo/hodl/hodl-wolf.h: -------------------------------------------------------------------------------- 1 | #ifndef __HODL_H 2 | #define __HODL_H 3 | 4 | #include 5 | #include 6 | #include "miner.h" 7 | 8 | #define AES_ITERATIONS 15 9 | 10 | #define GARBAGE_SIZE (1 << 30) 11 | #define GARBAGE_CHUNK_SIZE (1 << 6) 12 | #define GARBAGE_SLICE_SIZE (1 << 12) 13 | #define TOTAL_CHUNKS (1 << 24) // GARBAGE_SIZE / GARBAGE_CHUNK_SIZE 14 | #define COMPARE_SIZE (1 << 18) // GARBAGE_SIZE / GARBAGE_SLICE_SIZE 15 | 16 | typedef union _CacheEntry 17 | { 18 | uint32_t dwords[GARBAGE_SLICE_SIZE >> 2] __attribute__((aligned(16))); 19 | __m128i dqwords[GARBAGE_SLICE_SIZE >> 4] __attribute__((aligned(16))); 20 | } CacheEntry; 21 | 22 | int scanhash_hodl_wolf( struct work* work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | 25 | void GenRandomGarbage( CacheEntry *Garbage, uint32_t *pdata, int thr_id); 26 | 27 | #endif // __HODL_H 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Dockerfile for cpuminer-opt 3 | # usage: docker build -t cpuminer-opt:latest . 4 | # run: docker run -it --rm cpuminer-opt:latest [ARGS] 5 | # ex: docker run -it --rm cpuminer-opt:latest -a cryptonight -o cryptonight.eu.nicehash.com:3355 -u 1MiningDW2GKzf4VQfmp4q2XoUvR6iy6PD.worker1 -p x -t 3 6 | # 7 | 8 | # Build 9 | FROM ubuntu:16.04 as builder 10 | 11 | RUN apt-get update \ 12 | && apt-get install -y \ 13 | build-essential \ 14 | libssl-dev \ 15 | libgmp-dev \ 16 | libcurl4-openssl-dev \ 17 | libjansson-dev \ 18 | automake \ 19 | && rm -rf /var/lib/apt/lists/* 20 | 21 | COPY . /app/ 22 | RUN cd /app/ && ./build.sh 23 | 24 | # App 25 | FROM ubuntu:16.04 26 | 27 | RUN apt-get update \ 28 | && apt-get install -y \ 29 | libcurl3 \ 30 | libjansson4 \ 31 | && rm -rf /var/lib/apt/lists/* 32 | 33 | COPY --from=builder /app/cpuminer . 34 | ENTRYPOINT ["./cpuminer"] 35 | CMD ["-h"] 36 | -------------------------------------------------------------------------------- /uint256.cpp: -------------------------------------------------------------------------------- 1 | #include "uint256.h" 2 | 3 | #ifdef __cplusplus 4 | extern "C"{ 5 | #endif 6 | 7 | #include "miner.h" 8 | 9 | // compute the diff ratio between a found hash and the target 10 | double hash_target_ratio(uint32_t* hash, uint32_t* target) 11 | { 12 | uint256 h, t; 13 | double dhash; 14 | 15 | if (!opt_showdiff) 16 | return 0.0; 17 | 18 | memcpy(&t, (void*) target, 32); 19 | memcpy(&h, (void*) hash, 32); 20 | 21 | dhash = h.getdouble(); 22 | if (dhash > 0.) 23 | return t.getdouble() / dhash; 24 | else 25 | return dhash; 26 | } 27 | 28 | // store ratio in work struct 29 | void work_set_target_ratio( struct work* work, uint32_t* hash ) 30 | { 31 | // only if the option is enabled (to reduce cpu usage) 32 | if (opt_showdiff) { 33 | work->shareratio = hash_target_ratio(hash, work->target); 34 | work->sharediff = work->targetdiff * work->shareratio; 35 | } 36 | } 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /mingw64.sh: -------------------------------------------------------------------------------- 1 | ./autogen.sh 2 | 3 | CURL_PREFIX=/usr/local 4 | SSL_PREFIX=/usr/local/ssl 5 | 6 | # gcc 4.4 7 | extracflags="-O3 -Wall -D_REENTRANT -fmerge-all-constants" # -funroll-loops -fvariable-expansion-in-unroller -fbranch-target-load-optimize2 -fsched2-use-superblocks -falign-loops=16 -falign-functions=16 -falign-jumps=16 -falign-labels=16" 8 | 9 | # gcc 4.8+ 10 | # extracflags="$extracflags -Ofast -fuse-linker-plugin -ftree-loop-if-convert-stores" # -flto " 11 | 12 | # extracflags="-pg -static -fno-inline-small-functions" 13 | CFLAGS="-DCURL_STATICLIB -DOPENSSL_NO_ASM -DUSE_ASM $extracflags" 14 | # CPPFLAGS="" 15 | 16 | # icon 17 | windres res/icon.rc icon.o 18 | 19 | ./configure --build=x86_64-w64-mingw32 --with-crypto=$SSL_PREFIX --with-curl=$CURL_PREFIX \ 20 | CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="icon.o" 21 | 22 | make 23 | 24 | strip -p --strip-debug --strip-unneeded cpuminer.exe 25 | 26 | if [ -e sign.sh ] ; then 27 | . sign.sh 28 | fi 29 | 30 | -------------------------------------------------------------------------------- /algo/blake/blake2b-hash-4way.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __BLAKE2B_HASH_4WAY_H__ 3 | #define __BLAKE2B_HASH_4WAY_H__ 4 | 5 | #if defined(__AVX2__) 6 | 7 | #include "simd-utils.h" 8 | #include 9 | #include 10 | 11 | #if defined(_MSC_VER) 12 | #include 13 | #define inline __inline 14 | #define ALIGN(x) __declspec(align(x)) 15 | #else 16 | #define ALIGN(x) __attribute__((aligned(x))) 17 | #endif 18 | 19 | // state context 20 | ALIGN(64) typedef struct { 21 | __m256i b[16]; // input buffer 22 | __m256i h[8]; // chained state 23 | uint64_t t[2]; // total number of bytes 24 | size_t c; // pointer for b[] 25 | size_t outlen; // digest size 26 | } blake2b_4way_ctx __attribute__((aligned(64))); 27 | 28 | int blake2b_4way_init( blake2b_4way_ctx *ctx ); 29 | void blake2b_4way_update( blake2b_4way_ctx *ctx, const void *input, 30 | size_t inlen ); 31 | void blake2b_4way_final( blake2b_4way_ctx *ctx, void *out ); 32 | 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /algo/x11/x11evo-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X11EVO_GATE_H__ 2 | #define X11EVO_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define X11EVO_4WAY 9 | #endif 10 | 11 | #define X11EVO_INITIAL_DATE 1462060800 12 | #define X11EVO_FUNC_COUNT 11 13 | 14 | extern int s_seq; 15 | 16 | bool register_x11evo_algo( algo_gate_t* gate ); 17 | 18 | #if defined(X11EVO_4WAY) 19 | 20 | void x11evo_4way_hash( void *state, const void *input ); 21 | 22 | int scanhash_x11evo_4way( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | 25 | void init_x11evo_4way_ctx(); 26 | 27 | #endif 28 | 29 | void x11evo_hash( void *state, const void *input ); 30 | 31 | int scanhash_x11evo( struct work *work, uint32_t max_nonce, 32 | uint64_t *hashes_done, struct thr_info *mythr ); 33 | 34 | void init_x11evo_ctx(); 35 | 36 | void evo_twisted_code( uint32_t ntime, char *permstr ); 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /algo/blake/blakecoin-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __BLAKECOIN_GATE_H__ 2 | #define __BLAKECOIN_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__SSE4_2__) 8 | #define BLAKECOIN_4WAY 9 | #endif 10 | #if defined(__AVX2__) 11 | #define BLAKECOIN_8WAY 12 | #endif 13 | 14 | #if defined (BLAKECOIN_8WAY) 15 | void blakecoin_8way_hash(void *state, const void *input); 16 | int scanhash_blakecoin_8way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | #endif 19 | 20 | #if defined (BLAKECOIN_4WAY) 21 | void blakecoin_4way_hash(void *state, const void *input); 22 | int scanhash_blakecoin_4way( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | #endif 25 | 26 | void blakecoinhash( void *state, const void *input ); 27 | int scanhash_blakecoin( struct work *work, uint32_t max_nonce, 28 | uint64_t *hashes_done, struct thr_info *mythr ); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /algo/scryptjane/scrypt-jane-mix_salsa64.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA64_INCLUDED) 2 | 3 | #undef SCRYPT_MIX 4 | #define SCRYPT_MIX "Salsa64/8 Ref" 5 | 6 | #undef SCRYPT_SALSA64_INCLUDED 7 | #define SCRYPT_SALSA64_INCLUDED 8 | #define SCRYPT_SALSA64_BASIC 9 | 10 | static void 11 | salsa64_core_basic(uint64_t state[16]) { 12 | const size_t rounds = 8; 13 | uint64_t v[16], t; 14 | size_t i; 15 | 16 | for (i = 0; i < 16; i++) v[i] = state[i]; 17 | 18 | #define G(a,b,c,d) \ 19 | t = v[a]+v[d]; t = ROTL64(t, 32); v[b] ^= t; \ 20 | t = v[b]+v[a]; t = ROTL64(t, 13); v[c] ^= t; \ 21 | t = v[c]+v[b]; t = ROTL64(t, 39); v[d] ^= t; \ 22 | t = v[d]+v[c]; t = ROTL64(t, 32); v[a] ^= t; \ 23 | 24 | for (i = 0; i < rounds; i += 2) { 25 | G( 0, 4, 8,12); 26 | G( 5, 9,13, 1); 27 | G(10,14, 2, 6); 28 | G(15, 3, 7,11); 29 | G( 0, 1, 2, 3); 30 | G( 5, 6, 7, 4); 31 | G(10,11, 8, 9); 32 | G(15,12,13,14); 33 | } 34 | 35 | for (i = 0; i < 16; i++) state[i] += v[i]; 36 | 37 | #undef G 38 | } 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /algo/x13/x13sm3-gate.c: -------------------------------------------------------------------------------- 1 | #include "x13sm3-gate.h" 2 | 3 | bool register_x13sm3_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (X13SM3_4WAY) 6 | init_x13sm3_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x13sm3_4way; 8 | gate->hash = (void*)&x13sm3_4way_hash; 9 | #else 10 | init_x13sm3_ctx(); 11 | gate->scanhash = (void*)&scanhash_x13sm3; 12 | gate->hash = (void*)&x13sm3_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | gate->get_max64 = (void*)&get_max64_0x3ffff; 16 | return true; 17 | }; 18 | 19 | bool register_x13bcd_algo( algo_gate_t* gate ) 20 | { 21 | #if defined (X13SM3_4WAY) 22 | init_x13bcd_4way_ctx(); 23 | gate->scanhash = (void*)&scanhash_x13bcd_4way; 24 | gate->hash = (void*)&x13bcd_4way_hash; 25 | #else 26 | init_x13bcd_ctx(); 27 | gate->scanhash = (void*)&scanhash_x13bcd; 28 | gate->hash = (void*)&x13bcd_hash; 29 | #endif 30 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 31 | gate->get_max64 = (void*)&get_max64_0x3ffff; 32 | return true; 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/sj/scrypt-jane-mix_salsa64.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA64_INCLUDED) 2 | 3 | #undef SCRYPT_MIX 4 | #define SCRYPT_MIX "Salsa64/8 Ref" 5 | 6 | #undef SCRYPT_SALSA64_INCLUDED 7 | #define SCRYPT_SALSA64_INCLUDED 8 | #define SCRYPT_SALSA64_BASIC 9 | 10 | static void 11 | salsa64_core_basic(uint64_t state[16]) { 12 | const size_t rounds = 8; 13 | uint64_t v[16], t; 14 | size_t i; 15 | 16 | for (i = 0; i < 16; i++) v[i] = state[i]; 17 | 18 | #define G(a,b,c,d) \ 19 | t = v[a]+v[d]; t = ROTL64(t, 32); v[b] ^= t; \ 20 | t = v[b]+v[a]; t = ROTL64(t, 13); v[c] ^= t; \ 21 | t = v[c]+v[b]; t = ROTL64(t, 39); v[d] ^= t; \ 22 | t = v[d]+v[c]; t = ROTL64(t, 32); v[a] ^= t; \ 23 | 24 | for (i = 0; i < rounds; i += 2) { 25 | G( 0, 4, 8,12); 26 | G( 5, 9,13, 1); 27 | G(10,14, 2, 6); 28 | G(15, 3, 7,11); 29 | G( 0, 1, 2, 3); 30 | G( 5, 6, 7, 4); 31 | G(10,11, 8, 9); 32 | G(15,12,13,14); 33 | } 34 | 35 | for (i = 0; i < 16; i++) state[i] += v[i]; 36 | 37 | #undef G 38 | } 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /algo/argon2/argon2d/argon2d-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2D_GATE_H__ 2 | #define ARGON2D_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | // Credits: version = 0x10, m_cost = 250. 8 | bool register_argon2d_crds_algo( algo_gate_t* gate ); 9 | 10 | void argon2d_crds_hash( void *state, const void *input ); 11 | 12 | int scanhash_argon2d_crds( struct work *work, uint32_t max_nonce, 13 | uint64_t *hashes_done, struct thr_info *mythr ); 14 | 15 | // Dynamic: version = 0x10, m_cost = 500. 16 | bool register_argon2d_dyn_algo( algo_gate_t* gate ); 17 | 18 | void argon2d_dyn_hash( void *state, const void *input ); 19 | 20 | int scanhash_argon2d_dyn( struct work *work, uint32_t max_nonce, 21 | uint64_t *hashes_done, struct thr_info *mythr ); 22 | 23 | 24 | // Unitus: version = 0x13, m_cost = 4096. 25 | bool register_argon2d4096_algo( algo_gate_t* gate ); 26 | 27 | int scanhash_argon2d4096( struct work *work, uint32_t max_nonce, 28 | uint64_t *hashes_done, struct thr_info *mythr ); 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /compat/jansson/strbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef STRBUFFER_H 9 | #define STRBUFFER_H 10 | 11 | typedef struct { 12 | char *value; 13 | size_t length; /* bytes used */ 14 | size_t size; /* bytes allocated */ 15 | } strbuffer_t; 16 | 17 | int strbuffer_init(strbuffer_t *strbuff); 18 | void strbuffer_close(strbuffer_t *strbuff); 19 | 20 | void strbuffer_clear(strbuffer_t *strbuff); 21 | 22 | const char *strbuffer_value(const strbuffer_t *strbuff); 23 | 24 | /* Steal the value and close the strbuffer */ 25 | char *strbuffer_steal_value(strbuffer_t *strbuff); 26 | 27 | int strbuffer_append(strbuffer_t *strbuff, const char *string); 28 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte); 29 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); 30 | 31 | char strbuffer_pop(strbuffer_t *strbuff); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/sj/scrypt-jane-romix.h: -------------------------------------------------------------------------------- 1 | #if defined(SCRYPT_SALSA64) 2 | #include "scrypt-jane-salsa64.h" 3 | #else 4 | #define SCRYPT_MIX_BASE "ERROR" 5 | typedef uint32_t scrypt_mix_word_t; 6 | #define SCRYPT_WORDTO8_LE U32TO8_LE 7 | #define SCRYPT_WORD_ENDIAN_SWAP U32_SWAP 8 | #define SCRYPT_BLOCK_BYTES 64 9 | #define SCRYPT_BLOCK_WORDS (SCRYPT_BLOCK_BYTES / sizeof(scrypt_mix_word_t)) 10 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) 11 | static void FASTCALL scrypt_ROMix_error(scrypt_mix_word_t *X/*[chunkWords]*/, scrypt_mix_word_t *Y/*[chunkWords]*/, scrypt_mix_word_t *V/*[chunkWords * N]*/, uint32_t N, uint32_t r) {} 12 | static scrypt_ROMixfn scrypt_getROMix(void) { return scrypt_ROMix_error; } 13 | #else 14 | static void FASTCALL scrypt_ROMix(scrypt_mix_word_t *X, scrypt_mix_word_t *Y, scrypt_mix_word_t *V, uint32_t N, uint32_t r) {} 15 | #endif 16 | static int scrypt_test_mix(void) { return 0; } 17 | #error must define a mix function! 18 | #endif 19 | 20 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) 21 | #undef SCRYPT_MIX 22 | #define SCRYPT_MIX SCRYPT_MIX_BASE 23 | #endif 24 | -------------------------------------------------------------------------------- /algo/x20/x20r-gate.c: -------------------------------------------------------------------------------- 1 | #include "x20r-gate.h" 2 | 3 | void getAlgoString( const uint8_t* prevblock, char *output ) 4 | { 5 | char *sptr = outpuit; 6 | 7 | for ( int j = 0; j < X20R_HASH_FUNC_COUNT; j++ ) 8 | { 9 | char b = (19 - j) >> 1; // 16 ascii hex chars, reversed 10 | uint8_t algoDigit = (j & 1) ? prevblock[b] & 0xF : prevblock[b] >> 4; 11 | if (algoDigit >= 10) 12 | sprintf(sptr, "%c", 'A' + (algoDigit - 10)); 13 | else 14 | sprintf(sptr, "%u", (uint32_t) algoDigit); 15 | sptr++; 16 | } 17 | *sptr = '\0'; 18 | } 19 | 20 | bool register_x20r_algo( algo_gate_t* gate ) 21 | { 22 | #if defined (X20R_4WAY) 23 | gate->scanhash = (void*)&scanhash_x20r_4way; 24 | gate->hash = (void*)&x20r_4way_hash; 25 | #else 26 | gate->scanhash = (void*)&scanhash_x20r; 27 | gate->hash = (void*)&x20r_hash; 28 | #endif 29 | gate->set_target = (void*)&alt_set_target; 30 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 31 | x20_r_s_getAlgoString = (void*)&x20r_getAlgoString; 32 | return true; 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /algo/blake/blake2s-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __BLAKE2S_GATE_H__ 2 | #define __BLAKE2S_GATE_H__ 1 3 | 4 | #include 5 | #include "algo-gate-api.h" 6 | 7 | //#if defined(__SSE4_2__) 8 | #if defined(__SSE2__) 9 | #define BLAKE2S_4WAY 10 | #endif 11 | #if defined(__AVX2__) 12 | #define BLAKE2S_8WAY 13 | #endif 14 | 15 | bool register_blake2s_algo( algo_gate_t* gate ); 16 | 17 | #if defined(BLAKE2S_8WAY) 18 | 19 | void blake2s_8way_hash( void *state, const void *input ); 20 | int scanhash_blake2s_8way( struct work *work, uint32_t max_nonce, 21 | uint64_t *hashes_done, struct thr_info *mythr ); 22 | 23 | #elif defined (BLAKE2S_4WAY) 24 | 25 | void blake2s_4way_hash( void *state, const void *input ); 26 | int scanhash_blake2s_4way( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | #else 29 | 30 | void blake2s_hash( void *state, const void *input ); 31 | int scanhash_blake2s( struct work *work, uint32_t max_nonce, 32 | uint64_t *hashes_done, struct thr_info *mythr ); 33 | 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /algo/blake/sph_blake2b.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __BLAKE2B_H__ 3 | #define __BLAKE2B_H__ 4 | 5 | #include 6 | #include 7 | 8 | #if defined(_MSC_VER) 9 | #include 10 | #define inline __inline 11 | #define ALIGN(x) __declspec(align(x)) 12 | #else 13 | #define ALIGN(x) __attribute__((aligned(x))) 14 | #endif 15 | 16 | #if defined(_MSC_VER) || defined(__x86_64__) || defined(__x86__) 17 | #define NATIVE_LITTLE_ENDIAN 18 | #endif 19 | 20 | // state context 21 | ALIGN(64) typedef struct { 22 | uint8_t b[128]; // input buffer 23 | uint64_t h[8]; // chained state 24 | uint64_t t[2]; // total number of bytes 25 | size_t c; // pointer for b[] 26 | size_t outlen; // digest size 27 | } sph_blake2b_ctx; 28 | 29 | #if defined(__cplusplus) 30 | extern "C" { 31 | #endif 32 | 33 | int sph_blake2b_init( sph_blake2b_ctx *ctx, size_t outlen, const void *key, size_t keylen); 34 | void sph_blake2b_update( sph_blake2b_ctx *ctx, const void *in, size_t inlen); 35 | void sph_blake2b_final( sph_blake2b_ctx *ctx, void *out); 36 | 37 | #if defined(__cplusplus) 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /algo/x11/timetravel-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMETRAVEL_GATE_H__ 2 | #define TIMETRAVEL_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define TIMETRAVEL_4WAY 9 | #endif 10 | 11 | // Machinecoin Genesis Timestamp 12 | #define TT8_FUNC_BASE_TIMESTAMP 1389040865 13 | 14 | #define TT8_FUNC_COUNT 8 15 | #define TT8_FUNC_COUNT_PERMUTATIONS 40320 16 | 17 | void tt8_next_permutation( int *pbegin, int *pend ); 18 | 19 | bool register_timetravel_algo( algo_gate_t* gate ); 20 | 21 | #if defined(TIMETRAVEL_4WAY) 22 | 23 | void timetravel_4way_hash( void *state, const void *input ); 24 | 25 | int scanhash_timetravel_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | 28 | void init_tt8_4way_ctx(); 29 | 30 | #endif 31 | 32 | void timetravel_hash( void *state, const void *input ); 33 | 34 | int scanhash_timetravel( struct work *work, uint32_t max_nonce, 35 | uint64_t *hashes_done, struct thr_info *mythr ); 36 | 37 | void init_tt8_ctx(); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /algo/x11/timetravel10-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMETRAVEL10_GATE_H__ 2 | #define TIMETRAVEL10_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define TIMETRAVEL10_4WAY 9 | #endif 10 | 11 | // BitCore Genesis Timestamp 12 | #define TT10_FUNC_BASE_TIMESTAMP 1492973331U 13 | #define TT10_FUNC_COUNT 10 14 | #define TT10_FUNC_COUNT_PERMUTATIONS 40320 15 | 16 | void tt10_next_permutation( int *pbegin, int *pend ); 17 | 18 | bool register_timetravel10_algo( algo_gate_t* gate ); 19 | 20 | #if defined(TIMETRAVEL10_4WAY) 21 | 22 | void timetravel10_4way_hash( void *state, const void *input ); 23 | 24 | int scanhash_timetravel10_4way( struct work *work, 25 | uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ); 26 | 27 | void init_tt10_4way_ctx(); 28 | 29 | #endif 30 | 31 | void timetravel10_hash( void *state, const void *input ); 32 | 33 | int scanhash_timetravel10( struct work *work, uint32_t max_nonce, 34 | uint64_t *hashes_done, struct thr_info *mythr ); 35 | 36 | void init_tt10_ctx(); 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /algo/blake/blakecoin-gate.c: -------------------------------------------------------------------------------- 1 | #include "blakecoin-gate.h" 2 | #include 3 | 4 | // changed to get_max64_0x3fffffLL in cpuminer-multi-decred 5 | int64_t blakecoin_get_max64 () 6 | { 7 | return 0x7ffffLL; 8 | // return 0x3fffffLL; 9 | } 10 | 11 | // vanilla uses default gen merkle root, otherwise identical to blakecoin 12 | bool register_vanilla_algo( algo_gate_t* gate ) 13 | { 14 | #if defined(BLAKECOIN_8WAY) 15 | gate->scanhash = (void*)&scanhash_blakecoin_8way; 16 | gate->hash = (void*)&blakecoin_8way_hash; 17 | 18 | #elif defined(BLAKECOIN_4WAY) 19 | gate->scanhash = (void*)&scanhash_blakecoin_4way; 20 | gate->hash = (void*)&blakecoin_4way_hash; 21 | #else 22 | gate->scanhash = (void*)&scanhash_blakecoin; 23 | gate->hash = (void*)&blakecoinhash; 24 | #endif 25 | gate->optimizations = SSE42_OPT | AVX2_OPT; 26 | gate->get_max64 = (void*)&blakecoin_get_max64; 27 | return true; 28 | } 29 | 30 | bool register_blakecoin_algo( algo_gate_t* gate ) 31 | { 32 | register_vanilla_algo( gate ); 33 | gate->gen_merkle_root = (void*)&SHA256_gen_merkle_root; 34 | return true; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /algo/hodl/sha512-avx.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHA512_H 2 | #define _SHA512_H 3 | 4 | #include 5 | #include "emmintrin.h" 6 | 7 | //SHA-512 block size 8 | #define SHA512_BLOCK_SIZE 128 9 | //SHA-512 digest size 10 | #define SHA512_DIGEST_SIZE 64 11 | 12 | /* 13 | #ifndef __AVX2__ 14 | #ifndef __AVX__ 15 | #error "Either AVX or AVX2 supported needed" 16 | #endif // __AVX__ 17 | #endif // __AVX2__ 18 | */ 19 | 20 | typedef struct 21 | { 22 | #ifdef __AVX2__ 23 | __m256i h[8]; 24 | __m256i w[80]; 25 | #elif defined(__SSE4_2__) 26 | //#elif defined(__AVX__) 27 | __m128i h[8]; 28 | __m128i w[80]; 29 | #else 30 | int dummy; 31 | #endif 32 | } Sha512Context; 33 | 34 | #ifdef __AVX2__ 35 | #define SHA512_PARALLEL_N 8 36 | #elif defined(__SSE4_2__) 37 | //#elif defined(__AVX__) 38 | #define SHA512_PARALLEL_N 4 39 | #else 40 | #define SHA512_PARALLEL_N 1 // dummy value 41 | #endif 42 | 43 | //SHA-512 related functions 44 | void sha512Compute32b_parallel( 45 | uint64_t *data[SHA512_PARALLEL_N], 46 | uint64_t *digest[SHA512_PARALLEL_N]); 47 | 48 | void sha512ProcessBlock(Sha512Context *context); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /algo/cubehash/cube-hash-2way.h: -------------------------------------------------------------------------------- 1 | #ifndef CUBE_HASH_2WAY_H__ 2 | #define CUBE_HASH_2WAY_H__ 3 | 4 | #if defined(__AVX2__) 5 | 6 | #include 7 | #include "simd-utils.h" 8 | 9 | // 2x128, 2 way parallel SSE2 10 | 11 | struct _cube_2way_context 12 | { 13 | __m256i h[8]; 14 | int hashlen; // __m128i 15 | int rounds; 16 | int blocksize; // __m128i 17 | int pos; // number of __m128i read into x from current block 18 | } __attribute__ ((aligned (64))); 19 | 20 | typedef struct _cube_2way_context cube_2way_context; 21 | 22 | int cube_2way_init( cube_2way_context* sp, int hashbitlen, int rounds, 23 | int blockbytes ); 24 | // reinitialize context with same parameters, much faster. 25 | int cube_2way_reinit( cube_2way_context *sp ); 26 | 27 | int cube_2way_update( cube_2way_context *sp, const void *data, size_t size ); 28 | 29 | int cube_2way_close( cube_2way_context *sp, void *output ); 30 | 31 | int cube_2way_update_close( cube_2way_context *sp, void *output, 32 | const void *data, size_t size ); 33 | 34 | 35 | #endif 36 | #endif 37 | -------------------------------------------------------------------------------- /algo/ripemd/ripemd-hash-4way.h: -------------------------------------------------------------------------------- 1 | #ifndef RIPEMD_HASH_4WAY_H__ 2 | #define RIPEMD_HASH_4WAY_H__ 3 | 4 | #include 5 | #include "algo/sha/sph_types.h" 6 | 7 | #if defined(__SSE4_2__) 8 | 9 | #include "simd-utils.h" 10 | 11 | typedef struct 12 | { 13 | __m128i buf[64>>2]; 14 | __m128i val[5]; 15 | uint32_t count_high, count_low; 16 | } __attribute__ ((aligned (64))) ripemd160_4way_context; 17 | 18 | void ripemd160_4way_init( ripemd160_4way_context *sc ); 19 | void ripemd160_4way( ripemd160_4way_context *sc, const void *data, size_t len ); 20 | void ripemd160_4way_close( ripemd160_4way_context *sc, void *dst ); 21 | 22 | #if defined (__AVX2__) 23 | 24 | typedef struct 25 | { 26 | __m256i buf[64>>2]; 27 | __m256i val[5]; 28 | uint32_t count_high, count_low; 29 | } __attribute__ ((aligned (64))) ripemd160_8way_context; 30 | 31 | void ripemd160_8way_init( ripemd160_8way_context *sc ); 32 | void ripemd160_8way( ripemd160_8way_context *sc, const void *data, size_t len ); 33 | void ripemd160_8way_close( ripemd160_8way_context *sc, void *dst ); 34 | 35 | 36 | #endif // __AVX2__ 37 | #endif // __SSE4_2__ 38 | #endif // RIPEMD_HASH_4WAY_H__ 39 | -------------------------------------------------------------------------------- /compat/jansson/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, 2010 Petri Lehtinen 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /algo/blake/decred-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __DECRED_GATE_H__ 2 | #define __DECRED_GATE_H__ 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #define DECRED_NBITS_INDEX 29 8 | #define DECRED_NTIME_INDEX 34 9 | #define DECRED_NONCE_INDEX 35 10 | #define DECRED_XNONCE_INDEX 36 11 | #define DECRED_DATA_SIZE 192 12 | #define DECRED_WORK_COMPARE_SIZE 140 13 | #define DECRED_MIDSTATE_LEN 128 14 | 15 | #if defined (__AVX2__) 16 | //void blakehash_84way(void *state, const void *input); 17 | //int scanhash_blake_8way( struct work *work, uint32_t max_nonce, 18 | // uint64_t *hashes_done ); 19 | #endif 20 | 21 | #if defined(__SSE4_2__) 22 | #define DECRED_4WAY 23 | #endif 24 | 25 | #if defined (DECRED_4WAY) 26 | void decred_hash_4way(void *state, const void *input); 27 | int scanhash_decred_4way( struct work *work, uint32_t max_nonce, 28 | uint64_t *hashes_done, struct thr_info *mythr ); 29 | #endif 30 | 31 | void decred_hash( void *state, const void *input ); 32 | int scanhash_decred( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /algo/ripemd/lbry-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef LBRY_GATE_H__ 2 | #define LBRY_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if !defined(__SHA__) 8 | #if defined(__AVX2__) 9 | #define LBRY_8WAY 10 | #endif 11 | #endif 12 | 13 | #define LBRY_NTIME_INDEX 25 14 | #define LBRY_NBITS_INDEX 26 15 | #define LBRY_NONCE_INDEX 27 16 | #define LBRY_WORK_DATA_SIZE 192 17 | #define LBRY_WORK_CMP_SIZE 76 // same as default 18 | 19 | bool register_lbry_algo( algo_gate_t* gate ); 20 | 21 | #if defined(LBRY_8WAY) 22 | 23 | void lbry_8way_hash( void *state, const void *input ); 24 | int scanhash_lbry_8way( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | /* 27 | #elif defined(LBRY_4WAY) 28 | 29 | void lbry_4way_hash( void *state, const void *input ); 30 | int scanhash_lbry_4way( struct work *work, uint32_t max_nonce, 31 | uint64_t *hashes_done ); 32 | */ 33 | #else 34 | 35 | void lbry_hash( void *state, const void *input ); 36 | int scanhash_lbry( struct work *work, uint32_t max_nonce, 37 | uint64_t *hashes_done, struct thr_info *mythr ); 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /compat/jansson/utf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef UTF_H 9 | #define UTF_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include 13 | 14 | #ifdef HAVE_INTTYPES_H 15 | /* inttypes.h includes stdint.h in a standard environment, so there's 16 | no need to include stdint.h separately. If inttypes.h doesn't define 17 | int32_t, it's defined in config.h. */ 18 | #include 19 | #endif /* HAVE_INTTYPES_H */ 20 | 21 | #else /* !HAVE_CONFIG_H */ 22 | #ifdef _WIN32 23 | typedef int int32_t; 24 | #else /* !_WIN32 */ 25 | /* Assume a standard environment */ 26 | #include 27 | #endif /* _WIN32 */ 28 | 29 | #endif /* HAVE_CONFIG_H */ 30 | 31 | int utf8_encode(int codepoint, char *buffer, int *size); 32 | 33 | int utf8_check_first(char byte); 34 | int utf8_check_full(const char *buffer, int size, int32_t *codepoint); 35 | const char *utf8_iterate(const char *buffer, int32_t *codepoint); 36 | 37 | int utf8_check_string(const char *string, int length); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /algo/scryptjane/scrypt-jane-romix.h: -------------------------------------------------------------------------------- 1 | #if defined(SCRYPT_CHACHA) 2 | #include "scrypt-jane-chacha.h" 3 | #elif defined(SCRYPT_SALSA) 4 | #include "scrypt-jane-salsa.h" 5 | #elif defined(SCRYPT_SALSA64) 6 | #include "scrypt-jane-salsa64.h" 7 | #else 8 | #define SCRYPT_MIX_BASE "ERROR" 9 | typedef uint32_t scrypt_mix_word_t; 10 | #define SCRYPT_WORDTO8_LE U32TO8_LE 11 | #define SCRYPT_WORD_ENDIAN_SWAP U32_SWAP 12 | #define SCRYPT_BLOCK_BYTES 64 13 | #define SCRYPT_BLOCK_WORDS (SCRYPT_BLOCK_BYTES / sizeof(scrypt_mix_word_t)) 14 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) 15 | static void FASTCALL scrypt_ROMix_error(scrypt_mix_word_t *X/*[chunkWords]*/, scrypt_mix_word_t *Y/*[chunkWords]*/, scrypt_mix_word_t *V/*[chunkWords * N]*/, uint32_t N, uint32_t r) {} 16 | static scrypt_ROMixfn scrypt_getROMix() { return scrypt_ROMix_error; } 17 | #else 18 | static void FASTCALL scrypt_ROMix(scrypt_mix_word_t *X, scrypt_mix_word_t *Y, scrypt_mix_word_t *V, uint32_t N, uint32_t r) {} 19 | #endif 20 | static int scrypt_test_mix() { return 0; } 21 | #error must define a mix function! 22 | #endif 23 | 24 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) 25 | #undef SCRYPT_MIX 26 | #define SCRYPT_MIX SCRYPT_MIX_BASE 27 | #endif 28 | -------------------------------------------------------------------------------- /nomacro.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Copyright 2012 pooler@litecoinpool.org 3 | # 4 | # This program is free software; you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by the Free 6 | # Software Foundation; either version 2 of the License, or (at your option) 7 | # any later version. See COPYING for more details. 8 | # 9 | # nomacro.pl - convert assembler macros to C preprocessor macros. 10 | 11 | use strict; 12 | 13 | foreach my $f (<*.S>) { 14 | rename $f, "$f.orig"; 15 | open FIN, "$f.orig"; 16 | open FOUT, ">$f"; 17 | my $inmacro = 0; 18 | my %macros = (); 19 | while () { 20 | if (m/^\.macro\s+([_0-9A-Z]+)(?:\s*)(.*)$/i) { 21 | print FOUT "#define $1($2) \\\n"; 22 | $macros{$1} = 1; 23 | $inmacro = 1; 24 | next; 25 | } 26 | if (m/^\.endm/) { 27 | print FOUT "\n"; 28 | $inmacro = 0; 29 | next; 30 | } 31 | for my $m (keys %macros) { 32 | s/^([ \t]*)($m)(?:[ \t]+([^#\n]*))?([;\n])/\1\2(\3)\4/; 33 | } 34 | if ($inmacro) { 35 | if (m/^\s*#if/) { 36 | $_ = while (!m/^\s*#endif/); 37 | next; 38 | } 39 | next if (m/^\s*$/); 40 | s/\\//g; 41 | s/$/; \\/; 42 | } 43 | print FOUT; 44 | } 45 | close FOUT; 46 | close FIN; 47 | } 48 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/sj/scrypt-jane-test-vectors.h: -------------------------------------------------------------------------------- 1 | typedef struct scrypt_test_setting_t { 2 | const char *pw, *salt; 3 | uint8_t Nfactor, rfactor, pfactor; 4 | } scrypt_test_setting; 5 | 6 | static const scrypt_test_setting post_settings[] = { 7 | {"", "", 3, 0, 0}, 8 | {"password", "NaCl", 9, 3, 4}, 9 | {0, 0, 0, 0, 0} 10 | }; 11 | 12 | #if defined(SCRYPT_SKEIN512) 13 | #if defined(SCRYPT_SALSA64) 14 | static const uint8_t post_vectors[][64] = { 15 | {0xd2,0xad,0x32,0x05,0xee,0x80,0xe3,0x44,0x70,0xc6,0x34,0xde,0x05,0xb6,0xcf,0x60, 16 | 0x89,0x98,0x70,0xc0,0xb8,0xf5,0x54,0xf1,0xa6,0xb2,0xc8,0x76,0x34,0xec,0xc4,0x59, 17 | 0x8e,0x64,0x42,0xd0,0xa9,0xed,0xe7,0x19,0xb2,0x8a,0x11,0xc6,0xa6,0xbf,0xa7,0xa9, 18 | 0x4e,0x44,0x32,0x7e,0x12,0x91,0x9d,0xfe,0x52,0x48,0xa8,0x27,0xb3,0xfc,0xb1,0x89}, 19 | {0xd6,0x67,0xd2,0x3e,0x30,0x1e,0x9d,0xe2,0x55,0x68,0x17,0x3d,0x2b,0x75,0x5a,0xe5, 20 | 0x04,0xfb,0x3d,0x0e,0x86,0xe0,0xaa,0x1d,0xd4,0x72,0xda,0xb0,0x79,0x41,0xb7,0x99, 21 | 0x68,0xe5,0xd9,0x55,0x79,0x7d,0xc3,0xd1,0xa6,0x56,0xc1,0xbe,0x0b,0x6c,0x62,0x23, 22 | 0x66,0x67,0x91,0x47,0x99,0x13,0x6b,0xe3,0xda,0x59,0x55,0x18,0x67,0x8f,0x2e,0x3b} 23 | }; 24 | #endif 25 | #else 26 | static const uint8_t post_vectors[][64] = {{0}}; 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /algo/cubehash/cubehash_sse2.h: -------------------------------------------------------------------------------- 1 | #ifndef CUBEHASH_SSE2_H__ 2 | #define CUBEHASH_SSE2_H__ 3 | 4 | #include "compat.h" 5 | #include 6 | #include "algo/sha/sha3-defs.h" 7 | 8 | #define OPTIMIZE_SSE2 9 | 10 | #include 11 | 12 | /*!\brief Holds all the parameters necessary for the CUBEHASH algorithm. 13 | * \ingroup HASH_cubehash_m 14 | */ 15 | 16 | struct _cubehashParam 17 | { 18 | int hashlen; // __m128i 19 | int rounds; 20 | int blocksize; // __m128i 21 | int pos; // number of __m128i read into x from current block 22 | __m128i _ALIGN(256) x[8]; // aligned for __m256i 23 | }; 24 | 25 | typedef struct _cubehashParam cubehashParam; 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | int cubehashInit(cubehashParam* sp, int hashbitlen, int rounds, int blockbytes); 32 | // reinitialize context with same parameters, much faster. 33 | int cubehashReinit( cubehashParam* sp ); 34 | 35 | int cubehashUpdate(cubehashParam* sp, const byte *data, size_t size); 36 | 37 | int cubehashDigest(cubehashParam* sp, byte *digest); 38 | 39 | int cubehashUpdateDigest( cubehashParam *sp, byte *digest, const byte *data, 40 | size_t size ); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* H_CUBEHASH */ 47 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/ar2-scrypt-jane.h: -------------------------------------------------------------------------------- 1 | #ifndef AR2_SCRYPT_JANE_H 2 | #define AR2_SCRYPT_JANE_H 3 | 4 | #ifdef _MSC_VER 5 | #undef SCRYPT_CHOOSE_COMPILETIME 6 | #endif 7 | //#define SCRYPT_TEST 8 | #define SCRYPT_SKEIN512 9 | #define SCRYPT_SALSA64 10 | 11 | /* 12 | Nfactor: Increases CPU & Memory Hardness 13 | N = (1 << (Nfactor + 1)): How many times to mix a chunk and how many temporary chunks are used 14 | 15 | rfactor: Increases Memory Hardness 16 | r = (1 << rfactor): How large a chunk is 17 | 18 | pfactor: Increases CPU Hardness 19 | p = (1 << pfactor): Number of times to mix the main chunk 20 | 21 | A block is the basic mixing unit (salsa/chacha block = 64 bytes) 22 | A chunk is (2 * r) blocks 23 | 24 | ~Memory used = (N + 2) * ((2 * r) * block size) 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | typedef void (*scrypt_fatal_errorfn)(const char *msg); 31 | void scrypt_set_fatal_error(scrypt_fatal_errorfn fn); 32 | 33 | void scrypt(const unsigned char *password, size_t password_len, const unsigned char *salt, size_t salt_len, unsigned char Nfactor, unsigned char rfactor, unsigned char pfactor, unsigned char *out, size_t bytes); 34 | void my_scrypt(const uint8_t *password, size_t password_len, const uint8_t *salt, size_t salt_len, uint8_t *out); 35 | #endif /* AR2_SCRYPT_JANE_H */ 36 | -------------------------------------------------------------------------------- /compat/jansson/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * Copyright (c) 2011-2012 Basile Starynkevitch 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify it 6 | * under the terms of the MIT license. See LICENSE for details. 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #include "jansson.h" 13 | #include "jansson_private.h" 14 | 15 | /* memory function pointers */ 16 | static json_malloc_t do_malloc = malloc; 17 | static json_free_t do_free = free; 18 | 19 | void *jsonp_malloc(size_t size) 20 | { 21 | if(!size) 22 | return NULL; 23 | 24 | return (*do_malloc)(size); 25 | } 26 | 27 | void jsonp_free(void *ptr) 28 | { 29 | if(!ptr) 30 | return; 31 | 32 | (*do_free)(ptr); 33 | } 34 | 35 | char *jsonp_strdup(const char *str) 36 | { 37 | char *new_str; 38 | size_t len; 39 | 40 | len = strlen(str); 41 | if(len == (size_t)-1) 42 | return NULL; 43 | 44 | new_str = jsonp_malloc(len + 1); 45 | if(!new_str) 46 | return NULL; 47 | 48 | memcpy(new_str, str, len + 1); 49 | return new_str; 50 | } 51 | 52 | void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn) 53 | { 54 | do_malloc = malloc_fn; 55 | do_free = free_fn; 56 | } 57 | -------------------------------------------------------------------------------- /algo/x13/x13sm3-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X13SM3_GATE_H__ 2 | #define X13SM3_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX2__) && defined(__AES__) 8 | #define X13SM3_4WAY 9 | #endif 10 | 11 | bool register_x13sm3_algo( algo_gate_t* gate ); 12 | 13 | bool register_x13bcd_algo( algo_gate_t* gate ); 14 | 15 | #if defined(X13SM3_4WAY) 16 | 17 | void x13sm3_4way_hash( void *state, const void *input ); 18 | int scanhash_x13sm3_4way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | void init_x13sm3_4way_ctx(); 21 | 22 | void x13bcd_4way_hash( void *state, const void *input ); 23 | int scanhash_x13bcd_4way( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_x13bcd_4way_ctx(); 26 | 27 | #endif 28 | 29 | void x13sm3_hash( void *state, const void *input ); 30 | int scanhash_x13sm3( struct work *work, uint32_t max_nonce, 31 | uint64_t *hashes_done, struct thr_info *mythr ); 32 | void init_x13sm3_ctx(); 33 | 34 | void x13bcd_hash( void *state, const void *input ); 35 | int scanhash_x13bcd( struct work *work, uint32_t max_nonce, 36 | uint64_t *hashes_done, struct thr_info *mythr ); 37 | void init_x13bcd_ctx(); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /cpuminer.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 2013 3 | VisualStudioVersion = 12.0.30723.0 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpuminer", "cpuminer.vcxproj", "{36DC07F9-A4A6-4877-A146-1B960083CF6F}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|x64 = Debug|x64 10 | Debug|Win32 = Debug|Win32 11 | Release|x64 = Release|x64 12 | Release|Win32 = Release|Win32 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Debug|x64.ActiveCfg = Debug|x64 16 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Debug|x64.Build.0 = Debug|x64 18 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Debug|Win32.Build.0 = Debug|Win32 19 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Release|x64.ActiveCfg = Release|x64 20 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Release|x64.Build.0 = Release|x64 21 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Release|Win32.ActiveCfg = Release|Win32 22 | {36DC07F9-A4A6-4877-A146-1B960083CF6F}.Release|Win32.Build.0 = Release|Win32 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /crypto/c_blake256.h: -------------------------------------------------------------------------------- 1 | #ifndef _BLAKE256_H_ 2 | #define _BLAKE256_H_ 3 | 4 | #include 5 | 6 | typedef struct { 7 | uint32_t h[8], s[4], t[2]; 8 | int buflen, nullt; 9 | uint8_t buf[64]; 10 | } state; 11 | 12 | typedef struct { 13 | state inner; 14 | state outer; 15 | } hmac_state; 16 | 17 | void blake256_init(state *); 18 | void blake224_init(state *); 19 | 20 | void blake256_update(state *, const uint8_t *, uint64_t); 21 | void blake224_update(state *, const uint8_t *, uint64_t); 22 | 23 | void blake256_final(state *, uint8_t *); 24 | void blake224_final(state *, uint8_t *); 25 | 26 | void blake256_hash(uint8_t *, const uint8_t *, uint64_t); 27 | void blake224_hash(uint8_t *, const uint8_t *, uint64_t); 28 | 29 | /* HMAC functions: */ 30 | 31 | void hmac_blake256_init(hmac_state *, const uint8_t *, uint64_t); 32 | void hmac_blake224_init(hmac_state *, const uint8_t *, uint64_t); 33 | 34 | void hmac_blake256_update(hmac_state *, const uint8_t *, uint64_t); 35 | void hmac_blake224_update(hmac_state *, const uint8_t *, uint64_t); 36 | 37 | void hmac_blake256_final(hmac_state *, uint8_t *); 38 | void hmac_blake224_final(hmac_state *, uint8_t *); 39 | 40 | void hmac_blake256_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 41 | void hmac_blake224_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 42 | 43 | #endif /* _BLAKE256_H_ */ 44 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/sj/scrypt-jane-hash.h: -------------------------------------------------------------------------------- 1 | #if defined(SCRYPT_SKEIN512) 2 | #include "scrypt-jane-hash_skein512.h" 3 | #else 4 | #define SCRYPT_HASH "ERROR" 5 | #define SCRYPT_HASH_BLOCK_SIZE 64 6 | #define SCRYPT_HASH_DIGEST_SIZE 64 7 | typedef struct scrypt_hash_state_t { size_t dummy; } scrypt_hash_state; 8 | typedef uint8_t scrypt_hash_digest[SCRYPT_HASH_DIGEST_SIZE]; 9 | static void scrypt_hash_init(scrypt_hash_state *S) {} 10 | static void scrypt_hash_update(scrypt_hash_state *S, const uint8_t *in, size_t inlen) {} 11 | static void scrypt_hash_finish(scrypt_hash_state *S, uint8_t *hash) {} 12 | static const uint8_t scrypt_test_hash_expected[SCRYPT_HASH_DIGEST_SIZE] = {0}; 13 | #error must define a hash function! 14 | #endif 15 | 16 | #include "scrypt-jane-pbkdf2.h" 17 | 18 | #define SCRYPT_TEST_HASH_LEN 257 /* (2 * largest block size) + 1 */ 19 | 20 | static int 21 | scrypt_test_hash(void) { 22 | scrypt_hash_state st; 23 | scrypt_hash_digest hash, final; 24 | uint8_t msg[SCRYPT_TEST_HASH_LEN]; 25 | size_t i; 26 | 27 | for (i = 0; i < SCRYPT_TEST_HASH_LEN; i++) 28 | msg[i] = (uint8_t)i; 29 | 30 | scrypt_hash_init(&st); 31 | for (i = 0; i < SCRYPT_TEST_HASH_LEN + 1; i++) { 32 | scrypt_hash(hash, msg, i); 33 | scrypt_hash_update(&st, hash, sizeof(hash)); 34 | } 35 | scrypt_hash_finish(&st, final); 36 | return scrypt_verify(final, scrypt_test_hash_expected, SCRYPT_HASH_DIGEST_SIZE); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /algo/x20/x20r-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X20R_GATE_H__ 2 | #define X20R_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | /* 8 | #if defined(__AVX2__) && defined(__AES__) 9 | #define X20R_4WAY 10 | #endif 11 | */ 12 | 13 | enum x20r_Algo { 14 | BLAKE = 0, 15 | BMW, 16 | GROESTL, 17 | JH, 18 | KECCAK, 19 | SKEIN, 20 | LUFFA, 21 | CUBEHASH, 22 | SHAVITE, 23 | SIMD, 24 | ECHO, 25 | HAMSI, 26 | FUGUE, 27 | SHABAL, 28 | WHIRLPOOL, 29 | SHA_512, 30 | HAVAL, // 256-bits output 31 | GOST, 32 | RADIOGATUN, // 256-bits output 33 | PANAMA, // 256-bits output 34 | X20R_HASH_FUNC_COUNT 35 | }; 36 | 37 | void (*x20_r_s_getAlgoString) ( const uint8_t*, char* ); 38 | 39 | void x20r_getAlgoString( const uint8_t* prevblock, char *output ); 40 | 41 | bool register_xi20r_algo( algo_gate_t* gate ); 42 | 43 | #if defined(X20R_4WAY) 44 | 45 | void x20r_4way_hash( void *state, const void *input ); 46 | 47 | int scanhash_x20r_4way( int thr_id, struct work *work, uint32_t max_nonce, 48 | uint64_t *hashes_done ); 49 | 50 | #endif 51 | 52 | void x20rhash( void *state, const void *input ); 53 | 54 | int scanhash_x20r( int thr_id, struct work *work, uint32_t max_nonce, 55 | uint64_t *hashes_done ); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /crypto/magimath.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 The Magi 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 | #ifndef MAGI_MATH_H 5 | #define MAGI_MATH_H 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | uint32_t sw_(int nnounce, int divs); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | 20 | inline double exp_n(double xt) 21 | { 22 | double p1 = -700.0, p3 = -0.8e-8, p4 = 0.8e-8, p6 = 700.0; 23 | if(xt < p1) 24 | return 0; 25 | else if(xt > p6) 26 | return 1e200; 27 | else if(xt > p3 && xt < p4) 28 | return (1.0 + xt); 29 | else 30 | return exp(xt); 31 | } 32 | 33 | // 1 / (1 + exp(x1-x2)) 34 | inline double exp_n2(double x1, double x2) 35 | { 36 | double p1 = -700., p2 = -37., p3 = -0.8e-8, p4 = 0.8e-8, p5 = 37., p6 = 700.; 37 | double xt = x1 - x2; 38 | if (xt < p1+1.e-200) 39 | return 1.; 40 | else if (xt > p1 && xt < p2 + 1.e-200) 41 | return ( 1. - exp(xt) ); 42 | else if (xt > p2 && xt < p3 + 1.e-200) 43 | return ( 1. / (1. + exp(xt)) ); 44 | else if (xt > p3 && xt < p4) 45 | return ( 1. / (2. + xt) ); 46 | else if (xt > p4 - 1.e-200 && xt < p5) 47 | return ( exp(-xt) / (1. + exp(-xt)) ); 48 | else if (xt > p5 - 1.e-200 && xt < p6) 49 | return ( exp(-xt) ); 50 | else //if (xt > p6 - 1.e-200) 51 | return 0.; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /compat/jansson/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The configure script copies this file to jansson_config.h and 13 | * replaces @var@ substitutions by values that fit your system. If you 14 | * cannot run the configure script, you can do the value substitution 15 | * by hand. 16 | */ 17 | 18 | #ifndef JANSSON_CONFIG_H 19 | #define JANSSON_CONFIG_H 20 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 21 | defined to `inline', otherwise empty. In C++, the inline is always 22 | supported. */ 23 | 24 | #ifdef _MSC_VER 25 | #define inline __inline 26 | #endif 27 | 28 | #ifdef __cplusplus 29 | #define JSON_INLINE inline 30 | #else 31 | #define JSON_INLINE inline 32 | #endif 33 | 34 | /* If your compiler supports the `long long` type and the strtoll() 35 | library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, 36 | otherwise to 0. */ 37 | #define JSON_INTEGER_IS_LONG_LONG 1 38 | 39 | /* If locale.h and localeconv() are available, define to 1, 40 | otherwise to 0. */ 41 | #define JSON_HAVE_LOCALECONV 1 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /algo/simd/simd_iv.h: -------------------------------------------------------------------------------- 1 | #if !defined(SIMD_IV_H__) 2 | #define SIMD_IV_H__ 3 | 4 | u32 IV_224[] = { 5 | 0x33586e9f, 0x12fff033, 0xb2d9f64d, 0x6f8fea53, 6 | 0xde943106, 0x2742e439, 0x4fbab5ac, 0x62b9ff96, 7 | 0x22e7b0af, 0xc862b3a8, 0x33e00cdc, 0x236b86a6, 8 | 0xf64ae77c, 0xfa373b76, 0x7dc1ee5b, 0x7fb29ce8 9 | }; 10 | 11 | u32 IV_256[] = { 12 | 0x4d567983, 0x07190ba9, 0x8474577b, 0x39d726e9, 13 | 0xaaf3d925, 0x3ee20b03, 0xafd5e751, 0xc96006d3, 14 | 0xc2c2ba14, 0x49b3bcb4, 0xf67caf46, 0x668626c9, 15 | 0xe2eaa8d2, 0x1ff47833, 0xd0c661a5, 0x55693de1 16 | }; 17 | 18 | u32 IV_384[] = { 19 | 0x8a36eebc, 0x94a3bd90, 0xd1537b83, 0xb25b070b, 0xf463f1b5, 0xb6f81e20, 0x0055c339, 0xb4d144d1, 20 | 0x7360ca61, 0x18361a03, 0x17dcb4b9, 0x3414c45a, 0xa699a9d2, 0xe39e9664, 0x468bfe77, 0x51d062f8, 21 | 0xb9e3bfe8, 0x63bece2a, 0x8fe506b9, 0xf8cc4ac2, 0x7ae11542, 0xb1aadda1, 0x64b06794, 0x28d2f462, 22 | 0xe64071ec, 0x1deb91a8, 0x8ac8db23, 0x3f782ab5, 0x039b5cb8, 0x71ddd962, 0xfade2cea, 0x1416df71 23 | }; 24 | 25 | u32 IV_512[] = { 26 | 0x0ba16b95, 0x72f999ad, 0x9fecc2ae, 0xba3264fc, 0x5e894929, 0x8e9f30e5, 0x2f1daa37, 0xf0f2c558, 27 | 0xac506643, 0xa90635a5, 0xe25b878b, 0xaab7878f, 0x88817f7a, 0x0a02892b, 0x559a7550, 0x598f657e, 28 | 0x7eef60a1, 0x6b70e3e8, 0x9c1714d1, 0xb958e2a8, 0xab02675e, 0xed1c014f, 0xcd8d65bb, 0xfdb7a257, 29 | 0x09254899, 0xd699c7bc, 0x9019b6dc, 0x2b9022e4, 0x8fa14956, 0x21bf9bd3, 0xb94d0943, 0x6ffddc22 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /algo/bmw/bmw512.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "sph_bmw.h" 8 | 9 | void bmw512hash(void *state, const void *input) 10 | { 11 | sph_bmw512_context ctx; 12 | uint32_t hash[32]; 13 | 14 | sph_bmw512_init( &ctx ); 15 | sph_bmw512( &ctx,input, 80 ); 16 | sph_bmw512_close( &ctx, hash ); 17 | 18 | memcpy( state, hash, 32 ); 19 | } 20 | 21 | int scanhash_bmw512( struct work *work, uint32_t max_nonce, 22 | uint64_t *hashes_done, struct thr_info *mythr ) 23 | { 24 | uint32_t *pdata = work->data; 25 | uint32_t *ptarget = work->target; 26 | uint32_t n = pdata[19] - 1; 27 | const uint32_t first_nonce = pdata[19]; 28 | //const uint32_t Htarg = ptarget[7]; 29 | int thr_id = mythr->id; // thr_id arg is deprecated 30 | 31 | uint32_t _ALIGN(32) hash64[8]; 32 | uint32_t endiandata[32]; 33 | 34 | for (int i=0; i < 19; i++) 35 | be32enc(&endiandata[i], pdata[i]); 36 | 37 | do { 38 | 39 | pdata[19] = ++n; 40 | be32enc(&endiandata[19], n); 41 | bmw512hash(hash64, endiandata); 42 | if (((hash64[7]&0xFFFFFF00)==0) && 43 | fulltest(hash64, ptarget)) { 44 | *hashes_done = n - first_nonce + 1; 45 | return true; 46 | } 47 | } while (n < max_nonce && !work_restart[thr_id].restart); 48 | 49 | *hashes_done = n - first_nonce + 1; 50 | pdata[19] = n; 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /algo/sha/sha256t-gate.c: -------------------------------------------------------------------------------- 1 | #include "sha256t-gate.h" 2 | 3 | bool register_sha256t_algo( algo_gate_t* gate ) 4 | { 5 | #if defined(SHA256T_8WAY) 6 | gate->optimizations = SSE2_OPT | AVX2_OPT | SHA_OPT; 7 | gate->scanhash = (void*)&scanhash_sha256t_8way; 8 | gate->hash = (void*)&sha256t_8way_hash; 9 | #elif defined(SHA256T_4WAY) 10 | gate->optimizations = SSE2_OPT | AVX2_OPT | SHA_OPT; 11 | gate->scanhash = (void*)&scanhash_sha256t_4way; 12 | gate->hash = (void*)&sha256t_4way_hash; 13 | #else 14 | gate->optimizations = SHA_OPT; 15 | gate->scanhash = (void*)&scanhash_sha256t; 16 | gate->hash = (void*)&sha256t_hash; 17 | #endif 18 | gate->get_max64 = (void*)&get_max64_0x3ffff; 19 | return true; 20 | } 21 | 22 | bool register_sha256q_algo( algo_gate_t* gate ) 23 | { 24 | #if defined(SHA256T_8WAY) 25 | gate->optimizations = SSE2_OPT | AVX2_OPT | SHA_OPT; 26 | gate->scanhash = (void*)&scanhash_sha256q_8way; 27 | gate->hash = (void*)&sha256q_8way_hash; 28 | #elif defined(SHA256T_4WAY) 29 | gate->optimizations = SSE2_OPT | AVX2_OPT | SHA_OPT; 30 | gate->scanhash = (void*)&scanhash_sha256q_4way; 31 | gate->hash = (void*)&sha256q_4way_hash; 32 | #else 33 | gate->optimizations = SHA_OPT; 34 | gate->scanhash = (void*)&scanhash_sha256q; 35 | gate->hash = (void*)&sha256q_hash; 36 | #endif 37 | gate->get_max64 = (void*)&get_max64_0x3ffff; 38 | return true; 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /algo/keccak/keccak.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "sph_keccak.h" 8 | 9 | void keccakhash(void *state, const void *input) 10 | { 11 | sph_keccak256_context ctx_keccak; 12 | uint32_t hash[32]; 13 | 14 | sph_keccak256_init(&ctx_keccak); 15 | sph_keccak256 (&ctx_keccak,input, 80); 16 | sph_keccak256_close(&ctx_keccak, hash); 17 | 18 | memcpy(state, hash, 32); 19 | } 20 | 21 | int scanhash_keccak( struct work *work, 22 | uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ) 23 | { 24 | uint32_t *pdata = work->data; 25 | uint32_t *ptarget = work->target; 26 | uint32_t n = pdata[19] - 1; 27 | const uint32_t first_nonce = pdata[19]; 28 | //const uint32_t Htarg = ptarget[7]; 29 | int thr_id = mythr->id; // thr_id arg is deprecated 30 | 31 | uint32_t _ALIGN(32) hash64[8]; 32 | uint32_t endiandata[32]; 33 | 34 | for (int i=0; i < 19; i++) 35 | be32enc(&endiandata[i], pdata[i]); 36 | 37 | do { 38 | 39 | pdata[19] = ++n; 40 | be32enc(&endiandata[19], n); 41 | keccakhash(hash64, endiandata); 42 | if (((hash64[7]&0xFFFFFF00)==0) && 43 | fulltest(hash64, ptarget)) { 44 | *hashes_done = n - first_nonce + 1; 45 | return true; 46 | } 47 | } while (n < max_nonce && !work_restart[thr_id].restart); 48 | 49 | *hashes_done = n - first_nonce + 1; 50 | pdata[19] = n; 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /algo/keccak/keccak-gate.c: -------------------------------------------------------------------------------- 1 | #include "keccak-gate.h" 2 | 3 | void keccak_set_target( struct work* work, double job_diff ) 4 | { 5 | work_set_target( work, job_diff / (128.0 * opt_diff_factor) ); 6 | } 7 | 8 | int64_t keccak_get_max64() { return 0x7ffffLL; } 9 | 10 | bool register_keccak_algo( algo_gate_t* gate ) 11 | { 12 | gate->optimizations = AVX2_OPT; 13 | gate->gen_merkle_root = (void*)&SHA256_gen_merkle_root; 14 | gate->set_target = (void*)&keccak_set_target; 15 | gate->get_max64 = (void*)&keccak_get_max64; 16 | #if defined (KECCAK_4WAY) 17 | gate->scanhash = (void*)&scanhash_keccak_4way; 18 | gate->hash = (void*)&keccakhash_4way; 19 | #else 20 | gate->scanhash = (void*)&scanhash_keccak; 21 | gate->hash = (void*)&keccakhash; 22 | #endif 23 | return true; 24 | }; 25 | 26 | void keccakc_set_target( struct work* work, double job_diff ) 27 | { 28 | work_set_target( work, job_diff / (256.0 * opt_diff_factor) ); 29 | } 30 | 31 | bool register_keccakc_algo( algo_gate_t* gate ) 32 | { 33 | gate->optimizations = AVX2_OPT; 34 | gate->gen_merkle_root = (void*)&sha256d_gen_merkle_root; 35 | gate->set_target = (void*)&keccakc_set_target; 36 | gate->get_max64 = (void*)&keccak_get_max64; 37 | #if defined (KECCAK_4WAY) 38 | gate->scanhash = (void*)&scanhash_keccak_4way; 39 | gate->hash = (void*)&keccakhash_4way; 40 | #else 41 | gate->scanhash = (void*)&scanhash_keccak; 42 | gate->hash = (void*)&keccakhash; 43 | #endif 44 | return true; 45 | }; 46 | 47 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/genkat.h.hide: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 source code package 3 | * 4 | * Written by Daniel Dinu and Dmitry Khovratovich, 2015 5 | * 6 | * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. 7 | * 8 | * You should have received a copy of the CC0 Public Domain Dedication along 9 | * with 10 | * this software. If not, see 11 | * . 12 | */ 13 | 14 | #ifndef ARGON2_KAT_H 15 | #define ARGON2_KAT_H 16 | 17 | /* 18 | * Initial KAT function that prints the inputs to the file 19 | * @param blockhash Array that contains pre-hashing digest 20 | * @param context Holds inputs 21 | * @param type Argon2 type 22 | * @pre blockhash must point to INPUT_INITIAL_HASH_LENGTH bytes 23 | * @pre context member pointers must point to allocated memory of size according 24 | * to the length values 25 | */ 26 | void initial_kat(const uint8_t *blockhash, const argon2_context *context, 27 | argon2_type type); 28 | 29 | /* 30 | * Function that prints the output tag 31 | * @param out output array pointer 32 | * @param outlen digest length 33 | * @pre out must point to @a outlen bytes 34 | **/ 35 | void print_tag(const void *out, uint32_t outlen); 36 | 37 | /* 38 | * Function that prints the internal state at given moment 39 | * @param instance pointer to the current instance 40 | * @param pass current pass number 41 | * @pre instance must have necessary memory allocated 42 | **/ 43 | void internal_kat(const argon2_instance_t *instance, uint32_t pass); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /algo/luffa/luffa.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "sph_luffa.h" 9 | 10 | void luffahash(void *output, const void *input) 11 | { 12 | unsigned char _ALIGN(128) hash[64]; 13 | sph_luffa512_context ctx_luffa; 14 | 15 | sph_luffa512_init(&ctx_luffa); 16 | sph_luffa512 (&ctx_luffa, input, 80); 17 | sph_luffa512_close(&ctx_luffa, (void*) hash); 18 | 19 | memcpy(output, hash, 32); 20 | } 21 | 22 | int scanhash_luffa(int thr_id, struct work *work, 23 | uint32_t max_nonce, uint64_t *hashes_done) 24 | { 25 | uint32_t *pdata = work->data; 26 | uint32_t *ptarget = work->target; 27 | 28 | uint32_t _ALIGN(64) hash64[8]; 29 | uint32_t _ALIGN(64) endiandata[20]; 30 | 31 | const uint32_t Htarg = ptarget[7]; 32 | const uint32_t first_nonce = pdata[19]; 33 | 34 | uint32_t n = first_nonce; 35 | 36 | for (int i=0; i < 19; i++) 37 | be32enc(&endiandata[i], pdata[i]); 38 | 39 | do { 40 | be32enc(&endiandata[19], n); 41 | luffahash(hash64, endiandata); 42 | if (hash64[7] < Htarg && fulltest(hash64, ptarget)) { 43 | *hashes_done = n - first_nonce + 1; 44 | pdata[19] = n; 45 | return true; 46 | } 47 | n++; 48 | 49 | } while (n < max_nonce && !work_restart[thr_id].restart); 50 | 51 | *hashes_done = n - first_nonce + 1; 52 | pdata[19] = n; 53 | 54 | return 0; 55 | } 56 | 57 | bool register_luffa_algo( algo_gate_t* gate ) 58 | { 59 | gate->scanhash = (void*)&scanhash_luffa; 60 | gate->hash = (void*)&luffahash; 61 | return true; 62 | }; 63 | 64 | -------------------------------------------------------------------------------- /algo/echo/aes_ni/hash_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * file : hash_api.h 3 | * version : 1.0.208 4 | * date : 14.12.2010 5 | * 6 | * ECHO vperm implementation Hash API 7 | * 8 | * Cagdas Calik 9 | * ccalik@metu.edu.tr 10 | * Institute of Applied Mathematics, Middle East Technical University, Turkey. 11 | * 12 | */ 13 | 14 | 15 | #ifndef HASH_API_H 16 | #define HASH_API_H 17 | 18 | #ifndef NO_AES_NI 19 | #define HASH_IMPL_STR "ECHO-aesni" 20 | #else 21 | #define HASH_IMPL_STR "ECHO-vperm" 22 | #endif 23 | 24 | 25 | #include "algo/sha/sha3_common.h" 26 | 27 | #include 28 | 29 | 30 | typedef struct 31 | { 32 | __m128i state[4][4]; 33 | BitSequence buffer[192]; 34 | __m128i k; 35 | __m128i hashsize; 36 | __m128i const1536; 37 | 38 | unsigned int uRounds; 39 | unsigned int uHashSize; 40 | unsigned int uBlockLength; 41 | unsigned int uBufferBytes; 42 | DataLength processed_bits; 43 | 44 | } hashState_echo __attribute__ ((aligned (64))); 45 | 46 | HashReturn init_echo(hashState_echo *state, int hashbitlen); 47 | 48 | HashReturn reinit_echo(hashState_echo *state); 49 | 50 | HashReturn update_echo(hashState_echo *state, const BitSequence *data, DataLength databitlen); 51 | 52 | HashReturn final_echo(hashState_echo *state, BitSequence *hashval); 53 | 54 | HashReturn hash_echo(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval); 55 | 56 | HashReturn update_final_echo( hashState_echo *state, BitSequence *hashval, 57 | const BitSequence *data, DataLength databitlen ); 58 | 59 | #endif // HASH_API_H 60 | 61 | -------------------------------------------------------------------------------- /algo/bmw/bmw256.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "sph_bmw.h" 7 | 8 | void bmwhash(void *output, const void *input) 9 | { 10 | /* 11 | uint32_t hash[16]; 12 | sph_bmw256_context ctx; 13 | 14 | sph_bmw256_init(&ctx); 15 | sph_bmw256(&ctx, input, 80); 16 | sph_bmw256_close(&ctx, hash); 17 | 18 | memcpy(output, hash, 32); 19 | */ 20 | } 21 | 22 | int scanhash_bmw( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ) 24 | { 25 | uint32_t *pdata = work->data; 26 | uint32_t *ptarget = work->target; 27 | 28 | uint32_t _ALIGN(64) hash64[8]; 29 | uint32_t _ALIGN(64) endiandata[20]; 30 | int thr_id = mythr->id; 31 | 32 | const uint32_t Htarg = ptarget[7]; 33 | const uint32_t first_nonce = pdata[19]; 34 | 35 | uint32_t n = first_nonce; 36 | 37 | for (int k = 0; k < 19; k++) 38 | be32enc(&endiandata[k], pdata[k]); 39 | 40 | do { 41 | be32enc(&endiandata[19], n); 42 | bmwhash(hash64, endiandata); 43 | if (hash64[7] < Htarg && fulltest(hash64, ptarget)) { 44 | *hashes_done = n - first_nonce + 1; 45 | pdata[19] = n; 46 | return true; 47 | } 48 | n++; 49 | 50 | } while (n < max_nonce && !work_restart[thr_id].restart); 51 | 52 | *hashes_done = n - first_nonce + 1; 53 | pdata[19] = n; 54 | 55 | return 0; 56 | } 57 | 58 | bool register_bmw256_algo( algo_gate_t* gate ) 59 | { 60 | algo_not_implemented(); 61 | return false; 62 | // gate->scanhash = (void*)&scanhash_bmw; 63 | // gate->hash = (void*)&bmwhash; 64 | return true; 65 | }; 66 | 67 | -------------------------------------------------------------------------------- /asm/aesb-x64.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if defined(__linux__) && defined(__ELF__) 4 | .section .note.GNU-stack,"",%progbits 5 | #endif 6 | 7 | .text 8 | .p2align 6 9 | .globl fast_aesb_single_round 10 | .globl _fast_aesb_single_round 11 | fast_aesb_single_round: 12 | _fast_aesb_single_round: 13 | #if defined(_WIN64) || defined(__CYGWIN__) 14 | movdqa (%rcx), %xmm1 15 | aesenc (%r8), %xmm1 16 | movdqa %xmm1, (%rdx) 17 | #else 18 | movdqa (%rdi), %xmm1 19 | aesenc (%rdx), %xmm1 20 | movdqa %xmm1, (%rsi) 21 | #endif 22 | ret 23 | 24 | .text 25 | .p2align 6 26 | .globl fast_aesb_pseudo_round_mut 27 | .globl _fast_aesb_pseudo_round_mut 28 | fast_aesb_pseudo_round_mut: 29 | _fast_aesb_pseudo_round_mut: 30 | #if defined(_WIN64) || defined(__CYGWIN__) 31 | mov %rdx, %r9 32 | add $0xA0, %r9 33 | movdqa (%rcx), %xmm1 34 | 35 | .LOOP: 36 | aesenc (%rdx), %xmm1 37 | add $0x10, %rdx 38 | cmp %r9, %rdx 39 | jl .LOOP 40 | 41 | movdqa %xmm1, (%rcx) 42 | #else 43 | mov %rsi, %r9 44 | add $0xA0, %r9 45 | movdqa (%rdi), %xmm1 46 | 47 | .LOOP: 48 | aesenc (%rsi), %xmm1 49 | add $0x10, %rsi 50 | cmp %r9, %rsi 51 | jl .LOOP 52 | 53 | movdqa %xmm1, (%rdi) 54 | #endif 55 | ret 56 | 57 | .text 58 | .globl mul128 59 | .globl _mul128 60 | mul128: 61 | _mul128: 62 | #if defined(_WIN64) || defined(__CYGWIN__) 63 | mov %rcx, %rax 64 | mul %rdx 65 | mov %rdx, (%r8) 66 | #else 67 | mov %rdx, %r8 68 | mov %rdi, %rax 69 | mul %rsi 70 | mov %rdx, (%r8) 71 | #endif 72 | ret 73 | -------------------------------------------------------------------------------- /algo/simd/nist.h: -------------------------------------------------------------------------------- 1 | #ifndef __NIST_H__ 2 | #define __NIST_H__ 3 | 4 | /*define data alignment for different C compilers*/ 5 | #if defined(__GNUC__) 6 | #define DATA_ALIGN(x) x __attribute__((aligned(16))) 7 | #else 8 | #define DATA_ALIGN(x) __declspec(align(16)) x 9 | #endif 10 | 11 | #include "simd-compat.h" 12 | #include "algo/sha/sha3-defs.h" 13 | /* 14 | * NIST API Specific types. 15 | */ 16 | 17 | typedef struct { 18 | unsigned int hashbitlen; 19 | unsigned int blocksize; 20 | unsigned int n_feistels; 21 | 22 | #ifdef HAS_64 23 | u64 count; 24 | #else 25 | u32 count_low; 26 | u32 count_high; 27 | #endif 28 | 29 | DATA_ALIGN(u32 A[32]); 30 | u32 *B; 31 | u32 *C; 32 | u32 *D; 33 | DATA_ALIGN(unsigned char buffer[128]); 34 | 35 | } hashState_sd; 36 | 37 | /* 38 | * NIST API 39 | */ 40 | 41 | HashReturn init_sd(hashState_sd *state, int hashbitlen); 42 | 43 | HashReturn update_sd(hashState_sd *state, const BitSequence *data, DataLength databitlen); 44 | 45 | HashReturn final_sd(hashState_sd *state, BitSequence *hashval); 46 | 47 | HashReturn update_final_sd( hashState_sd *state, BitSequence *hashval, 48 | const BitSequence *data, DataLength databitlen ); 49 | 50 | //HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, 51 | // BitSequence *hashval); 52 | 53 | /* 54 | * Internal API 55 | */ 56 | 57 | int SupportedLength(int hashbitlen); 58 | int RequiredAlignment(void); 59 | void SIMD_Compress(hashState_sd * state, const unsigned char *M, int final); 60 | 61 | void fft128_natural(fft_t *a, unsigned char *x); 62 | void fft256_natural(fft_t *a, unsigned char *x); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /algo/blake/blake2b.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Blake2-B Implementation 3 | * tpruvot@github 2015-2016 4 | */ 5 | 6 | #include "blake2b-gate.h" 7 | #include 8 | #include 9 | #include "algo/blake/sph_blake2b.h" 10 | 11 | #define MIDLEN 76 12 | #define A 64 13 | 14 | void blake2b_hash(void *output, const void *input) 15 | { 16 | uint8_t _ALIGN(A) hash[32]; 17 | sph_blake2b_ctx ctx __attribute__ ((aligned (64))); 18 | 19 | sph_blake2b_init(&ctx, 32, NULL, 0); 20 | sph_blake2b_update(&ctx, input, 80); 21 | sph_blake2b_final(&ctx, hash); 22 | 23 | memcpy(output, hash, 32); 24 | } 25 | 26 | int scanhash_blake2b( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ) 28 | { 29 | uint32_t _ALIGN(A) vhashcpu[8]; 30 | uint32_t _ALIGN(A) endiandata[20]; 31 | uint32_t *pdata = work->data; 32 | uint32_t *ptarget = work->target; 33 | int thr_id = mythr->id; // thr_id arg is deprecated 34 | 35 | const uint32_t Htarg = ptarget[7]; 36 | const uint32_t first_nonce = pdata[19]; 37 | 38 | uint32_t n = first_nonce; 39 | 40 | for (int i=0; i < 19; i++) { 41 | be32enc(&endiandata[i], pdata[i]); 42 | } 43 | 44 | do { 45 | be32enc(&endiandata[19], n); 46 | //blake2b_hash_end(vhashcpu, endiandata); 47 | blake2b_hash(vhashcpu, endiandata); 48 | 49 | if (vhashcpu[7] < Htarg && fulltest(vhashcpu, ptarget)) { 50 | work_set_target_ratio(work, vhashcpu); 51 | *hashes_done = n - first_nonce + 1; 52 | pdata[19] = n; 53 | return 1; 54 | } 55 | n++; 56 | 57 | } while (n < max_nonce && !work_restart[thr_id].restart); 58 | *hashes_done = n - first_nonce + 1; 59 | pdata[19] = n; 60 | 61 | return 0; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /algo/cryptonight/cryptonight.h: -------------------------------------------------------------------------------- 1 | #ifndef __CRYPTONIGHT_H_INCLUDED 2 | #define __CRYPTONIGHT_H_INCLUDED 3 | 4 | #include 5 | #include "crypto/oaes_lib.h" 6 | #include "miner.h" 7 | 8 | #define MEMORY (1 << 21) /* 2 MiB */ 9 | #define MEMORY_M128I (MEMORY >> 4) // 2 MiB / 16 = 128 ki * __m128i 10 | #define ITER (1 << 20) 11 | #define AES_BLOCK_SIZE 16 12 | #define AES_KEY_SIZE 32 /*16*/ 13 | #define INIT_SIZE_BLK 8 14 | #define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE) // 128 15 | #define INIT_SIZE_M128I (INIT_SIZE_BYTE >> 4) // 8 16 | 17 | 18 | #pragma pack(push, 1) 19 | union hash_state { 20 | uint8_t b[200]; 21 | uint64_t w[25]; 22 | }; 23 | #pragma pack(pop) 24 | 25 | #pragma pack(push, 1) 26 | union cn_slow_hash_state { 27 | union hash_state hs; 28 | struct { 29 | uint8_t k[64]; 30 | uint8_t init[INIT_SIZE_BYTE]; 31 | }; 32 | }; 33 | #pragma pack(pop) 34 | 35 | void do_blake_hash(const void* input, size_t len, char* output); 36 | void do_groestl_hash(const void* input, size_t len, char* output); 37 | void do_jh_hash(const void* input, size_t len, char* output); 38 | void do_skein_hash(const void* input, size_t len, char* output); 39 | void cryptonight_hash_ctx(void* output, const void* input, int len); 40 | void keccakf(uint64_t st[25], int rounds); 41 | extern void (* const extra_hashes[4])(const void *, size_t, char *); 42 | 43 | int scanhash_cryptonight( struct work *work, uint32_t max_nonce, 44 | uint64_t *hashes_done, struct thr_info *mythr ); 45 | 46 | void cryptonight_hash_aes( void *restrict output, const void *input, int len ); 47 | 48 | extern bool cryptonightV7; 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /algo/scryptjane/scrypt-jane-mix_chacha.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_CHACHA_INCLUDED) 2 | 3 | #undef SCRYPT_MIX 4 | #define SCRYPT_MIX "ChaCha20/8 Ref" 5 | 6 | #undef SCRYPT_CHACHA_INCLUDED 7 | #define SCRYPT_CHACHA_INCLUDED 8 | #define SCRYPT_CHACHA_BASIC 9 | 10 | static void 11 | chacha_core_basic(uint32_t state[16]) { 12 | size_t rounds = 8; 13 | uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,t; 14 | 15 | x0 = state[0]; 16 | x1 = state[1]; 17 | x2 = state[2]; 18 | x3 = state[3]; 19 | x4 = state[4]; 20 | x5 = state[5]; 21 | x6 = state[6]; 22 | x7 = state[7]; 23 | x8 = state[8]; 24 | x9 = state[9]; 25 | x10 = state[10]; 26 | x11 = state[11]; 27 | x12 = state[12]; 28 | x13 = state[13]; 29 | x14 = state[14]; 30 | x15 = state[15]; 31 | 32 | #define quarter(a,b,c,d) \ 33 | a += b; t = d^a; d = ROTL32(t,16); \ 34 | c += d; t = b^c; b = ROTL32(t,12); \ 35 | a += b; t = d^a; d = ROTL32(t, 8); \ 36 | c += d; t = b^c; b = ROTL32(t, 7); 37 | 38 | for (; rounds; rounds -= 2) { 39 | quarter( x0, x4, x8,x12) 40 | quarter( x1, x5, x9,x13) 41 | quarter( x2, x6,x10,x14) 42 | quarter( x3, x7,x11,x15) 43 | quarter( x0, x5,x10,x15) 44 | quarter( x1, x6,x11,x12) 45 | quarter( x2, x7, x8,x13) 46 | quarter( x3, x4, x9,x14) 47 | } 48 | 49 | state[0] += x0; 50 | state[1] += x1; 51 | state[2] += x2; 52 | state[3] += x3; 53 | state[4] += x4; 54 | state[5] += x5; 55 | state[6] += x6; 56 | state[7] += x7; 57 | state[8] += x8; 58 | state[9] += x9; 59 | state[10] += x10; 60 | state[11] += x11; 61 | state[12] += x12; 62 | state[13] += x13; 63 | state[14] += x14; 64 | state[15] += x15; 65 | 66 | #undef quarter 67 | } 68 | 69 | #endif -------------------------------------------------------------------------------- /algo/scryptjane/scrypt-jane-mix_salsa.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA_INCLUDED) 2 | 3 | #undef SCRYPT_MIX 4 | #define SCRYPT_MIX "Salsa20/8 Ref" 5 | 6 | #undef SCRYPT_SALSA_INCLUDED 7 | #define SCRYPT_SALSA_INCLUDED 8 | #define SCRYPT_SALSA_BASIC 9 | 10 | static void 11 | salsa_core_basic(uint32_t state[16]) { 12 | size_t rounds = 8; 13 | uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,t; 14 | 15 | x0 = state[0]; 16 | x1 = state[1]; 17 | x2 = state[2]; 18 | x3 = state[3]; 19 | x4 = state[4]; 20 | x5 = state[5]; 21 | x6 = state[6]; 22 | x7 = state[7]; 23 | x8 = state[8]; 24 | x9 = state[9]; 25 | x10 = state[10]; 26 | x11 = state[11]; 27 | x12 = state[12]; 28 | x13 = state[13]; 29 | x14 = state[14]; 30 | x15 = state[15]; 31 | 32 | #define quarter(a,b,c,d) \ 33 | t = a+d; t = ROTL32(t, 7); b ^= t; \ 34 | t = b+a; t = ROTL32(t, 9); c ^= t; \ 35 | t = c+b; t = ROTL32(t, 13); d ^= t; \ 36 | t = d+c; t = ROTL32(t, 18); a ^= t; \ 37 | 38 | for (; rounds; rounds -= 2) { 39 | quarter( x0, x4, x8,x12) 40 | quarter( x5, x9,x13, x1) 41 | quarter(x10,x14, x2, x6) 42 | quarter(x15, x3, x7,x11) 43 | quarter( x0, x1, x2, x3) 44 | quarter( x5, x6, x7, x4) 45 | quarter(x10,x11, x8, x9) 46 | quarter(x15,x12,x13,x14) 47 | } 48 | 49 | state[0] += x0; 50 | state[1] += x1; 51 | state[2] += x2; 52 | state[3] += x3; 53 | state[4] += x4; 54 | state[5] += x5; 55 | state[6] += x6; 56 | state[7] += x7; 57 | state[8] += x8; 58 | state[9] += x9; 59 | state[10] += x10; 60 | state[11] += x11; 61 | state[12] += x12; 62 | state[13] += x13; 63 | state[14] += x14; 64 | state[15] += x15; 65 | 66 | #undef quarter 67 | } 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /algo/skein/skein.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | #include 3 | #include 4 | #include "sph_skein.h" 5 | #include 6 | 7 | void skeinhash(void *state, const void *input) 8 | { 9 | uint32_t hash[16] __attribute__ ((aligned (64))); 10 | sph_skein512_context ctx_skein; 11 | SHA256_CTX ctx_sha256; 12 | 13 | sph_skein512_init( &ctx_skein ); 14 | sph_skein512( &ctx_skein, input, 80 ); 15 | sph_skein512_close( &ctx_skein, hash ); 16 | 17 | SHA256_Init( &ctx_sha256 ); 18 | SHA256_Update( &ctx_sha256, (unsigned char*)hash, 64 ); 19 | SHA256_Final( (unsigned char*) hash, &ctx_sha256 ); 20 | 21 | memcpy(state, hash, 32); 22 | } 23 | 24 | int scanhash_skein( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ) 26 | { 27 | uint32_t *pdata = work->data; 28 | uint32_t *ptarget = work->target; 29 | uint32_t hash64[8] __attribute__ ((aligned (64))); 30 | uint32_t endiandata[20] __attribute__ ((aligned (64))); 31 | const uint32_t Htarg = ptarget[7]; 32 | const uint32_t first_nonce = pdata[19]; 33 | uint32_t n = first_nonce; 34 | int thr_id = mythr->id; // thr_id arg is deprecated 35 | 36 | swab32_array( endiandata, pdata, 20 ); 37 | 38 | do { 39 | be32enc(&endiandata[19], n); 40 | skeinhash(hash64, endiandata); 41 | if (hash64[7] < Htarg && fulltest(hash64, ptarget)) { 42 | *hashes_done = n - first_nonce + 1; 43 | pdata[19] = n; 44 | return true; 45 | } 46 | n++; 47 | 48 | } while (n < max_nonce && !work_restart[thr_id].restart); 49 | 50 | *hashes_done = n - first_nonce + 1; 51 | pdata[19] = n; 52 | 53 | return 0; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /crypto/c_groestl.h: -------------------------------------------------------------------------------- 1 | #ifndef __hash_h 2 | #define __hash_h 3 | /* 4 | #include "crypto_uint8.h" 5 | #include "crypto_uint32.h" 6 | #include "crypto_uint64.h" 7 | #include "crypto_hash.h" 8 | 9 | typedef crypto_uint8 uint8_t; 10 | typedef crypto_uint32 uint32_t; 11 | typedef crypto_uint64 uint64_t; 12 | */ 13 | #include 14 | 15 | #include "hash.h" 16 | 17 | /* some sizes (number of bytes) */ 18 | #define ROWS 8 19 | #define LENGTHFIELDLEN ROWS 20 | #define COLS512 8 21 | 22 | #define SIZE512 (ROWS*COLS512) 23 | 24 | #define ROUNDS512 10 25 | #define HASH_BIT_LEN 256 26 | 27 | #define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff)) 28 | 29 | 30 | #define li_32(h) 0x##h##u 31 | #define EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n))) 32 | #define u32BIG(a) \ 33 | ((ROTL32(a,8) & li_32(00FF00FF)) | \ 34 | (ROTL32(a,24) & li_32(FF00FF00))) 35 | 36 | 37 | /* NIST API begin */ 38 | typedef struct { 39 | uint32_t chaining[SIZE512/sizeof(uint32_t)]; /* actual state */ 40 | uint32_t block_counter1, 41 | block_counter2; /* message block counter(s) */ 42 | BitSequence buffer[SIZE512]; /* data buffer */ 43 | int buf_ptr; /* data buffer pointer */ 44 | int bits_in_last_byte; /* no. of message bits in last byte of 45 | data buffer */ 46 | } groestlHashState; 47 | 48 | /*void Init(hashState*); 49 | void Update(hashState*, const BitSequence*, DataLength); 50 | void Final(hashState*, BitSequence*); */ 51 | void groestl(const BitSequence*, DataLength, BitSequence*); 52 | /* NIST API end */ 53 | 54 | /* 55 | int crypto_hash(unsigned char *out, 56 | const unsigned char *in, 57 | unsigned long long len); 58 | */ 59 | 60 | #endif /* __hash_h */ 61 | -------------------------------------------------------------------------------- /compat/jansson/error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "jansson_private.h" 3 | 4 | void jsonp_error_init(json_error_t *error, const char *source) 5 | { 6 | if(error) 7 | { 8 | error->text[0] = '\0'; 9 | error->line = -1; 10 | error->column = -1; 11 | error->position = 0; 12 | if(source) 13 | jsonp_error_set_source(error, source); 14 | else 15 | error->source[0] = '\0'; 16 | } 17 | } 18 | 19 | void jsonp_error_set_source(json_error_t *error, const char *source) 20 | { 21 | size_t length; 22 | 23 | if(!error || !source) 24 | return; 25 | 26 | length = strlen(source); 27 | if(length < JSON_ERROR_SOURCE_LENGTH) 28 | strcpy(error->source, source); 29 | else { 30 | size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; 31 | strcpy(error->source, "..."); 32 | strcpy(error->source + 3, source + extra); 33 | } 34 | } 35 | 36 | void jsonp_error_set(json_error_t *error, int line, int column, 37 | size_t position, const char *msg, ...) 38 | { 39 | va_list ap; 40 | 41 | va_start(ap, msg); 42 | jsonp_error_vset(error, line, column, position, msg, ap); 43 | va_end(ap); 44 | } 45 | 46 | void jsonp_error_vset(json_error_t *error, int line, int column, 47 | size_t position, const char *msg, va_list ap) 48 | { 49 | if(!error) 50 | return; 51 | 52 | if(error->text[0] != '\0') { 53 | /* error already set */ 54 | return; 55 | } 56 | 57 | error->line = line; 58 | error->column = column; 59 | error->position = position; 60 | 61 | vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap); 62 | error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; 63 | } 64 | -------------------------------------------------------------------------------- /crypto/hash-ops.h: -------------------------------------------------------------------------------- 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 | 5 | #pragma once 6 | 7 | #if !defined(__cplusplus) 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "int-util.h" 15 | 16 | #if 0 17 | static inline void *padd(void *p, size_t i) { 18 | return (char *) p + i; 19 | } 20 | 21 | static inline const void *cpadd(const void *p, size_t i) { 22 | return (const char *) p + i; 23 | } 24 | 25 | static inline void place_length(uint8_t *buffer, size_t bufsize, size_t length) { 26 | if (sizeof(size_t) == 4) { 27 | *(uint32_t*) padd(buffer, bufsize - 4) = swap32be(length); 28 | } else { 29 | *(uint64_t*) padd(buffer, bufsize - 8) = swap64be(length); 30 | } 31 | } 32 | #endif 33 | 34 | #pragma pack(push, 1) 35 | union hash_state { 36 | uint8_t b[200]; 37 | uint64_t w[25]; 38 | }; 39 | #pragma pack(pop) 40 | 41 | void hash_permutation(union hash_state *state); 42 | void hash_process(union hash_state *state, const uint8_t *buf, int count); 43 | 44 | #endif 45 | 46 | enum { 47 | HASH_SIZE = 32, 48 | HASH_DATA_AREA = 136 49 | }; 50 | 51 | void cn_fast_hash(const void *data, int len, char *hash); 52 | void cn_slow_hash(const void *data, size_t length, char *hash); 53 | 54 | void hash_extra_blake(const void *data, size_t length, char *hash); 55 | void hash_extra_groestl(const void *data, size_t length, char *hash); 56 | void hash_extra_jh(const void *data, size_t length, char *hash); 57 | void hash_extra_skein(const void *data, size_t length, char *hash); 58 | 59 | void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash); 60 | -------------------------------------------------------------------------------- /algo/scryptjane/scrypt-jane-hash.h: -------------------------------------------------------------------------------- 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 | */ 49 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/ref.h.hide: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 source code package 3 | * 4 | * Written by Daniel Dinu and Dmitry Khovratovich, 2015 5 | * 6 | * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. 7 | * 8 | * You should have received a copy of the CC0 Public Domain Dedication along 9 | * with 10 | * this software. If not, see 11 | * . 12 | */ 13 | 14 | #ifndef ARGON2_REF_H 15 | #define ARGON2_REF_H 16 | 17 | /* 18 | * Function fills a new memory block 19 | * @param prev_block Pointer to the previous block 20 | * @param ref_block Pointer to the reference block 21 | * @param next_block Pointer to the block to be constructed 22 | * @pre all block pointers must be valid 23 | */ 24 | void fill_block(const block *prev_block, const block *ref_block, 25 | block *next_block); 26 | 27 | /* 28 | * Generate pseudo-random values to reference blocks in the segment and puts 29 | * them into the array 30 | * @param instance Pointer to the current instance 31 | * @param position Pointer to the current position 32 | * @param pseudo_rands Pointer to the array of 64-bit values 33 | * @pre pseudo_rands must point to @a instance->segment_length allocated values 34 | */ 35 | void generate_addresses(const argon2_instance_t *instance, 36 | const argon2_position_t *position, 37 | uint64_t *pseudo_rands); 38 | 39 | /* 40 | * Function that fills the segment using previous segments also from other 41 | * threads 42 | * @param instance Pointer to the current instance 43 | * @param position Current position 44 | * @pre all block pointers must be valid 45 | */ 46 | void fill_segment(const argon2_instance_t *instance, 47 | argon2_position_t position); 48 | 49 | #endif /* ARGON2_REF_H */ 50 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | This file is included in the Windows binary package. Compile instructions 2 | for Linux and Windows can be found in RELEASE_NOTES. 3 | 4 | cpuminer is a console program that is executed from a DOS command prompt. 5 | There is no GUI and no mouse support. 6 | 7 | Miner programs are often flagged as malware by antivirus programs. This is 8 | a false positive, they are flagged simply because they are cryptocurrency 9 | miners. The source code is open for anyone to inspect. If you don't trust 10 | the software, don't use it. 11 | 12 | Choose the exe that best matches you CPU's features or use trial and 13 | error to find the fastest one that doesn't crash. Pay attention to 14 | the features listed at cpuminer startup to ensure you are mining at 15 | optimum speed using the best available features. 16 | 17 | Architecture names and compile options used are only provided for Intel 18 | Core series. Even the newest Pentium and Celeron CPUs are often missing 19 | features. 20 | 21 | AMD CPUs older than Piledriver, including Athlon x2 and Phenom II x4, are not 22 | supported by cpuminer-opt due to an incompatible implementation of SSE2 on 23 | these CPUs. Some algos may crash the miner with an invalid instruction. 24 | Users are recommended to use an unoptimized miner such as cpuminer-multi. 25 | 26 | Exe name Compile flags Arch name 27 | 28 | cpuminer-sse2.exe "-msse2" Core2, Nehalem 29 | cpuminer-aes-sse42.exe "-march=westmere" Westmere 30 | cpuminer-avx.exe "-march=corei7-avx" Sandy-Ivybridge 31 | cpuminer-avx2.exe "-march=core-avx2" Haswell, Sky-Kaby-Coffeelake 32 | cpuminer-zen "-march=znver1" AMD Ryzen, Threadripper 33 | 34 | If you like this software feel free to donate: 35 | 36 | BTC: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT 37 | 38 | 39 | -------------------------------------------------------------------------------- /algo/argon2/argon2d/argon2d/argon2d_thread.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 reference source code package - reference C implementations 3 | * 4 | * Copyright 2015 5 | * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves 6 | * 7 | * You may use this work under the terms of a Creative Commons CC0 1.0 8 | * License/Waiver or the Apache Public License 2.0, at your option. The terms of 9 | * these licenses can be found at: 10 | * 11 | * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 12 | * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * You should have received a copy of both of these licenses along with this 15 | * software. If not, they may be obtained at the above URLs. 16 | */ 17 | 18 | #if !defined(ARGON2_NO_THREADS) 19 | 20 | #include "argon2d_thread.h" 21 | #if defined(_WIN32) 22 | #include 23 | #endif 24 | 25 | int argon2_thread_create(argon2_thread_handle_t *handle, 26 | argon2_thread_func_t func, void *args) { 27 | if (NULL == handle || func == NULL) { 28 | return -1; 29 | } 30 | #if defined(_WIN32) 31 | *handle = _beginthreadex(NULL, 0, func, args, 0, NULL); 32 | return *handle != 0 ? 0 : -1; 33 | #else 34 | return pthread_create(handle, NULL, func, args); 35 | #endif 36 | } 37 | 38 | int argon2_thread_join(argon2_thread_handle_t handle) { 39 | #if defined(_WIN32) 40 | if (WaitForSingleObject((HANDLE)handle, INFINITE) == WAIT_OBJECT_0) { 41 | return CloseHandle((HANDLE)handle) != 0 ? 0 : -1; 42 | } 43 | return -1; 44 | #else 45 | return pthread_join(handle, NULL); 46 | #endif 47 | } 48 | 49 | void argon2_thread_exit(void) { 50 | #if defined(_WIN32) 51 | _endthreadex(0); 52 | #else 53 | pthread_exit(NULL); 54 | #endif 55 | } 56 | 57 | #endif /* ARGON2_NO_THREADS */ 58 | -------------------------------------------------------------------------------- /algo/sha/sha256t-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __SHA256T_GATE_H__ 2 | #define __SHA256T_GATE_H__ 1 3 | 4 | #include 5 | #include "algo-gate-api.h" 6 | 7 | // Override multi way on ryzen, SHA is better. 8 | #if !defined(__SHA__) 9 | #if defined(__AVX2__) 10 | #define SHA256T_8WAY 11 | #elif defined(__SSE2__) 12 | #define SHA256T_4WAY 13 | #endif 14 | #endif 15 | 16 | bool register_sha256t_algo( algo_gate_t* gate ); 17 | bool register_sha256q_algo( algo_gate_t* gate ); 18 | 19 | #if defined(SHA256T_8WAY) 20 | 21 | void sha256t_8way_hash( void *output, const void *input ); 22 | int scanhash_sha256t_8way( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | void sha256q_8way_hash( void *output, const void *input ); 25 | int scanhash_sha256q_8way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | #endif 28 | 29 | #if defined(SHA256T_4WAY) 30 | 31 | void sha256t_4way_hash( void *output, const void *input ); 32 | int scanhash_sha256t_4way( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | void sha256q_4way_hash( void *output, const void *input ); 35 | int scanhash_sha256q_4way( struct work *work, uint32_t max_nonce, 36 | uint64_t *hashes_done, struct thr_info *mythr ); 37 | #endif 38 | 39 | void sha256t_hash( void *output, const void *input ); 40 | int scanhash_sha256t( struct work *work, uint32_t max_nonce, 41 | uint64_t *hashes_done, struct thr_info *mythr ); 42 | void sha256q_hash( void *output, const void *input ); 43 | int scanhash_sha256q( struct work *work, uint32_t max_nonce, 44 | uint64_t *hashes_done, struct thr_info *mythr ); 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /algo/x11/timetravel-gate.c: -------------------------------------------------------------------------------- 1 | #include "timetravel-gate.h" 2 | 3 | void tt8_set_target( struct work* work, double job_diff ) 4 | { 5 | work_set_target( work, job_diff / (256.0 * opt_diff_factor) ); 6 | } 7 | 8 | bool register_timetravel_algo( algo_gate_t* gate ) 9 | { 10 | #ifdef TIMETRAVEL_4WAY 11 | init_tt8_4way_ctx(); 12 | gate->scanhash = (void*)&scanhash_timetravel_4way; 13 | gate->hash = (void*)&timetravel_4way_hash; 14 | #else 15 | init_tt8_ctx(); 16 | gate->scanhash = (void*)&scanhash_timetravel; 17 | gate->hash = (void*)&timetravel_hash; 18 | #endif 19 | gate->set_target = (void*)&tt8_set_target; 20 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 21 | gate->get_max64 = (void*)&get_max64_0xffffLL; 22 | return true; 23 | }; 24 | 25 | inline void tt_swap( int *a, int *b ) 26 | { 27 | int c = *a; 28 | *a = *b; 29 | *b = c; 30 | } 31 | 32 | inline void reverse( int *pbegin, int *pend ) 33 | { 34 | while ( (pbegin != pend) && (pbegin != --pend) ) 35 | { 36 | tt_swap( pbegin, pend ); 37 | pbegin++; 38 | } 39 | } 40 | 41 | void tt8_next_permutation( int *pbegin, int *pend ) 42 | { 43 | if ( pbegin == pend ) 44 | return; 45 | 46 | int *i = pbegin; 47 | ++i; 48 | if ( i == pend ) 49 | return; 50 | 51 | i = pend; 52 | --i; 53 | 54 | while (1) 55 | { 56 | int *j = i; 57 | --i; 58 | 59 | if ( *i < *j ) 60 | { 61 | int *k = pend; 62 | 63 | while ( !(*i < *--k) ) /* do nothing */ ; 64 | 65 | tt_swap( i, k ); 66 | reverse(j, pend); 67 | return; // true 68 | } 69 | 70 | if ( i == pbegin ) 71 | { 72 | reverse(pbegin, pend); 73 | return; // false 74 | } 75 | // else? 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /algo/x11/timetravel10-gate.c: -------------------------------------------------------------------------------- 1 | #include "timetravel10-gate.h" 2 | 3 | void tt10_set_target( struct work* work, double job_diff ) 4 | { 5 | work_set_target( work, job_diff / (256.0 * opt_diff_factor) ); 6 | } 7 | 8 | bool register_timetravel10_algo( algo_gate_t* gate ) 9 | { 10 | #ifdef TIMETRAVEL10_4WAY 11 | init_tt10_4way_ctx(); 12 | gate->scanhash = (void*)&scanhash_timetravel10_4way; 13 | gate->hash = (void*)&timetravel10_4way_hash; 14 | #else 15 | init_tt10_ctx(); 16 | gate->scanhash = (void*)&scanhash_timetravel10; 17 | gate->hash = (void*)&timetravel10_hash; 18 | #endif 19 | gate->set_target = (void*)&tt10_set_target; 20 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 21 | gate->get_max64 = (void*)&get_max64_0xffffLL; 22 | return true; 23 | }; 24 | 25 | inline void tt10_swap( int *a, int *b ) 26 | { 27 | int c = *a; 28 | *a = *b; 29 | *b = c; 30 | } 31 | 32 | inline void reverse( int *pbegin, int *pend ) 33 | { 34 | while ( (pbegin != pend) && (pbegin != --pend) ) 35 | { 36 | tt10_swap( pbegin, pend ); 37 | pbegin++; 38 | } 39 | } 40 | 41 | void tt10_next_permutation( int *pbegin, int *pend ) 42 | { 43 | if ( pbegin == pend ) 44 | return; 45 | 46 | int *i = pbegin; 47 | ++i; 48 | if ( i == pend ) 49 | return; 50 | 51 | i = pend; 52 | --i; 53 | 54 | while (1) 55 | { 56 | int *j = i; 57 | --i; 58 | 59 | if ( *i < *j ) 60 | { 61 | int *k = pend; 62 | 63 | while ( !(*i < *--k) ) /* do nothing */ ; 64 | 65 | tt10_swap( i, k ); 66 | reverse(j, pend); 67 | return; // true 68 | } 69 | 70 | if ( i == pbegin ) 71 | { 72 | reverse(pbegin, pend); 73 | return; // false 74 | } 75 | // else? 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /algo/skein/skein2.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | #include 3 | #include 4 | 5 | #include "sph_skein.h" 6 | 7 | // ctx caching seems slower with this algo 8 | //typedef struct { 9 | // sph_skein512_context skein; 10 | //} skein2_ctx_holder; 11 | 12 | //skein2_ctx_holder skein2_ctx; 13 | 14 | //void init_skein2_ctx() 15 | //{ 16 | // sph_skein512_init(&skein2_ctx.skein); 17 | //} 18 | 19 | void skein2hash(void *output, const void *input) 20 | { 21 | sph_skein512_context ctx_skein; 22 | 23 | uint32_t hash[16] __attribute__ ((aligned (64))); 24 | 25 | sph_skein512_init(&ctx_skein); 26 | sph_skein512(&ctx_skein, input, 80); 27 | sph_skein512_close(&ctx_skein, hash); 28 | 29 | sph_skein512_init(&ctx_skein); 30 | sph_skein512(&ctx_skein, hash, 64); 31 | sph_skein512_close(&ctx_skein, hash); 32 | 33 | memcpy(output, hash, 32); 34 | 35 | } 36 | 37 | int scanhash_skein2( struct work *work, uint32_t max_nonce, 38 | uint64_t *hashes_done, struct thr_info *mythr ) 39 | { 40 | uint32_t *pdata = work->data; 41 | uint32_t *ptarget = work->target; 42 | uint32_t hash64[8] __attribute__ ((aligned (64))); 43 | uint32_t endiandata[20] __attribute__ ((aligned (64))); 44 | const uint32_t Htarg = ptarget[7]; 45 | const uint32_t first_nonce = pdata[19]; 46 | uint32_t n = first_nonce; 47 | int thr_id = mythr->id; // thr_id arg is deprecated 48 | 49 | swab32_array( endiandata, pdata, 20 ); 50 | 51 | do { 52 | be32enc(&endiandata[19], n); 53 | skein2hash(hash64, endiandata); 54 | if (hash64[7] < Htarg && fulltest(hash64, ptarget)) { 55 | *hashes_done = n - first_nonce + 1; 56 | pdata[19] = n; 57 | return true; 58 | } 59 | n++; 60 | 61 | } while (n < max_nonce && !work_restart[thr_id].restart); 62 | 63 | *hashes_done = n - first_nonce + 1; 64 | pdata[19] = n; 65 | 66 | return 0; 67 | } 68 | 69 | 70 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/opt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 source code package 3 | * 4 | * Written by Daniel Dinu and Dmitry Khovratovich, 2015 5 | * 6 | * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. 7 | * 8 | * You should have received a copy of the CC0 Public Domain Dedication along 9 | * with 10 | * this software. If not, see 11 | * . 12 | */ 13 | 14 | #ifndef ARGON2_OPT_H 15 | #define ARGON2_OPT_H 16 | 17 | /* 18 | * Function fills a new memory block. Differs from the 19 | * @param state Pointer to the just produced block. Content will be updated(!) 20 | * @param ref_block Pointer to the reference block 21 | * @param next_block Pointer to the block to be constructed 22 | * @pre all block pointers must be valid 23 | */ 24 | void ar2_fill_block(__m128i *state, __m128i const *ref_block, __m128i *next_block); 25 | 26 | /* 27 | * Generate pseudo-random values to reference blocks in the segment and puts 28 | * them into the array 29 | * @param instance Pointer to the current instance 30 | * @param position Pointer to the current position 31 | * @param pseudo_rands Pointer to the array of 64-bit values 32 | * @pre pseudo_rands must point to @a instance->segment_length allocated values 33 | */ 34 | void ar2_generate_addresses(const argon2_instance_t *instance, 35 | const argon2_position_t *position, 36 | uint64_t *pseudo_rands); 37 | 38 | /* 39 | * Function that fills the segment using previous segments also from other 40 | * threads. 41 | * Identical to the reference code except that it calls optimized FillBlock() 42 | * @param instance Pointer to the current instance 43 | * @param position Current position 44 | * @pre all block pointers must be valid 45 | */ 46 | void ar2_fill_segment(const argon2_instance_t *instance, 47 | argon2_position_t position); 48 | 49 | #endif /* ARGON2_OPT_H */ 50 | -------------------------------------------------------------------------------- /api/websocket.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Simple WebSocket call sample 6 | 7 | 8 |
9 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /algo/bmw/bmw512-4way.c: -------------------------------------------------------------------------------- 1 | #include "bmw512-gate.h" 2 | 3 | #ifdef BMW512_4WAY 4 | 5 | #include 6 | #include 7 | #include 8 | //#include "sph_keccak.h" 9 | #include "bmw-hash-4way.h" 10 | 11 | void bmw512hash_4way(void *state, const void *input) 12 | { 13 | bmw512_4way_context ctx; 14 | bmw512_4way_init( &ctx ); 15 | bmw512_4way( &ctx, input, 80 ); 16 | bmw512_4way_close( &ctx, state ); 17 | } 18 | 19 | int scanhash_bmw512_4way( struct work *work, uint32_t max_nonce, 20 | uint64_t *hashes_done, struct thr_info *mythr ) 21 | { 22 | uint32_t vdata[24*4] __attribute__ ((aligned (64))); 23 | uint32_t hash[16*4] __attribute__ ((aligned (32))); 24 | uint32_t lane_hash[8] __attribute__ ((aligned (32))); 25 | uint32_t *hash7 = &(hash[25]); // 3*8+1 26 | uint32_t *pdata = work->data; 27 | uint32_t *ptarget = work->target; 28 | uint32_t n = pdata[19]; 29 | const uint32_t first_nonce = pdata[19]; 30 | __m256i *noncev = (__m256i*)vdata + 9; // aligned 31 | // const uint32_t Htarg = ptarget[7]; 32 | int thr_id = mythr->id; // thr_id arg is deprecated 33 | 34 | mm256_bswap32_intrlv80_4x64( vdata, pdata ); 35 | do { 36 | *noncev = mm256_intrlv_blend_32( mm256_bswap_32( 37 | _mm256_set_epi32( n+3, 0, n+2, 0, n+1, 0, n, 0 ) ), *noncev ); 38 | 39 | bmw512hash_4way( hash, vdata ); 40 | 41 | for ( int lane = 0; lane < 4; lane++ ) 42 | if ( ( ( hash7[ lane<<1 ] & 0xFFFFFF00 ) == 0 ) ) 43 | { 44 | extr_lane_4x64( lane_hash, hash, lane, 256 ); 45 | if ( fulltest( lane_hash, ptarget ) ) 46 | { 47 | pdata[19] = n + lane; 48 | submit_lane_solution( work, lane_hash, mythr, lane ); 49 | } 50 | } 51 | n += 4; 52 | 53 | } while ( (n < max_nonce-4) && !work_restart[thr_id].restart); 54 | 55 | *hashes_done = n - first_nonce + 1; 56 | return 0; 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /crypto/magimath.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 The Magi 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 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "magimath.h" 14 | 15 | #define EPS1 (std::numeric_limits::epsilon()) 16 | #define EPS2 3.0e-11 17 | 18 | static void gauleg(double x1, double x2, double x[], double w[], const int n) 19 | { 20 | int m,j,i; 21 | double z1, z, xm, xl, pp, p3, p2, p1; 22 | m=(n+1)/2; 23 | xm=0.5*(x2+x1); 24 | xl=0.5*(x2-x1); 25 | for (i=1;i<=m;i++) { 26 | z=cos(3.141592654*(i-0.25)/(n+0.5)); 27 | do { 28 | p1=1.0; 29 | p2=0.0; 30 | for (j=1;j<=n;j++) { 31 | p3=p2; 32 | p2=p1; 33 | p1=((2.0*j-1.0)*z*p2-(j-1.0)*p3)/j; 34 | } 35 | pp=n*(z*p1-p2)/(z*z-1.0); 36 | z1=z; 37 | z=z1-p1/pp; 38 | } while (fabs(z-z1) > EPS2); 39 | x[i]=xm-xl*z; 40 | x[n+1-i]=xm+xl*z; 41 | w[i]=2.0*xl/((1.0-z*z)*pp*pp); 42 | w[n+1-i]=w[i]; 43 | } 44 | } 45 | 46 | static double GaussianQuad_N(double func(const double), const double a2, const double b2, const int NptGQ) 47 | { 48 | double s=0.0; 49 | #ifdef _MSC_VER 50 | #define SW_DIVS 23 51 | double x[SW_DIVS+1], w[SW_DIVS+1]; 52 | #else 53 | double x[NptGQ+1], w[NptGQ+1]; 54 | #endif 55 | 56 | gauleg(a2, b2, x, w, NptGQ); 57 | 58 | for (int j=1; j<=NptGQ; j++) { 59 | s += w[j]*func(x[j]); 60 | } 61 | 62 | return s; 63 | } 64 | 65 | static double swit_(double wvnmb) 66 | { 67 | return pow( (5.55243*(exp_n(-0.3*wvnmb/15.762) - exp_n(-0.6*wvnmb/15.762)))*wvnmb, 0.5) 68 | / 1034.66 * pow(sin(wvnmb/65.), 2.); 69 | } 70 | 71 | uint32_t sw_(int nnounce, int divs) 72 | { 73 | double wmax = ((sqrt((double)(nnounce))*(1.+EPS1))/450+100); 74 | return ((uint32_t)(GaussianQuad_N(swit_, 0., wmax, divs)*(1.+EPS1)*1.e6)); 75 | } 76 | -------------------------------------------------------------------------------- /algo/keccak/keccak-4way.c: -------------------------------------------------------------------------------- 1 | #include "keccak-gate.h" 2 | 3 | #ifdef KECCAK_4WAY 4 | 5 | #include 6 | #include 7 | #include 8 | #include "sph_keccak.h" 9 | #include "keccak-hash-4way.h" 10 | 11 | void keccakhash_4way(void *state, const void *input) 12 | { 13 | keccak256_4way_context ctx; 14 | keccak256_4way_init( &ctx ); 15 | keccak256_4way( &ctx, input, 80 ); 16 | keccak256_4way_close( &ctx, state ); 17 | } 18 | 19 | int scanhash_keccak_4way( struct work *work, uint32_t max_nonce, 20 | uint64_t *hashes_done, struct thr_info *mythr ) 21 | { 22 | uint32_t vdata[24*4] __attribute__ ((aligned (64))); 23 | uint32_t hash[16*4] __attribute__ ((aligned (32))); 24 | uint32_t lane_hash[8] __attribute__ ((aligned (32))); 25 | uint32_t *hash7 = &(hash[25]); // 3*8+1 26 | uint32_t *pdata = work->data; 27 | uint32_t *ptarget = work->target; 28 | uint32_t n = pdata[19]; 29 | const uint32_t first_nonce = pdata[19]; 30 | __m256i *noncev = (__m256i*)vdata + 9; // aligned 31 | // const uint32_t Htarg = ptarget[7]; 32 | int thr_id = mythr->id; // thr_id arg is deprecated 33 | 34 | mm256_bswap32_intrlv80_4x64( vdata, pdata ); 35 | do { 36 | *noncev = mm256_intrlv_blend_32( mm256_bswap_32( 37 | _mm256_set_epi32( n+3, 0, n+2, 0, n+1, 0, n, 0 ) ), *noncev ); 38 | 39 | keccakhash_4way( hash, vdata ); 40 | 41 | for ( int lane = 0; lane < 4; lane++ ) 42 | if ( ( hash7[ lane<<1 ] & 0xFFFFFF00 ) == 0 ) 43 | { 44 | extr_lane_4x64( lane_hash, hash, lane, 256 ); 45 | if ( fulltest( lane_hash, ptarget ) && !opt_benchmark ) 46 | { 47 | pdata[19] = n + lane; 48 | submit_lane_solution( work, lane_hash, mythr, lane ); 49 | } 50 | } 51 | n += 4; 52 | 53 | } while ( (n < max_nonce-4) && !work_restart[thr_id].restart); 54 | 55 | *hashes_done = n - first_nonce + 1; 56 | return 0; 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /algo/blake/sse2/blake/sse41/hash.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "config.h" 8 | #include "rounds.h" 9 | /* 10 | #ifndef NOT_SUPERCOP 11 | 12 | #include "crypto_hash.h" 13 | #include "crypto_uint64.h" 14 | #include "crypto_uint32.h" 15 | #include "crypto_uint8.h" 16 | 17 | typedef crypto_uint64 u64; 18 | typedef crypto_uint32 u32; 19 | typedef crypto_uint8 u8; 20 | 21 | #else 22 | */ 23 | typedef unsigned long long u64; 24 | typedef unsigned int u32; 25 | typedef unsigned char u8; 26 | 27 | typedef struct 28 | { 29 | __m128i h[4]; 30 | u64 s[4], t[2]; 31 | u32 buflen, nullt; 32 | u8 buf[128]; 33 | } hashState_blake __attribute__ ((aligned (64))); 34 | /* 35 | #endif 36 | 37 | #define U8TO32(p) \ 38 | (((u32)((p)[0]) << 24) | ((u32)((p)[1]) << 16) | \ 39 | ((u32)((p)[2]) << 8) | ((u32)((p)[3]) )) 40 | #define U8TO64(p) \ 41 | (((u64)U8TO32(p) << 32) | (u64)U8TO32((p) + 4)) 42 | #define U32TO8(p, v) \ 43 | (p)[0] = (u8)((v) >> 24); (p)[1] = (u8)((v) >> 16); \ 44 | (p)[2] = (u8)((v) >> 8); (p)[3] = (u8)((v) ); 45 | #define U64TO8(p, v) \ 46 | U32TO8((p), (u32)((v) >> 32)); \ 47 | U32TO8((p) + 4, (u32)((v) )); 48 | */ 49 | 50 | /* 51 | static const u8 padding[129] = 52 | { 53 | 0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 54 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 55 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 56 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 57 | }; 58 | 59 | */ 60 | static inline void blake512_init( hashState_blake * S, u64 datalen ); 61 | 62 | 63 | static void blake512_update( hashState_blake * S, const u8 * data, u64 datalen ) ; 64 | 65 | static inline void blake512_final( hashState_blake * S, u8 * digest ) ; 66 | 67 | 68 | int crypto_hash( unsigned char *out, const unsigned char *in, unsigned long long inlen ) ; 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /algo/fugue/sph_fugue.h: -------------------------------------------------------------------------------- 1 | #ifndef SPH_FUGUE_H__ 2 | #define SPH_FUGUE_H__ 3 | 4 | #include 5 | #include "algo/sha/sph_types.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C"{ 9 | #endif 10 | 11 | #define SPH_SIZE_fugue224 224 12 | 13 | #define SPH_SIZE_fugue256 256 14 | 15 | #define SPH_SIZE_fugue384 384 16 | 17 | #define SPH_SIZE_fugue512 512 18 | 19 | typedef struct { 20 | #ifndef DOXYGEN_IGNORE 21 | sph_u32 partial; 22 | unsigned partial_len; 23 | unsigned round_shift; 24 | sph_u32 S[36]; 25 | #if SPH_64 26 | sph_u64 bit_count; 27 | #else 28 | sph_u32 bit_count_high, bit_count_low; 29 | #endif 30 | #endif 31 | } sph_fugue_context; 32 | 33 | typedef sph_fugue_context sph_fugue224_context; 34 | 35 | typedef sph_fugue_context sph_fugue256_context; 36 | 37 | typedef sph_fugue_context sph_fugue384_context; 38 | 39 | typedef sph_fugue_context sph_fugue512_context; 40 | 41 | void sph_fugue224_init(void *cc); 42 | 43 | void sph_fugue224(void *cc, const void *data, size_t len); 44 | 45 | void sph_fugue224_close(void *cc, void *dst); 46 | 47 | void sph_fugue224_addbits_and_close( 48 | void *cc, unsigned ub, unsigned n, void *dst); 49 | 50 | void sph_fugue256_init(void *cc); 51 | 52 | void sph_fugue256(void *cc, const void *data, size_t len); 53 | 54 | void sph_fugue256_close(void *cc, void *dst); 55 | 56 | void sph_fugue256_addbits_and_close( 57 | void *cc, unsigned ub, unsigned n, void *dst); 58 | 59 | void sph_fugue384_init(void *cc); 60 | 61 | void sph_fugue384(void *cc, const void *data, size_t len); 62 | 63 | void sph_fugue384_close(void *cc, void *dst); 64 | 65 | void sph_fugue384_addbits_and_close( 66 | void *cc, unsigned ub, unsigned n, void *dst); 67 | 68 | void sph_fugue512_init(void *cc); 69 | 70 | void sph_fugue512(void *cc, const void *data, size_t len); 71 | 72 | void sph_fugue512_close(void *cc, void *dst); 73 | 74 | void sph_fugue512_addbits_and_close( 75 | void *cc, unsigned ub, unsigned n, void *dst); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /algo/whirlpool/whirlpoolx.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "sph_whirlpool.h" 8 | 9 | void whirlpoolx_hash(void *state, const void *input) 10 | { 11 | sph_whirlpool_context ctx_whirlpool; 12 | 13 | unsigned char hash[64]; 14 | // unsigned char hash_xored[32]; 15 | 16 | sph_whirlpool1_init(&ctx_whirlpool); 17 | sph_whirlpool1(&ctx_whirlpool, input, 80); 18 | sph_whirlpool1_close(&ctx_whirlpool, hash); 19 | 20 | // compress the 48 first bytes of the hash to 32 21 | // for (int i = 0; i < 32; i++) 22 | // hash_xored[i] = hash[i] ^ hash[i + 16]; 23 | 24 | memcpy(state, hash, 32); 25 | } 26 | 27 | int scanhash_whirlpoolx( struct work* work, uint32_t max_nonce, 28 | uint64_t *hashes_done, struct thr_info *mythr ) 29 | { 30 | uint32_t _ALIGN(128) endiandata[20]; 31 | uint32_t* pdata = work->data; 32 | uint32_t* ptarget = work->target; 33 | const uint32_t first_nonce = pdata[19]; 34 | uint32_t n = first_nonce - 1; 35 | int thr_id = mythr->id; // thr_id arg is deprecated 36 | 37 | if (opt_benchmark) 38 | ((uint32_t*)ptarget)[7] = 0x0000ff; 39 | 40 | for (int i=0; i < 19; i++) 41 | be32enc(&endiandata[i], pdata[i]); 42 | 43 | do { 44 | const uint32_t Htarg = ptarget[7]; 45 | uint32_t vhash[8]; 46 | pdata[19] = ++n; 47 | be32enc(&endiandata[19], n ); 48 | whirlpoolx_hash(vhash, endiandata); 49 | 50 | if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) 51 | { 52 | work_set_target_ratio(work, vhash); 53 | *hashes_done = n - first_nonce + 1; 54 | return true; 55 | } 56 | 57 | } while ( n < max_nonce && !work_restart[thr_id].restart); 58 | 59 | *hashes_done = n - first_nonce + 1; 60 | pdata[19] = n; 61 | return 0; 62 | } 63 | 64 | bool register_whirlpoolx_algo( algo_gate_t* gate ) 65 | { 66 | algo_not_tested(); 67 | gate->scanhash = (void*)&scanhash_whirlpoolx; 68 | gate->hash = (void*)&whirlpoolx_hash; 69 | return true; 70 | }; 71 | 72 | -------------------------------------------------------------------------------- /algo/yespower/TESTS-OK: -------------------------------------------------------------------------------- 1 | yespower(5, 2048, 8, "Client Key") = a5 9f ec 4c 4f dd a1 6e 3b 14 05 ad da 66 d5 25 b6 8e 7c ad fc fe 6a c0 66 c7 ad 11 8c d8 05 90 2 | yespower(5, 2048, 8, BSTY) = 5e a2 b2 95 6a 9e ac e3 0a 32 37 ff 1d 44 1e de e1 dc 25 aa b8 f0 ea 15 c1 21 65 f8 3a 7b c2 65 3 | yespower(5, 4096, 16, "Client Key") = 92 7e 72 d0 de d3 d8 04 75 47 3f 40 f1 74 3c 67 28 9d 45 3d 52 42 d4 f5 5a f4 e3 25 e0 66 99 c5 4 | yespower(5, 4096, 24, "Jagaricoin") = 0e 13 66 97 32 11 e7 fe a8 ad 9d 81 98 9c 84 a2 54 d9 68 c9 d3 33 dd 8f f0 99 32 4f 38 61 1e 04 5 | yespower(5, 4096, 32, "WaviBanana") = 3a e0 5a bb 3c 5c f6 f7 54 15 a9 25 54 c9 8d 50 e3 8e c9 55 2c fa 78 37 36 16 f4 80 b2 4e 55 9f 6 | yespower(5, 2048, 32, "Client Key") = 56 0a 89 1b 5c a2 e1 c6 36 11 1a 9f f7 c8 94 a5 d0 a2 60 2f 43 fd cf a5 94 9b 95 e2 2f e4 46 1e 7 | yespower(5, 1024, 32, "Client Key") = 2a 79 e5 3d 1b e6 66 9b c5 56 cc c4 17 bc e3 d2 2a 74 a2 32 f5 6b 8e 1d 39 b4 57 92 67 5d e1 08 8 | yespower(5, 2048, 8, NULL) = 5e cb d8 e8 d7 c9 0b ae d4 bb f8 91 6a 12 25 dc c3 c6 5f 5c 91 65 ba e8 1c dd e3 cf fa d1 28 e8 9 | yespower(10, 2048, 8, NULL) = 69 e0 e8 95 b3 df 7a ee b8 37 d7 1f e1 99 e9 d3 4f 7e c4 6e cb ca 7a 2c 43 08 e5 18 57 ae 9b 46 10 | yespower(10, 4096, 16, NULL) = 33 fb 8f 06 38 24 a4 a0 20 f6 3d ca 53 5f 5c a6 6a b5 57 64 68 c7 5d 1c ca ac 75 42 f7 64 95 ac 11 | yespower(10, 4096, 32, NULL) = 77 1a ee fd a8 fe 79 a0 82 5b c7 f2 ae e1 62 ab 55 78 57 46 39 ff c6 ca 37 23 cc 18 e5 e3 e2 85 12 | yespower(10, 2048, 32, NULL) = d5 ef b8 13 cd 26 3e 9b 34 54 01 30 23 3c bb c6 a9 21 fb ff 34 31 e5 ec 1a 1a bd e2 ae a6 ff 4d 13 | yespower(10, 1024, 32, NULL) = 50 1b 79 2d b4 2e 38 8f 6e 7d 45 3c 95 d0 3a 12 a3 60 16 a5 15 4a 68 83 90 dd c6 09 a4 0c 67 99 14 | yespower(10, 1024, 32, "personality test") = 1f 02 69 ac f5 65 c4 9a dc 0e f9 b8 f2 6a b3 80 8c dc 38 39 4a 25 4f dd ee dc c3 aa cf f6 ad 9d 15 | XOR of yespower(5, ...) = 44 6c 17 2d fd 2b 39 64 d9 34 08 a3 bf 55 9e c7 42 31 7a 2c f2 b2 48 7c ec 41 17 e8 3d 7d 96 b0 16 | XOR of yespower(10, ...) = a9 fe c9 66 53 bd 25 ea 18 24 f3 f9 cc 96 c5 98 5f 19 1d 1d ca ee d3 e9 d0 52 f8 ac 76 bc bb da 17 | -------------------------------------------------------------------------------- /crypto/c_skein.h: -------------------------------------------------------------------------------- 1 | #ifndef _SKEIN_H_ 2 | #define _SKEIN_H_ 1 3 | /************************************************************************** 4 | ** 5 | ** Interface declarations and internal definitions for Skein hashing. 6 | ** 7 | ** Source code author: Doug Whiting, 2008. 8 | ** 9 | ** This algorithm and source code is released to the public domain. 10 | ** 11 | *************************************************************************** 12 | ** 13 | ** The following compile-time switches may be defined to control some 14 | ** tradeoffs between speed, code size, error checking, and security. 15 | ** 16 | ** The "default" note explains what happens when the switch is not defined. 17 | ** 18 | ** SKEIN_DEBUG -- make callouts from inside Skein code 19 | ** to examine/display intermediate values. 20 | ** [default: no callouts (no overhead)] 21 | ** 22 | ** SKEIN_ERR_CHECK -- how error checking is handled inside Skein 23 | ** code. If not defined, most error checking 24 | ** is disabled (for performance). Otherwise, 25 | ** the switch value is interpreted as: 26 | ** 0: use assert() to flag errors 27 | ** 1: return SKEIN_FAIL to flag errors 28 | ** 29 | ***************************************************************************/ 30 | #include "skein_port.h" /* get platform-specific definitions */ 31 | 32 | typedef enum 33 | { 34 | SKEIN_SUCCESS = 0, /* return codes from Skein calls */ 35 | SKEIN_FAIL = 1, 36 | SKEIN_BAD_HASHLEN = 2 37 | } 38 | SkeinHashReturn; 39 | 40 | typedef size_t SkeinDataLength; /* bit count type */ 41 | typedef u08b_t SkeinBitSequence; /* bit stream type */ 42 | 43 | /* "all-in-one" call */ 44 | SkeinHashReturn skein_hash(int hashbitlen, const SkeinBitSequence *data, 45 | SkeinDataLength databitlen, SkeinBitSequence *hashval); 46 | 47 | #endif /* ifndef _SKEIN_H_ */ 48 | -------------------------------------------------------------------------------- /algo/skein/skein2-4way.c: -------------------------------------------------------------------------------- 1 | #include "skein2-gate.h" 2 | #include 3 | #include 4 | #include "skein-hash-4way.h" 5 | 6 | #if defined(SKEIN2_4WAY) 7 | 8 | void skein2hash_4way( void *output, const void *input ) 9 | { 10 | skein512_4way_context ctx; 11 | uint64_t hash[16*4] __attribute__ ((aligned (64))); 12 | 13 | skein512_4way_init( &ctx ); 14 | skein512_4way( &ctx, input, 80 ); 15 | skein512_4way_close( &ctx, hash ); 16 | 17 | skein512_4way_init( &ctx ); 18 | skein512_4way( &ctx, hash, 64 ); 19 | skein512_4way_close( &ctx, output ); 20 | } 21 | 22 | int scanhash_skein2_4way( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ) 24 | { 25 | uint32_t hash[16*4] __attribute__ ((aligned (64))); 26 | uint32_t vdata[20*4] __attribute__ ((aligned (64))); 27 | uint32_t lane_hash[8] __attribute__ ((aligned (64))); 28 | uint32_t *hash7 = &(hash[25]); 29 | uint32_t *pdata = work->data; 30 | uint32_t *ptarget = work->target; 31 | const uint32_t Htarg = ptarget[7]; 32 | const uint32_t first_nonce = pdata[19]; 33 | uint32_t n = first_nonce; 34 | __m256i *noncev = (__m256i*)vdata + 9; // aligned 35 | int thr_id = mythr->id; // thr_id arg is deprecated 36 | 37 | mm256_bswap32_intrlv80_4x64( vdata, pdata ); 38 | do 39 | { 40 | *noncev = mm256_intrlv_blend_32( mm256_bswap_32( 41 | _mm256_set_epi32( n+3, 0, n+2, 0, n+1, 0, n, 0 ) ), *noncev ); 42 | 43 | skein2hash_4way( hash, vdata ); 44 | 45 | for ( int lane = 0; lane < 4; lane++ ) 46 | if ( hash7[ lane<<1 ] <= Htarg ) 47 | { 48 | extr_lane_4x64( lane_hash, hash, lane, 256 ); 49 | if ( fulltest( lane_hash, ptarget ) && !opt_benchmark ) 50 | { 51 | pdata[19] = n + lane; 52 | submit_lane_solution( work, lane_hash, mythr, lane ); 53 | } 54 | } 55 | n += 4; 56 | } while ( (n < max_nonce) && !work_restart[thr_id].restart ); 57 | 58 | *hashes_done = n - first_nonce + 1; 59 | return 0; 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /crypto/oaes_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * --------------------------------------------------------------------------- 3 | * OpenAES License 4 | * --------------------------------------------------------------------------- 5 | * Copyright (c) 2012, Nabil S. Al Ramli, www.nalramli.com 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * - Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * - Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | * POSSIBILITY OF SUCH DAMAGE. 28 | * --------------------------------------------------------------------------- 29 | */ 30 | 31 | #ifndef _OAES_CONFIG_H 32 | #define _OAES_CONFIG_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | //#ifndef OAES_HAVE_ISAAC 39 | //#define OAES_HAVE_ISAAC 1 40 | //#endif // OAES_HAVE_ISAAC 41 | 42 | //#ifndef OAES_DEBUG 43 | //#define OAES_DEBUG 0 44 | //#endif // OAES_DEBUG 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif // _OAES_CONFIG_H 51 | -------------------------------------------------------------------------------- /algo/blake/blake2b-4way.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Blake2-B Implementation 3 | * tpruvot@github 2015-2016 4 | */ 5 | 6 | #include "blake2b-gate.h" 7 | 8 | #if defined(BLAKE2B_4WAY) 9 | 10 | #include 11 | #include 12 | #include "blake2b-hash-4way.h" 13 | 14 | // Function not used, code inlined. 15 | void blake2b_4way_hash(void *output, const void *input) 16 | { 17 | blake2b_4way_ctx ctx; 18 | blake2b_4way_init( &ctx ); 19 | blake2b_4way_update( &ctx, input, 80 ); 20 | blake2b_4way_final( &ctx, output ); 21 | } 22 | 23 | int scanhash_blake2b_4way( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ) 25 | { 26 | uint32_t hash[8*4] __attribute__ ((aligned (64)));; 27 | uint32_t vdata[20*4] __attribute__ ((aligned (32)));; 28 | uint32_t lane_hash[8] __attribute__ ((aligned (32))); 29 | blake2b_4way_ctx ctx __attribute__ ((aligned (32))); 30 | uint32_t *hash7 = &(hash[25]); // 3*8+1 31 | uint32_t *pdata = work->data; 32 | uint32_t *ptarget = work->target; 33 | int thr_id = mythr->id; 34 | __m256i *noncev = (__m256i*)vdata + 9; // aligned 35 | const uint32_t Htarg = ptarget[7]; 36 | const uint32_t first_nonce = pdata[19]; 37 | 38 | uint32_t n = first_nonce; 39 | 40 | mm256_bswap32_intrlv80_4x64( vdata, pdata ); 41 | 42 | do { 43 | *noncev = mm256_intrlv_blend_32( mm256_bswap_32( 44 | _mm256_set_epi32( n+3, 0, n+2, 0, n+1, 0, n, 0 ) ), *noncev ); 45 | 46 | blake2b_4way_init( &ctx ); 47 | blake2b_4way_update( &ctx, vdata, 80 ); 48 | blake2b_4way_final( &ctx, hash ); 49 | 50 | for ( int lane = 0; lane < 4; lane++ ) 51 | if ( hash7[ lane<<1 ] < Htarg ) 52 | { 53 | extr_lane_4x64( lane_hash, hash, lane, 256 ); 54 | if ( fulltest( lane_hash, ptarget ) && !opt_benchmark ) 55 | { 56 | pdata[19] = n + lane; 57 | submit_lane_solution( work, lane_hash, mythr, lane ); 58 | } 59 | } 60 | n += 4; 61 | } while ( (n < max_nonce-4) && !work_restart[thr_id].restart); 62 | 63 | *hashes_done = n - first_nonce + 1; 64 | return 0; 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /algo/bmw/sse2/sph_bmw.h: -------------------------------------------------------------------------------- 1 | /* $Id: sph_bmw.h 216 2010-06-08 09:46:57Z tp $ */ 2 | /** 3 | * BMW interface. BMW (aka "Blue Midnight Wish") is a family of 4 | * functions which differ by their output size; this implementation 5 | * defines BMW for output sizes 224, 256, 384 and 512 bits. 6 | * 7 | * ==========================(LICENSE BEGIN)============================ 8 | * 9 | * Copyright (c) 2007-2010 Projet RNRT SAPHIR 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining 12 | * a copy of this software and associated documentation files (the 13 | * "Software"), to deal in the Software without restriction, including 14 | * without limitation the rights to use, copy, modify, merge, publish, 15 | * distribute, sublicense, and/or sell copies of the Software, and to 16 | * permit persons to whom the Software is furnished to do so, subject to 17 | * the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be 20 | * included in all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 25 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 26 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 27 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 28 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | * 30 | * ===========================(LICENSE END)============================= 31 | * 32 | * @file sph_bmw.h 33 | * @author Thomas Pornin 34 | */ 35 | 36 | #ifndef SPH_BMW_H__ 37 | #define SPH_BMW_H__ 38 | 39 | #ifdef __cplusplus 40 | extern "C"{ 41 | #endif 42 | 43 | #include 44 | #include "sph_types.h" 45 | 46 | #define SPH_SIZE_bmw512 512 47 | 48 | typedef struct { 49 | #ifndef DOXYGEN_IGNORE 50 | sph_u64 bmwH[16]; 51 | #endif 52 | } sph_bmw_big_context; 53 | 54 | typedef sph_bmw_big_context sph_bmw512_context; 55 | 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /algo/lyra2/lyra2h.c: -------------------------------------------------------------------------------- 1 | #include "lyra2-gate.h" 2 | #include 3 | #include 4 | #include "lyra2.h" 5 | #include "algo/blake/sph_blake.h" 6 | 7 | __thread uint64_t* lyra2h_matrix; 8 | 9 | bool lyra2h_thread_init() 10 | { 11 | lyra2h_matrix = _mm_malloc( LYRA2H_MATRIX_SIZE, 64 ); 12 | return lyra2h_matrix; 13 | } 14 | 15 | static __thread sph_blake256_context lyra2h_blake_mid; 16 | 17 | void lyra2h_midstate( const void* input ) 18 | { 19 | sph_blake256_init( &lyra2h_blake_mid ); 20 | sph_blake256( &lyra2h_blake_mid, input, 64 ); 21 | } 22 | 23 | void lyra2h_hash( void *state, const void *input ) 24 | { 25 | uint32_t _ALIGN(64) hash[16]; 26 | 27 | sph_blake256_context ctx_blake __attribute__ ((aligned (64))); 28 | 29 | memcpy( &ctx_blake, &lyra2h_blake_mid, sizeof lyra2h_blake_mid ); 30 | sph_blake256( &ctx_blake, input + 64, 16 ); 31 | sph_blake256_close( &ctx_blake, hash ); 32 | 33 | LYRA2Z( lyra2h_matrix, hash, 32, hash, 32, hash, 32, 16, 16, 16 ); 34 | 35 | memcpy(state, hash, 32); 36 | } 37 | 38 | int scanhash_lyra2h( struct work *work, uint32_t max_nonce, 39 | uint64_t *hashes_done, struct thr_info *mythr ) 40 | { 41 | uint32_t _ALIGN(64) hash[8]; 42 | uint32_t _ALIGN(64) endiandata[20]; 43 | uint32_t *pdata = work->data; 44 | uint32_t *ptarget = work->target; 45 | const uint32_t Htarg = ptarget[7]; 46 | const uint32_t first_nonce = pdata[19]; 47 | uint32_t nonce = first_nonce; 48 | int thr_id = mythr->id; // thr_id arg is deprecated 49 | 50 | if (opt_benchmark) 51 | ptarget[7] = 0x0000ff; 52 | 53 | for (int i=0; i < 19; i++) { 54 | be32enc(&endiandata[i], pdata[i]); 55 | } 56 | 57 | lyra2h_midstate( endiandata ); 58 | do { 59 | be32enc(&endiandata[19], nonce); 60 | lyra2h_hash( hash, endiandata ); 61 | 62 | if ( hash[7] <= Htarg ) 63 | if ( fulltest( hash, ptarget ) && !opt_benchmark ) 64 | { 65 | pdata[19] = nonce; 66 | submit_solution( work, hash, mythr ); 67 | } 68 | nonce++; 69 | } while (nonce < max_nonce && !work_restart[thr_id].restart); 70 | pdata[19] = nonce; 71 | *hashes_done = pdata[19] - first_nonce + 1; 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/blake2/blamka-round-ref.h: -------------------------------------------------------------------------------- 1 | #ifndef BLAKE_ROUND_MKA_H 2 | #define BLAKE_ROUND_MKA_H 3 | 4 | #include "blake2.h" 5 | #include "blake2-impl.h" 6 | 7 | /*designed by the Lyra PHC team */ 8 | static BLAKE2_INLINE uint64_t fBlaMka(uint64_t x, uint64_t y) { 9 | const uint64_t m = UINT64_C(0xFFFFFFFF); 10 | const uint64_t xy = (x & m) * (y & m); 11 | return x + y + 2 * xy; 12 | } 13 | 14 | #define G(a, b, c, d) \ 15 | do { \ 16 | a = fBlaMka(a, b); \ 17 | d = rotr64(d ^ a, 32); \ 18 | c = fBlaMka(c, d); \ 19 | b = rotr64(b ^ c, 24); \ 20 | a = fBlaMka(a, b); \ 21 | d = rotr64(d ^ a, 16); \ 22 | c = fBlaMka(c, d); \ 23 | b = rotr64(b ^ c, 63); \ 24 | } while ((void)0, 0) 25 | 26 | #define BLAKE2_ROUND_NOMSG(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, \ 27 | v12, v13, v14, v15) \ 28 | do { \ 29 | G(v0, v4, v8, v12); \ 30 | G(v1, v5, v9, v13); \ 31 | G(v2, v6, v10, v14); \ 32 | G(v3, v7, v11, v15); \ 33 | G(v0, v5, v10, v15); \ 34 | G(v1, v6, v11, v12); \ 35 | G(v2, v7, v8, v13); \ 36 | G(v3, v4, v9, v14); \ 37 | } while ((void)0, 0) 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /algo/hodl/hodl-endian.h: -------------------------------------------------------------------------------- 1 | #ifndef HODL_BYTESWAP_H 2 | #define HODL_BYTESWAP_H 1 3 | 4 | #define __bswap_constant_16(x) \ 5 | ((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) 6 | 7 | static __inline unsigned short int 8 | __bswap_16 (unsigned short int __bsx) 9 | { 10 | return __bswap_constant_16 (__bsx); 11 | } 12 | 13 | // LE 14 | # define htobe16(x) __bswap_16 (x) 15 | # define htole16(x) (x) 16 | # define be16toh(x) __bswap_16 (x) 17 | # define le16toh(x) (x) 18 | 19 | // BE 20 | //# define htole16(x) __bswap_16 (x) 21 | //# define htobe16(x) (x) 22 | //# define le16toh(x) __bswap_16 (x) 23 | //# define be16toh(x) (x) 24 | 25 | #define __bswap_constant_32(x) \ 26 | ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ 27 | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) 28 | 29 | static __inline unsigned int 30 | __bswap_32 (unsigned int __bsx) 31 | { 32 | return __builtin_bswap32 (__bsx); 33 | } 34 | 35 | // LE 36 | # define htobe32(x) __bswap_32 (x) 37 | # define htole32(x) (x) 38 | # define be32toh(x) __bswap_32 (x) 39 | # define le32toh(x) (x) 40 | 41 | // BE 42 | //# define htole32(x) __bswap_32 (x) 43 | //# define htobe32(x) (x) 44 | //# define le32toh(x) __bswap_32 (x) 45 | //# define be32toh(x) (x) 46 | 47 | # define __bswap_constant_64(x) \ 48 | ((((x) & 0xff00000000000000ull) >> 56) \ 49 | | (((x) & 0x00ff000000000000ull) >> 40) \ 50 | | (((x) & 0x0000ff0000000000ull) >> 24) \ 51 | | (((x) & 0x000000ff00000000ull) >> 8) \ 52 | | (((x) & 0x00000000ff000000ull) << 8) \ 53 | | (((x) & 0x0000000000ff0000ull) << 24) \ 54 | | (((x) & 0x000000000000ff00ull) << 40) \ 55 | | (((x) & 0x00000000000000ffull) << 56)) 56 | 57 | static __inline uint64_t 58 | __bswap_64 (uint64_t __bsx) 59 | { 60 | return __bswap_constant_64 (__bsx); 61 | } 62 | 63 | // LE 64 | # define htobe64(x) __bswap_64 (x) 65 | # define htole64(x) (x) 66 | # define be64toh(x) __bswap_64 (x) 67 | # define le64toh(x) (x) 68 | 69 | // BE 70 | //# define htole64(x) __bswap_64 (x) 71 | //# define htobe64(x) (x) 72 | //# define le64toh(x) __bswap_64 (x) 73 | //# define be64toh(x) (x) 74 | 75 | #endif -------------------------------------------------------------------------------- /algo/argon2/argon2d/argon2d/encoding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 reference source code package - reference C implementations 3 | * 4 | * Copyright 2015 5 | * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves 6 | * 7 | * You may use this work under the terms of a Creative Commons CC0 1.0 8 | * License/Waiver or the Apache Public License 2.0, at your option. The terms of 9 | * these licenses can be found at: 10 | * 11 | * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 12 | * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * You should have received a copy of both of these licenses along with this 15 | * software. If not, they may be obtained at the above URLs. 16 | */ 17 | 18 | #ifndef ENCODING_H 19 | #define ENCODING_H 20 | #include "argon2.h" 21 | 22 | #define ARGON2_MAX_DECODED_LANES UINT32_C(255) 23 | #define ARGON2_MIN_DECODED_SALT_LEN UINT32_C(8) 24 | #define ARGON2_MIN_DECODED_OUT_LEN UINT32_C(12) 25 | 26 | /* 27 | * encode an Argon2 hash string into the provided buffer. 'dst_len' 28 | * contains the size, in characters, of the 'dst' buffer; if 'dst_len' 29 | * is less than the number of required characters (including the 30 | * terminating 0), then this function returns ARGON2_ENCODING_ERROR. 31 | * 32 | * on success, ARGON2_OK is returned. 33 | */ 34 | int encode_string(char *dst, size_t dst_len, argon2_context *ctx, 35 | argon2_type type); 36 | 37 | /* 38 | * Decodes an Argon2 hash string into the provided structure 'ctx'. 39 | * The only fields that must be set prior to this call are ctx.saltlen and 40 | * ctx.outlen (which must be the maximal salt and out length values that are 41 | * allowed), ctx.salt and ctx.out (which must be buffers of the specified 42 | * length), and ctx.pwd and ctx.pwdlen which must hold a valid password. 43 | * 44 | * Invalid input string causes an error. On success, the ctx is valid and all 45 | * fields have been initialized. 46 | * 47 | * Returned value is ARGON2_OK on success, other ARGON2_ codes on error. 48 | */ 49 | int decode_string(argon2_context *ctx, const char *str, argon2_type type); 50 | 51 | /* Returns the length of the encoded byte stream with length len */ 52 | size_t b64len(uint32_t len); 53 | 54 | /* Returns the length of the encoded number num */ 55 | size_t numlen(uint32_t num); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /algo/x11/x11evo-gate.c: -------------------------------------------------------------------------------- 1 | #include "x11evo-gate.h" 2 | 3 | int s_seq = -1; 4 | 5 | static inline int getCurrentAlgoSeq( uint32_t current_time ) 6 | { 7 | // change once per day 8 | return (int) (current_time - X11EVO_INITIAL_DATE) / (60 * 60 * 24); 9 | } 10 | 11 | // swap_vars doesn't work here 12 | void evo_swap( uint8_t *a, uint8_t *b ) 13 | { 14 | uint8_t __tmp = *a; 15 | *a = *b; 16 | *b = __tmp; 17 | } 18 | 19 | void initPerm( uint8_t n[], uint8_t count ) 20 | { 21 | int i; 22 | for ( i = 0; i0 && n[i - 1] >= n[i]; i-- ); 34 | tail = i; 35 | 36 | if ( tail > 0 ) 37 | { 38 | for ( j = count - 1; j>tail && n[j] <= n[tail - 1]; j-- ); 39 | evo_swap( &n[tail - 1], &n[j] ); 40 | } 41 | 42 | for ( i = tail, j = count - 1; i= 10 ) 63 | sprintf( sptr, "%c", 'A' + (algoList[j] - 10) ); 64 | else 65 | sprintf( sptr, "%u", algoList[j] ); 66 | sptr++; 67 | } 68 | *sptr = 0; 69 | 70 | //applog(LOG_DEBUG, "nextPerm %s", str); 71 | } 72 | 73 | void evo_twisted_code( uint32_t ntime, char *permstr ) 74 | { 75 | int seq = getCurrentAlgoSeq( ntime ); 76 | if ( s_seq != seq ) 77 | { 78 | getAlgoString( permstr, seq ); 79 | s_seq = seq; 80 | } 81 | } 82 | 83 | bool register_x11evo_algo( algo_gate_t* gate ) 84 | { 85 | #if defined (X11EVO_4WAY) 86 | init_x11evo_4way_ctx(); 87 | gate->scanhash = (void*)&scanhash_x11evo_4way; 88 | gate->hash = (void*)&x11evo_4way_hash; 89 | #else 90 | init_x11evo_ctx(); 91 | gate->scanhash = (void*)&scanhash_x11evo; 92 | gate->hash = (void*)&x11evo_hash; 93 | #endif 94 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 95 | return true; 96 | }; 97 | 98 | -------------------------------------------------------------------------------- /algo/x14/axiom.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "algo/shabal/sph_shabal.h" 7 | 8 | static __thread uint32_t _ALIGN(64) M[65536][8]; 9 | 10 | void axiomhash(void *output, const void *input) 11 | { 12 | sph_shabal256_context ctx __attribute__ ((aligned (64))); 13 | const int N = 65536; 14 | 15 | sph_shabal256_init(&ctx); 16 | sph_shabal256(&ctx, input, 80); 17 | sph_shabal256_close(&ctx, M[0]); 18 | 19 | for(int i = 1; i < N; i++) { 20 | sph_shabal256_init(&ctx); 21 | sph_shabal256(&ctx, M[i-1], 32); 22 | sph_shabal256_close(&ctx, M[i]); 23 | } 24 | 25 | for(int b = 0; b < N; b++) 26 | { 27 | const int p = b > 0 ? b - 1 : 0xFFFF; 28 | const int q = M[p][0] % 0xFFFF; 29 | const int j = (b + q) % N; 30 | 31 | sph_shabal256_init(&ctx); 32 | #if 0 33 | sph_shabal256(&ctx, M[p], 32); 34 | sph_shabal256(&ctx, M[j], 32); 35 | #else 36 | uint8_t _ALIGN(64) hash[64]; 37 | memcpy(hash, M[p], 32); 38 | memcpy(&hash[32], M[j], 32); 39 | sph_shabal256(&ctx, hash, 64); 40 | #endif 41 | sph_shabal256_close(&ctx, M[b]); 42 | } 43 | memcpy(output, M[N-1], 32); 44 | } 45 | 46 | int scanhash_axiom( struct work *work, 47 | uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ) 48 | { 49 | uint32_t *pdata = work->data; 50 | uint32_t *ptarget = work->target; 51 | uint32_t _ALIGN(64) hash64[8]; 52 | uint32_t _ALIGN(64) endiandata[20]; 53 | int thr_id = mythr->id; // thr_id arg is deprecated 54 | 55 | const uint32_t Htarg = ptarget[7]; 56 | const uint32_t first_nonce = pdata[19]; 57 | 58 | uint32_t n = first_nonce; 59 | 60 | for (int k = 0; k < 19; k++) 61 | be32enc(&endiandata[k], pdata[k]); 62 | 63 | do { 64 | be32enc(&endiandata[19], n); 65 | axiomhash(hash64, endiandata); 66 | if (hash64[7] < Htarg && fulltest(hash64, ptarget)) { 67 | *hashes_done = n - first_nonce + 1; 68 | pdata[19] = n; 69 | work_set_target_ratio( work, hash64 ); 70 | return true; 71 | } 72 | n++; 73 | 74 | } while (n < max_nonce && !work_restart[thr_id].restart); 75 | 76 | *hashes_done = n - first_nonce + 1; 77 | pdata[19] = n; 78 | 79 | return 0; 80 | } 81 | 82 | bool register_axiom_algo( algo_gate_t* gate ) 83 | { 84 | gate->scanhash = (void*)&scanhash_axiom; 85 | gate->hash = (void*)&axiomhash; 86 | gate->get_max64 = (void*)&get_max64_0x40LL; 87 | return true; 88 | } 89 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # Sample Android repo Makefile, used to test arm on the Tegra K1 3 | ################################################################ 4 | 5 | cpuminer-src := $(call my-dir) 6 | 7 | LOCAL_PATH := $(cpuminer-src) 8 | include $(CLEAR_VARS) 9 | 10 | LOCAL_MODULE=cpuminer-jansson 11 | LOCAL_MODULE_TAGS=optional 12 | 13 | define all-c-files-under 14 | $(patsubst ./%,%, \ 15 | $(shell cd $(LOCAL_PATH) ; \ 16 | find -L $(1) -name "*.c" -and -not -name ".*") \ 17 | ) 18 | endef 19 | 20 | LOCAL_SRC_FILES := $(call all-c-files-under,compat/jansson) 21 | LOCAL_C_INCLUDES := $(cpuminer-src)/compat/jansson 22 | 23 | include $(BUILD_STATIC_LIBRARY) 24 | 25 | ################################################################ 26 | 27 | 28 | LOCAL_PATH := $(cpuminer-src) 29 | include $(CLEAR_VARS) 30 | 31 | LOCAL_MODULE=cpuminer 32 | LOCAL_MODULE_TAGS=optional 33 | LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES 34 | LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities 35 | LOCAL_MODULE_STEM := $(LOCAL_MODULE) 36 | 37 | LOCAL_C_INCLUDES := $(cpuminer-src)/compat/bionic \ 38 | $(cpuminer-src)/compat/jansson \ 39 | $(TARGET_OUT_INTERMEDIATES)/include/libcurl \ 40 | external/openssl/include \ 41 | 42 | LOCAL_CFLAGS := -std=c99 -Wno-pointer-sign -Wno-missing-field-initializers \ 43 | -Wno-unused-parameter #-DNOASM 44 | LOCAL_CFLAGS += -DVERSION=\"1.2\" 45 | 46 | sph_files:=$(call all-c-files-under,sha3) 47 | 48 | LOCAL_SRC_FILES=\ 49 | cpu-miner.c util.c \ 50 | api.c sysinfos.c \ 51 | $(call all-c-files-under,algo) \ 52 | $(filter-out sha3/md_helper.c,$(sph_files)) \ 53 | $(call all-c-files-under,crypto) \ 54 | $(call all-c-files-under,lyra2) \ 55 | asm/sha2-$(TARGET_ARCH).S \ 56 | asm/scrypt-$(TARGET_ARCH).S \ 57 | asm/neoscrypt_asm.S 58 | 59 | LOCAL_STATIC_LIBRARIES := libm cpuminer-jansson 60 | LOCAL_STATIC_LIBRARIES += libz libcrypto_static 61 | LOCAL_STATIC_LIBRARIES += libssl_static 62 | 63 | # Require curl config changes and an addional 64 | # module definition in external/curl(_static?) 65 | #LOCAL_FORCE_STATIC_EXECUTABLE := true 66 | 67 | ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) 68 | LOCAL_CFLAGS += -DCURL_STATICLIB # -DHTTP_ONLY 69 | LOCAL_STATIC_LIBRARIES += libcurl_static libc 70 | else 71 | LOCAL_SHARED_LIBRARIES := libssl libcrypto 72 | LOCAL_SHARED_LIBRARIES += libcurl 73 | #LOCAL_STATIC_LIBRARIES += libcurl_static 74 | endif 75 | 76 | include $(BUILD_EXECUTABLE) 77 | 78 | -------------------------------------------------------------------------------- /compat/gettimeofday.c: -------------------------------------------------------------------------------- 1 | #include < time.h > 2 | #include //I've ommited this line. 3 | #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) 4 | #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 5 | #else 6 | #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL 7 | #endif 8 | 9 | struct timezone 10 | { 11 | int tz_minuteswest; /* minutes W of Greenwich */ 12 | int tz_dsttime; /* type of dst correction */ 13 | }; 14 | 15 | int gettimeofday(struct timeval *tv, struct timezone *tz) 16 | { 17 | FILETIME ft; 18 | unsigned __int64 tmpres = 0; 19 | static int tzflag; 20 | 21 | if (NULL != tv) 22 | { 23 | GetSystemTimeAsFileTime(&ft); 24 | 25 | tmpres |= ft.dwHighDateTime; 26 | tmpres <<= 32; 27 | tmpres |= ft.dwLowDateTime; 28 | 29 | /*converting file time to unix epoch*/ 30 | tmpres /= 10; /*convert into microseconds*/ 31 | tmpres -= DELTA_EPOCH_IN_MICROSECS; 32 | tv->tv_sec = (long)(tmpres / 1000000UL); 33 | tv->tv_usec = (long)(tmpres % 1000000UL); 34 | } 35 | 36 | if (NULL != tz) 37 | { 38 | if (!tzflag) 39 | { 40 | _tzset(); 41 | tzflag++; 42 | } 43 | tz->tz_minuteswest = _timezone / 60; 44 | tz->tz_dsttime = _daylight; 45 | } 46 | 47 | return 0; 48 | } 49 | 50 | void usleep(__int64 waitTime) 51 | { 52 | if (waitTime > 0) 53 | { 54 | if (waitTime > 100) 55 | { 56 | // use a waitable timer for larger intervals > 0.1ms 57 | 58 | HANDLE timer; 59 | LARGE_INTEGER ft; 60 | 61 | ft.QuadPart = -(10*waitTime); // Convert to 100 nanosecond interval, negative value indicates relative time 62 | 63 | timer = CreateWaitableTimer(NULL, TRUE, NULL); 64 | SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); 65 | WaitForSingleObject(timer, INFINITE); 66 | CloseHandle(timer); 67 | } 68 | else 69 | { 70 | // use a polling loop for short intervals <= 100ms 71 | 72 | LARGE_INTEGER perfCnt, start, now; 73 | __int64 elapsed; 74 | 75 | QueryPerformanceFrequency(&perfCnt); 76 | QueryPerformanceCounter(&start); 77 | do { 78 | QueryPerformanceCounter((LARGE_INTEGER*) &now); 79 | elapsed = (__int64)((now.QuadPart - start.QuadPart) / (float)perfCnt.QuadPart * 1000 * 1000); 80 | } while ( elapsed < waitTime ); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/ar2/blake2/blake2.h: -------------------------------------------------------------------------------- 1 | #ifndef PORTABLE_BLAKE2_H 2 | #define PORTABLE_BLAKE2_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #if defined(__cplusplus) 9 | extern "C" { 10 | #endif 11 | 12 | enum blake2b_constant { 13 | BLAKE2B_BLOCKBYTES = 128, 14 | BLAKE2B_OUTBYTES = 64, 15 | BLAKE2B_KEYBYTES = 64, 16 | BLAKE2B_SALTBYTES = 16, 17 | BLAKE2B_PERSONALBYTES = 16 18 | }; 19 | 20 | #pragma pack(push, 1) 21 | typedef struct __blake2b_param { 22 | uint8_t digest_length; /* 1 */ 23 | uint8_t key_length; /* 2 */ 24 | uint8_t fanout; /* 3 */ 25 | uint8_t depth; /* 4 */ 26 | uint32_t leaf_length; /* 8 */ 27 | uint64_t node_offset; /* 16 */ 28 | uint8_t node_depth; /* 17 */ 29 | uint8_t inner_length; /* 18 */ 30 | uint8_t reserved[14]; /* 32 */ 31 | uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */ 32 | uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */ 33 | } blake2b_param; 34 | #pragma pack(pop) 35 | 36 | typedef struct __blake2b_state { 37 | uint64_t h[8]; 38 | uint64_t t[2]; 39 | uint64_t f[2]; 40 | unsigned buflen; 41 | unsigned outlen; 42 | uint8_t last_node; 43 | uint8_t buf[BLAKE2B_BLOCKBYTES]; 44 | } blake2b_state; 45 | 46 | /* Ensure param structs have not been wrongly padded */ 47 | /* Poor man's static_assert */ 48 | enum { 49 | blake2_size_check_0 = 1 / !!(CHAR_BIT == 8), 50 | blake2_size_check_2 = 51 | 1 / !!(sizeof(blake2b_param) == sizeof(uint64_t) * CHAR_BIT) 52 | }; 53 | 54 | /* Streaming API */ 55 | int ar2_blake2b_init(blake2b_state *S, size_t outlen); 56 | int ar2_blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, 57 | size_t keylen); 58 | int ar2_blake2b_init_param(blake2b_state *S, const blake2b_param *P); 59 | int ar2_blake2b_update(blake2b_state *S, const void *in, size_t inlen); 60 | void my_blake2b_update(blake2b_state *S, const void *in, size_t inlen); 61 | int ar2_blake2b_final(blake2b_state *S, void *out, size_t outlen); 62 | 63 | /* Simple API */ 64 | int ar2_blake2b(void *out, const void *in, const void *key, size_t keylen); 65 | 66 | /* Argon2 Team - Begin Code */ 67 | int ar2_blake2b_long(void *out, const void *in); 68 | /* Argon2 Team - End Code */ 69 | /* Miouyouyou */ 70 | void ar2_blake2b_too(void *out, const void *in); 71 | 72 | #if defined(__cplusplus) 73 | } 74 | #endif 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /algo/blake/blake.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | #include "sph_blake.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* Move init out of loop, so init once externally, 9 | * and then use one single memcpy */ 10 | static __thread sph_blake256_context blake_mid; 11 | static __thread bool ctx_midstate_done = false; 12 | 13 | static void init_blake_hash(void) 14 | { 15 | sph_blake256_init(&blake_mid); 16 | ctx_midstate_done = true; 17 | } 18 | 19 | void blakehash(void *state, const void *input) 20 | { 21 | sph_blake256_context ctx; 22 | 23 | uint8_t hash[64] __attribute__ ((aligned (32))); 24 | uint8_t *ending = (uint8_t*) input; 25 | ending += 64; 26 | 27 | // do one memcopy to get a fresh context 28 | if (!ctx_midstate_done) { 29 | init_blake_hash(); 30 | sph_blake256(&blake_mid, input, 64); 31 | } 32 | 33 | memcpy(&ctx, &blake_mid, sizeof(blake_mid)); 34 | 35 | sph_blake256(&ctx, ending, 16); 36 | sph_blake256_close(&ctx, hash); 37 | 38 | memcpy(state, hash, 32); 39 | 40 | } 41 | 42 | int scanhash_blake( struct work *work, uint32_t max_nonce, 43 | uint64_t *hashes_done, struct thr_info *mythr ) 44 | { 45 | uint32_t *pdata = work->data; 46 | uint32_t *ptarget = work->target; 47 | const uint32_t first_nonce = pdata[19]; 48 | uint32_t HTarget = ptarget[7]; 49 | uint32_t _ALIGN(32) hash64[8]; 50 | uint32_t _ALIGN(32) endiandata[20]; 51 | uint32_t n = first_nonce; 52 | int thr_id = mythr->id; // thr_id arg is deprecated 53 | 54 | ctx_midstate_done = false; 55 | 56 | if (opt_benchmark) 57 | HTarget = 0x7f; 58 | 59 | // we need big endian data... 60 | swab32_array( endiandata, pdata, 20 ); 61 | 62 | #ifdef DEBUG_ALGO 63 | applog(LOG_DEBUG,"[%d] Target=%08x %08x", thr_id, ptarget[6], ptarget[7]); 64 | #endif 65 | 66 | do { 67 | be32enc(&endiandata[19], n); 68 | blakehash(hash64, endiandata); 69 | #ifndef DEBUG_ALGO 70 | if (hash64[7] <= HTarget && fulltest(hash64, ptarget)) { 71 | *hashes_done = n - first_nonce + 1; 72 | return true; 73 | } 74 | #else 75 | if (!(n % 0x1000) && !thr_id) printf("."); 76 | if (hash64[7] == 0) { 77 | printf("[%d]",thr_id); 78 | if (fulltest(hash64, ptarget)) { 79 | *hashes_done = n - first_nonce + 1; 80 | return true; 81 | } 82 | } 83 | #endif 84 | n++; pdata[19] = n; 85 | 86 | } while (n < max_nonce && !work_restart[thr_id].restart); 87 | 88 | *hashes_done = n - first_nonce + 1; 89 | pdata[19] = n; 90 | return 0; 91 | } 92 | 93 | -------------------------------------------------------------------------------- /algo/blake/blake2s.c: -------------------------------------------------------------------------------- 1 | #include "blake2s-gate.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "sph-blake2s.h" 7 | 8 | static __thread blake2s_state blake2s_ctx; 9 | //static __thread blake2s_state s_ctx; 10 | #define MIDLEN 76 11 | 12 | void blake2s_hash( void *output, const void *input ) 13 | { 14 | unsigned char _ALIGN(64) hash[BLAKE2S_OUTBYTES]; 15 | blake2s_state ctx __attribute__ ((aligned (64))); 16 | 17 | memcpy( &ctx, &blake2s_ctx, sizeof ctx ); 18 | blake2s_update( &ctx, input+64, 16 ); 19 | 20 | // blake2s_init(&ctx, BLAKE2S_OUTBYTES); 21 | // blake2s_update(&ctx, input, 80); 22 | blake2s_final( &ctx, hash, BLAKE2S_OUTBYTES ); 23 | 24 | memcpy(output, hash, 32); 25 | } 26 | /* 27 | static void blake2s_hash_end(uint32_t *output, const uint32_t *input) 28 | { 29 | s_ctx.buflen = MIDLEN; 30 | memcpy(&s_ctx, &s_midstate, 32 + 16 + MIDLEN); 31 | blake2s_update(&s_ctx, (uint8_t*) &input[MIDLEN/4], 80 - MIDLEN); 32 | blake2s_final(&s_ctx, (uint8_t*) output, BLAKE2S_OUTBYTES); 33 | } 34 | */ 35 | int scanhash_blake2s( struct work *work, 36 | uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ) 37 | { 38 | uint32_t *pdata = work->data; 39 | uint32_t *ptarget = work->target; 40 | 41 | uint32_t _ALIGN(64) hash64[8]; 42 | uint32_t _ALIGN(64) endiandata[20]; 43 | int thr_id = mythr->id; // thr_id arg is deprecated 44 | 45 | const uint32_t Htarg = ptarget[7]; 46 | const uint32_t first_nonce = pdata[19]; 47 | 48 | uint32_t n = first_nonce; 49 | 50 | swab32_array( endiandata, pdata, 20 ); 51 | 52 | // midstate 53 | blake2s_init( &blake2s_ctx, BLAKE2S_OUTBYTES ); 54 | blake2s_update( &blake2s_ctx, (uint8_t*) endiandata, 64 ); 55 | 56 | do { 57 | be32enc(&endiandata[19], n); 58 | blake2s_hash( hash64, endiandata ); 59 | if (hash64[7] < Htarg && fulltest(hash64, ptarget)) { 60 | *hashes_done = n - first_nonce + 1; 61 | pdata[19] = n; 62 | return true; 63 | } 64 | n++; 65 | 66 | } while (n < max_nonce && !work_restart[thr_id].restart); 67 | 68 | *hashes_done = n - first_nonce + 1; 69 | pdata[19] = n; 70 | 71 | return 0; 72 | } 73 | /* 74 | // changed to get_max64_0x3fffffLL in cpuminer-multi-decred 75 | int64_t blake2s_get_max64 () 76 | { 77 | return 0x7ffffLL; 78 | } 79 | 80 | bool register_blake2s_algo( algo_gate_t* gate ) 81 | { 82 | gate->scanhash = (void*)&scanhash_blake2s; 83 | gate->hash = (void*)&blake2s_hash; 84 | gate->get_max64 = (void*)&blake2s_get_max64; 85 | return true; 86 | }; 87 | */ 88 | -------------------------------------------------------------------------------- /compat.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMPAT_H__ 2 | #define __COMPAT_H__ 3 | 4 | #ifdef WIN32 5 | 6 | #include 7 | #include 8 | 9 | #ifndef localtime_r 10 | #define localtime_r(src, dst) localtime_s(dst, src) 11 | #endif 12 | 13 | #define sleep(secs) Sleep((secs) * 1000) 14 | 15 | enum { 16 | PRIO_PROCESS = 0, 17 | }; 18 | 19 | extern int opt_priority; 20 | static __inline int setpriority(int which, int who, int prio) 21 | { 22 | switch (opt_priority) { 23 | case 5: 24 | prio = THREAD_PRIORITY_TIME_CRITICAL; 25 | break; 26 | case 4: 27 | prio = THREAD_PRIORITY_HIGHEST; 28 | break; 29 | case 3: 30 | prio = THREAD_PRIORITY_ABOVE_NORMAL; 31 | break; 32 | case 2: 33 | prio = THREAD_PRIORITY_NORMAL; 34 | break; 35 | case 1: 36 | prio = THREAD_PRIORITY_BELOW_NORMAL; 37 | break; 38 | case 0: 39 | default: 40 | prio = THREAD_PRIORITY_IDLE; 41 | } 42 | return -!SetThreadPriority(GetCurrentThread(), prio); 43 | } 44 | 45 | #ifdef _MSC_VER 46 | #define snprintf(...) _snprintf(__VA_ARGS__) 47 | #define strdup(...) _strdup(__VA_ARGS__) 48 | #define strncasecmp(x,y,z) _strnicmp(x,y,z) 49 | #define strcasecmp(x,y) _stricmp(x,y) 50 | #define __func__ __FUNCTION__ 51 | #define __thread __declspec(thread) 52 | #define _ALIGN(x) __declspec(align(x)) 53 | typedef int ssize_t; 54 | 55 | #include 56 | // This static var is made to be compatible with linux/mingw (no free on string result) 57 | // This is not thread safe but we only use that once on process start 58 | static char dirname_buffer[_MAX_PATH] = { 0 }; 59 | static __inline char * dirname(char *file) { 60 | char drive[_MAX_DRIVE] = { 0 }; 61 | char dir[_MAX_DIR] = { 0 }; 62 | char fname[_MAX_FNAME], ext[_MAX_EXT]; 63 | _splitpath_s(file, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT); 64 | if (dir && strlen(dir) && dir[strlen(dir)-1] == '\\') { 65 | dir[strlen(dir) - 1] = '\0'; 66 | } 67 | sprintf(dirname_buffer, "%s%s", drive, dir); 68 | return &dirname_buffer[0]; 69 | } 70 | #endif 71 | 72 | #endif /* WIN32 */ 73 | 74 | #ifndef _MSC_VER 75 | #define _ALIGN(x) __attribute__ ((aligned(x))) 76 | #endif 77 | 78 | #undef unlikely 79 | #undef likely 80 | #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) 81 | #define unlikely(expr) (__builtin_expect(!!(expr), 0)) 82 | #define likely(expr) (__builtin_expect(!!(expr), 1)) 83 | #else 84 | #define unlikely(expr) (expr) 85 | #define likely(expr) (expr) 86 | #endif 87 | 88 | #ifndef WIN32 89 | #define MAX_PATH PATH_MAX 90 | #endif 91 | 92 | #endif /* __COMPAT_H__ */ 93 | --------------------------------------------------------------------------------