├── res ├── icon.rc ├── setup.ico ├── cpuminer.ico ├── cpuminer.rc └── resource.h ├── algo ├── groestl │ ├── aes_ni │ │ ├── architectures │ │ ├── api.h │ │ ├── implementors │ │ └── README │ ├── groestl-gate.c │ ├── myrgr-gate.c │ ├── groestl-gate.h │ ├── myrgr-gate.h │ ├── groestl512-hash-4way.h │ ├── groestl-4way.c │ └── groestl256-hash-4way.h ├── echo │ ├── aes_ni │ │ ├── api.h │ │ └── hash_api.h │ └── echo-hash-4way.h ├── yescrypt │ └── yescrypt-best.c ├── hodl │ ├── hodl-gate.h │ ├── wolf-aes.h │ ├── hodl-wolf.h │ ├── sha512-avx.h │ └── hodl-endian.h ├── swifftx │ ├── sha3_interface.h │ ├── hash_interface.h │ ├── inttypes.h │ ├── stdbool.h │ └── stdint.h ├── blake │ ├── blake-gate.c │ ├── pentablake-gate.c │ ├── blake2b-gate.c │ ├── blake-gate.h │ ├── pentablake-gate.h │ ├── blake2s-gate.c │ ├── blakecoin-gate.c │ ├── blakecoin-gate.h │ ├── sph_blake2b.h │ ├── blake2b-gate.h │ ├── decred-gate.h │ ├── blake2s-gate.h │ ├── blake2b-hash-4way.h │ ├── blake2b.c │ └── blake2s.c ├── 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 ├── x14 │ ├── polytimos-gate.c │ ├── veltor-gate.c │ ├── x14-gate.c │ ├── polytimos-gate.h │ ├── veltor-gate.h │ ├── x14-gate.h │ └── axiom.c ├── whirlpool │ ├── whirlpool-gate.c │ ├── whirlpool-gate.h │ └── whirlpoolx.c ├── jh │ ├── jha-gate.c │ └── jha-gate.h ├── x17 │ ├── x17-gate.c │ ├── sonoa-gate.c │ ├── xevan-gate.c │ ├── x17-gate.h │ ├── sonoa-gate.h │ └── xevan-gate.h ├── nist5 │ ├── nist5-gate.c │ └── nist5-gate.h ├── bmw │ ├── bmw512-gate.c │ ├── bmw512-gate.h │ ├── bmw512.c │ └── bmw256.c ├── x11 │ ├── c11-gate.c │ ├── x11-gate.c │ ├── tribus-gate.c │ ├── x11gost-gate.c │ ├── x11evo-gate.h │ ├── timetravel-gate.h │ ├── timetravel10-gate.h │ ├── tribus-gate.h │ ├── x11-gate.h │ ├── c11-gate.h │ ├── x11gost-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 │ ├── x13sm3-gate.c │ ├── x13-gate.h │ ├── skunk-gate.h │ ├── phi1612-gate.h │ └── x13sm3-gate.h ├── x15 │ ├── x15-gate.c │ └── x15-gate.h ├── sha │ ├── sha3-defs.h │ ├── sha3_common.h │ ├── sha256t-gate.c │ └── sha256t-gate.h ├── shavite │ ├── shavite-hash-2way.h │ └── shavite-hash-4way.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 │ │ └── argon2a.c │ └── argon2d │ │ ├── argon2d-gate.h │ │ └── argon2d │ │ ├── argon2d_thread.c │ │ └── encoding.h ├── x20 │ ├── x20r-gate.c │ └── x20r-gate.h ├── panama │ └── panama-hash-4way.h ├── skein │ ├── skein-gate.c │ ├── skein-gate.h │ ├── skein.c │ └── skein2.c ├── yespower │ ├── crypto │ │ └── blake2b-yp.h │ ├── yescrypt-r8g.h │ └── TESTS-OK ├── m7m │ ├── magimath.h │ └── magimath.cpp ├── cubehash │ ├── cubehash_sse2.h │ └── cube-hash-2way.h ├── simd │ ├── simd_iv.h │ ├── nist.h │ └── simd-hash-2way.h ├── keccak │ ├── keccak.c │ ├── sha3d.c │ └── keccak-gate.h ├── ripemd │ ├── lbry-gate.h │ └── ripemd-hash-4way.h ├── x16 │ └── x16rt.c ├── x22 │ ├── x22i-gate.c │ └── x22i-gate.h ├── lanehash │ └── lane.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 ├── autogen.sh ├── .travis.yml ├── clean-all.sh ├── AUTHORS ├── cpuminer-conf.json ├── asm ├── aesb-x86.S └── aesb-x64.S ├── .gitignore ├── Dockerfile ├── junk ├── mingw64.sh └── Android.mk ├── nomacro.pl ├── cpuminer.sln ├── api └── websocket.htm └── README.txt /res/icon.rc: -------------------------------------------------------------------------------- 1 | 0 ICON cpuminer.ico 2 | -------------------------------------------------------------------------------- /algo/groestl/aes_ni/architectures: -------------------------------------------------------------------------------- 1 | amd64 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/groestl/aes_ni/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 64 2 | #define CRYPTO_VERSION "2.2" 3 | -------------------------------------------------------------------------------- /res/setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EasyX-Community/cpuminer-opt/master/res/setup.ico -------------------------------------------------------------------------------- /res/cpuminer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EasyX-Community/cpuminer-opt/master/res/cpuminer.ico -------------------------------------------------------------------------------- /res/cpuminer.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EasyX-Community/cpuminer-opt/master/res/cpuminer.rc -------------------------------------------------------------------------------- /res/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EasyX-Community/cpuminer-opt/master/res/resource.h -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /algo/yescrypt/yescrypt-best.c: -------------------------------------------------------------------------------- 1 | #ifdef __SSE2__ 2 | #include "yescrypt-simd.c" 3 | #else 4 | #include "yescrypt-opt.c" 5 | #endif 6 | -------------------------------------------------------------------------------- /compat/pthreads/x64/libpthreadGC2.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EasyX-Community/cpuminer-opt/master/compat/pthreads/x64/libpthreadGC2.a -------------------------------------------------------------------------------- /compat/pthreads/x64/pthreadVC2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EasyX-Community/cpuminer-opt/master/compat/pthreads/x64/pthreadVC2.lib -------------------------------------------------------------------------------- /compat/pthreads/x86/pthreadVC2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EasyX-Community/cpuminer-opt/master/compat/pthreads/x86/pthreadVC2.lib -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/swifftx/sha3_interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | //#include 5 | #include "hash_interface.h" 6 | 7 | namespace sha3 { 8 | 9 | using BitSequence = hash::BitSequence; 10 | using DataLength = hash::DataLength; 11 | 12 | struct sha3_interface : hash::hash_interface {}; 13 | 14 | } // namespace sha3 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /clean-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # imake clean and rm all the targetted executables. 4 | # tips to users. 5 | 6 | rm cpuminer-avx512 cpuminer-avx2 cpuminer-aes-avx cpuminer-aes-sse42 cpuminer-sse2 cpuminer-zen > /dev/null 7 | 8 | rm cpuminer-avx512.exe cpuminer-avx2.exe cpuminer-aes-avx.exe cpuminer-aes-sse42.exe cpuminer-sse2.exe cpuminer-zen.exe > /dev/null 9 | 10 | make distclean > /dev/null 11 | -------------------------------------------------------------------------------- /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/blake/blake-gate.c: -------------------------------------------------------------------------------- 1 | #include "blake-gate.h" 2 | 3 | bool register_blake_algo( algo_gate_t* gate ) 4 | { 5 | gate->optimizations = AVX2_OPT; 6 | #if defined(BLAKE_4WAY) 7 | four_way_not_tested(); 8 | gate->scanhash = (void*)&scanhash_blake_4way; 9 | gate->hash = (void*)&blakehash_4way; 10 | #else 11 | gate->scanhash = (void*)&scanhash_blake; 12 | gate->hash = (void*)&blakehash; 13 | #endif 14 | return true; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /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 | 37 | Colin Percival 38 | Alexander Peslyak 39 | -------------------------------------------------------------------------------- /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 | return true; 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /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/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 | return true; 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /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 | 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/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 | opt_target_factor = 65536.0; 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 | -------------------------------------------------------------------------------- /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/x17/x17-gate.c: -------------------------------------------------------------------------------- 1 | #include "x17-gate.h" 2 | 3 | bool register_x17_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (X17_8WAY) 6 | gate->scanhash = (void*)&scanhash_x17_8way; 7 | gate->hash = (void*)&x17_8way_hash; 8 | #elif defined (X17_4WAY) 9 | gate->scanhash = (void*)&scanhash_x17_4way; 10 | gate->hash = (void*)&x17_4way_hash; 11 | #else 12 | gate->scanhash = (void*)&scanhash_x17; 13 | gate->hash = (void*)&x17_hash; 14 | #endif 15 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /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 | AVX512_OPT; 6 | #if defined (NIST5_8WAY) 7 | gate->scanhash = (void*)&scanhash_nist5_8way; 8 | gate->hash = (void*)&nist5hash_8way; 9 | #elif defined (NIST5_4WAY) 10 | gate->scanhash = (void*)&scanhash_nist5_4way; 11 | gate->hash = (void*)&nist5hash_4way; 12 | #else 13 | gate->scanhash = (void*)&scanhash_nist5; 14 | gate->hash = (void*)&nist5hash; 15 | #endif 16 | return true; 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /algo/blake/blake2b-gate.c: -------------------------------------------------------------------------------- 1 | #include "blake2b-gate.h" 2 | 3 | 4 | bool register_blake2b_algo( algo_gate_t* gate ) 5 | { 6 | #if defined(BLAKE2B_8WAY) 7 | gate->scanhash = (void*)&scanhash_blake2b_8way; 8 | // gate->hash = (void*)&blake2b_8way_hash; 9 | #elif defined(BLAKE2B_4WAY) 10 | gate->scanhash = (void*)&scanhash_blake2b_4way; 11 | gate->hash = (void*)&blake2b_4way_hash; 12 | #else 13 | gate->scanhash = (void*)&scanhash_blake2b; 14 | gate->hash = (void*)&blake2b_hash; 15 | #endif 16 | gate->optimizations = AVX2_OPT | AVX512_OPT; 17 | return true; 18 | }; 19 | 20 | 21 | -------------------------------------------------------------------------------- /algo/swifftx/hash_interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace hash { 6 | 7 | using BitSequence = unsigned char; 8 | using DataLength = unsigned long long; 9 | 10 | struct hash_interface { 11 | virtual ~hash_interface() = default; 12 | 13 | virtual int Init(int hash_bitsize) = 0; 14 | virtual int Update(const BitSequence *data, DataLength data_bitsize) = 0; 15 | virtual int Final(BitSequence *hash) = 0; 16 | 17 | virtual int 18 | Hash(int hash_bitsize, const BitSequence *data, DataLength data_bitsize, BitSequence *hash) = 0; 19 | }; 20 | 21 | } // namespace hash 22 | -------------------------------------------------------------------------------- /algo/bmw/bmw512-gate.c: -------------------------------------------------------------------------------- 1 | #include "bmw512-gate.h" 2 | 3 | bool register_bmw512_algo( algo_gate_t* gate ) 4 | { 5 | gate->optimizations = AVX2_OPT | AVX512_OPT; 6 | opt_target_factor = 256.0; 7 | #if defined (BMW512_8WAY) 8 | gate->scanhash = (void*)&scanhash_bmw512_8way; 9 | gate->hash = (void*)&bmw512hash_8way; 10 | #elif 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/x17/sonoa-gate.c: -------------------------------------------------------------------------------- 1 | #include "sonoa-gate.h" 2 | 3 | bool register_sonoa_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (SONOA_8WAY) 6 | gate->scanhash = (void*)&scanhash_sonoa_8way; 7 | gate->hash = (void*)&sonoa_8way_hash; 8 | #elif defined (SONOA_4WAY) 9 | gate->scanhash = (void*)&scanhash_sonoa_4way; 10 | gate->hash = (void*)&sonoa_4way_hash; 11 | #else 12 | init_sonoa_ctx(); 13 | gate->scanhash = (void*)&scanhash_sonoa; 14 | gate->hash = (void*)&sonoa_hash; 15 | #endif 16 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 17 | return true; 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /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_8WAY) 6 | init_c11_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_c11_8way; 8 | gate->hash = (void*)&c11_8way_hash; 9 | #elif defined (C11_4WAY) 10 | init_c11_4way_ctx(); 11 | gate->scanhash = (void*)&scanhash_c11_4way; 12 | gate->hash = (void*)&c11_4way_hash; 13 | #else 14 | init_c11_ctx(); 15 | gate->scanhash = (void*)&scanhash_c11; 16 | gate->hash = (void*)&c11_hash; 17 | #endif 18 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 19 | return true; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /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_8WAY) 6 | init_x11_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x11_8way; 8 | gate->hash = (void*)&x11_8way_hash; 9 | #elif defined (X11_4WAY) 10 | init_x11_4way_ctx(); 11 | gate->scanhash = (void*)&scanhash_x11_4way; 12 | gate->hash = (void*)&x11_4way_hash; 13 | #else 14 | init_x11_ctx(); 15 | gate->scanhash = (void*)&scanhash_x11; 16 | gate->hash = (void*)&x11_hash; 17 | #endif 18 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT ; 19 | return true; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /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_8WAY) 6 | init_x12_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x12_8way; 8 | gate->hash = (void*)&x12_8way_hash; 9 | #elif defined (X12_4WAY) 10 | init_x12_4way_ctx(); 11 | gate->scanhash = (void*)&scanhash_x12_4way; 12 | gate->hash = (void*)&x12_4way_hash; 13 | #else 14 | init_x12_ctx(); 15 | gate->scanhash = (void*)&scanhash_x12; 16 | gate->hash = (void*)&x12hash; 17 | #endif 18 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 19 | return true; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /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_8WAY) 6 | init_x13_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x13_8way; 8 | gate->hash = (void*)&x13_8way_hash; 9 | #elif defined (X13_4WAY) 10 | init_x13_4way_ctx(); 11 | gate->scanhash = (void*)&scanhash_x13_4way; 12 | gate->hash = (void*)&x13_4way_hash; 13 | #else 14 | init_x13_ctx(); 15 | gate->scanhash = (void*)&scanhash_x13; 16 | gate->hash = (void*)&x13hash; 17 | #endif 18 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 19 | return true; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /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_8WAY) 6 | init_x14_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x14_8way; 8 | gate->hash = (void*)&x14_8way_hash; 9 | #elif defined (X14_4WAY) 10 | init_x14_4way_ctx(); 11 | gate->scanhash = (void*)&scanhash_x14_4way; 12 | gate->hash = (void*)&x14_4way_hash; 13 | #else 14 | init_x14_ctx(); 15 | gate->scanhash = (void*)&scanhash_x14; 16 | gate->hash = (void*)&x14hash; 17 | #endif 18 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 19 | return true; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /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_8WAY) 6 | init_x15_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x15_8way; 8 | gate->hash = (void*)&x15_8way_hash; 9 | #elif defined (X15_4WAY) 10 | init_x15_4way_ctx(); 11 | gate->scanhash = (void*)&scanhash_x15_4way; 12 | gate->hash = (void*)&x15_4way_hash; 13 | #else 14 | init_x15_ctx(); 15 | gate->scanhash = (void*)&scanhash_x15; 16 | gate->hash = (void*)&x15hash; 17 | #endif 18 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 19 | return true; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /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/quark/quark-gate.c: -------------------------------------------------------------------------------- 1 | #include "quark-gate.h" 2 | 3 | bool register_quark_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (QUARK_8WAY) 6 | init_quark_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_quark_8way; 8 | gate->hash = (void*)&quark_8way_hash; 9 | #elif defined (QUARK_4WAY) 10 | init_quark_4way_ctx(); 11 | gate->scanhash = (void*)&scanhash_quark_4way; 12 | gate->hash = (void*)&quark_4way_hash; 13 | #else 14 | gate->scanhash = (void*)&scanhash_quark; 15 | gate->hash = (void*)&quark_hash; 16 | #endif 17 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 18 | return true; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /algo/x17/xevan-gate.c: -------------------------------------------------------------------------------- 1 | #include "xevan-gate.h" 2 | 3 | bool register_xevan_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (XEVAN_8WAY) 6 | gate->scanhash = (void*)&scanhash_xevan_8way; 7 | gate->hash = (void*)&xevan_8way_hash; 8 | #elif defined (XEVAN_4WAY) 9 | gate->scanhash = (void*)&scanhash_xevan_4way; 10 | gate->hash = (void*)&xevan_4way_hash; 11 | #else 12 | init_xevan_ctx(); 13 | gate->scanhash = (void*)&scanhash_xevan; 14 | gate->hash = (void*)&xevan_hash; 15 | #endif 16 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 17 | opt_target_factor = 256.0; 18 | return true; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /algo/groestl/groestl-gate.c: -------------------------------------------------------------------------------- 1 | #include "groestl-gate.h" 2 | 3 | bool register_dmd_gr_algo( algo_gate_t *gate ) 4 | { 5 | #if defined (GROESTL_4WAY_VAES) 6 | gate->scanhash = (void*)&scanhash_groestl_4way; 7 | gate->hash = (void*)&groestl_4way_hash; 8 | #else 9 | init_groestl_ctx(); 10 | gate->scanhash = (void*)&scanhash_groestl; 11 | gate->hash = (void*)&groestlhash; 12 | #endif 13 | gate->optimizations = AES_OPT | VAES_OPT; 14 | return true; 15 | }; 16 | 17 | bool register_groestl_algo( algo_gate_t* gate ) 18 | { 19 | register_dmd_gr_algo( gate ); 20 | gate->gen_merkle_root = (void*)&SHA256_gen_merkle_root; 21 | return true; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /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_8WAY) 6 | gate->scanhash = (void*)&scanhash_hmq1725_8way; 7 | gate->hash = (void*)&hmq1725_8way_hash; 8 | #elif defined(HMQ1725_4WAY) 9 | gate->scanhash = (void*)&scanhash_hmq1725_4way; 10 | gate->hash = (void*)&hmq1725_4way_hash; 11 | #else 12 | init_hmq1725_ctx(); 13 | gate->scanhash = (void*)&scanhash_hmq1725; 14 | gate->hash = (void*)&hmq1725hash; 15 | #endif 16 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 17 | opt_target_factor = 65536.0; 18 | return true; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /algo/qubit/qubit-gate.c: -------------------------------------------------------------------------------- 1 | #include "qubit-gate.h" 2 | 3 | bool register_qubit_algo( algo_gate_t* gate ) 4 | { 5 | 6 | #if defined (QUBIT_4WAY) 7 | init_qubit_4way_ctx(); 8 | gate->scanhash = (void*)&scanhash_qubit_4way; 9 | gate->hash = (void*)&qubit_4way_hash; 10 | #elif defined (QUBIT_2WAY) 11 | init_qubit_2way_ctx(); 12 | gate->scanhash = (void*)&scanhash_qubit_2way; 13 | gate->hash = (void*)&qubit_2way_hash; 14 | #else 15 | init_qubit_ctx(); 16 | gate->scanhash = (void*)&scanhash_qubit; 17 | gate->hash = (void*)&qubit_hash; 18 | #endif 19 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 20 | return true; 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /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 | AVX512_OPT | VAES_OPT; 6 | #if defined (TRIBUS_8WAY) 7 | gate->scanhash = (void*)&scanhash_tribus_8way; 8 | gate->hash = (void*)&tribus_hash_8way; 9 | #elif defined (TRIBUS_4WAY) 10 | gate->scanhash = (void*)&scanhash_tribus_4way; 11 | gate->hash = (void*)&tribus_hash_4way; 12 | #else 13 | gate->miner_thread_init = (void*)&tribus_thread_init; 14 | gate->scanhash = (void*)&scanhash_tribus; 15 | gate->hash = (void*)&tribus_hash; 16 | #endif 17 | return true; 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /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_8WAY) 6 | init_x11gost_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_x11gost_8way; 8 | gate->hash = (void*)&x11gost_8way_hash; 9 | #elif defined (X11GOST_4WAY) 10 | init_x11gost_4way_ctx(); 11 | gate->scanhash = (void*)&scanhash_x11gost_4way; 12 | gate->hash = (void*)&x11gost_4way_hash; 13 | #else 14 | init_x11gost_ctx(); 15 | gate->scanhash = (void*)&scanhash_x11gost; 16 | gate->hash = (void*)&x11gost_hash; 17 | #endif 18 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 19 | return true; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /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_8WAY) 6 | init_phi1612_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_phi1612_8way; 8 | gate->hash = (void*)&phi1612_8way_hash; 9 | #elif defined(PHI1612_4WAY) 10 | init_phi1612_4way_ctx(); 11 | gate->scanhash = (void*)&scanhash_phi1612_4way; 12 | gate->hash = (void*)&phi1612_4way_hash; 13 | #else 14 | init_phi1612_ctx(); 15 | gate->scanhash = (void*)&scanhash_phi1612; 16 | gate->hash = (void*)&phi1612_hash; 17 | #endif 18 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 19 | return true; 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /.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/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 | AVX512_OPT; 6 | #if defined (SKUNK_8WAY) 7 | gate->miner_thread_init = (void*)&skunk_8way_thread_init; 8 | gate->scanhash = (void*)&scanhash_skunk_8way; 9 | gate->hash = (void*)&skunk_8way_hash; 10 | #elif defined (SKUNK_4WAY) 11 | gate->miner_thread_init = (void*)&skunk_4way_thread_init; 12 | gate->scanhash = (void*)&scanhash_skunk_4way; 13 | gate->hash = (void*)&skunk_4way_hash; 14 | #else 15 | gate->miner_thread_init = (void*)&skunk_thread_init; 16 | gate->scanhash = (void*)&scanhash_skunk; 17 | gate->hash = (void*)&skunkhash; 18 | #endif 19 | return true; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /algo/blake/blake2s-gate.c: -------------------------------------------------------------------------------- 1 | #include "blake2s-gate.h" 2 | 3 | bool register_blake2s_algo( algo_gate_t* gate ) 4 | { 5 | #if defined(BLAKE2S_16WAY) 6 | gate->scanhash = (void*)&scanhash_blake2s_16way; 7 | gate->hash = (void*)&blake2s_16way_hash; 8 | #elif defined(BLAKE2S_8WAY) 9 | //#if defined(BLAKE2S_8WAY) 10 | gate->scanhash = (void*)&scanhash_blake2s_8way; 11 | gate->hash = (void*)&blake2s_8way_hash; 12 | #elif defined(BLAKE2S_4WAY) 13 | gate->scanhash = (void*)&scanhash_blake2s_4way; 14 | gate->hash = (void*)&blake2s_4way_hash; 15 | #else 16 | gate->scanhash = (void*)&scanhash_blake2s; 17 | gate->hash = (void*)&blake2s_hash; 18 | #endif 19 | gate->optimizations = SSE2_OPT | AVX2_OPT | AVX512_OPT; 20 | return true; 21 | }; 22 | 23 | 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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/groestl/myrgr-gate.c: -------------------------------------------------------------------------------- 1 | #include "myrgr-gate.h" 2 | 3 | bool register_myriad_algo( algo_gate_t* gate ) 4 | { 5 | #if defined (MYRGR_8WAY) 6 | init_myrgr_8way_ctx(); 7 | gate->scanhash = (void*)&scanhash_myriad_8way; 8 | gate->hash = (void*)&myriad_8way_hash; 9 | gate->optimizations = AES_OPT | AVX2_OPT | VAES_OPT; 10 | #elif defined (MYRGR_4WAY) 11 | init_myrgr_4way_ctx(); 12 | gate->scanhash = (void*)&scanhash_myriad_4way; 13 | gate->hash = (void*)&myriad_4way_hash; 14 | gate->optimizations = AES_OPT | SSE2_OPT | AVX2_OPT | VAES_OPT; 15 | #else 16 | init_myrgr_ctx(); 17 | gate->scanhash = (void*)&scanhash_myriad; 18 | gate->hash = (void*)&myriad_hash; 19 | gate->optimizations = AES_OPT | SSE2_OPT | AVX2_OPT | SHA_OPT | VAES_OPT; 20 | #endif 21 | return true; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /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/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/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/blake/blakecoin-gate.c: -------------------------------------------------------------------------------- 1 | #include "blakecoin-gate.h" 2 | #include 3 | 4 | // vanilla uses default gen merkle root, otherwise identical to blakecoin 5 | bool register_vanilla_algo( algo_gate_t* gate ) 6 | { 7 | #if defined(BLAKECOIN_8WAY) 8 | gate->scanhash = (void*)&scanhash_blakecoin_8way; 9 | gate->hash = (void*)&blakecoin_8way_hash; 10 | 11 | #elif defined(BLAKECOIN_4WAY) 12 | gate->scanhash = (void*)&scanhash_blakecoin_4way; 13 | gate->hash = (void*)&blakecoin_4way_hash; 14 | #else 15 | gate->scanhash = (void*)&scanhash_blakecoin; 16 | gate->hash = (void*)&blakecoinhash; 17 | #endif 18 | gate->optimizations = SSE42_OPT | AVX2_OPT; 19 | return true; 20 | } 21 | 22 | bool register_blakecoin_algo( algo_gate_t* gate ) 23 | { 24 | register_vanilla_algo( gate ); 25 | gate->gen_merkle_root = (void*)&SHA256_gen_merkle_root; 26 | return true; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /junk/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/groestl/groestl-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef GROESTL_GATE_H__ 2 | #define GROESTL_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__VAES__) && defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define GROESTL_4WAY_VAES 1 9 | #endif 10 | 11 | bool register_dmd_gr_algo( algo_gate_t* gate ); 12 | 13 | bool register_groestl_algo( algo_gate_t* gate ); 14 | 15 | #if defined(GROESTL_4WAY_VAES) 16 | 17 | void groestl_4way_hash( void *state, const void *input ); 18 | int scanhash_groestl_4way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | 21 | #else 22 | 23 | void groestlhash( void *state, const void *input ); 24 | int scanhash_groestl( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | void init_groestl_ctx(); 27 | 28 | #endif 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /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 | void shavite512_2way_full( shavite512_2way_context *ctx, void *dst, 22 | const void *data, size_t len ); 23 | 24 | #endif // AVX2 25 | 26 | #endif // SHAVITE_HASH_2WAY_H__ 27 | 28 | -------------------------------------------------------------------------------- /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/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/bmw/bmw512-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef BMW512_GATE_H__ 2 | #define BMW512_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define BMW512_8WAY 1 9 | #elif defined(__AVX2__) 10 | #define BMW512_4WAY 1 11 | #endif 12 | 13 | #if defined(BMW512_8WAY) 14 | 15 | void bmw512hash_8way( void *state, const void *input ); 16 | int scanhash_bmw512_8way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | 19 | #elif defined(BMW512_4WAY) 20 | 21 | void bmw512hash_4way( void *state, const void *input ); 22 | int scanhash_bmw512_4way( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | 25 | #else 26 | 27 | void bmw512hash( void *state, const void *input ); 28 | int scanhash_bmw512( struct work *work, uint32_t max_nonce, 29 | uint64_t *hashes_done, struct thr_info *mythr ); 30 | 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /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->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 30 | x20_r_s_getAlgoString = (void*)&x20r_getAlgoString; 31 | opt_target_factor = 256.; 32 | return true; 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /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/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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define X17_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define X17_4WAY 1 11 | #endif 12 | 13 | bool register_x17_algo( algo_gate_t* gate ); 14 | 15 | #if defined(X17_8WAY) 16 | 17 | void x17_8way_hash( void *state, const void *input ); 18 | int scanhash_x17_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | #elif defined(X17_4WAY) 21 | 22 | void x17_4way_hash( void *state, const void *input ); 23 | int scanhash_x17_4way( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | 26 | #endif 27 | 28 | void x17_hash( void *state, const void *input ); 29 | int scanhash_x17( struct work *work, uint32_t max_nonce, 30 | uint64_t *hashes_done, struct thr_info *mythr ); 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /algo/shavite/shavite-hash-4way.h: -------------------------------------------------------------------------------- 1 | #ifndef SHAVITE_HASH_4WAY_H__ 2 | #define SHAVITE_HASH_4WAY_H__ 1 3 | 4 | #if defined(__VAES__) && defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 5 | 6 | #include "simd-utils.h" 7 | 8 | typedef struct { 9 | unsigned char buf[128<<2]; 10 | uint32_t h[16<<2]; 11 | size_t ptr; 12 | uint32_t count0, count1, count2, count3; 13 | } shavite512_4way_context __attribute__ ((aligned (64))); 14 | 15 | void shavite512_4way_init( shavite512_4way_context *ctx ); 16 | void shavite512_4way_update( shavite512_4way_context *ctx, const void *data, 17 | size_t len ); 18 | void shavite512_4way_close( shavite512_4way_context *ctx, void *dst ); 19 | void shavite512_4way_update_close( shavite512_4way_context *ctx, void *dst, 20 | const void *data, size_t len ); 21 | void shavite512_4way_full( shavite512_4way_context *ctx, void *dst, 22 | const void *data, size_t len ); 23 | 24 | #endif // VAES 25 | 26 | #endif // SHAVITE_HASH_4WAY_H__ 27 | 28 | -------------------------------------------------------------------------------- /algo/nist5/nist5-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef NIST5_GATE_H__ 2 | #define NIST5_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define NIST5_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define NIST5_4WAY 1 11 | #endif 12 | 13 | #if defined(NIST5_8WAY) 14 | 15 | void nist5hash_8way( void *state, const void *input ); 16 | 17 | int scanhash_nist5_8way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | #elif defined(NIST5_4WAY) 21 | 22 | void nist5hash_4way( void *state, const void *input ); 23 | 24 | int scanhash_nist5_4way( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | 27 | #else 28 | 29 | void nist5hash( void *state, const void *input ); 30 | 31 | int scanhash_nist5( 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/panama/panama-hash-4way.h: -------------------------------------------------------------------------------- 1 | #ifndef PANAMA_HASH_4WAY_H__ 2 | #define PANAMA_HASH_4WAY_H__ 1 3 | 4 | #include 5 | #include "simd-utils.h" 6 | 7 | /** 8 | * Output size (in bits) for PANAMA. 9 | */ 10 | #define SPH_SIZE_panama 256 11 | 12 | typedef struct { 13 | unsigned char data[32<<2]; 14 | __m128i buffer[32][8]; 15 | __m128i state[17]; 16 | unsigned data_ptr; 17 | unsigned buffer_ptr; 18 | } panama_4way_context __attribute__ ((aligned (64))); 19 | 20 | void panama_4way_init( void *cc ); 21 | 22 | void panama_4way_update( void *cc, const void *data, size_t len ); 23 | 24 | void panama_4way_close( void *cc, void *dst ); 25 | 26 | #if defined(__AVX2__) 27 | 28 | typedef struct { 29 | unsigned char data[32<<3]; 30 | __m256i buffer[32][8]; 31 | __m256i state[17]; 32 | unsigned data_ptr; 33 | unsigned buffer_ptr; 34 | } panama_8way_context __attribute__ ((aligned (128))); 35 | 36 | void panama_8way_init( void *cc ); 37 | 38 | void panama_8way_update( void *cc, const void *data, size_t len ); 39 | 40 | void panama_8way_close( void *cc, void *dst ); 41 | 42 | #endif 43 | #endif 44 | -------------------------------------------------------------------------------- /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/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 | return true; 16 | }; 17 | 18 | bool register_x13bcd_algo( algo_gate_t* gate ) 19 | { 20 | #if defined (X13BCD_8WAY) 21 | init_x13bcd_8way_ctx(); 22 | gate->scanhash = (void*)&scanhash_x13bcd_8way; 23 | gate->hash = (void*)&x13bcd_8way_hash; 24 | #elif defined (X13BCD_4WAY) 25 | init_x13bcd_4way_ctx(); 26 | gate->scanhash = (void*)&scanhash_x13bcd_4way; 27 | gate->hash = (void*)&x13bcd_4way_hash; 28 | #else 29 | init_x13bcd_ctx(); 30 | gate->scanhash = (void*)&scanhash_x13bcd; 31 | gate->hash = (void*)&x13bcd_hash; 32 | #endif 33 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT; 34 | return true; 35 | }; 36 | 37 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define BLAKE2B_8WAY 9 | #elif defined(__AVX2__) 10 | #define BLAKE2B_4WAY 11 | #endif 12 | 13 | bool register_blake2b_algo( algo_gate_t* gate ); 14 | 15 | #if defined(BLAKE2B_8WAY) 16 | 17 | //void blake2b_8way_hash( void *state, const void *input ); 18 | int scanhash_blake2b_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | 21 | #elif defined(BLAKE2B_4WAY) 22 | 23 | void blake2b_4way_hash( void *state, const void *input ); 24 | int scanhash_blake2b_4way( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | #else 27 | 28 | void blake2b_hash( void *state, const void *input ); 29 | int scanhash_blake2b( struct work *work, uint32_t max_nonce, 30 | uint64_t *hashes_done, struct thr_info *mythr ); 31 | 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /algo/x11/tribus-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef TRIBUS_GATE_H__ 2 | #define TRIBUS_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define TRIBUS_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define TRIBUS_4WAY 1 11 | #endif 12 | 13 | #if defined(TRIBUS_8WAY) 14 | 15 | void tribus_hash_8way( void *state, const void *input ); 16 | 17 | int scanhash_tribus_8way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | 20 | #elif defined(TRIBUS_4WAY) 21 | 22 | void tribus_hash_4way( void *state, const void *input ); 23 | 24 | int scanhash_tribus_4way( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | 27 | #else 28 | 29 | void tribus_hash( void *state, const void *input ); 30 | 31 | int scanhash_tribus( struct work *work, uint32_t max_nonce, 32 | uint64_t *hashes_done, struct thr_info *mythr ); 33 | 34 | bool tribus_thread_init(); 35 | 36 | #endif 37 | 38 | #endif 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/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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define SONOA_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define SONOA_4WAY 1 11 | #endif 12 | 13 | bool register_sonoa_algo( algo_gate_t* gate ); 14 | 15 | #if defined(SONOA_8WAY) 16 | 17 | void sonoa_8way_hash( void *state, const void *input ); 18 | int scanhash_sonoa_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | 21 | #elif defined(SONOA_4WAY) 22 | 23 | void sonoa_4way_hash( void *state, const void *input ); 24 | int scanhash_sonoa_4way( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | 27 | #else 28 | 29 | void sonoa_hash( void *state, const void *input ); 30 | int scanhash_sonoa( struct work *work, uint32_t max_nonce, 31 | uint64_t *hashes_done, struct thr_info *mythr ); 32 | void init_sonoa_ctx(); 33 | 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /algo/skein/skein-gate.c: -------------------------------------------------------------------------------- 1 | #include "skein-gate.h" 2 | #include "sph_skein.h" 3 | #include "skein-hash-4way.h" 4 | 5 | bool register_skein_algo( algo_gate_t* gate ) 6 | { 7 | gate->optimizations = AVX2_OPT | AVX512_OPT | SHA_OPT; 8 | #if defined (SKEIN_8WAY) 9 | gate->scanhash = (void*)&scanhash_skein_8way; 10 | gate->hash = (void*)&skeinhash_8way; 11 | #elif defined (SKEIN_4WAY) 12 | gate->scanhash = (void*)&scanhash_skein_4way; 13 | gate->hash = (void*)&skeinhash_4way; 14 | #else 15 | gate->scanhash = (void*)&scanhash_skein; 16 | gate->hash = (void*)&skeinhash; 17 | #endif 18 | return true; 19 | }; 20 | 21 | bool register_skein2_algo( algo_gate_t* gate ) 22 | { 23 | gate->optimizations = AVX2_OPT | AVX512_OPT; 24 | #if defined (SKEIN_8WAY) 25 | gate->scanhash = (void*)&scanhash_skein2_8way; 26 | gate->hash = (void*)&skein2hash_8way; 27 | #elif defined (SKEIN_4WAY) 28 | gate->scanhash = (void*)&scanhash_skein2_4way; 29 | gate->hash = (void*)&skein2hash_4way; 30 | #else 31 | gate->scanhash = (void*)&scanhash_skein2; 32 | gate->hash = (void*)&skein2hash; 33 | #endif 34 | return true; 35 | }; 36 | 37 | 38 | -------------------------------------------------------------------------------- /algo/swifftx/inttypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | inttypes.h 3 | 4 | Contributors: 5 | Created by Marek Michalkiewicz 6 | 7 | THIS SOFTWARE IS NOT COPYRIGHTED 8 | 9 | This source code is offered for use in the public domain. You may 10 | use, modify or distribute it freely. 11 | 12 | This code is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 14 | DISCLAIMED. This includes but is not limited to warranties of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #ifndef __INTTYPES_H_ 19 | #define __INTTYPES_H_ 20 | 21 | /* Use [u]intN_t if you need exactly N bits. 22 | XXX - doesn't handle the -mint8 option. */ 23 | 24 | typedef signed char swift_int8_t; 25 | typedef unsigned char swift_uint8_t; 26 | 27 | typedef int swift_int16_t; 28 | typedef unsigned int swift_uint16_t; 29 | 30 | typedef long swift_int32_t; 31 | typedef unsigned long swift_uint32_t; 32 | 33 | typedef long long swift_int64_t; 34 | typedef unsigned long long swift_uint64_t; 35 | 36 | //typedef swift_int16_t intptr_t; 37 | //typedef swift_uint16_t uintptr_t; 38 | 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/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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define X13_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define X13_4WAY 1 11 | #endif 12 | 13 | bool register_x13_algo( algo_gate_t* gate ); 14 | 15 | #if defined(X13_8WAY) 16 | 17 | void x13_8way_hash( void *state, const void *input ); 18 | int scanhash_x13_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | void init_x13_8way_ctx(); 21 | 22 | #elif defined(X13_4WAY) 23 | 24 | void x13_4way_hash( void *state, const void *input ); 25 | int scanhash_x13_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | void init_x13_4way_ctx(); 28 | 29 | #else 30 | 31 | void x13hash( void *state, const void *input ); 32 | int scanhash_x13( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | void init_x13_ctx(); 35 | 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define X14_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define X14_4WAY 1 11 | #endif 12 | 13 | bool register_x14_algo( algo_gate_t* gate ); 14 | 15 | #if defined(X14_8WAY) 16 | 17 | void x14_8way_hash( void *state, const void *input ); 18 | int scanhash_x14_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | void init_x14_8way_ctx(); 21 | 22 | #elif defined(X14_4WAY) 23 | 24 | void x14_4way_hash( void *state, const void *input ); 25 | int scanhash_x14_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | void init_x14_4way_ctx(); 28 | 29 | #else 30 | 31 | void x14hash( void *state, const void *input ); 32 | int scanhash_x14( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | void init_x14_ctx(); 35 | 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define X12_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define X12_4WAY 1 11 | #endif 12 | 13 | bool register_x12_algo( algo_gate_t* gate ); 14 | 15 | #if defined(X12_8WAY) 16 | 17 | void x12_8way_hash( void *state, const void *input ); 18 | int scanhash_x12_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | void init_x12_8way_ctx(); 21 | 22 | #elif defined(X12_4WAY) 23 | 24 | void x12_4way_hash( void *state, const void *input ); 25 | int scanhash_x12_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | void init_x12_4way_ctx(); 28 | 29 | #else 30 | 31 | void x12hash( void *state, const void *input ); 32 | int scanhash_x12( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | void init_x12_ctx(); 35 | 36 | #endif 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define QUARK_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define QUARK_4WAY 1 11 | #endif 12 | 13 | bool register_quark_algo( algo_gate_t* gate ); 14 | 15 | #if defined(QUARK_8WAY) 16 | 17 | void quark_8way_hash( void *state, const void *input ); 18 | int scanhash_quark_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | void init_quark_8way_ctx(); 21 | 22 | #elif defined(QUARK_4WAY) 23 | 24 | void quark_4way_hash( void *state, const void *input ); 25 | int scanhash_quark_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | void init_quark_4way_ctx(); 28 | 29 | #else 30 | 31 | void quark_hash( void *state, const void *input ); 32 | int scanhash_quark( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | 35 | #endif 36 | #endif 37 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define X11_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define X11_4WAY 1 11 | #endif 12 | 13 | bool register_x11_algo( algo_gate_t* gate ); 14 | #if defined(X11_8WAY) 15 | 16 | void x11_8way_hash( void *state, const void *input ); 17 | int scanhash_x11_8way( struct work *work, uint32_t max_nonce, 18 | uint64_t *hashes_done, struct thr_info *mythr ); 19 | void init_x11_8way_ctx(); 20 | 21 | #elif defined(X11_4WAY) 22 | 23 | void x11_4way_hash( void *state, const void *input ); 24 | int scanhash_x11_4way( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | void init_x11_4way_ctx(); 27 | 28 | #else 29 | 30 | void x11_hash( void *state, const void *input ); 31 | int scanhash_x11( struct work *work, uint32_t max_nonce, 32 | uint64_t *hashes_done, struct thr_info *mythr ); 33 | void init_x11_ctx(); 34 | 35 | #endif 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define C11_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define C11_4WAY 1 11 | #endif 12 | 13 | 14 | bool register_c11_algo( algo_gate_t* gate ); 15 | #if defined(C11_8WAY) 16 | 17 | void c11_8way_hash( void *state, const void *input ); 18 | int scanhash_c11_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | void init_c11_8way_ctx(); 21 | 22 | #elif defined(C11_4WAY) 23 | 24 | void c11_4way_hash( void *state, const void *input ); 25 | int scanhash_c11_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | void init_c11_4way_ctx(); 28 | 29 | #else 30 | 31 | void c11_hash( void *state, const void *input ); 32 | int scanhash_c11( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | void init_c11_ctx(); 35 | 36 | #endif 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define SKUNK_8WAY 1 9 | #elif defined(__AVX2__) 10 | #define SKUNK_4WAY 1 11 | #endif 12 | 13 | bool register_skunk_algo( algo_gate_t* gate ); 14 | 15 | #if defined(SKUNK_8WAY) 16 | 17 | void skunk_8way_hash( void *state, const void *input ); 18 | int scanhash_skunk_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | bool skunk_8way_thread_init(); 21 | 22 | #elif defined(SKUNK_4WAY) 23 | 24 | void skunk_4way_hash( void *state, const void *input ); 25 | int scanhash_skunk_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | bool skunk_4way_thread_init(); 28 | 29 | #endif 30 | 31 | void skunkhash( void *state, const void *input ); 32 | int scanhash_skunk( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | bool skunk_thread_init(); 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define X15_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define X15_4WAY 1 11 | #endif 12 | 13 | 14 | bool register_x15_algo( algo_gate_t* gate ); 15 | 16 | #if defined(X15_8WAY) 17 | 18 | void x15_8way_hash( void *state, const void *input ); 19 | int scanhash_x15_8way( struct work *work, uint32_t max_nonce, 20 | uint64_t *hashes_done, struct thr_info *mythr ); 21 | void init_x15_8way_ctx(); 22 | 23 | #elif defined(X15_4WAY) 24 | 25 | void x15_4way_hash( void *state, const void *input ); 26 | int scanhash_x15_4way( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | void init_x15_4way_ctx(); 29 | 30 | #else 31 | 32 | void x15hash( void *state, const void *input ); 33 | int scanhash_x15( struct work *work, uint32_t max_nonce, 34 | uint64_t *hashes_done, struct thr_info *mythr ); 35 | void init_x15_ctx(); 36 | 37 | #endif 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /algo/groestl/myrgr-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef MYRGR_GATE_H__ 2 | #define MYRGR_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__VAES__) && defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define MYRGR_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) && !defined(__SHA__) 10 | #define MYRGR_4WAY 1 11 | #endif 12 | 13 | #if defined(MYRGR_8WAY) 14 | 15 | void myriad_8way_hash( void *state, const void *input ); 16 | int scanhash_myriad_8way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | void init_myrgr_8way_ctx(); 19 | 20 | #elif defined(MYRGR_4WAY) 21 | 22 | void myriad_4way_hash( void *state, const void *input ); 23 | int scanhash_myriad_4way( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_myrgr_4way_ctx(); 26 | 27 | #else 28 | 29 | void myriad_hash( void *state, const void *input ); 30 | int scanhash_myriad( struct work *work, uint32_t max_nonce, 31 | uint64_t *hashes_done, struct thr_info *mythr ); 32 | void init_myrgr_ctx(); 33 | 34 | #endif 35 | #endif 36 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define XEVAN_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define XEVAN_4WAY 1 11 | #endif 12 | 13 | bool register_xevan_algo( algo_gate_t* gate ); 14 | 15 | #if defined(XEVAN_8WAY) 16 | 17 | void xevan_8way_hash( void *state, const void *input ); 18 | 19 | int scanhash_xevan_8way( struct work *work, uint32_t max_nonce, 20 | uint64_t *hashes_done, struct thr_info *mythr ); 21 | #elif defined(XEVAN_4WAY) 22 | 23 | void xevan_4way_hash( void *state, const void *input ); 24 | 25 | int scanhash_xevan_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | 28 | //void init_xevan_4way_ctx(); 29 | 30 | #else 31 | 32 | void xevan_hash( void *state, const void *input ); 33 | 34 | int scanhash_xevan( struct work *work, uint32_t max_nonce, 35 | uint64_t *hashes_done, struct thr_info *mythr ); 36 | 37 | void init_xevan_ctx(); 38 | 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define HMQ1725_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define HMQ1725_4WAY 1 11 | #endif 12 | 13 | bool register_hmq1725_algo( algo_gate_t* gate ); 14 | 15 | #if defined(HMQ1725_8WAY) 16 | 17 | void hmq1725_8way_hash( void *state, const void *input ); 18 | int scanhash_hmq1725_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | 21 | #elif defined(HMQ1725_4WAY) 22 | 23 | void hmq1725_4way_hash( void *state, const void *input ); 24 | int scanhash_hmq1725_4way( struct work *work, uint32_t max_nonce, 25 | uint64_t *hashes_done, struct thr_info *mythr ); 26 | 27 | #else 28 | 29 | void hmq1725hash( void *state, const void *input ); 30 | int scanhash_hmq1725( struct work *work, uint32_t max_nonce, 31 | uint64_t *hashes_done, struct thr_info *mythr ); 32 | void init_hmq1725_ctx(); 33 | 34 | #endif 35 | 36 | #endif // HMQ1725_GATE_H__ 37 | -------------------------------------------------------------------------------- /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 | 8 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 9 | #define QUBIT_4WAY 1 10 | #elif defined(__AVX2__) && defined(__AES__) 11 | #define QUBIT_2WAY 1 12 | #endif 13 | 14 | bool register_qubit_algo( algo_gate_t* gate ); 15 | 16 | #if defined(QUBIT_4WAY) 17 | 18 | void qubit_4way_hash( void *state, const void *input ); 19 | int scanhash_qubit_4way( struct work *work, uint32_t max_nonce, 20 | uint64_t *hashes_done, struct thr_info *mythr ); 21 | void init_qubit_4way_ctx(); 22 | 23 | #elif defined(QUBIT_2WAY) 24 | 25 | void qubit_2way_hash( void *state, const void *input ); 26 | int scanhash_qubit_2way( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | void init_qubit_2way_ctx(); 29 | 30 | #endif 31 | 32 | void qubit_hash( void *state, const void *input ); 33 | int scanhash_qubit( struct work *work, uint32_t max_nonce, 34 | uint64_t *hashes_done, struct thr_info *mythr ); 35 | void init_qubit_ctx(); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /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/echo/echo-hash-4way.h: -------------------------------------------------------------------------------- 1 | #if !defined(ECHO_HASH_4WAY_H__) 2 | #define ECHO_HASH_4WAY_H__ 1 3 | 4 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 5 | 6 | #include "simd-utils.h" 7 | 8 | typedef struct 9 | { 10 | __m512i state[4][4]; 11 | __m512i buffer[ 4 * 192 / 16 ]; // 4x128 interleaved 192 bytes 12 | __m512i k; 13 | __m512i hashsize; 14 | __m512i const1536; 15 | 16 | unsigned int uRounds; 17 | unsigned int uHashSize; 18 | unsigned int uBlockLength; 19 | unsigned int uBufferBytes; 20 | unsigned int processed_bits; 21 | 22 | } echo_4way_context __attribute__ ((aligned (64))); 23 | 24 | int echo_4way_init( echo_4way_context *state, int hashbitlen ); 25 | 26 | 27 | int echo_4way_update( echo_4way_context *state, const void *data, 28 | unsigned int databitlen); 29 | 30 | int echo_close( echo_4way_context *state, void *hashval ); 31 | 32 | int echo_4way_update_close( echo_4way_context *state, void *hashval, 33 | const void *data, int databitlen ); 34 | 35 | int echo_4way_full( echo_4way_context *ctx, void *hashval, int nHashSize, 36 | const void *data, int datalen ); 37 | 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /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/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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define X11GOST_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define X11GOST_4WAY 1 11 | #endif 12 | 13 | bool register_x11gost_algo( algo_gate_t* gate ); 14 | 15 | #if defined(X11GOST_8WAY) 16 | 17 | void x11gost_8way_hash( void *state, const void *input ); 18 | int scanhash_x11gost_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | void init_x11gost_8way_ctx(); 21 | 22 | #elif defined(X11GOST_4WAY) 23 | 24 | void x11gost_4way_hash( void *state, const void *input ); 25 | int scanhash_x11gost_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | void init_x11gost_4way_ctx(); 28 | 29 | #else 30 | 31 | void x11gost_hash( void *state, const void *input ); 32 | int scanhash_x11gost( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | void init_x11gost_ctx(); 35 | 36 | #endif 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /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(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define PHI1612_8WAY 1 9 | #elif defined(__AVX2__) && defined(__AES__) 10 | #define PHI1612_4WAY 1 11 | #endif 12 | 13 | bool register_phi1612_algo( algo_gate_t* gate ); 14 | 15 | #if defined(PHI1612_8WAY) 16 | 17 | void phi1612_8way_hash( void *state, const void *input ); 18 | int scanhash_phi1612_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | void init_phi1612_8way_ctx(); 21 | 22 | #elif defined(PHI1612_4WAY) 23 | 24 | void phi1612_4way_hash( void *state, const void *input ); 25 | int scanhash_phi1612_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | void init_phi1612_4way_ctx(); 28 | 29 | #else 30 | 31 | void phi1612_hash( void *state, const void *input ); 32 | int scanhash_phi1612( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | void init_phi1612_ctx(); 35 | 36 | #endif 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /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/yespower/crypto/blake2b-yp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __BLAKE2B_H__ 3 | #define __BLAKE2B_H__ 4 | 5 | #include 6 | #include 7 | 8 | #if defined(_MSC_VER) || defined(__x86_64__) || defined(__x86__) 9 | #define NATIVE_LITTLE_ENDIAN 10 | #endif 11 | 12 | // state context 13 | typedef struct { 14 | uint8_t b[128]; // input buffer 15 | uint64_t h[8]; // chained state 16 | uint64_t t[2]; // total number of bytes 17 | size_t c; // pointer for b[] 18 | size_t outlen; // digest size 19 | } blake2b_yp_ctx; 20 | 21 | typedef struct { 22 | blake2b_yp_ctx inner; 23 | blake2b_yp_ctx outer; 24 | } hmac_yp_ctx; 25 | 26 | #if defined(__cplusplus) 27 | extern "C" { 28 | #endif 29 | 30 | int blake2b_yp_init(blake2b_yp_ctx *ctx, size_t outlen, const void *key, size_t keylen); 31 | void blake2b_yp_update(blake2b_yp_ctx *ctx, const void *in, size_t inlen); 32 | void blake2b_yp_final(blake2b_yp_ctx *ctx, void *out); 33 | void blake2b_yp_hash(void *out, const void *in, size_t inlen); 34 | void hmac_blake2b_yp_hash(void *out, const void *key, size_t keylen, const void *in, size_t inlen); 35 | void pbkdf2_blake2b_yp(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt, 36 | size_t saltlen, uint64_t c, uint8_t * buf, size_t dkLen); 37 | 38 | #if defined(__cplusplus) 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /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 | return true; 19 | } 20 | 21 | bool register_sha256q_algo( algo_gate_t* gate ) 22 | { 23 | #if defined(SHA256T_8WAY) 24 | gate->optimizations = SSE2_OPT | AVX2_OPT | SHA_OPT; 25 | gate->scanhash = (void*)&scanhash_sha256q_8way; 26 | gate->hash = (void*)&sha256q_8way_hash; 27 | #elif defined(SHA256T_4WAY) 28 | gate->optimizations = SSE2_OPT | AVX2_OPT | SHA_OPT; 29 | gate->scanhash = (void*)&scanhash_sha256q_4way; 30 | gate->hash = (void*)&sha256q_4way_hash; 31 | #else 32 | gate->optimizations = SHA_OPT; 33 | gate->scanhash = (void*)&scanhash_sha256q; 34 | gate->hash = (void*)&sha256q_hash; 35 | #endif 36 | return true; 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/m7m/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/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(64) 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 | int cubehash_full( cubehashParam* sp, byte *digest, int hashbitlen, 43 | const byte *data, size_t size ); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* H_CUBEHASH */ 50 | -------------------------------------------------------------------------------- /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/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( struct work *work, uint32_t max_nonce, 48 | uint64_t *hashes_done, struct thr_info *mythr ); 49 | 50 | #endif 51 | 52 | void x20rhash( void *state, const void *input ); 53 | 54 | int scanhash_x20r( struct work *work, uint32_t max_nonce, 55 | uint64_t *hashes_done, struct thr_info *mythr ); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /algo/bmw/bmw512.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | 3 | #if !defined(BMW512_8WAY) && !defined(BMW512_4WAY) 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "sph_bmw.h" 10 | 11 | void bmw512hash(void *state, const void *input) 12 | { 13 | sph_bmw512_context ctx; 14 | uint32_t hash[32]; 15 | 16 | sph_bmw512_init( &ctx ); 17 | sph_bmw512( &ctx,input, 80 ); 18 | sph_bmw512_close( &ctx, hash ); 19 | 20 | memcpy( state, hash, 32 ); 21 | } 22 | 23 | int scanhash_bmw512( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ) 25 | { 26 | uint32_t *pdata = work->data; 27 | uint32_t *ptarget = work->target; 28 | uint32_t n = pdata[19] - 1; 29 | const uint32_t first_nonce = pdata[19]; 30 | //const uint32_t Htarg = ptarget[7]; 31 | int thr_id = mythr->id; // thr_id arg is deprecated 32 | 33 | uint32_t _ALIGN(32) hash64[8]; 34 | uint32_t endiandata[32]; 35 | 36 | for (int i=0; i < 19; i++) 37 | be32enc(&endiandata[i], pdata[i]); 38 | 39 | do { 40 | 41 | pdata[19] = ++n; 42 | be32enc(&endiandata[19], n); 43 | bmw512hash(hash64, endiandata); 44 | if (((hash64[7]&0xFFFFFF00)==0) && 45 | fulltest(hash64, ptarget)) { 46 | *hashes_done = n - first_nonce + 1; 47 | return true; 48 | } 49 | } while (n < max_nonce && !work_restart[thr_id].restart); 50 | 51 | *hashes_done = n - first_nonce + 1; 52 | pdata[19] = n; 53 | return 0; 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /algo/keccak/keccak.c: -------------------------------------------------------------------------------- 1 | #include "keccak-gate.h" 2 | 3 | #if !defined(KECCAK_8WAY) && !defined(KECCAK_4WAY) 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "sph_keccak.h" 10 | 11 | void keccakhash(void *state, const void *input) 12 | { 13 | sph_keccak256_context ctx_keccak; 14 | uint32_t hash[32]; 15 | 16 | sph_keccak256_init(&ctx_keccak); 17 | sph_keccak256 (&ctx_keccak,input, 80); 18 | sph_keccak256_close(&ctx_keccak, hash); 19 | 20 | memcpy(state, hash, 32); 21 | } 22 | 23 | int scanhash_keccak( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ) 25 | { 26 | uint32_t _ALIGN(64) hash64[8]; 27 | uint32_t _ALIGN(64) endiandata[32]; 28 | uint32_t *pdata = work->data; 29 | uint32_t *ptarget = work->target; 30 | uint32_t n = pdata[19]; 31 | const uint32_t first_nonce = pdata[19]; 32 | const uint32_t last_nonce = max_nonce; 33 | const int thr_id = mythr->id; 34 | 35 | for ( int i=0; i < 19; i++ ) 36 | be32enc( &endiandata[i], pdata[i] ); 37 | 38 | do { 39 | be32enc( &endiandata[19], n ); 40 | keccakhash( hash64, endiandata ); 41 | if ( valid_hash( hash64, ptarget ) && !opt_benchmark ) 42 | { 43 | pdata[19] = n; 44 | submit_solution( work, hash64, mythr ); 45 | } 46 | n++; 47 | } while ( n < last_nonce && !work_restart[thr_id].restart ); 48 | 49 | *hashes_done = n - first_nonce; 50 | pdata[19] = n; 51 | return 0; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /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 | 12 | #if defined(__AVX2__) 13 | #define BLAKE2S_8WAY 14 | #endif 15 | 16 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 17 | #define BLAKE2S_16WAY 18 | #endif 19 | 20 | bool register_blake2s_algo( algo_gate_t* gate ); 21 | 22 | #if defined(BLAKE2S_16WAY) 23 | 24 | void blake2s_16way_hash( void *state, const void *input ); 25 | int scanhash_blake2s_16way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | 28 | #elif defined (BLAKE2S_8WAY) 29 | 30 | //#if defined(BLAKE2S_8WAY) 31 | 32 | void blake2s_8way_hash( void *state, const void *input ); 33 | int scanhash_blake2s_8way( struct work *work, uint32_t max_nonce, 34 | uint64_t *hashes_done, struct thr_info *mythr ); 35 | 36 | #elif defined (BLAKE2S_4WAY) 37 | 38 | void blake2s_4way_hash( void *state, const void *input ); 39 | int scanhash_blake2s_4way( struct work *work, uint32_t max_nonce, 40 | uint64_t *hashes_done, struct thr_info *mythr ); 41 | #else 42 | 43 | void blake2s_hash( void *state, const void *input ); 44 | int scanhash_blake2s( struct work *work, uint32_t max_nonce, 45 | uint64_t *hashes_done, struct thr_info *mythr ); 46 | 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /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/blake/blake2b-hash-4way.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __BLAKE2B_HASH_4WAY_H__ 3 | #define __BLAKE2B_HASH_4WAY_H__ 4 | 5 | #include "simd-utils.h" 6 | #include 7 | #include 8 | 9 | #if defined(_MSC_VER) 10 | #include 11 | #define inline __inline 12 | #define ALIGN(x) __declspec(align(x)) 13 | #else 14 | #define ALIGN(x) __attribute__((aligned(x))) 15 | #endif 16 | 17 | 18 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 19 | 20 | ALIGN(128) typedef struct { 21 | __m512i b[16]; // input buffer 22 | __m512i 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_8way_ctx; 27 | 28 | int blake2b_8way_init( blake2b_8way_ctx *ctx ); 29 | void blake2b_8way_update( blake2b_8way_ctx *ctx, const void *input, 30 | size_t inlen ); 31 | void blake2b_8way_final( blake2b_8way_ctx *ctx, void *out ); 32 | 33 | #endif 34 | 35 | #if defined(__AVX2__) 36 | 37 | // state context 38 | ALIGN(128) typedef struct { 39 | __m256i b[16]; // input buffer 40 | __m256i h[8]; // chained state 41 | uint64_t t[2]; // total number of bytes 42 | size_t c; // pointer for b[] 43 | size_t outlen; // digest size 44 | } blake2b_4way_ctx; 45 | 46 | int blake2b_4way_init( blake2b_4way_ctx *ctx ); 47 | void blake2b_4way_update( blake2b_4way_ctx *ctx, const void *input, 48 | size_t inlen ); 49 | void blake2b_4way_final( blake2b_4way_ctx *ctx, void *out ); 50 | 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /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 | 8 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 9 | #define LBRY_16WAY 1 10 | #elif defined(__AVX2__) 11 | #define LBRY_8WAY 1 12 | #endif 13 | /* 14 | #if !defined(__SHA__) 15 | #if defined(__AVX2__) 16 | #define LBRY_8WAY 17 | #endif 18 | #endif 19 | */ 20 | 21 | #define LBRY_NTIME_INDEX 25 22 | #define LBRY_NBITS_INDEX 26 23 | #define LBRY_NONCE_INDEX 27 24 | #define LBRY_WORK_DATA_SIZE 192 25 | #define LBRY_WORK_CMP_SIZE 76 // same as default 26 | 27 | bool register_lbry_algo( algo_gate_t* gate ); 28 | 29 | #if defined(LBRY_16WAY) 30 | 31 | void lbry_16way_hash( void *state, const void *input ); 32 | int scanhash_lbry_16way( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | #elif defined(LBRY_8WAY) 35 | 36 | void lbry_8way_hash( void *state, const void *input ); 37 | int scanhash_lbry_8way( struct work *work, uint32_t max_nonce, 38 | uint64_t *hashes_done, struct thr_info *mythr ); 39 | 40 | #elif defined(LBRY_4WAY) 41 | 42 | void lbry_4way_hash( void *state, const void *input ); 43 | int scanhash_lbry_4way( struct work *work, uint32_t max_nonce, 44 | uint64_t *hashes_done ); 45 | 46 | #else 47 | 48 | void lbry_hash( void *state, const void *input ); 49 | int scanhash_lbry( struct work *work, uint32_t max_nonce, 50 | uint64_t *hashes_done, struct thr_info *mythr ); 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /algo/x11/timetravel-gate.c: -------------------------------------------------------------------------------- 1 | #include "timetravel-gate.h" 2 | 3 | bool register_timetravel_algo( algo_gate_t* gate ) 4 | { 5 | #ifdef TIMETRAVEL_4WAY 6 | init_tt8_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_timetravel_4way; 8 | gate->hash = (void*)&timetravel_4way_hash; 9 | #else 10 | init_tt8_ctx(); 11 | gate->scanhash = (void*)&scanhash_timetravel; 12 | gate->hash = (void*)&timetravel_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | opt_target_factor = 256.0; 16 | return true; 17 | }; 18 | 19 | inline void tt_swap( int *a, int *b ) 20 | { 21 | int c = *a; 22 | *a = *b; 23 | *b = c; 24 | } 25 | 26 | inline void reverse( int *pbegin, int *pend ) 27 | { 28 | while ( (pbegin != pend) && (pbegin != --pend) ) 29 | { 30 | tt_swap( pbegin, pend ); 31 | pbegin++; 32 | } 33 | } 34 | 35 | void tt8_next_permutation( int *pbegin, int *pend ) 36 | { 37 | if ( pbegin == pend ) 38 | return; 39 | 40 | int *i = pbegin; 41 | ++i; 42 | if ( i == pend ) 43 | return; 44 | 45 | i = pend; 46 | --i; 47 | 48 | while (1) 49 | { 50 | int *j = i; 51 | --i; 52 | 53 | if ( *i < *j ) 54 | { 55 | int *k = pend; 56 | 57 | while ( !(*i < *--k) ) /* do nothing */ ; 58 | 59 | tt_swap( i, k ); 60 | reverse(j, pend); 61 | return; // true 62 | } 63 | 64 | if ( i == pbegin ) 65 | { 66 | reverse(pbegin, pend); 67 | return; // false 68 | } 69 | // else? 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /algo/keccak/sha3d.c: -------------------------------------------------------------------------------- 1 | #include "keccak-gate.h" 2 | 3 | #if !defined(KECCAK_8WAY) && !defined(KECCAK_4WAY) 4 | 5 | #include 6 | #include 7 | #include 8 | #include "sph_keccak.h" 9 | 10 | void sha3d_hash(void *state, const void *input) 11 | { 12 | uint32_t buffer[16]; 13 | sph_keccak256_context ctx_keccak; 14 | 15 | sph_keccak256_init( &ctx_keccak ); 16 | sph_keccak256 ( &ctx_keccak, input, 80 ); 17 | sph_keccak256_close( &ctx_keccak, buffer ); 18 | sph_keccak256_init( &ctx_keccak ); 19 | sph_keccak256 ( &ctx_keccak, buffer, 32 ); 20 | sph_keccak256_close( &ctx_keccak, state ); 21 | } 22 | 23 | int scanhash_sha3d( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ) 25 | { 26 | uint32_t _ALIGN(64) hash64[8]; 27 | uint32_t _ALIGN(64) endiandata[32]; 28 | uint32_t *pdata = work->data; 29 | uint32_t *ptarget = work->target; 30 | uint32_t n = pdata[19]; 31 | const uint32_t first_nonce = pdata[19]; 32 | const uint32_t last_nonce = max_nonce; 33 | const int thr_id = mythr->id; 34 | 35 | for ( int i=0; i < 19; i++ ) 36 | be32enc( &endiandata[i], pdata[i] ); 37 | 38 | do { 39 | be32enc( &endiandata[19], n ); 40 | sha3d_hash( hash64, endiandata ); 41 | if ( valid_hash( hash64, ptarget ) && !opt_benchmark ) 42 | { 43 | pdata[19] = n; 44 | submit_solution( work, hash64, mythr ); 45 | } 46 | n++; 47 | } while ( n < last_nonce && !work_restart[thr_id].restart ); 48 | 49 | *hashes_done = n - first_nonce; 50 | pdata[19] = n; 51 | return 0; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /algo/x11/timetravel10-gate.c: -------------------------------------------------------------------------------- 1 | #include "timetravel10-gate.h" 2 | 3 | bool register_timetravel10_algo( algo_gate_t* gate ) 4 | { 5 | #ifdef TIMETRAVEL10_4WAY 6 | init_tt10_4way_ctx(); 7 | gate->scanhash = (void*)&scanhash_timetravel10_4way; 8 | gate->hash = (void*)&timetravel10_4way_hash; 9 | #else 10 | init_tt10_ctx(); 11 | gate->scanhash = (void*)&scanhash_timetravel10; 12 | gate->hash = (void*)&timetravel10_hash; 13 | #endif 14 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT; 15 | opt_target_factor = 256.0; 16 | return true; 17 | }; 18 | 19 | inline void tt10_swap( int *a, int *b ) 20 | { 21 | int c = *a; 22 | *a = *b; 23 | *b = c; 24 | } 25 | 26 | inline void reverse( int *pbegin, int *pend ) 27 | { 28 | while ( (pbegin != pend) && (pbegin != --pend) ) 29 | { 30 | tt10_swap( pbegin, pend ); 31 | pbegin++; 32 | } 33 | } 34 | 35 | void tt10_next_permutation( int *pbegin, int *pend ) 36 | { 37 | if ( pbegin == pend ) 38 | return; 39 | 40 | int *i = pbegin; 41 | ++i; 42 | if ( i == pend ) 43 | return; 44 | 45 | i = pend; 46 | --i; 47 | 48 | while (1) 49 | { 50 | int *j = i; 51 | --i; 52 | 53 | if ( *i < *j ) 54 | { 55 | int *k = pend; 56 | 57 | while ( !(*i < *--k) ) /* do nothing */ ; 58 | 59 | tt10_swap( i, k ); 60 | reverse(j, pend); 61 | return; // true 62 | } 63 | 64 | if ( i == pbegin ) 65 | { 66 | reverse(pbegin, pend); 67 | return; // false 68 | } 69 | // else? 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /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 | int simd_full( hashState_sd *state, BitSequence *hashval, 51 | const BitSequence *data, DataLength databitlen ); 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 | 8 | #if !defined(BLAKE2B_8WAY) && !defined(BLAKE2B_4WAY) 9 | 10 | #include 11 | #include 12 | #include "algo/blake/sph_blake2b.h" 13 | 14 | #define MIDLEN 76 15 | #define A 64 16 | 17 | void blake2b_hash(void *output, const void *input) 18 | { 19 | uint8_t _ALIGN(A) hash[32]; 20 | sph_blake2b_ctx ctx __attribute__ ((aligned (64))); 21 | 22 | sph_blake2b_init(&ctx, 32, NULL, 0); 23 | sph_blake2b_update(&ctx, input, 80); 24 | sph_blake2b_final(&ctx, hash); 25 | 26 | memcpy(output, hash, 32); 27 | } 28 | 29 | int scanhash_blake2b( struct work *work, uint32_t max_nonce, 30 | uint64_t *hashes_done, struct thr_info *mythr ) 31 | { 32 | uint32_t _ALIGN(A) vhashcpu[8]; 33 | uint32_t _ALIGN(A) endiandata[20]; 34 | uint32_t *pdata = work->data; 35 | uint32_t *ptarget = work->target; 36 | int thr_id = mythr->id; // thr_id arg is deprecated 37 | 38 | const uint32_t Htarg = ptarget[7]; 39 | const uint32_t first_nonce = pdata[19]; 40 | 41 | uint32_t n = first_nonce; 42 | 43 | for (int i=0; i < 19; i++) { 44 | be32enc(&endiandata[i], pdata[i]); 45 | } 46 | 47 | do { 48 | be32enc(&endiandata[19], n); 49 | blake2b_hash(vhashcpu, endiandata); 50 | 51 | if (vhashcpu[7] <= Htarg && fulltest(vhashcpu, ptarget)) 52 | { 53 | pdata[19] = n; 54 | submit_solution( work, vhashcpu, mythr ); 55 | } 56 | n++; 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 | #endif 65 | -------------------------------------------------------------------------------- /algo/skein/skein-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef __SKEIN_GATE_H__ 2 | #define __SKEIN_GATE_H__ 1 3 | #include 4 | #include "algo-gate-api.h" 5 | 6 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 7 | #define SKEIN_8WAY 1 8 | #elif defined(__AVX2__) 9 | #define SKEIN_4WAY 1 10 | #endif 11 | 12 | #if defined(SKEIN_8WAY) 13 | 14 | void skeinhash_8way( void *output, const void *input ); 15 | int scanhash_skein_8way( struct work *work, uint32_t max_nonce, 16 | uint64_t *hashes_done, struct thr_info *mythr ); 17 | 18 | void skein2hash_8way( void *output, const void *input ); 19 | int scanhash_skein2_8way( struct work *work, uint32_t max_nonce, 20 | uint64_t* hashes_done, struct thr_info *mythr ); 21 | 22 | #elif defined(SKEIN_4WAY) 23 | 24 | void skeinhash_4way( void *output, const void *input ); 25 | int scanhash_skein_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ); 27 | 28 | void skein2hash_4way( void *output, const void *input ); 29 | int scanhash_skein2_4way( struct work *work, uint32_t max_nonce, 30 | uint64_t* hashes_done, struct thr_info *mythr ); 31 | 32 | #else 33 | 34 | void skeinhash( void *output, const void *input ); 35 | int scanhash_skein( struct work *work, uint32_t max_nonce, 36 | uint64_t *hashes_done, struct thr_info *mythr ); 37 | 38 | void skein2hash( void *output, const void *input ); 39 | int scanhash_skein2( struct work *work, uint32_t max_nonce, 40 | uint64_t *hashes_done, struct thr_info *mythr ); 41 | 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /algo/keccak/keccak-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef KECCAK_GATE_H__ 2 | #define KECCAK_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include 6 | 7 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 8 | #define KECCAK_8WAY 1 9 | #elif defined(__AVX2__) 10 | #define KECCAK_4WAY 1 11 | #endif 12 | 13 | extern int hard_coded_eb; 14 | 15 | #if defined(KECCAK_8WAY) 16 | 17 | void keccakhash_8way( void *state, const void *input ); 18 | int scanhash_keccak_8way( struct work *work, uint32_t max_nonce, 19 | uint64_t *hashes_done, struct thr_info *mythr ); 20 | 21 | void sha3d_hash_8way( void *state, const void *input ); 22 | int scanhash_sha3d_8way( struct work *work, uint32_t max_nonce, 23 | uint64_t *hashes_done, struct thr_info *mythr ); 24 | 25 | #elif defined(KECCAK_4WAY) 26 | 27 | void keccakhash_4way( void *state, const void *input ); 28 | int scanhash_keccak_4way( struct work *work, uint32_t max_nonce, 29 | uint64_t *hashes_done, struct thr_info *mythr ); 30 | 31 | void sha3d_hash_4way( void *state, const void *input ); 32 | int scanhash_sha3d_4way( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | 35 | #else 36 | 37 | void keccakhash( void *state, const void *input ); 38 | int scanhash_keccak( struct work *work, uint32_t max_nonce, 39 | uint64_t *hashes_done, struct thr_info *mythr ); 40 | 41 | void sha3d_hash( void *state, const void *input ); 42 | int scanhash_sha3d( struct work *work, uint32_t max_nonce, 43 | uint64_t *hashes_done, struct thr_info *mythr ); 44 | 45 | #endif 46 | #endif 47 | -------------------------------------------------------------------------------- /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 | #ifdef __AES__ 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 | HashReturn echo_full( hashState_echo *state, BitSequence *hashval, 59 | int nHashSize, const BitSequence *data, DataLength databitlen ); 60 | 61 | #endif // HASH_API_H 62 | 63 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /algo/skein/skein.c: -------------------------------------------------------------------------------- 1 | #include "algo-gate-api.h" 2 | 3 | #if !defined(SKEIN_8WAY) && !defined(SKEIN_4WAY) 4 | 5 | #include 6 | #include 7 | #include "sph_skein.h" 8 | #include 9 | 10 | void skeinhash(void *state, const void *input) 11 | { 12 | uint32_t hash[16] __attribute__ ((aligned (64))); 13 | sph_skein512_context ctx_skein; 14 | SHA256_CTX ctx_sha256; 15 | 16 | sph_skein512_init( &ctx_skein ); 17 | sph_skein512( &ctx_skein, input, 80 ); 18 | sph_skein512_close( &ctx_skein, hash ); 19 | 20 | SHA256_Init( &ctx_sha256 ); 21 | SHA256_Update( &ctx_sha256, (unsigned char*)hash, 64 ); 22 | SHA256_Final( (unsigned char*) hash, &ctx_sha256 ); 23 | 24 | memcpy(state, hash, 32); 25 | } 26 | 27 | int scanhash_skein( struct work *work, uint32_t max_nonce, 28 | uint64_t *hashes_done, struct thr_info *mythr ) 29 | { 30 | uint32_t *pdata = work->data; 31 | uint32_t *ptarget = work->target; 32 | uint32_t hash64[8] __attribute__ ((aligned (64))); 33 | uint32_t endiandata[20] __attribute__ ((aligned (64))); 34 | const uint32_t Htarg = ptarget[7]; 35 | const uint32_t first_nonce = pdata[19]; 36 | uint32_t n = first_nonce; 37 | int thr_id = mythr->id; // thr_id arg is deprecated 38 | 39 | swab32_array( endiandata, pdata, 20 ); 40 | 41 | do { 42 | be32enc(&endiandata[19], n); 43 | skeinhash(hash64, endiandata); 44 | if (hash64[7] < Htarg && fulltest(hash64, ptarget)) { 45 | *hashes_done = n - first_nonce + 1; 46 | pdata[19] = n; 47 | return true; 48 | } 49 | n++; 50 | 51 | } while (n < max_nonce && !work_restart[thr_id].restart); 52 | 53 | *hashes_done = n - first_nonce + 1; 54 | pdata[19] = n; 55 | 56 | return 0; 57 | } 58 | #endif 59 | -------------------------------------------------------------------------------- /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_update( ripemd160_4way_context *sc, const void *data, 20 | size_t len ); 21 | void ripemd160_4way_close( ripemd160_4way_context *sc, void *dst ); 22 | 23 | #if defined (__AVX2__) 24 | 25 | typedef struct 26 | { 27 | __m256i buf[64>>2]; 28 | __m256i val[5]; 29 | uint32_t count_high, count_low; 30 | } __attribute__ ((aligned (128))) ripemd160_8way_context; 31 | 32 | void ripemd160_8way_init( ripemd160_8way_context *sc ); 33 | void ripemd160_8way_update( ripemd160_8way_context *sc, const void *data, 34 | size_t len ); 35 | void ripemd160_8way_close( ripemd160_8way_context *sc, void *dst ); 36 | 37 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 38 | 39 | typedef struct 40 | { 41 | __m512i buf[64>>2]; 42 | __m512i val[5]; 43 | uint32_t count_high, count_low; 44 | } __attribute__ ((aligned (128))) ripemd160_16way_context; 45 | 46 | void ripemd160_16way_init( ripemd160_16way_context *sc ); 47 | void ripemd160_16way_update( ripemd160_16way_context *sc, const void *data, 48 | size_t len ); 49 | void ripemd160_16way_close( ripemd160_16way_context *sc, void *dst ); 50 | 51 | #endif // AVX512 52 | #endif // __AVX2__ 53 | #endif // __SSE4_2__ 54 | #endif // RIPEMD_HASH_4WAY_H__ 55 | -------------------------------------------------------------------------------- /algo/x16/x16rt.c: -------------------------------------------------------------------------------- 1 | #include "x16r-gate.h" 2 | 3 | #if !defined(X16R_8WAY) && !defined(X16R_4WAY) 4 | 5 | int scanhash_x16rt( struct work *work, uint32_t max_nonce, 6 | uint64_t *hashes_done, struct thr_info *mythr ) 7 | { 8 | uint32_t _ALIGN(128) hash32[8]; 9 | uint32_t _ALIGN(128) edata[20]; 10 | uint32_t _ALIGN(64) timeHash[8]; 11 | uint32_t *pdata = work->data; 12 | uint32_t *ptarget = work->target; 13 | const uint32_t first_nonce = pdata[19]; 14 | const int thr_id = mythr->id; 15 | uint32_t nonce = first_nonce; 16 | volatile uint8_t *restart = &(work_restart[thr_id].restart); 17 | const bool bench = opt_benchmark; 18 | if ( bench ) ptarget[7] = 0x0cff; 19 | 20 | mm128_bswap32_80( edata, pdata ); 21 | 22 | static __thread uint32_t s_ntime = UINT32_MAX; 23 | uint32_t ntime = swab32( pdata[17] ); 24 | if ( s_ntime != ntime ) 25 | { 26 | x16rt_getTimeHash( ntime, &timeHash ); 27 | x16rt_getAlgoString( &timeHash[0], x16r_hash_order ); 28 | s_ntime = ntime; 29 | if ( opt_debug && !thr_id ) 30 | applog( LOG_INFO, "hash order: %s time: (%08x) time hash: (%08x)", 31 | x16r_hash_order, ntime, timeHash ); 32 | } 33 | 34 | x16r_prehash( edata, pdata ); 35 | 36 | do 37 | { 38 | edata[19] = nonce; 39 | x16r_hash( hash32, edata ); 40 | 41 | if ( valid_hash( hash32, ptarget ) && !bench ) 42 | { 43 | pdata[19] = bswap_32( nonce ); 44 | submit_solution( work, hash32, mythr ); 45 | } 46 | nonce++; 47 | } while ( nonce < max_nonce && !(*restart) ); 48 | pdata[19] = nonce; 49 | *hashes_done = pdata[19] - first_nonce + 1; 50 | return 0; 51 | } 52 | 53 | #endif // !defined(X16R_8WAY) && !defined(X16R_4WAY) 54 | 55 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/x22/x22i-gate.c: -------------------------------------------------------------------------------- 1 | #include "x22i-gate.h" 2 | 3 | // Ryzen has poor AVX2 performance so use SHA over AVX2. 4 | // Intel has AVX512 so use AVX512 over SHA. 5 | // When Ryzen AVX2 improves use AVX2 over SHA. 6 | 7 | bool register_x22i_algo( algo_gate_t* gate ) 8 | { 9 | #if defined (X22I_8WAY) 10 | gate->scanhash = (void*)&scanhash_x22i_8way; 11 | gate->hash = (void*)&x22i_8way_hash; 12 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT 13 | | AVX512_OPT | VAES_OPT; 14 | #elif defined (X22I_4WAY) 15 | gate->scanhash = (void*)&scanhash_x22i_4way; 16 | gate->hash = (void*)&x22i_4way_hash; 17 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | SHA_OPT 18 | | AVX512_OPT | VAES_OPT; 19 | #else 20 | gate->scanhash = (void*)&scanhash_x22i; 21 | gate->hash = (void*)&x22i_hash; 22 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | SHA_OPT 23 | | AVX512_OPT | VAES_OPT; 24 | #endif 25 | return true; 26 | }; 27 | 28 | bool register_x25x_algo( algo_gate_t* gate ) 29 | { 30 | #if defined (X25X_8WAY) 31 | gate->scanhash = (void*)&scanhash_x25x_8way; 32 | gate->hash = (void*)&x25x_8way_hash; 33 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT 34 | | AVX512_OPT | VAES_OPT; 35 | #elif defined (X25X_4WAY) 36 | gate->scanhash = (void*)&scanhash_x25x_4way; 37 | gate->hash = (void*)&x25x_4way_hash; 38 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | SHA_OPT 39 | | AVX512_OPT | VAES_OPT; 40 | #else 41 | gate->scanhash = (void*)&scanhash_x25x; 42 | gate->hash = (void*)&x25x_hash; 43 | gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | SHA_OPT 44 | | AVX512_OPT | VAES_OPT; 45 | #endif 46 | // gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | SHA_OPT; 47 | 48 | return true; 49 | }; 50 | 51 | -------------------------------------------------------------------------------- /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 | 11 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 12 | 13 | typedef struct { 14 | uint32_t A[ 32*4 ]; 15 | uint8_t buffer[ 128*4 ]; 16 | uint64_t count; 17 | unsigned int hashbitlen; 18 | unsigned int blocksize; 19 | unsigned int n_feistels; 20 | 21 | } simd_4way_context __attribute__((aligned(128))); 22 | 23 | int simd_4way_init( simd_4way_context *state, int hashbitlen ); 24 | int simd_4way_update( simd_4way_context *state, const void *data, 25 | int databitlen ); 26 | int simd_4way_close( simd_4way_context *state, void *hashval ); 27 | int simd_4way_update_close( simd_4way_context *state, void *hashval, 28 | const void *data, int databitlen ); 29 | int simd512_4way_full( simd_4way_context *state, void *hashval, 30 | const void *data, int datalen ); 31 | 32 | #endif 33 | 34 | typedef struct { 35 | uint32_t A[ 32*2 ]; 36 | uint8_t buffer[ 128*2 ]; 37 | uint64_t count; 38 | unsigned int hashbitlen; 39 | unsigned int blocksize; 40 | unsigned int n_feistels; 41 | 42 | } simd_2way_context __attribute__((aligned(128))); 43 | 44 | int simd_2way_init( simd_2way_context *state, int hashbitlen ); 45 | int simd_2way_update( simd_2way_context *state, const void *data, 46 | int databitlen ); 47 | int simd_2way_close( simd_2way_context *state, void *hashval ); 48 | int simd_2way_update_close( simd_2way_context *state, void *hashval, 49 | const void *data, int databitlen ); 50 | int simd512_2way_full( simd_2way_context *state, void *hashval, 51 | const void *data, int datalen ); 52 | 53 | #endif 54 | #endif 55 | -------------------------------------------------------------------------------- /algo/lanehash/lane.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Sebastiaan Indesteege 3 | * 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | /* 19 | * Optimised ANSI-C implementation of LANE 20 | */ 21 | 22 | #ifndef LANE_H 23 | #define LANE_H 24 | 25 | #include 26 | //#include "algo/sha/sha3-defs.h" 27 | #include 28 | 29 | typedef unsigned char BitSequence; 30 | typedef unsigned long long DataLength; 31 | 32 | //typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHBITLEN = 2, BAD_DATABITLEN = 3 } HashReturn; 33 | 34 | //typedef unsigned char u8; 35 | //typedef unsigned int u32; 36 | //typedef unsigned long long u64; 37 | 38 | typedef struct { 39 | int hashbitlen; 40 | uint64_t ctr; 41 | uint32_t h[16]; 42 | uint8_t buffer[128]; 43 | } hashState; 44 | 45 | void laneInit (hashState *state, int hashbitlen); 46 | void laneUpdate (hashState *state, const BitSequence *data, DataLength databitlen); 47 | void laneFinal (hashState *state, BitSequence *hashval); 48 | void laneHash (int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval); 49 | 50 | #endif /* LANE_H */ 51 | -------------------------------------------------------------------------------- /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 1 9 | #endif 10 | 11 | bool register_x13sm3_algo( algo_gate_t* gate ); 12 | 13 | #if defined(X13SM3_4WAY) 14 | 15 | void x13sm3_4way_hash( void *state, const void *input ); 16 | int scanhash_x13sm3_4way( struct work *work, uint32_t max_nonce, 17 | uint64_t *hashes_done, struct thr_info *mythr ); 18 | void init_x13sm3_4way_ctx(); 19 | 20 | #else 21 | 22 | void x13sm3_hash( void *state, const void *input ); 23 | int scanhash_x13sm3( struct work *work, uint32_t max_nonce, 24 | uint64_t *hashes_done, struct thr_info *mythr ); 25 | void init_x13sm3_ctx(); 26 | 27 | #endif 28 | 29 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 30 | #define X13BCD_8WAY 1 31 | #elif defined(__AVX2__) && defined(__AES__) 32 | #define X13BCD_4WAY 1 33 | #endif 34 | 35 | bool register_x13bcd_algo( algo_gate_t* gate ); 36 | 37 | #if defined(X13BCD_8WAY) 38 | 39 | void x13bcd_8way_hash( void *state, const void *input ); 40 | int scanhash_x13bcd_8way( struct work *work, uint32_t max_nonce, 41 | uint64_t *hashes_done, struct thr_info *mythr ); 42 | void init_x13bcd_8way_ctx(); 43 | 44 | #elif defined(X13BCD_4WAY) 45 | 46 | void x13bcd_4way_hash( void *state, const void *input ); 47 | int scanhash_x13bcd_4way( struct work *work, uint32_t max_nonce, 48 | uint64_t *hashes_done, struct thr_info *mythr ); 49 | void init_x13bcd_4way_ctx(); 50 | 51 | #else 52 | 53 | void x13bcd_hash( void *state, const void *input ); 54 | int scanhash_x13bcd( struct work *work, uint32_t max_nonce, 55 | uint64_t *hashes_done, struct thr_info *mythr ); 56 | void init_x13bcd_ctx(); 57 | 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /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/skein/skein2.c: -------------------------------------------------------------------------------- 1 | #include "skein-gate.h" 2 | 3 | #if !defined(SKEIN_8WAY) && !defined(SKEIN_4WAY) 4 | 5 | #include 6 | #include 7 | 8 | #include "sph_skein.h" 9 | 10 | // ctx caching seems slower with this algo 11 | //typedef struct { 12 | // sph_skein512_context skein; 13 | //} skein2_ctx_holder; 14 | 15 | //skein2_ctx_holder skein2_ctx; 16 | 17 | //void init_skein2_ctx() 18 | //{ 19 | // sph_skein512_init(&skein2_ctx.skein); 20 | //} 21 | 22 | void skein2hash(void *output, const void *input) 23 | { 24 | sph_skein512_context ctx_skein; 25 | 26 | uint32_t hash[16] __attribute__ ((aligned (64))); 27 | 28 | sph_skein512_init(&ctx_skein); 29 | sph_skein512(&ctx_skein, input, 80); 30 | sph_skein512_close(&ctx_skein, hash); 31 | 32 | sph_skein512_init(&ctx_skein); 33 | sph_skein512(&ctx_skein, hash, 64); 34 | sph_skein512_close(&ctx_skein, hash); 35 | 36 | memcpy(output, hash, 32); 37 | 38 | } 39 | 40 | int scanhash_skein2( struct work *work, uint32_t max_nonce, 41 | uint64_t *hashes_done, struct thr_info *mythr ) 42 | { 43 | uint32_t *pdata = work->data; 44 | uint32_t *ptarget = work->target; 45 | uint32_t hash64[8] __attribute__ ((aligned (64))); 46 | uint32_t endiandata[20] __attribute__ ((aligned (64))); 47 | const uint32_t Htarg = ptarget[7]; 48 | const uint32_t first_nonce = pdata[19]; 49 | uint32_t n = first_nonce; 50 | int thr_id = mythr->id; // thr_id arg is deprecated 51 | 52 | swab32_array( endiandata, pdata, 20 ); 53 | 54 | do { 55 | be32enc(&endiandata[19], n); 56 | skein2hash(hash64, endiandata); 57 | if (hash64[7] < Htarg && fulltest(hash64, ptarget)) { 58 | *hashes_done = n - first_nonce + 1; 59 | pdata[19] = n; 60 | return true; 61 | } 62 | n++; 63 | 64 | } while (n < max_nonce && !work_restart[thr_id].restart); 65 | 66 | *hashes_done = n - first_nonce + 1; 67 | pdata[19] = n; 68 | 69 | return 0; 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /algo/m7m/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/swifftx/stdbool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Jeroen Ruigrok van der Werven 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | * 26 | * $FreeBSD: src/include/stdbool.h,v 1.6 2002/08/16 07:33:14 alfred Exp $ 27 | */ 28 | 29 | #ifndef _STDBOOL_H_ 30 | #define _STDBOOL_H_ 31 | 32 | #define __bool_true_false_are_defined 1 33 | 34 | #ifndef __cplusplus 35 | 36 | #define false 0 37 | #define true 1 38 | 39 | //#define bool _Bool 40 | //#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 41 | //typedef int _Bool; 42 | //#endif 43 | typedef int bool; 44 | 45 | #endif /* !__cplusplus */ 46 | 47 | #endif /* !_STDBOOL_H_ */ 48 | -------------------------------------------------------------------------------- /algo/swifftx/stdint.h: -------------------------------------------------------------------------------- 1 | #ifndef _SWIFFT_STDINT_H 2 | #define _SWIFFT_STDINT_H 3 | 4 | /////////////////////////////////////////////////////////////////////////////////////////////// 5 | // 6 | // A note from SWIFFTX implementers: 7 | // 8 | // Although the submission was targeted for Microsoft Visual Studio 2005 compiler, we strived 9 | // to make the code as portable as possible. This is why we preferred to use the types defined 10 | // here, instead of Microsoft-specific types. We compiled the code with gcc to make this sure. 11 | // However, we couldn't use this header as is, due to VS2005 compiler objections. This is why 12 | // we commented out certain defines and clearly marked it. 13 | // To compile our code on gcc you may define SYS_STDINT. 14 | // 15 | /////////////////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #ifdef SYS_STDINT 18 | 19 | #include 20 | 21 | #else 22 | 23 | #include "inttypes.h" 24 | // The following was commented out by SWIFFTX implementers: 25 | // __BEGIN_DECLS 26 | 27 | typedef swift_int8_t swifftx_int_least8_t; 28 | typedef swift_int16_t swifftx_int_least16_t; 29 | typedef swift_int32_t swifftx_int_least32_t; 30 | typedef swift_uint8_t swifftx_uint_least8_t; 31 | typedef swift_uint16_t swifftx_uint_least16_t; 32 | typedef swift_uint32_t swifftx_uint_least32_t; 33 | 34 | #ifndef __STRICT_ANSI__ 35 | typedef swift_int64_t swifftx_int_least64_t; 36 | typedef swift_uint64_t swifftx_uint_least64_t; 37 | #endif 38 | 39 | /*typedef signed char int_fast8_t; 40 | typedef signed long int int_fast16_t; 41 | typedef signed long int int_fast32_t; 42 | typedef signed long long int int_fast64_t; 43 | 44 | typedef unsigned char uint_fast8_t; 45 | typedef unsigned long int uint_fast16_t; 46 | typedef unsigned long int uint_fast32_t; 47 | typedef unsigned long long int uint_fast64_t;*/ 48 | 49 | // The following was commented out by SWIFFTX implementers: 50 | // #include 51 | // __END_DECLS 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /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 | submit_solution( work, vhash, mythr ); 52 | 53 | } while ( n < max_nonce && !work_restart[thr_id].restart); 54 | 55 | *hashes_done = n - first_nonce + 1; 56 | pdata[19] = n; 57 | return 0; 58 | } 59 | 60 | bool register_whirlpoolx_algo( algo_gate_t* gate ) 61 | { 62 | algo_not_tested(); 63 | gate->scanhash = (void*)&scanhash_whirlpoolx; 64 | gate->hash = (void*)&whirlpoolx_hash; 65 | return true; 66 | }; 67 | 68 | -------------------------------------------------------------------------------- /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/groestl/groestl512-hash-4way.h: -------------------------------------------------------------------------------- 1 | #if !defined(GROESTL512_HASH_4WAY_H__) 2 | #define GROESTL512_HASH_4WAY_H__ 1 3 | 4 | #include "simd-utils.h" 5 | #include 6 | #include 7 | #include 8 | #if defined(_WIN64) || defined(__WINDOWS__) 9 | #include 10 | #endif 11 | #include 12 | 13 | #if defined(__VAES__) && defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 14 | 15 | #define LENGTH (512) 16 | 17 | /* some sizes (number of bytes) */ 18 | #define ROWS (8) 19 | #define LENGTHFIELDLEN (ROWS) 20 | //#define COLS512 (8) 21 | #define COLS1024 (16) 22 | //#define SIZE512 ((ROWS)*(COLS512)) 23 | #define SIZE_1024 ((ROWS)*(COLS1024)) 24 | //#define ROUNDS512 (10) 25 | #define ROUNDS1024 (14) 26 | 27 | //#if LENGTH<=256 28 | //#define COLS (COLS512) 29 | //#define SIZE (SIZE512) 30 | //#define ROUNDS (ROUNDS512) 31 | //#else 32 | #define COLS (COLS1024) 33 | //#define SIZE (SIZE1024) 34 | #define ROUNDS (ROUNDS1024) 35 | //#endif 36 | 37 | #define SIZE512 (SIZE_1024/16) 38 | 39 | typedef struct { 40 | __attribute__ ((aligned (128))) __m512i chaining[SIZE512]; 41 | __attribute__ ((aligned (64))) __m512i buffer[SIZE512]; 42 | int blk_count; // SIZE_m128i 43 | int buf_ptr; // __m128i offset 44 | int rem_ptr; 45 | int databitlen; // bits 46 | } groestl512_4way_context; 47 | 48 | 49 | int groestl512_4way_init( groestl512_4way_context*, uint64_t ); 50 | 51 | //int reinit_groestl( hashState_groestl* ); 52 | 53 | int groestl512_4way_update( groestl512_4way_context*, const void*, 54 | uint64_t ); 55 | int groestl512_4way_close( groestl512_4way_context*, void* ); 56 | int groestl512_4way_update_close( groestl512_4way_context*, void*, 57 | const void*, uint64_t ); 58 | int groestl512_4way_full( groestl512_4way_context*, void*, 59 | const void*, uint64_t ); 60 | 61 | #endif // VAES 62 | #endif // GROESTL512_HASH_4WAY_H__ 63 | -------------------------------------------------------------------------------- /algo/cubehash/cube-hash-2way.h: -------------------------------------------------------------------------------- 1 | #ifndef CUBE_HASH_2WAY_H__ 2 | #define CUBE_HASH_2WAY_H__ 1 3 | 4 | #include 5 | #include "simd-utils.h" 6 | 7 | #if defined(__AVX2__) 8 | 9 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 10 | 11 | struct _cube_4way_context 12 | { 13 | __m512i h[8]; 14 | int hashlen; 15 | int rounds; 16 | int blocksize; 17 | int pos; 18 | } __attribute__ ((aligned (128))); 19 | 20 | typedef struct _cube_4way_context cube_4way_context; 21 | 22 | int cube_4way_init( cube_4way_context* sp, int hashbitlen, int rounds, 23 | int blockbytes ); 24 | int cube_4way_update( cube_4way_context *sp, const void *data, size_t size ); 25 | int cube_4way_close( cube_4way_context *sp, void *output ); 26 | int cube_4way_update_close( cube_4way_context *sp, void *output, 27 | const void *data, size_t size ); 28 | int cube_4way_full( cube_4way_context *sp, void *output, int hashbitlen, 29 | const void *data, size_t size ); 30 | 31 | #endif 32 | 33 | // 2x128, 2 way parallel SSE2 34 | 35 | struct _cube_2way_context 36 | { 37 | __m256i h[8]; 38 | int hashlen; // __m128i 39 | int rounds; 40 | int blocksize; // __m128i 41 | int pos; // number of __m128i read into x from current block 42 | } __attribute__ ((aligned (128))); 43 | 44 | typedef struct _cube_2way_context cube_2way_context; 45 | 46 | int cube_2way_init( cube_2way_context* sp, int hashbitlen, int rounds, 47 | int blockbytes ); 48 | int cube_2way_update( cube_2way_context *sp, const void *data, size_t size ); 49 | int cube_2way_close( cube_2way_context *sp, void *output ); 50 | int cube_2way_update_close( cube_2way_context *sp, void *output, 51 | const void *data, size_t size ); 52 | int cube_2way_full( cube_2way_context *sp, void *output, int hashbitlen, 53 | const void *data, size_t size ); 54 | 55 | 56 | #endif 57 | #endif 58 | -------------------------------------------------------------------------------- /algo/yespower/yescrypt-r8g.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2009 Colin Percival 3 | * Copyright 2013-2018 Alexander Peslyak 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | * 27 | * This file was originally written by Colin Percival as part of the Tarsnap 28 | * online backup system. 29 | */ 30 | #ifndef _YESPOWERR8G_H_ 31 | #define _YESPOWERR8G_H_ 32 | 33 | #include 34 | #include /* for size_t */ 35 | #include "algo-gate-api.h" 36 | #include "algo/yespower/yespower.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | extern int yespowerr8g_tls(const uint8_t *src, size_t srclen, 43 | const yespower_params_t *params, yespower_binary_t *dst); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* !_YESPOWERR8G_H_ */ 50 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /algo/groestl/groestl-4way.c: -------------------------------------------------------------------------------- 1 | #include "groestl-gate.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #if defined(GROESTL_4WAY_VAES) 8 | 9 | #include "groestl512-hash-4way.h" 10 | 11 | void groestl_4way_hash( void *output, const void *input ) 12 | { 13 | uint32_t hash[16*4] __attribute__ ((aligned (128))); 14 | groestl512_4way_context ctx; 15 | 16 | groestl512_4way_init( &ctx, 64 ); 17 | groestl512_4way_update_close( &ctx, hash, input, 640 ); 18 | 19 | groestl512_4way_init( &ctx, 64 ); 20 | groestl512_4way_update_close( &ctx, hash, hash, 512 ); 21 | 22 | dintrlv_4x128( output, output+32, output+64, output+96, hash, 256 ); 23 | } 24 | 25 | int scanhash_groestl_4way( struct work *work, uint32_t max_nonce, 26 | uint64_t *hashes_done, struct thr_info *mythr ) 27 | { 28 | uint32_t hash[8*4] __attribute__ ((aligned (128))); 29 | uint32_t vdata[24*4] __attribute__ ((aligned (64))); 30 | uint32_t *pdata = work->data; 31 | uint32_t *ptarget = work->target; 32 | uint32_t n = pdata[19]; 33 | const uint32_t first_nonce = pdata[19]; 34 | const uint32_t last_nonce = max_nonce - 4; 35 | uint32_t *noncep = vdata + 64+3; // 4*16 + 3 36 | int thr_id = mythr->id; 37 | const uint32_t Htarg = ptarget[7]; 38 | 39 | mm512_bswap32_intrlv80_4x128( vdata, pdata ); 40 | 41 | do 42 | { 43 | be32enc( noncep, n ); 44 | be32enc( noncep+ 4, n+1 ); 45 | be32enc( noncep+ 8, n+2 ); 46 | be32enc( noncep+12, n+3 ); 47 | 48 | groestl_4way_hash( hash, vdata ); 49 | pdata[19] = n; 50 | 51 | for ( int lane = 0; lane < 4; lane++ ) 52 | if ( ( hash+(lane<<3) )[7] <= Htarg ) 53 | if ( fulltest( hash+(lane<<3), ptarget) && !opt_benchmark ) 54 | { 55 | pdata[19] = n + lane; 56 | submit_lane_solution( work, hash+(lane<<3), mythr, lane ); 57 | } 58 | n += 4; 59 | } while ( ( n < last_nonce ) && !work_restart[thr_id].restart ); 60 | *hashes_done = n - first_nonce; 61 | return 0; 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /algo/x22/x22i-gate.h: -------------------------------------------------------------------------------- 1 | #ifndef X22I_GATE_H__ 2 | #define X22I_GATE_H__ 1 3 | 4 | #include "algo-gate-api.h" 5 | #include "simd-utils.h" 6 | #include 7 | #include 8 | 9 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 10 | #define X22I_8WAY 1 11 | #elif defined(__AVX2__) && defined(__AES__) 12 | #define X22I_4WAY 1 13 | #endif 14 | 15 | bool register_x22i_algo( algo_gate_t* gate ); 16 | 17 | #if defined(X22I_8WAY) 18 | 19 | void x22i_8way_hash( void *state, const void *input ); 20 | int scanhash_x22i_8way( struct work *work, uint32_t max_nonce, 21 | uint64_t *hashes_done, struct thr_info *mythr ); 22 | 23 | #elif defined(X22I_4WAY) 24 | 25 | void x22i_4way_hash( void *state, const void *input ); 26 | int scanhash_x22i_4way( struct work *work, uint32_t max_nonce, 27 | uint64_t *hashes_done, struct thr_info *mythr ); 28 | 29 | #else 30 | 31 | void x22i_hash( void *state, const void *input ); 32 | int scanhash_x22i( struct work *work, uint32_t max_nonce, 33 | uint64_t *hashes_done, struct thr_info *mythr ); 34 | 35 | #endif 36 | 37 | #if defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 38 | #define X25X_8WAY 1 39 | #elif defined(__AVX2__) && defined(__AES__) 40 | #define X25X_4WAY 1 41 | #endif 42 | 43 | bool register_x25i_algo( algo_gate_t* gate ); 44 | 45 | #if defined(X25X_8WAY) 46 | 47 | void x25x_8way_hash( void *state, const void *input ); 48 | int scanhash_x25x_8way( struct work *work, uint32_t max_nonce, 49 | uint64_t *hashes_done, struct thr_info *mythr ); 50 | 51 | #elif defined(X25X_4WAY) 52 | 53 | void x25x_4way_hash( void *state, const void *input ); 54 | int scanhash_x25x_4way( struct work *work, uint32_t max_nonce, 55 | uint64_t *hashes_done, struct thr_info *mythr ); 56 | 57 | #else 58 | 59 | void x25x_hash( void *state, const void *input ); 60 | int scanhash_x25x( struct work *work, uint32_t max_nonce, 61 | uint64_t *hashes_done, struct thr_info *mythr ); 62 | 63 | #endif 64 | 65 | #endif // X22I_GATE_H__ 66 | -------------------------------------------------------------------------------- /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. Budget CPUs like Pentium and Celeron are often missing the 19 | latest 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 | More information for Intel and AMD CPU architectures and their features 27 | can be found on Wikipedia. 28 | 29 | https://en.wikipedia.org/wiki/List_of_Intel_CPU_microarchitectures 30 | 31 | https://en.wikipedia.org/wiki/List_of_AMD_CPU_microarchitectures 32 | 33 | 34 | Exe name Compile flags Arch name 35 | 36 | cpuminer-sse2.exe "-msse2" Core2, Nehalem 37 | cpuminer-aes-sse42.exe "-march=westmere" Westmere 38 | cpuminer-avx.exe "-march=corei7-avx" Sandybridge 39 | cpuminer-avx2.exe "-march=core-avx2 -maes" Haswell, Skylake, Coffeelake 40 | cpuminer-avx512.exe "-march=skylake-avx512" Skylake-X, Cascadelake-X 41 | cpuminer-zen "-march=znver1" AMD Ryzen, Threadripper 42 | 43 | If you like this software feel free to donate: 44 | 45 | BTC: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT 46 | 47 | 48 | -------------------------------------------------------------------------------- /algo/blake/blake2s.c: -------------------------------------------------------------------------------- 1 | #include "blake2s-gate.h" 2 | 3 | #if !defined(BLAKE2S_16WAY) && !defined(BLAKE2S_8WAY) && !defined(BLAKE2S) 4 | 5 | #include 6 | #include 7 | 8 | #include "sph-blake2s.h" 9 | 10 | static __thread blake2s_state blake2s_ctx; 11 | //static __thread blake2s_state s_ctx; 12 | #define MIDLEN 76 13 | 14 | void blake2s_hash( void *output, const void *input ) 15 | { 16 | unsigned char _ALIGN(64) hash[BLAKE2S_OUTBYTES]; 17 | blake2s_state ctx __attribute__ ((aligned (64))); 18 | 19 | memcpy( &ctx, &blake2s_ctx, sizeof ctx ); 20 | blake2s_update( &ctx, input+64, 16 ); 21 | 22 | // blake2s_init(&ctx, BLAKE2S_OUTBYTES); 23 | // blake2s_update(&ctx, input, 80); 24 | blake2s_final( &ctx, hash, BLAKE2S_OUTBYTES ); 25 | 26 | memcpy(output, hash, 32); 27 | } 28 | /* 29 | static void blake2s_hash_end(uint32_t *output, const uint32_t *input) 30 | { 31 | s_ctx.buflen = MIDLEN; 32 | memcpy(&s_ctx, &s_midstate, 32 + 16 + MIDLEN); 33 | blake2s_update(&s_ctx, (uint8_t*) &input[MIDLEN/4], 80 - MIDLEN); 34 | blake2s_final(&s_ctx, (uint8_t*) output, BLAKE2S_OUTBYTES); 35 | } 36 | */ 37 | int scanhash_blake2s( struct work *work, 38 | uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ) 39 | { 40 | uint32_t *pdata = work->data; 41 | uint32_t *ptarget = work->target; 42 | 43 | uint32_t _ALIGN(64) hash64[8]; 44 | uint32_t _ALIGN(64) endiandata[20]; 45 | int thr_id = mythr->id; // thr_id arg is deprecated 46 | 47 | const uint32_t Htarg = ptarget[7]; 48 | const uint32_t first_nonce = pdata[19]; 49 | 50 | uint32_t n = first_nonce; 51 | 52 | swab32_array( endiandata, pdata, 20 ); 53 | 54 | // midstate 55 | blake2s_init( &blake2s_ctx, BLAKE2S_OUTBYTES ); 56 | blake2s_update( &blake2s_ctx, (uint8_t*) endiandata, 64 ); 57 | 58 | do { 59 | be32enc(&endiandata[19], n); 60 | blake2s_hash( hash64, endiandata ); 61 | if (hash64[7] <= Htarg && fulltest(hash64, ptarget)) { 62 | *hashes_done = n - first_nonce + 1; 63 | pdata[19] = n; 64 | return true; 65 | } 66 | n++; 67 | 68 | } while (n < max_nonce && !work_restart[thr_id].restart); 69 | 70 | *hashes_done = n - first_nonce + 1; 71 | pdata[19] = n; 72 | 73 | return 0; 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /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/lyra2/lyra2h.c: -------------------------------------------------------------------------------- 1 | #include "lyra2-gate.h" 2 | 3 | #if !( defined(LYRA2H_8WAY) || defined(LYRA2H_4WAY) ) 4 | 5 | #include 6 | #include 7 | #include "lyra2.h" 8 | #include "algo/blake/sph_blake.h" 9 | 10 | __thread uint64_t* lyra2h_matrix; 11 | 12 | bool lyra2h_thread_init() 13 | { 14 | lyra2h_matrix = _mm_malloc( LYRA2H_MATRIX_SIZE, 64 ); 15 | return lyra2h_matrix; 16 | } 17 | 18 | static __thread sph_blake256_context lyra2h_blake_mid; 19 | 20 | void lyra2h_midstate( const void* input ) 21 | { 22 | sph_blake256_init( &lyra2h_blake_mid ); 23 | sph_blake256( &lyra2h_blake_mid, input, 64 ); 24 | } 25 | 26 | void lyra2h_hash( void *state, const void *input ) 27 | { 28 | uint32_t _ALIGN(64) hash[16]; 29 | 30 | sph_blake256_context ctx_blake __attribute__ ((aligned (64))); 31 | 32 | memcpy( &ctx_blake, &lyra2h_blake_mid, sizeof lyra2h_blake_mid ); 33 | sph_blake256( &ctx_blake, input + 64, 16 ); 34 | sph_blake256_close( &ctx_blake, hash ); 35 | 36 | LYRA2Z( lyra2h_matrix, hash, 32, hash, 32, hash, 32, 16, 16, 16 ); 37 | 38 | memcpy(state, hash, 32); 39 | } 40 | 41 | int scanhash_lyra2h( struct work *work, uint32_t max_nonce, 42 | uint64_t *hashes_done, struct thr_info *mythr ) 43 | { 44 | uint32_t _ALIGN(64) hash[8]; 45 | uint32_t _ALIGN(64) endiandata[20]; 46 | uint32_t *pdata = work->data; 47 | uint32_t *ptarget = work->target; 48 | const uint32_t Htarg = ptarget[7]; 49 | const uint32_t first_nonce = pdata[19]; 50 | uint32_t nonce = first_nonce; 51 | int thr_id = mythr->id; // thr_id arg is deprecated 52 | 53 | if (opt_benchmark) 54 | ptarget[7] = 0x0000ff; 55 | 56 | for (int i=0; i < 19; i++) { 57 | be32enc(&endiandata[i], pdata[i]); 58 | } 59 | 60 | lyra2h_midstate( endiandata ); 61 | do { 62 | be32enc(&endiandata[19], nonce); 63 | lyra2h_hash( hash, endiandata ); 64 | 65 | if ( hash[7] <= Htarg ) 66 | if ( fulltest( hash, ptarget ) && !opt_benchmark ) 67 | { 68 | pdata[19] = nonce; 69 | submit_solution( work, hash, mythr ); 70 | } 71 | nonce++; 72 | } while (nonce < max_nonce && !work_restart[thr_id].restart); 73 | pdata[19] = nonce; 74 | *hashes_done = pdata[19] - first_nonce + 1; 75 | return 0; 76 | } 77 | #endif 78 | -------------------------------------------------------------------------------- /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 | { 68 | pdata[19] = n; 69 | submit_solution( work, hash64, mythr ); 70 | } 71 | n++; 72 | 73 | } while (n < max_nonce && !work_restart[thr_id].restart); 74 | 75 | *hashes_done = n - first_nonce + 1; 76 | pdata[19] = n; 77 | 78 | return 0; 79 | } 80 | 81 | bool register_axiom_algo( algo_gate_t* gate ) 82 | { 83 | gate->scanhash = (void*)&scanhash_axiom; 84 | gate->hash = (void*)&axiomhash; 85 | return true; 86 | } 87 | -------------------------------------------------------------------------------- /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/groestl/groestl256-hash-4way.h: -------------------------------------------------------------------------------- 1 | /* hash.h Aug 2011 2 | * 3 | * Groestl implementation for different versions. 4 | * Author: Krystian Matusiewicz, Günther A. Roland, Martin Schläffer 5 | * 6 | * This code is placed in the public domain 7 | */ 8 | 9 | #if !defined(GROESTL256_HASH_4WAY_H__) 10 | #define GROESTL256_HASH_4WAY_H__ 1 11 | 12 | #include "simd-utils.h" 13 | #include 14 | #include 15 | #include 16 | #if defined(_WIN64) || defined(__WINDOWS__) 17 | #include 18 | #endif 19 | #include 20 | 21 | #if defined(__VAES__) && defined(__AVX512F__) && defined(__AVX512VL__) && defined(__AVX512DQ__) && defined(__AVX512BW__) 22 | 23 | #define LENGTH (256) 24 | 25 | //#include "brg_endian.h" 26 | //#define NEED_UINT_64T 27 | //#include "algo/sha/brg_types.h" 28 | 29 | /* some sizes (number of bytes) */ 30 | #define ROWS (8) 31 | #define LENGTHFIELDLEN (ROWS) 32 | #define COLS512 (8) 33 | //#define COLS1024 (16) 34 | #define SIZE_512 ((ROWS)*(COLS512)) 35 | //#define SIZE_1024 ((ROWS)*(COLS1024)) 36 | #define ROUNDS512 (10) 37 | //#define ROUNDS1024 (14) 38 | 39 | //#if LENGTH<=256 40 | #define COLS (COLS512) 41 | #define SIZE (SIZE512) 42 | #define ROUNDS (ROUNDS512) 43 | //#else 44 | //#define COLS (COLS1024) 45 | //#define SIZE (SIZE1024) 46 | //#define ROUNDS (ROUNDS1024) 47 | //#endif 48 | 49 | #define SIZE256 (SIZE_512/16) 50 | 51 | typedef struct { 52 | __attribute__ ((aligned (128))) __m512i chaining[SIZE256]; 53 | __attribute__ ((aligned (64))) __m512i buffer[SIZE256]; 54 | int hashlen; // byte 55 | int blk_count; // SIZE_m128i 56 | int buf_ptr; // __m128i offset 57 | int rem_ptr; 58 | int databitlen; // bits 59 | } groestl256_4way_context; 60 | 61 | 62 | int groestl256_4way_init( groestl256_4way_context*, uint64_t ); 63 | 64 | //int reinit_groestl( hashState_groestl* ); 65 | 66 | //int groestl512_4way_update( groestl256_4way_context*, const void*, 67 | // uint64_t ); 68 | 69 | //int groestl512_4way_close( groestl512_4way_context*, void* ); 70 | 71 | int groestl256_4way_update_close( groestl256_4way_context*, void*, 72 | const void*, uint64_t ); 73 | 74 | int groestl256_4way_full( groestl256_4way_context*, void*, 75 | const void*, uint64_t ); 76 | 77 | #endif 78 | #endif 79 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /junk/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 | -------------------------------------------------------------------------------- /algo/argon2/argon2a/argon2a.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "ar2/argon2.h" 7 | #include "ar2/cores.h" 8 | #include "ar2/ar2-scrypt-jane.h" 9 | #include "algo-gate-api.h" 10 | 11 | #define T_COSTS 2 12 | #define M_COSTS 16 13 | #define MASK 8 14 | #define ZERO 0 15 | 16 | inline void argon_call(void *out, void *in, void *salt, int type) 17 | { 18 | argon2_context context; 19 | 20 | context.out = (uint8_t *)out; 21 | context.pwd = (uint8_t *)in; 22 | context.salt = (uint8_t*)salt; 23 | context.pwdlen = 0; 24 | context.allocate_cbk = NULL; 25 | context.free_cbk = NULL; 26 | 27 | ar2_argon2_core(&context, type); 28 | } 29 | 30 | void argon2hash(void *output, const void *input) 31 | { 32 | uint32_t _ALIGN(64) hashA[8], hashB[8]; 33 | 34 | my_scrypt((const unsigned char *)input, 80, 35 | (const unsigned char *)input, 80, 36 | (unsigned char *)hashA); 37 | 38 | argon_call(hashB, hashA, hashA, (hashA[0] & MASK) == ZERO); 39 | 40 | my_scrypt((const unsigned char *)hashB, 32, 41 | (const unsigned char *)hashB, 32, 42 | (unsigned char *)output); 43 | } 44 | 45 | int scanhash_argon2( struct work* work, uint32_t max_nonce, 46 | uint64_t *hashes_done, struct thr_info *mythr ) 47 | { 48 | uint32_t _ALIGN(64) endiandata[20]; 49 | uint32_t _ALIGN(64) hash[8]; 50 | uint32_t *pdata = work->data; 51 | uint32_t *ptarget = work->target; 52 | int thr_id = mythr->id; // thr_id arg is deprecated 53 | 54 | const uint32_t first_nonce = pdata[19]; 55 | const uint32_t Htarg = ptarget[7]; 56 | uint32_t nonce = first_nonce; 57 | 58 | swab32_array( endiandata, pdata, 20 ); 59 | 60 | do { 61 | be32enc(&endiandata[19], nonce); 62 | argon2hash(hash, endiandata); 63 | if (hash[7] <= Htarg && fulltest(hash, ptarget)) { 64 | pdata[19] = nonce; 65 | submit_solution( work, hash, mythr ); 66 | } 67 | nonce++; 68 | } while (nonce < max_nonce && !work_restart[thr_id].restart); 69 | 70 | pdata[19] = nonce; 71 | *hashes_done = pdata[19] - first_nonce + 1; 72 | return 0; 73 | } 74 | 75 | bool register_argon2_algo( algo_gate_t* gate ) 76 | { 77 | gate->optimizations = SSE2_OPT | AVX_OPT | AVX2_OPT; 78 | gate->scanhash = (void*)&scanhash_argon2; 79 | gate->hash = (void*)&argon2hash; 80 | gate->gen_merkle_root = (void*)&SHA256_gen_merkle_root; 81 | opt_target_factor = 65536.0; 82 | 83 | return true; 84 | }; 85 | 86 | --------------------------------------------------------------------------------