├── m4 ├── .gitignore └── ltversion.m4 ├── algo ├── blake2b.c ├── bmw256.c ├── keccak.c ├── luffa.c ├── bmw512.c ├── skein2.c ├── skein.c ├── ink.c ├── groestl.c ├── myr-groestl.c ├── blake.c ├── yescrypt.c ├── power2b.c ├── axiom.c ├── lyra2v3.c ├── blakecoin.c ├── lyra2re.c ├── blake2.c ├── skunk.c ├── allium.c ├── decred.c ├── lyra2rev2.c ├── phi1612.c ├── veltor.c ├── lbry.c ├── tribus.c ├── s3.c └── pentablake.c ├── crypto ├── chacha2.c ├── hash.h ├── c_keccak.h ├── hash.c ├── c_jh.h ├── chacha20_dispatch.c ├── blake2b.h ├── chacha20.h ├── c_blake256.h ├── cpu-features.h ├── c_groestl.h ├── hash-ops.h ├── c_skein.h ├── oaes_config.h └── cpu-features.c ├── cryptonote ├── .dirstamp ├── .deps │ └── .dirstamp ├── crypto │ ├── .dirstamp │ ├── .deps │ │ └── .dirstamp │ ├── hash.h │ ├── c_keccak.h │ ├── hash.c │ ├── c_jh.h │ ├── c_blake256.h │ ├── c_groestl.h │ ├── hash-ops.h │ ├── c_skein.h │ └── oaes_config.h ├── cryptonight.h ├── cryptonight_dark.h ├── cryptonight_fast.h ├── cryptonight_lite.h ├── cryptonight_turtle.h ├── cryptonight_dark_lite.h ├── cryptonight_turtle_lite.h └── cryptonight_soft_shell.h ├── secp256k1 ├── obj │ └── .gitignore ├── autogen.sh ├── TODO ├── src │ ├── modules │ │ ├── ecdh │ │ │ ├── Makefile.am.include │ │ │ └── main_impl.h │ │ └── recovery │ │ │ └── Makefile.am.include │ ├── java │ │ ├── org_bitcoin_Secp256k1Context.c │ │ ├── org_bitcoin_Secp256k1Context.h │ │ └── org │ │ │ └── bitcoin │ │ │ ├── NativeSecp256k1Util.java │ │ │ └── Secp256k1Context.java │ ├── scalar_low.h │ ├── ecmult_const.h │ ├── num_gmp.h │ ├── num_impl.h │ ├── scalar_8x32.h │ ├── scalar_4x64.h │ ├── basic-config.h │ ├── ecdsa.h │ ├── eckey.h │ ├── ecmult.h │ ├── testrand.h │ ├── bench_sign.c │ ├── bench_ecdh.c │ ├── hash.h │ ├── field_5x52.h │ ├── bench.h │ ├── field_10x26.h │ ├── bench_recover.c │ ├── ecmult_gen.h │ └── gen_context.c ├── libsecp256k1.pc.in ├── .gitignore ├── COPYING ├── include │ └── secp256k1_ecdh.h ├── build-aux │ └── m4 │ │ └── bitcoin_secp.m4 └── .travis.yml ├── res ├── icon.rc ├── setup.ico ├── cpuminer.ico ├── resource.h ├── banner.h └── cpuminer.rc ├── compat ├── jansson │ ├── .deps │ │ ├── dump.Po │ │ ├── error.Po │ │ ├── load.Po │ │ ├── memory.Po │ │ ├── strconv.Po │ │ ├── utf.Po │ │ ├── value.Po │ │ ├── hashtable.Po │ │ ├── pack_unpack.Po │ │ └── strbuffer.Po │ ├── .gitignore │ ├── util.h │ ├── Makefile.am │ ├── strbuffer.h │ ├── LICENSE │ ├── utf.h │ ├── memory.c │ ├── jansson_config.h │ ├── error.c │ └── jansson_private.h ├── .deps │ └── cpuminer-winansi.Po ├── inttypes.h ├── unistd.h ├── curl-for-windows │ ├── openssl │ │ └── openssl │ │ │ ├── include │ │ │ └── openssl │ │ │ │ ├── e_os2.h │ │ │ │ ├── sha.h │ │ │ │ └── opensslconf.h │ │ │ └── crypto │ │ │ └── opensslconf.h │ └── curl │ │ └── include │ │ └── curl │ │ └── stdcheaders.h ├── Makefile.am ├── stdbool.h ├── pthreads │ ├── x64 │ │ ├── libpthreadGC2.a │ │ └── pthreadVC2.lib │ └── x86 │ │ └── pthreadVC2.lib ├── sys │ └── time.h ├── winansi.h └── gettimeofday.c ├── yescrypt ├── test.php ├── yescrypt-best.c └── sha256_Y.h ├── ChangeLog ├── yespower-1.0.1 ├── insecure_memzero.h ├── CHANGES └── TESTS-OK ├── yespower-1.0.1-power2b ├── insecure_memzero-p2b.h ├── CHANGES ├── blake2b.h └── TESTS-OK ├── LICENSE ├── depend.sh ├── AUTHORS ├── Dockerfile ├── cpuminer-conf.json ├── asm ├── aesb-x86.S └── aesb-x64.S ├── autogen.sh ├── scryptjane ├── scrypt-conf.h ├── scrypt-jane-mix_salsa64.h ├── scrypt-jane-romix.h ├── scrypt-jane-mix_chacha.h ├── scrypt-jane-mix_salsa.h ├── scrypt-jane-hash.h └── scrypt-jane-romix-basic.h ├── mingw64.sh ├── uint256.cpp ├── nomacro.pl ├── .github └── workflows │ └── build-manual.yml ├── cpuminer.sln ├── api └── websocket.htm ├── sha3 ├── sph_fugue.h └── sph_hefty1.h ├── lyra2 └── Lyra2.h ├── Android.mk └── compat.h /m4/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /algo/blake2b.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /crypto/chacha2.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cryptonote/.dirstamp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cryptonote/.deps/.dirstamp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cryptonote/crypto/.dirstamp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /secp256k1/obj/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cryptonote/crypto/.deps/.dirstamp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /res/icon.rc: -------------------------------------------------------------------------------- 1 | 0 ICON cpuminer.ico 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/dump.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/error.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/load.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/memory.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/strconv.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/utf.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/value.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/.deps/cpuminer-winansi.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/hashtable.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/pack_unpack.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/jansson/.deps/strbuffer.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /compat/inttypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | -------------------------------------------------------------------------------- /compat/unistd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "getopt/getopt.h" -------------------------------------------------------------------------------- /yescrypt/test.php: -------------------------------------------------------------------------------- 1 | 2 | phpinfo() 3 | 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /secp256k1/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | autoreconf -if --warnings=all 4 | -------------------------------------------------------------------------------- /res/setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wong-fi-hung/termux-miner/HEAD/res/setup.ico -------------------------------------------------------------------------------- /yespower-1.0.1/insecure_memzero.h: -------------------------------------------------------------------------------- 1 | #define insecure_memzero(buf, len) /* empty */ 2 | -------------------------------------------------------------------------------- /compat/curl-for-windows/openssl/openssl/include/openssl/e_os2.h: -------------------------------------------------------------------------------- 1 | #include "../../e_os2.h" 2 | -------------------------------------------------------------------------------- /res/cpuminer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wong-fi-hung/termux-miner/HEAD/res/cpuminer.ico -------------------------------------------------------------------------------- /res/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wong-fi-hung/termux-miner/HEAD/res/resource.h -------------------------------------------------------------------------------- /yespower-1.0.1-power2b/insecure_memzero-p2b.h: -------------------------------------------------------------------------------- 1 | #define insecure_memzero(buf, len) /* empty */ 2 | -------------------------------------------------------------------------------- /compat/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | if WANT_JANSSON 3 | SUBDIRS = jansson 4 | else 5 | SUBDIRS = 6 | endif 7 | 8 | -------------------------------------------------------------------------------- /compat/curl-for-windows/openssl/openssl/crypto/opensslconf.h: -------------------------------------------------------------------------------- 1 | #include "../../config/opensslconf.h" 2 | -------------------------------------------------------------------------------- /compat/curl-for-windows/openssl/openssl/include/openssl/sha.h: -------------------------------------------------------------------------------- 1 | #include "../../crypto/sha/sha.h" 2 | -------------------------------------------------------------------------------- /compat/stdbool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define false 0 4 | #define true 1 5 | 6 | #define bool int 7 | -------------------------------------------------------------------------------- /compat/curl-for-windows/openssl/openssl/include/openssl/opensslconf.h: -------------------------------------------------------------------------------- 1 | #include "../../crypto/opensslconf.h" 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | cpuminer is available under the terms of the GNU Public License version 2. 2 | 3 | See COPYING for details. 4 | -------------------------------------------------------------------------------- /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/wong-fi-hung/termux-miner/HEAD/compat/pthreads/x64/libpthreadGC2.a -------------------------------------------------------------------------------- /compat/pthreads/x64/pthreadVC2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wong-fi-hung/termux-miner/HEAD/compat/pthreads/x64/pthreadVC2.lib -------------------------------------------------------------------------------- /compat/pthreads/x86/pthreadVC2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wong-fi-hung/termux-miner/HEAD/compat/pthreads/x86/pthreadVC2.lib -------------------------------------------------------------------------------- /depend.sh: -------------------------------------------------------------------------------- 1 | apt-get install automake autoconf pkg-config libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev zlib1g-dev make g++ libtool 2 | -------------------------------------------------------------------------------- /crypto/hash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef unsigned char BitSequence; 4 | typedef unsigned long long DataLength; 5 | typedef enum {SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2} HashReturn; 6 | -------------------------------------------------------------------------------- /secp256k1/TODO: -------------------------------------------------------------------------------- 1 | * Unit tests for fieldelem/groupelem, including ones intended to 2 | trigger fieldelem's boundary cases. 3 | * Complete constant-time operations for signing/keygen 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /secp256k1/src/modules/ecdh/Makefile.am.include: -------------------------------------------------------------------------------- 1 | include_HEADERS += include/secp256k1_ecdh.h 2 | noinst_HEADERS += src/modules/ecdh/main_impl.h 3 | noinst_HEADERS += src/modules/ecdh/tests_impl.h 4 | if USE_BENCHMARK 5 | noinst_PROGRAMS += bench_ecdh 6 | bench_ecdh_SOURCES = src/bench_ecdh.c 7 | bench_ecdh_LDADD = libsecp256k1.la $(SECP_LIBS) $(COMMON_LIB) 8 | endif 9 | -------------------------------------------------------------------------------- /secp256k1/src/modules/recovery/Makefile.am.include: -------------------------------------------------------------------------------- 1 | include_HEADERS += include/secp256k1_recovery.h 2 | noinst_HEADERS += src/modules/recovery/main_impl.h 3 | noinst_HEADERS += src/modules/recovery/tests_impl.h 4 | if USE_BENCHMARK 5 | noinst_PROGRAMS += bench_recover 6 | bench_recover_SOURCES = src/bench_recover.c 7 | bench_recover_LDADD = libsecp256k1.la $(SECP_LIBS) $(COMMON_LIB) 8 | endif 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cryptonote/cryptonight.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTONIGHT_H 2 | #define CRYPTONIGHT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void cryptonight_hash(const char* input, char* output, uint32_t len, int variant); 11 | void cryptonight_fast_hash(const char* input, char* output, uint32_t len); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /secp256k1/libsecp256k1.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libsecp256k1 7 | Description: Optimized C library for EC operations on curve secp256k1 8 | URL: https://github.com/bitcoin-core/secp256k1 9 | Version: @PACKAGE_VERSION@ 10 | Cflags: -I${includedir} 11 | Libs.private: @SECP_LIBS@ 12 | Libs: -L${libdir} -lsecp256k1 13 | 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cryptonote/crypto/hash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "hash-ops.h" 4 | 5 | typedef unsigned char BitSequence; 6 | typedef unsigned long long DataLength; 7 | 8 | #ifdef __cplusplus 9 | 10 | #include 11 | 12 | typedef std::string blobdata; 13 | 14 | namespace crypto { 15 | #pragma pack(push, 1) 16 | class hash { 17 | char data[HASH_SIZE]; 18 | }; 19 | #pragma pack(pop) 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /cryptonote/cryptonight_dark.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTONIGHTDARK_H 2 | #define CRYPTONIGHTDARK_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void cryptonightdark_hash(const char* input, char* output, uint32_t len, int variant); 11 | void cryptonightdark_fast_hash(const char* input, char* output, uint32_t len); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /cryptonote/cryptonight_fast.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTONIGHTFAST_H 2 | #define CRYPTONIGHTFAST_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void cryptonightfast_hash(const char* input, char* output, uint32_t len, int variant); 11 | void cryptonightfast_fast_hash(const char* input, char* output, uint32_t len); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /cryptonote/cryptonight_lite.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTONIGHTLITE_H 2 | #define CRYPTONIGHTLITE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void cryptonightlite_hash(const char* input, char* output, uint32_t len, int variant); 11 | void cryptonightlite_fast_hash(const char* input, char* output, uint32_t len); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /cryptonote/cryptonight_turtle.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTONIGHTTURTLE_H 2 | #define CRYPTONIGHTTURTLE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void cryptonightturtle_hash(const char* input, char* output, uint32_t len, int variant); 11 | void cryptonightturtle_fast_hash(const char* input, char* output, uint32_t len); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /cryptonote/cryptonight_dark_lite.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTONIGHTDARKLITE_H 2 | #define CRYPTONIGHTDARKLITE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void cryptonightdarklite_hash(const char* input, char* output, uint32_t len, int variant); 11 | void cryptonightdarklite_fast_hash(const char* input, char* output, uint32_t len); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /cryptonote/cryptonight_turtle_lite.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTONIGHTTURTLELITE_H 2 | #define CRYPTONIGHTTURTLELITE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void cryptonightturtlelite_hash(const char* input, char* output, uint32_t len, int variant); 11 | void cryptonightturtlelite_fast_hash(const char* input, char* output, uint32_t len); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /cryptonote/cryptonight_soft_shell.h: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTONIGHT_SOFT_SHELL_H 2 | #define CRYPTONIGHT_SOFT_SHELL_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void cryptonight_soft_shell_hash(const char* input, char* output, uint32_t len, int variant, uint32_t scratchpad, uint32_t iterations); 11 | void cryptonight_soft_shell_fast_hash(const char* input, char* output, uint32_t len); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /secp256k1/src/java/org_bitcoin_Secp256k1Context.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "org_bitcoin_Secp256k1Context.h" 4 | #include "include/secp256k1.h" 5 | 6 | SECP256K1_API jlong JNICALL Java_org_bitcoin_Secp256k1Context_secp256k1_1init_1context 7 | (JNIEnv* env, jclass classObject) 8 | { 9 | secp256k1_context *ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); 10 | 11 | (void)classObject;(void)env; 12 | 13 | return (uintptr_t)ctx; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Usage: docker build . 2 | # Usage: docker run tpruvot/cpuminer-multi -a xevan --url=stratum+tcp://yiimp.ccminer.org:3739 --user=iGadPnKrdpW3pcdVC3aA77Ku4anrzJyaLG --pass=x 3 | 4 | FROM ubuntu:18.04 5 | MAINTAINER Tanguy Pruvot 6 | WORKDIR /cpuminer-multi 7 | RUN apt-get update -qq 8 | RUN apt-get install -qy automake autoconf pkg-config libcurl4-openssl-dev libssl-dev libjansson-dev libgmp-dev make g++ git libtool 9 | ADD . . 10 | RUN ./build.sh 11 | ENTRYPOINT ["./cpuminer"] 12 | -------------------------------------------------------------------------------- /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://yiimp.ccminer.org:4252", 8 | "user" : "benchmark", 9 | "pass" : "d=0.024", 10 | 11 | "algo" : "decred", 12 | "threads" : 0, 13 | "cpu-priority" : 0, 14 | "cpu-affinity" : -1, 15 | 16 | "benchmark" : false, 17 | "debug" : false, 18 | "protocol": false, 19 | "show-diff": true, 20 | "quiet" : false 21 | } 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2013-2016 The Bitcoin Core developers 3 | # Distributed under the MIT software license, see the accompanying 4 | # file COPYING or http://www.opensource.org/licenses/mit-license.php. 5 | 6 | set -e 7 | srcdir="$(dirname $0)" 8 | cd "$srcdir" 9 | if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="`which glibtoolize 2>/dev/null`"; then 10 | LIBTOOLIZE="${GLIBTOOLIZE}" 11 | export LIBTOOLIZE 12 | fi 13 | which autoreconf >/dev/null || \ 14 | (echo "configuration failed, please install autoconf first" && exit 1) 15 | autoreconf --install --force --warnings=all 16 | -------------------------------------------------------------------------------- /scryptjane/scrypt-conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | pick the best algo at runtime or compile time? 3 | ---------------------------------------------- 4 | SCRYPT_CHOOSE_COMPILETIME (gcc only!) 5 | SCRYPT_CHOOSE_RUNTIME 6 | */ 7 | #define SCRYPT_CHOOSE_RUNTIME 8 | 9 | 10 | /* 11 | hash function to use 12 | ------------------------------- 13 | SCRYPT_BLAKE256 14 | SCRYPT_BLAKE512 15 | SCRYPT_SHA256 16 | SCRYPT_SHA512 17 | SCRYPT_SKEIN512 18 | */ 19 | //#define SCRYPT_SHA256 20 | 21 | 22 | /* 23 | block mixer to use 24 | ----------------------------- 25 | SCRYPT_CHACHA 26 | SCRYPT_SALSA 27 | */ 28 | //#define SCRYPT_SALSA 29 | -------------------------------------------------------------------------------- /secp256k1/src/scalar_low.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2015 Andrew Poelstra * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_SCALAR_REPR_H 8 | #define SECP256K1_SCALAR_REPR_H 9 | 10 | #include 11 | 12 | /** A scalar modulo the group order of the secp256k1 curve. */ 13 | typedef uint32_t secp256k1_scalar; 14 | 15 | #endif /* SECP256K1_SCALAR_REPR_H */ 16 | -------------------------------------------------------------------------------- /crypto/c_keccak.h: -------------------------------------------------------------------------------- 1 | // keccak.h 2 | // 19-Nov-11 Markku-Juhani O. Saarinen 3 | 4 | #ifndef KECCAK_H 5 | #define KECCAK_H 6 | 7 | #include 8 | #include 9 | 10 | #ifndef KECCAK_ROUNDS 11 | #define KECCAK_ROUNDS 24 12 | #endif 13 | 14 | #ifndef ROTL64 15 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) 16 | #endif 17 | 18 | // compute a keccak hash (md) of given byte length from "in" 19 | int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen); 20 | 21 | // update the state 22 | void keccakf(uint64_t st[25], int norounds); 23 | 24 | void keccak1600(const uint8_t *in, int inlen, uint8_t *md); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /secp256k1/src/java/org_bitcoin_Secp256k1Context.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | #include "include/secp256k1.h" 4 | /* Header for class org_bitcoin_Secp256k1Context */ 5 | 6 | #ifndef _Included_org_bitcoin_Secp256k1Context 7 | #define _Included_org_bitcoin_Secp256k1Context 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | /* 12 | * Class: org_bitcoin_Secp256k1Context 13 | * Method: secp256k1_init_context 14 | * Signature: ()J 15 | */ 16 | SECP256K1_API jlong JNICALL Java_org_bitcoin_Secp256k1Context_secp256k1_1init_1context 17 | (JNIEnv *, jclass); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | #endif 23 | -------------------------------------------------------------------------------- /cryptonote/crypto/c_keccak.h: -------------------------------------------------------------------------------- 1 | // keccak.h 2 | // 19-Nov-11 Markku-Juhani O. Saarinen 3 | 4 | #ifndef KECCAK_H 5 | #define KECCAK_H 6 | 7 | #include 8 | #include 9 | 10 | #ifndef KECCAK_ROUNDS 11 | #define KECCAK_ROUNDS 24 12 | #endif 13 | 14 | #ifndef ROTL64 15 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) 16 | #endif 17 | 18 | // compute a keccak hash (md) of given byte length from "in" 19 | int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen); 20 | 21 | // update the state 22 | void keccakf(uint64_t st[25], int norounds); 23 | 24 | void keccak1600(const uint8_t *in, int inlen, uint8_t *md); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /secp256k1/src/ecmult_const.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2015 Andrew Poelstra * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_ECMULT_CONST_H 8 | #define SECP256K1_ECMULT_CONST_H 9 | 10 | #include "scalar.h" 11 | #include "group.h" 12 | 13 | static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q); 14 | 15 | #endif /* SECP256K1_ECMULT_CONST_H */ 16 | -------------------------------------------------------------------------------- /secp256k1/src/num_gmp.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_NUM_REPR_H 8 | #define SECP256K1_NUM_REPR_H 9 | 10 | #include 11 | 12 | #define NUM_LIMBS ((256+GMP_NUMB_BITS-1)/GMP_NUMB_BITS) 13 | 14 | typedef struct { 15 | mp_limb_t data[2*NUM_LIMBS]; 16 | int neg; 17 | int limbs; 18 | } secp256k1_num; 19 | 20 | #endif /* SECP256K1_NUM_REPR_H */ 21 | -------------------------------------------------------------------------------- /crypto/hash.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2013 The Cryptonote developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "hash-ops.h" 10 | #include "c_keccak.h" 11 | 12 | void hash_permutation(union hash_state *state) { 13 | keccakf((uint64_t*)state, 24); 14 | } 15 | 16 | void hash_process(union hash_state *state, const uint8_t *buf, int count) { 17 | keccak1600(buf, count, (uint8_t*)state); 18 | } 19 | 20 | void cn_fast_hash(const void *data, int len, char *hash) { 21 | union hash_state state; 22 | hash_process(&state, data, len); 23 | memcpy(hash, &state, HASH_SIZE); 24 | } 25 | -------------------------------------------------------------------------------- /compat/winansi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ANSI emulation wrappers 3 | */ 4 | #ifdef WIN32 5 | #include 6 | #include 7 | #include 8 | 9 | #define isatty(fd) _isatty(fd) 10 | #define fileno(fd) _fileno(fd) 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | int winansi_fputs(const char *str, FILE *stream); 16 | int winansi_printf(const char *format, ...); 17 | int winansi_fprintf(FILE *stream, const char *format, ...); 18 | int winansi_vfprintf(FILE *stream, const char *format, va_list list); 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #undef fputs 24 | #undef fprintf 25 | #undef vfprintf 26 | 27 | #define fputs winansi_fputs 28 | #define printf winansi_printf 29 | #define fprintf winansi_fprintf 30 | #define vfprintf winansi_vfprintf 31 | 32 | #endif -------------------------------------------------------------------------------- /crypto/c_jh.h: -------------------------------------------------------------------------------- 1 | /*This program gives the 64-bit optimized bitslice implementation of JH using ANSI C 2 | 3 | -------------------------------- 4 | Performance 5 | 6 | Microprocessor: Intel CORE 2 processor (Core 2 Duo Mobile T6600 2.2GHz) 7 | Operating System: 64-bit Ubuntu 10.04 (Linux kernel 2.6.32-22-generic) 8 | Speed for long message: 9 | 1) 45.8 cycles/byte compiler: Intel C++ Compiler 11.1 compilation option: icc -O2 10 | 2) 56.8 cycles/byte compiler: gcc 4.4.3 compilation option: gcc -O3 11 | 12 | -------------------------------- 13 | Last Modified: January 16, 2011 14 | */ 15 | #pragma once 16 | 17 | #include "hash.h" 18 | 19 | HashReturn jh_hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval); 20 | -------------------------------------------------------------------------------- /cryptonote/crypto/hash.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2013 The Cryptonote developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "hash-ops.h" 10 | #include "c_keccak.h" 11 | 12 | void hash_permutation(union hash_state *state) { 13 | keccakf((uint64_t*)state, 24); 14 | } 15 | 16 | void hash_process(union hash_state *state, const uint8_t *buf, size_t count) { 17 | keccak1600(buf, count, (uint8_t*)state); 18 | } 19 | 20 | void cn_fast_hash(const void *data, size_t length, char *hash) { 21 | union hash_state state; 22 | hash_process(&state, data, length); 23 | memcpy(hash, &state, HASH_SIZE); 24 | } 25 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 4179 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.6]) 16 | m4_define([LT_PACKAGE_REVISION], [2.4.6]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.6' 20 | macro_revision='2.4.6' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /secp256k1/src/num_impl.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_NUM_IMPL_H 8 | #define SECP256K1_NUM_IMPL_H 9 | 10 | #if defined HAVE_CONFIG_H 11 | #include "libsecp256k1-config.h" 12 | #endif 13 | 14 | #include "num.h" 15 | 16 | #if defined(USE_NUM_GMP) 17 | #include "num_gmp_impl.h" 18 | #elif defined(USE_NUM_NONE) 19 | /* Nothing. */ 20 | #else 21 | #error "Please select num implementation" 22 | #endif 23 | 24 | #endif /* SECP256K1_NUM_IMPL_H */ 25 | -------------------------------------------------------------------------------- /secp256k1/src/scalar_8x32.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_SCALAR_REPR_H 8 | #define SECP256K1_SCALAR_REPR_H 9 | 10 | #include 11 | 12 | /** A scalar modulo the group order of the secp256k1 curve. */ 13 | typedef struct { 14 | uint32_t d[8]; 15 | } secp256k1_scalar; 16 | 17 | #define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{(d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)}} 18 | 19 | #endif /* SECP256K1_SCALAR_REPR_H */ 20 | -------------------------------------------------------------------------------- /cryptonote/crypto/c_jh.h: -------------------------------------------------------------------------------- 1 | /*This program gives the 64-bit optimized bitslice implementation of JH using ANSI C 2 | 3 | -------------------------------- 4 | Performance 5 | 6 | Microprocessor: Intel CORE 2 processor (Core 2 Duo Mobile T6600 2.2GHz) 7 | Operating System: 64-bit Ubuntu 10.04 (Linux kernel 2.6.32-22-generic) 8 | Speed for long message: 9 | 1) 45.8 cycles/byte compiler: Intel C++ Compiler 11.1 compilation option: icc -O2 10 | 2) 56.8 cycles/byte compiler: gcc 4.4.3 compilation option: gcc -O3 11 | 12 | -------------------------------- 13 | Last Modified: January 16, 2011 14 | */ 15 | #pragma once 16 | #include "hash.h" 17 | 18 | typedef enum {SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2} HashReturn; 19 | 20 | HashReturn jh_hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval); 21 | -------------------------------------------------------------------------------- /yespower-1.0.1/CHANGES: -------------------------------------------------------------------------------- 1 | Changes made between 1.0.0 (2018/07/12) and 1.0.1 (2019/06/30). 2 | 3 | Fill the destination buffer with all set bits on error for fail-safety 4 | of the caller's "< target" check in case the caller neglects to check 5 | for errors. 6 | 7 | Simplified SMix2 for its final invocation with Nloop=2 in yespower 0.5. 8 | 9 | Revised the "XOR of yespower" tests to trigger duplicate index in the 10 | last SMix2 invocation in yespower 0.5 for N=2048 with at least one of 11 | the values of r being tested. This is needed to test that a proper 12 | kind of BlockMix is used in that special case, which would previously be 13 | left untested. 14 | 15 | Added x32 ABI support (x86-64 with 32-bit pointers). 16 | 17 | Added a bit more detail to the README on caching of the computed PoW 18 | hashes when integrating yespower in an altcoin based on Bitcoin Core. 19 | -------------------------------------------------------------------------------- /yespower-1.0.1-power2b/CHANGES: -------------------------------------------------------------------------------- 1 | Changes made between 1.0.0 (2018/07/12) and 1.0.1 (2019/06/30). 2 | 3 | Fill the destination buffer with all set bits on error for fail-safety 4 | of the caller's "< target" check in case the caller neglects to check 5 | for errors. 6 | 7 | Simplified SMix2 for its final invocation with Nloop=2 in yespower 0.5. 8 | 9 | Revised the "XOR of yespower" tests to trigger duplicate index in the 10 | last SMix2 invocation in yespower 0.5 for N=2048 with at least one of 11 | the values of r being tested. This is needed to test that a proper 12 | kind of BlockMix is used in that special case, which would previously be 13 | left untested. 14 | 15 | Added x32 ABI support (x86-64 with 32-bit pointers). 16 | 17 | Added a bit more detail to the README on caching of the computed PoW 18 | hashes when integrating yespower in an altcoin based on Bitcoin Core. 19 | -------------------------------------------------------------------------------- /secp256k1/src/scalar_4x64.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_SCALAR_REPR_H 8 | #define SECP256K1_SCALAR_REPR_H 9 | 10 | #include 11 | 12 | /** A scalar modulo the group order of the secp256k1 curve. */ 13 | typedef struct { 14 | uint64_t d[4]; 15 | } secp256k1_scalar; 16 | 17 | #define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{((uint64_t)(d1)) << 32 | (d0), ((uint64_t)(d3)) << 32 | (d2), ((uint64_t)(d5)) << 32 | (d4), ((uint64_t)(d7)) << 32 | (d6)}} 18 | 19 | #endif /* SECP256K1_SCALAR_REPR_H */ 20 | -------------------------------------------------------------------------------- /crypto/chacha20_dispatch.c: -------------------------------------------------------------------------------- 1 | #include "cpu-features.h" 2 | #include "chacha20.h" 3 | 4 | static bool initialized = false; 5 | static cpu_features_t f; 6 | 7 | void chacha_init() 8 | { 9 | #if defined(x86_64) 10 | get_cpu_features(&f); 11 | #endif 12 | 13 | initialized = true; 14 | } 15 | 16 | void chacha_encrypt(uint8_t *key, uint8_t *nonce, uint8_t *in, uint8_t *out, size_t bytes, uint32_t rounds) 17 | { 18 | 19 | if (!initialized) 20 | { 21 | chacha_init(); 22 | } 23 | 24 | 25 | #if defined(x86_64) 26 | if (f.HW_AVX2) 27 | { 28 | chacha_encrypt_avx2(key, nonce, in, out, bytes, rounds); 29 | return; 30 | } 31 | 32 | if (f.HW_SSE2) 33 | { 34 | chacha_encrypt_sse2(key, nonce, in, out, bytes, rounds); 35 | return; 36 | } 37 | #endif 38 | 39 | chacha_encrypt_portable(key, nonce, in, out, bytes, rounds); 40 | } 41 | -------------------------------------------------------------------------------- /secp256k1/.gitignore: -------------------------------------------------------------------------------- 1 | bench_inv 2 | bench_ecdh 3 | bench_sign 4 | bench_verify 5 | bench_schnorr_verify 6 | bench_recover 7 | bench_internal 8 | tests 9 | exhaustive_tests 10 | gen_context 11 | *.exe 12 | *.so 13 | *.a 14 | !.gitignore 15 | 16 | Makefile 17 | configure 18 | .libs/ 19 | Makefile.in 20 | aclocal.m4 21 | autom4te.cache/ 22 | config.log 23 | config.status 24 | *.tar.gz 25 | *.la 26 | libtool 27 | .deps/ 28 | .dirstamp 29 | *.lo 30 | *.o 31 | *~ 32 | src/libsecp256k1-config.h 33 | src/libsecp256k1-config.h.in 34 | src/ecmult_static_context.h 35 | build-aux/config.guess 36 | build-aux/config.sub 37 | build-aux/depcomp 38 | build-aux/install-sh 39 | build-aux/ltmain.sh 40 | build-aux/m4/libtool.m4 41 | build-aux/m4/lt~obsolete.m4 42 | build-aux/m4/ltoptions.m4 43 | build-aux/m4/ltsugar.m4 44 | build-aux/m4/ltversion.m4 45 | build-aux/missing 46 | build-aux/compile 47 | build-aux/test-driver 48 | src/stamp-h1 49 | libsecp256k1.pc 50 | -------------------------------------------------------------------------------- /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="$extracflags -march=native" 13 | 14 | # extracflags="-pg -static -fno-inline-small-functions" 15 | CFLAGS="-DCURL_STATICLIB -DOPENSSL_NO_ASM -DUSE_ASM -static-libgcc $extracflags" 16 | # CPPFLAGS="" 17 | 18 | # icon 19 | windres res/icon.rc icon.o 20 | 21 | ./configure --build=x86_64-w64-mingw32 --with-crypto=$SSL_PREFIX --with-curl=$CURL_PREFIX \ 22 | CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="icon.o" 23 | 24 | make 25 | 26 | strip -p --strip-debug --strip-unneeded cpuminer.exe 27 | 28 | if [ -e sign.sh ] ; then 29 | . sign.sh 30 | fi 31 | 32 | -------------------------------------------------------------------------------- /scryptjane/scrypt-jane-mix_salsa64.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA64_INCLUDED) 2 | 3 | #undef SCRYPT_MIX 4 | #define SCRYPT_MIX "Salsa64/8 Ref" 5 | 6 | #undef SCRYPT_SALSA64_INCLUDED 7 | #define SCRYPT_SALSA64_INCLUDED 8 | #define SCRYPT_SALSA64_BASIC 9 | 10 | static void 11 | salsa64_core_basic(uint64_t state[16]) { 12 | const size_t rounds = 8; 13 | uint64_t v[16], t; 14 | size_t i; 15 | 16 | for (i = 0; i < 16; i++) v[i] = state[i]; 17 | 18 | #define G(a,b,c,d) \ 19 | t = v[a]+v[d]; t = ROTL64(t, 32); v[b] ^= t; \ 20 | t = v[b]+v[a]; t = ROTL64(t, 13); v[c] ^= t; \ 21 | t = v[c]+v[b]; t = ROTL64(t, 39); v[d] ^= t; \ 22 | t = v[d]+v[c]; t = ROTL64(t, 32); v[a] ^= t; \ 23 | 24 | for (i = 0; i < rounds; i += 2) { 25 | G( 0, 4, 8,12); 26 | G( 5, 9,13, 1); 27 | G(10,14, 2, 6); 28 | G(15, 3, 7,11); 29 | G( 0, 1, 2, 3); 30 | G( 5, 6, 7, 4); 31 | G(10,11, 8, 9); 32 | G(15,12,13,14); 33 | } 34 | 35 | for (i = 0; i < 16; i++) state[i] += v[i]; 36 | 37 | #undef G 38 | } 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /uint256.cpp: -------------------------------------------------------------------------------- 1 | #include "uint256.h" 2 | 3 | #ifdef __cplusplus 4 | extern "C"{ 5 | #endif 6 | 7 | #include "miner.h" 8 | 9 | // compute the diff ratio between a found hash and the target 10 | double hash_target_ratio(uint32_t* hash, uint32_t* target) 11 | { 12 | uint256 h, t; 13 | double dhash; 14 | 15 | if (!opt_showdiff) 16 | return 0.0; 17 | 18 | memcpy(&t, (void*) target, 32); 19 | memcpy(&h, (void*) hash, 32); 20 | 21 | dhash = h.getdouble(); 22 | if (dhash > 0.) 23 | return t.getdouble() / dhash; 24 | else 25 | return dhash; 26 | } 27 | 28 | // store the share ratio in work struct 29 | void work_set_target_ratio(struct work* work, uint32_t* hash) 30 | { 31 | // only if the option is enabled (to reduce cpu usage) 32 | if (opt_showdiff && work) { 33 | work->shareratio = hash_target_ratio(hash, work->target); 34 | work->sharediff = work->targetdiff * work->shareratio; 35 | if (opt_debug) 36 | applog(LOG_DEBUG, "share diff %.5f (%.1fx)", work->sharediff, work->shareratio); 37 | } 38 | } 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /crypto/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 | } blake2b_ctx; 28 | 29 | #if defined(__cplusplus) 30 | extern "C" { 31 | #endif 32 | 33 | int blake2b_init(blake2b_ctx *ctx, size_t outlen, const void *key, size_t keylen); 34 | void blake2b_update(blake2b_ctx *ctx, const void *in, size_t inlen); 35 | void blake2b_final(blake2b_ctx *ctx, void *out); 36 | 37 | #if defined(__cplusplus) 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /secp256k1/src/basic-config.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_BASIC_CONFIG_H 8 | #define SECP256K1_BASIC_CONFIG_H 9 | 10 | #ifdef USE_BASIC_CONFIG 11 | 12 | #undef USE_ASM_X86_64 13 | #undef USE_ENDOMORPHISM 14 | #undef USE_FIELD_10X26 15 | #undef USE_FIELD_5X52 16 | #undef USE_FIELD_INV_BUILTIN 17 | #undef USE_FIELD_INV_NUM 18 | #undef USE_NUM_GMP 19 | #undef USE_NUM_NONE 20 | #undef USE_SCALAR_4X64 21 | #undef USE_SCALAR_8X32 22 | #undef USE_SCALAR_INV_BUILTIN 23 | #undef USE_SCALAR_INV_NUM 24 | 25 | #define USE_NUM_NONE 1 26 | #define USE_FIELD_INV_BUILTIN 1 27 | #define USE_SCALAR_INV_BUILTIN 1 28 | #define USE_FIELD_10X26 1 29 | #define USE_SCALAR_8X32 1 30 | 31 | #endif /* USE_BASIC_CONFIG */ 32 | 33 | #endif /* SECP256K1_BASIC_CONFIG_H */ 34 | -------------------------------------------------------------------------------- /secp256k1/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Pieter Wuille 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /secp256k1/include/secp256k1_ecdh.h: -------------------------------------------------------------------------------- 1 | #ifndef SECP256K1_ECDH_H 2 | #define SECP256K1_ECDH_H 3 | 4 | #include "secp256k1.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /** Compute an EC Diffie-Hellman secret in constant time 11 | * Returns: 1: exponentiation was successful 12 | * 0: scalar was invalid (zero or overflow) 13 | * Args: ctx: pointer to a context object (cannot be NULL) 14 | * Out: result: a 32-byte array which will be populated by an ECDH 15 | * secret computed from the point and scalar 16 | * In: pubkey: a pointer to a secp256k1_pubkey containing an 17 | * initialized public key 18 | * privkey: a 32-byte scalar with which to multiply the point 19 | */ 20 | SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh( 21 | const secp256k1_context* ctx, 22 | unsigned char *result, 23 | const secp256k1_pubkey *pubkey, 24 | const unsigned char *privkey 25 | ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* SECP256K1_ECDH_H */ 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /scryptjane/scrypt-jane-romix.h: -------------------------------------------------------------------------------- 1 | #if defined(SCRYPT_CHACHA) 2 | #include "scrypt-jane-chacha.h" 3 | #elif defined(SCRYPT_SALSA) 4 | #include "scrypt-jane-salsa.h" 5 | #elif defined(SCRYPT_SALSA64) 6 | #include "scrypt-jane-salsa64.h" 7 | #else 8 | #define SCRYPT_MIX_BASE "ERROR" 9 | typedef uint32_t scrypt_mix_word_t; 10 | #define SCRYPT_WORDTO8_LE U32TO8_LE 11 | #define SCRYPT_WORD_ENDIAN_SWAP U32_SWAP 12 | #define SCRYPT_BLOCK_BYTES 64 13 | #define SCRYPT_BLOCK_WORDS (SCRYPT_BLOCK_BYTES / sizeof(scrypt_mix_word_t)) 14 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) 15 | static void FASTCALL scrypt_ROMix_error(scrypt_mix_word_t *X/*[chunkWords]*/, scrypt_mix_word_t *Y/*[chunkWords]*/, scrypt_mix_word_t *V/*[chunkWords * N]*/, uint32_t N, uint32_t r) {} 16 | static scrypt_ROMixfn scrypt_getROMix() { return scrypt_ROMix_error; } 17 | #else 18 | static void FASTCALL scrypt_ROMix(scrypt_mix_word_t *X, scrypt_mix_word_t *Y, scrypt_mix_word_t *V, uint32_t N, uint32_t r) {} 19 | #endif 20 | static int scrypt_test_mix() { return 0; } 21 | #error must define a mix function! 22 | #endif 23 | 24 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) 25 | #undef SCRYPT_MIX 26 | #define SCRYPT_MIX SCRYPT_MIX_BASE 27 | #endif 28 | -------------------------------------------------------------------------------- /nomacro.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Copyright 2012 pooler@litecoinpool.org 3 | # 4 | # This program is free software; you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by the Free 6 | # Software Foundation; either version 2 of the License, or (at your option) 7 | # any later version. See COPYING for more details. 8 | # 9 | # nomacro.pl - convert assembler macros to C preprocessor macros. 10 | 11 | use strict; 12 | 13 | foreach my $f () { 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 | -------------------------------------------------------------------------------- /secp256k1/src/ecdsa.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_ECDSA_H 8 | #define SECP256K1_ECDSA_H 9 | 10 | #include 11 | 12 | #include "scalar.h" 13 | #include "group.h" 14 | #include "ecmult.h" 15 | 16 | static int secp256k1_ecdsa_sig_parse(secp256k1_scalar *r, secp256k1_scalar *s, const unsigned char *sig, size_t size); 17 | static int secp256k1_ecdsa_sig_serialize(unsigned char *sig, size_t *size, const secp256k1_scalar *r, const secp256k1_scalar *s); 18 | static int secp256k1_ecdsa_sig_verify(const secp256k1_ecmult_context *ctx, const secp256k1_scalar* r, const secp256k1_scalar* s, const secp256k1_ge *pubkey, const secp256k1_scalar *message); 19 | static int secp256k1_ecdsa_sig_sign(const secp256k1_ecmult_gen_context *ctx, secp256k1_scalar* r, secp256k1_scalar* s, const secp256k1_scalar *seckey, const secp256k1_scalar *message, const secp256k1_scalar *nonce, int *recid); 20 | 21 | #endif /* SECP256K1_ECDSA_H */ 22 | -------------------------------------------------------------------------------- /.github/workflows/build-manual.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: update 17 | run: sudo apt update 18 | - name: upgrade 19 | run: sudo apt upgrade -y 20 | - name: clean 21 | run: sudo apt clean 22 | - name: install_dependencies 23 | run: sudo apt install git wget nano gh tmate build-essential make m4 libcurl4-openssl-dev libjansson-dev automake autoconf libtool autotools-dev cmake zlib1g-dev openssl libssl-dev -y 24 | - name: clone_gitsource 25 | run: cd && git clone https://github.com/wong-fi-hung/termux-miner && cd termux-miner 26 | - name: generate_configure_script 27 | run: autoreconf -i 28 | - name: configuring 29 | run: ./configure --with-crypto --with-curl 30 | - name: Make 31 | run: make -j4 32 | - name: strip 33 | run: strip -s cpuminer 34 | - name: mktargz 35 | run: mkdir termux-miner-v3.0.0; cp cpuminer cpuminer-conf.json termux-miner-v3.0.0; tar -Jcvf termux-miner-v3.0.0_amd64.tar.xz termux-miner-v3.0.0 36 | - name: run_tmate_cmd 37 | run: tmate -F 38 | -------------------------------------------------------------------------------- /yespower-1.0.1-power2b/blake2b.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_ctx; 20 | 21 | typedef struct { 22 | blake2b_ctx inner; 23 | blake2b_ctx outer; 24 | } hmac_ctx; 25 | 26 | #if defined(__cplusplus) 27 | extern "C" { 28 | #endif 29 | 30 | int blake2b_init(blake2b_ctx *ctx, size_t outlen, const void *key, size_t keylen); 31 | void blake2b_update(blake2b_ctx *ctx, const void *in, size_t inlen); 32 | void blake2b_final(blake2b_ctx *ctx, void *out); 33 | void blake2b_hash(void *out, const void *in, size_t inlen); 34 | void hmac_blake2b_hash(void *out, const void *key, size_t keylen, const void *in, size_t inlen); 35 | void pbkdf2_blake2b(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/bmw256.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "sha3/sph_bmw.h" 7 | 8 | void bmwhash(void *output, const void *input) 9 | { 10 | uint32_t hash[16]; 11 | sph_bmw256_context ctx; 12 | 13 | sph_bmw256_init(&ctx); 14 | sph_bmw256(&ctx, input, 80); 15 | sph_bmw256_close(&ctx, hash); 16 | 17 | memcpy(output, hash, 32); 18 | } 19 | 20 | int scanhash_bmw(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 21 | { 22 | uint32_t _ALIGN(128) hash32[8]; 23 | uint32_t _ALIGN(128) endiandata[20]; 24 | uint32_t *pdata = work->data; 25 | uint32_t *ptarget = work->target; 26 | 27 | const uint32_t Htarg = ptarget[7]; 28 | const uint32_t first_nonce = pdata[19]; 29 | 30 | uint32_t n = first_nonce; 31 | 32 | for (int i=0; i < 19; i++) { 33 | be32enc(&endiandata[i], pdata[i]); 34 | }; 35 | 36 | do { 37 | be32enc(&endiandata[19], n); 38 | bmwhash(hash32, endiandata); 39 | if (hash32[7] < Htarg && fulltest(hash32, ptarget)) { 40 | work_set_target_ratio(work, hash32); 41 | *hashes_done = n - first_nonce + 1; 42 | pdata[19] = n; 43 | return 1; 44 | } 45 | n++; 46 | 47 | } while (n < max_nonce && !work_restart[thr_id].restart); 48 | 49 | *hashes_done = n - first_nonce + 1; 50 | pdata[19] = n; 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /secp256k1/src/eckey.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_ECKEY_H 8 | #define SECP256K1_ECKEY_H 9 | 10 | #include 11 | 12 | #include "group.h" 13 | #include "scalar.h" 14 | #include "ecmult.h" 15 | #include "ecmult_gen.h" 16 | 17 | static int secp256k1_eckey_pubkey_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size); 18 | static int secp256k1_eckey_pubkey_serialize(secp256k1_ge *elem, unsigned char *pub, size_t *size, int compressed); 19 | 20 | static int secp256k1_eckey_privkey_tweak_add(secp256k1_scalar *key, const secp256k1_scalar *tweak); 21 | static int secp256k1_eckey_pubkey_tweak_add(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak); 22 | static int secp256k1_eckey_privkey_tweak_mul(secp256k1_scalar *key, const secp256k1_scalar *tweak); 23 | static int secp256k1_eckey_pubkey_tweak_mul(const secp256k1_ecmult_context *ctx, secp256k1_ge *key, const secp256k1_scalar *tweak); 24 | 25 | #endif /* SECP256K1_ECKEY_H */ 26 | -------------------------------------------------------------------------------- /crypto/chacha20.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CHACHA20_H 3 | #define CHACHA20_H 4 | 5 | #include 6 | #include 7 | 8 | #define ChaCha20StateSizeBytes 48; 9 | #define ChaCha20KeySizeByte 32 10 | #define ChaCha20NonceSizeByte 12 11 | #define ChaCha20CounterSizeByte 4 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | void ChaCha20SetKey(uint8_t *state, const uint8_t *Key); 19 | void ChaCha20SetNonce(uint8_t *state, const uint8_t *Nonce); 20 | // void ChaCha20SetCtr(uint8_t *state, const uint8_t *Ctr); 21 | // void ChaCha20EncryptBytes(uint8_t *state, uint8_t *In, uint8_t *Out, size_t Size, uint32_t rounds); // if In=nullptr - just fill Out 22 | void ChaCha20IncrementNonce(uint8_t *state); 23 | void ChaCha20AddCounter(uint8_t *ChaCha, const uint32_t value_to_add); 24 | 25 | void chacha_encrypt_portable(uint8_t *key, uint8_t *nonce, uint8_t *in, uint8_t *out, size_t bytes, uint32_t rounds); 26 | void chacha_encrypt_sse2(uint8_t *key, uint8_t *nonce, uint8_t *in, uint8_t *out, size_t bytes, uint32_t rounds); 27 | void chacha_encrypt_avx2(uint8_t *key, uint8_t *nonce, uint8_t *in, uint8_t *out, size_t bytes, uint32_t rounds); 28 | void chacha_encrypt(uint8_t *key, uint8_t *nonce, uint8_t *in, uint8_t *out, size_t bytes, uint32_t rounds); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // CHACHA20_H 35 | -------------------------------------------------------------------------------- /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/keccak.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "sha3/sph_keccak.h" 7 | 8 | extern void keccakhash(void *state, const void *input) 9 | { 10 | sph_keccak256_context ctx_keccak; 11 | uint32_t hash[32]; 12 | 13 | sph_keccak256_init(&ctx_keccak); 14 | sph_keccak256 (&ctx_keccak,input, 80); 15 | sph_keccak256_close(&ctx_keccak, hash); 16 | 17 | memcpy(state, hash, 32); 18 | } 19 | 20 | int scanhash_keccak(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 21 | { 22 | uint32_t _ALIGN(128) hash32[8]; 23 | uint32_t _ALIGN(128) endiandata[20]; 24 | uint32_t *pdata = work->data; 25 | uint32_t *ptarget = work->target; 26 | 27 | uint32_t n = pdata[19] - 1; 28 | const uint32_t first_nonce = pdata[19]; 29 | 30 | for (int k=0; k < 19; k++) 31 | be32enc(&endiandata[k], pdata[k]); 32 | 33 | const uint32_t Htarg = ptarget[7]; 34 | do { 35 | 36 | pdata[19] = ++n; 37 | be32enc(&endiandata[19], n); 38 | keccakhash(hash32, endiandata); 39 | 40 | if (hash32[7] <= Htarg && fulltest(hash32, ptarget)) { 41 | work_set_target_ratio(work, hash32); 42 | pdata[19] = n; 43 | *hashes_done = pdata[19] - first_nonce; 44 | return true; 45 | } 46 | } while (n < max_nonce && !work_restart[thr_id].restart); 47 | 48 | *hashes_done = n - first_nonce + 1; 49 | pdata[19] = n; 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /crypto/c_blake256.h: -------------------------------------------------------------------------------- 1 | #ifndef _BLAKE256_H_ 2 | #define _BLAKE256_H_ 3 | 4 | #include 5 | 6 | typedef struct { 7 | uint32_t h[8], s[4], t[2]; 8 | int buflen, nullt; 9 | uint8_t buf[64]; 10 | } state; 11 | 12 | typedef struct { 13 | state inner; 14 | state outer; 15 | } hmac_state; 16 | 17 | void blake256_init(state *); 18 | void blake224_init(state *); 19 | 20 | void blake256_update(state *, const uint8_t *, uint64_t); 21 | void blake224_update(state *, const uint8_t *, uint64_t); 22 | 23 | void blake256_final(state *, uint8_t *); 24 | void blake224_final(state *, uint8_t *); 25 | 26 | void blake256_hash(uint8_t *, const uint8_t *, uint64_t); 27 | void blake224_hash(uint8_t *, const uint8_t *, uint64_t); 28 | 29 | /* HMAC functions: */ 30 | 31 | void hmac_blake256_init(hmac_state *, const uint8_t *, uint64_t); 32 | void hmac_blake224_init(hmac_state *, const uint8_t *, uint64_t); 33 | 34 | void hmac_blake256_update(hmac_state *, const uint8_t *, uint64_t); 35 | void hmac_blake224_update(hmac_state *, const uint8_t *, uint64_t); 36 | 37 | void hmac_blake256_final(hmac_state *, uint8_t *); 38 | void hmac_blake224_final(hmac_state *, uint8_t *); 39 | 40 | void hmac_blake256_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 41 | void hmac_blake224_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 42 | 43 | #endif /* _BLAKE256_H_ */ 44 | -------------------------------------------------------------------------------- /cryptonote/crypto/c_blake256.h: -------------------------------------------------------------------------------- 1 | #ifndef _BLAKE256_H_ 2 | #define _BLAKE256_H_ 3 | 4 | #include 5 | 6 | typedef struct { 7 | uint32_t h[8], s[4], t[2]; 8 | int buflen, nullt; 9 | uint8_t buf[64]; 10 | } state; 11 | 12 | typedef struct { 13 | state inner; 14 | state outer; 15 | } hmac_state; 16 | 17 | void blake256_init(state *); 18 | void blake224_init(state *); 19 | 20 | void blake256_update(state *, const uint8_t *, uint64_t); 21 | void blake224_update(state *, const uint8_t *, uint64_t); 22 | 23 | void blake256_final(state *, uint8_t *); 24 | void blake224_final(state *, uint8_t *); 25 | 26 | void blake256_hash(uint8_t *, const uint8_t *, uint64_t); 27 | void blake224_hash(uint8_t *, const uint8_t *, uint64_t); 28 | 29 | /* HMAC functions: */ 30 | 31 | void hmac_blake256_init(hmac_state *, const uint8_t *, uint64_t); 32 | void hmac_blake224_init(hmac_state *, const uint8_t *, uint64_t); 33 | 34 | void hmac_blake256_update(hmac_state *, const uint8_t *, uint64_t); 35 | void hmac_blake224_update(hmac_state *, const uint8_t *, uint64_t); 36 | 37 | void hmac_blake256_final(hmac_state *, uint8_t *); 38 | void hmac_blake224_final(hmac_state *, uint8_t *); 39 | 40 | void hmac_blake256_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 41 | void hmac_blake224_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 42 | 43 | #endif /* _BLAKE256_H_ */ 44 | -------------------------------------------------------------------------------- /algo/luffa.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "sha3/sph_luffa.h" 9 | 10 | void luffahash(void *output, const void *input) 11 | { 12 | unsigned char _ALIGN(128) hash[64]; 13 | sph_luffa512_context ctx_luffa; 14 | 15 | sph_luffa512_init(&ctx_luffa); 16 | sph_luffa512 (&ctx_luffa, input, 80); 17 | sph_luffa512_close(&ctx_luffa, (void*) hash); 18 | 19 | memcpy(output, hash, 32); 20 | } 21 | 22 | int scanhash_luffa(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 23 | { 24 | uint32_t _ALIGN(128) hash32[8]; 25 | uint32_t _ALIGN(128) endiandata[20]; 26 | uint32_t *pdata = work->data; 27 | uint32_t *ptarget = work->target; 28 | 29 | const uint32_t Htarg = ptarget[7]; 30 | const uint32_t first_nonce = pdata[19]; 31 | 32 | uint32_t n = first_nonce; 33 | 34 | for (int i=0; i < 19; i++) { 35 | be32enc(&endiandata[i], pdata[i]); 36 | } 37 | 38 | do { 39 | be32enc(&endiandata[19], n); 40 | luffahash(hash32, endiandata); 41 | if (hash32[7] < Htarg && fulltest(hash32, ptarget)) { 42 | work_set_target_ratio(work, hash32); 43 | *hashes_done = n - first_nonce + 1; 44 | pdata[19] = n; 45 | return true; 46 | } 47 | n++; 48 | 49 | } while (n < max_nonce && !work_restart[thr_id].restart); 50 | 51 | *hashes_done = n - first_nonce + 1; 52 | pdata[19] = n; 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /crypto/cpu-features.h: -------------------------------------------------------------------------------- 1 | #ifndef CPU_FEATURES_H 2 | #define CPU_FEATURES_H 3 | 4 | #include 5 | 6 | typedef struct cpu_features_t 7 | { 8 | // Misc. 9 | bool HW_MMX; 10 | bool HW_x64; 11 | bool HW_ABM; // Advanced Bit Manipulation 12 | bool HW_RDRAND; 13 | bool HW_BMI1; 14 | bool HW_BMI2; 15 | bool HW_ADX; 16 | bool HW_PREFETCHWT1; 17 | 18 | // SIMD: 128-bit 19 | bool HW_SSE; 20 | bool HW_SSE2; 21 | bool HW_SSE3; 22 | bool HW_SSSE3; 23 | bool HW_SSE41; 24 | bool HW_SSE42; 25 | bool HW_SSE4a; 26 | bool HW_AES; 27 | bool HW_SHA; 28 | 29 | // SIMD: 256-bit 30 | bool HW_AVX; 31 | bool HW_XOP; 32 | bool HW_FMA3; 33 | bool HW_FMA4; 34 | bool HW_AVX2; 35 | 36 | // SIMD: 512-bit 37 | bool HW_AVX512F; // AVX512 Foundation 38 | bool HW_AVX512CD; // AVX512 Conflict Detection 39 | bool HW_AVX512PF; // AVX512 Prefetch 40 | bool HW_AVX512ER; // AVX512 Exponential + Reciprocal 41 | bool HW_AVX512VL; // AVX512 Vector Length Extensions 42 | bool HW_AVX512BW; // AVX512 Byte + Word 43 | bool HW_AVX512DQ; // AVX512 Doubleword + Quadword 44 | bool HW_AVX512IFMA; // AVX512 Integer 52-bit Fused Multiply-Add 45 | bool HW_AVX512VBMI; // AVX512 Vector Byte Manipulation Instructions 46 | } cpu_features_t; 47 | 48 | void get_cpu_features(cpu_features_t *f); 49 | 50 | #endif // CPU_FEATURES_H 51 | -------------------------------------------------------------------------------- /algo/bmw512.c: -------------------------------------------------------------------------------- 1 | /** 2 | * bmw512 algorithm implementation 3 | * by maribun20@github 4 | */ 5 | 6 | #include "miner.h" 7 | 8 | #include 9 | #include 10 | 11 | #include "sha3/sph_bmw.h" 12 | 13 | void bmw512_hash(void *output, const void *input) 14 | { 15 | uint32_t hash[32]; 16 | sph_bmw512_context ctx; 17 | 18 | sph_bmw512_init(&ctx); 19 | sph_bmw512(&ctx, input, 80); 20 | sph_bmw512_close(&ctx, hash); 21 | 22 | memcpy(output, hash, 32); 23 | } 24 | 25 | int scanhash_bmw512(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 26 | { 27 | uint32_t _ALIGN(128) hash64[8]; 28 | uint32_t _ALIGN(128) endiandata[32]; 29 | uint32_t *pdata = work->data; 30 | uint32_t *ptarget = work->target; 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 i=0; i < 19; i++) { 38 | be32enc(&endiandata[i], pdata[i]); 39 | }; 40 | 41 | do { 42 | pdata[19] = ++n; 43 | be32enc(&endiandata[19], n); 44 | bmw512_hash(hash64, endiandata); 45 | if (((hash64[7]&0xFFFFFF00)==0) && fulltest(hash64, ptarget)) { 46 | work_set_target_ratio(work, hash64); 47 | *hashes_done = n - first_nonce + 1; 48 | pdata[19] = n; 49 | return 1; 50 | } 51 | n++; 52 | 53 | } while (n < max_nonce && !work_restart[thr_id].restart); 54 | 55 | *hashes_done = n - first_nonce + 1; 56 | pdata[19] = n; 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /algo/skein2.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "sha3/sph_skein.h" 7 | 8 | void skein2hash(void *output, const void *input) 9 | { 10 | uint32_t _ALIGN(128) hash[16]; 11 | 12 | sph_skein512_context ctx_skein; 13 | 14 | sph_skein512_init(&ctx_skein); 15 | sph_skein512(&ctx_skein, input, 80); 16 | sph_skein512_close(&ctx_skein, hash); 17 | 18 | sph_skein512_init(&ctx_skein); 19 | sph_skein512(&ctx_skein, hash, 64); 20 | sph_skein512_close(&ctx_skein, hash); 21 | 22 | memcpy(output, hash, 32); 23 | } 24 | 25 | int scanhash_skein2(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 26 | { 27 | uint32_t _ALIGN(128) hash32[8]; 28 | uint32_t _ALIGN(128) endiandata[20]; 29 | uint32_t *pdata = work->data; 30 | uint32_t *ptarget = work->target; 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 i=0; i < 19; i++) { 38 | be32enc(&endiandata[i], pdata[i]); 39 | } 40 | 41 | do { 42 | be32enc(&endiandata[19], n); 43 | skein2hash(hash32, endiandata); 44 | if (hash32[7] < Htarg && fulltest(hash32, ptarget)) { 45 | work_set_target_ratio(work, hash32); 46 | *hashes_done = n - first_nonce + 1; 47 | pdata[19] = n; 48 | return true; 49 | } 50 | n++; 51 | 52 | } while (n < max_nonce && !work_restart[thr_id].restart); 53 | 54 | *hashes_done = n - first_nonce + 1; 55 | pdata[19] = n; 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /compat/curl-for-windows/curl/include/curl/stdcheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDC_HEADERS_H 2 | #define __STDC_HEADERS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | 27 | size_t fread (void *, size_t, size_t, FILE *); 28 | size_t fwrite (const void *, size_t, size_t, FILE *); 29 | 30 | int strcasecmp(const char *, const char *); 31 | int strncasecmp(const char *, const char *, size_t); 32 | 33 | #endif /* __STDC_HEADERS_H */ 34 | -------------------------------------------------------------------------------- /algo/skein.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include "sha3/sph_skein.h" 9 | 10 | void skeinhash(void *state, const void *input) 11 | { 12 | sph_skein512_context ctx_skein; 13 | SHA256_CTX sha256; 14 | 15 | uint32_t hash[16]; 16 | 17 | sph_skein512_init(&ctx_skein); 18 | sph_skein512(&ctx_skein, input, 80); 19 | sph_skein512_close(&ctx_skein, hash); 20 | 21 | SHA256_Init(&sha256); 22 | SHA256_Update(&sha256, hash, 64); 23 | SHA256_Final((unsigned char*) hash, &sha256); 24 | 25 | memcpy(state, hash, 32); 26 | } 27 | 28 | int scanhash_skein(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 29 | { 30 | uint32_t _ALIGN(128) hash32[8]; 31 | uint32_t _ALIGN(128) endiandata[20]; 32 | uint32_t *pdata = work->data; 33 | uint32_t *ptarget = work->target; 34 | 35 | const uint32_t Htarg = ptarget[7]; 36 | const uint32_t first_nonce = pdata[19]; 37 | 38 | uint32_t n = first_nonce; 39 | 40 | for (int i=0; i < 19; i++) { 41 | be32enc(&endiandata[i], pdata[i]); 42 | }; 43 | 44 | do { 45 | be32enc(&endiandata[19], n); 46 | skeinhash(hash32, endiandata); 47 | if (hash32[7] < Htarg && fulltest(hash32, ptarget)) { 48 | work_set_target_ratio(work, hash32); 49 | *hashes_done = n - first_nonce + 1; 50 | pdata[19] = n; 51 | return true; 52 | } 53 | n++; 54 | 55 | } while (n < max_nonce && !work_restart[thr_id].restart); 56 | 57 | *hashes_done = n - first_nonce + 1; 58 | pdata[19] = n; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /algo/ink.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "sha3/sph_shavite.h" 7 | 8 | extern void inkhash(void *state, const void *input) 9 | { 10 | uint32_t _ALIGN(128) hash[16]; 11 | sph_shavite512_context ctx_shavite; 12 | 13 | sph_shavite512_init(&ctx_shavite); 14 | sph_shavite512 (&ctx_shavite, (const void*) input, 80); 15 | sph_shavite512_close(&ctx_shavite, (void*) hash); 16 | 17 | sph_shavite512_init(&ctx_shavite); 18 | sph_shavite512(&ctx_shavite, (const void*) hash, 64); 19 | sph_shavite512_close(&ctx_shavite, (void*) hash); 20 | 21 | memcpy(state, hash, 32); 22 | } 23 | 24 | int scanhash_ink(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 25 | { 26 | uint32_t _ALIGN(128) hash32[8]; 27 | uint32_t _ALIGN(128) endiandata[20]; 28 | uint32_t *pdata = work->data; 29 | uint32_t *ptarget = work->target; 30 | 31 | uint32_t n = pdata[19] - 1; 32 | const uint32_t first_nonce = pdata[19]; 33 | 34 | for (int k=0; k < 19; k++) 35 | be32enc(&endiandata[k], pdata[k]); 36 | 37 | const uint32_t Htarg = ptarget[7]; 38 | do { 39 | be32enc(&endiandata[19], n); 40 | inkhash(hash32, endiandata); 41 | 42 | if (hash32[7] <= Htarg && fulltest(hash32, ptarget)) { 43 | work_set_target_ratio(work, hash32); 44 | pdata[19] = n; 45 | *hashes_done = pdata[19] - first_nonce; 46 | return 1; 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 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /secp256k1/src/ecmult.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_ECMULT_H 8 | #define SECP256K1_ECMULT_H 9 | 10 | #include "num.h" 11 | #include "group.h" 12 | 13 | typedef struct { 14 | /* For accelerating the computation of a*P + b*G: */ 15 | secp256k1_ge_storage (*pre_g)[]; /* odd multiples of the generator */ 16 | #ifdef USE_ENDOMORPHISM 17 | secp256k1_ge_storage (*pre_g_128)[]; /* odd multiples of 2^128*generator */ 18 | #endif 19 | } secp256k1_ecmult_context; 20 | 21 | static void secp256k1_ecmult_context_init(secp256k1_ecmult_context *ctx); 22 | static void secp256k1_ecmult_context_build(secp256k1_ecmult_context *ctx, const secp256k1_callback *cb); 23 | static void secp256k1_ecmult_context_clone(secp256k1_ecmult_context *dst, 24 | const secp256k1_ecmult_context *src, const secp256k1_callback *cb); 25 | static void secp256k1_ecmult_context_clear(secp256k1_ecmult_context *ctx); 26 | static int secp256k1_ecmult_context_is_built(const secp256k1_ecmult_context *ctx); 27 | 28 | /** Double multiply: R = na*A + ng*G */ 29 | static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng); 30 | 31 | #endif /* SECP256K1_ECMULT_H */ 32 | -------------------------------------------------------------------------------- /secp256k1/src/testrand.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_TESTRAND_H 8 | #define SECP256K1_TESTRAND_H 9 | 10 | #if defined HAVE_CONFIG_H 11 | #include "libsecp256k1-config.h" 12 | #endif 13 | 14 | /* A non-cryptographic RNG used only for test infrastructure. */ 15 | 16 | /** Seed the pseudorandom number generator for testing. */ 17 | SECP256K1_INLINE static void secp256k1_rand_seed(const unsigned char *seed16); 18 | 19 | /** Generate a pseudorandom number in the range [0..2**32-1]. */ 20 | static uint32_t secp256k1_rand32(void); 21 | 22 | /** Generate a pseudorandom number in the range [0..2**bits-1]. Bits must be 1 or 23 | * more. */ 24 | static uint32_t secp256k1_rand_bits(int bits); 25 | 26 | /** Generate a pseudorandom number in the range [0..range-1]. */ 27 | static uint32_t secp256k1_rand_int(uint32_t range); 28 | 29 | /** Generate a pseudorandom 32-byte array. */ 30 | static void secp256k1_rand256(unsigned char *b32); 31 | 32 | /** Generate a pseudorandom 32-byte array with long sequences of zero and one bits. */ 33 | static void secp256k1_rand256_test(unsigned char *b32); 34 | 35 | /** Generate pseudorandom bytes with long sequences of zero and one bits. */ 36 | static void secp256k1_rand_bytes_test(unsigned char *bytes, size_t len); 37 | 38 | #endif /* SECP256K1_TESTRAND_H */ 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cryptonote/crypto/c_groestl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /* 3 | #include "crypto_uint8.h" 4 | #include "crypto_uint32.h" 5 | #include "crypto_uint64.h" 6 | #include "crypto_hash.h" 7 | 8 | typedef crypto_uint8 uint8_t; 9 | typedef crypto_uint32 uint32_t; 10 | typedef crypto_uint64 uint64_t; 11 | */ 12 | #include 13 | #include "hash.h" 14 | 15 | /* some sizes (number of bytes) */ 16 | #define ROWS 8 17 | #define LENGTHFIELDLEN ROWS 18 | #define COLS512 8 19 | 20 | #define SIZE512 (ROWS*COLS512) 21 | 22 | #define ROUNDS512 10 23 | #define HASH_BIT_LEN 256 24 | 25 | #define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff)) 26 | 27 | 28 | #define li_32(h) 0x##h##u 29 | #define EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n))) 30 | #define u32BIG(a) \ 31 | ((ROTL32(a,8) & li_32(00FF00FF)) | \ 32 | (ROTL32(a,24) & li_32(FF00FF00))) 33 | 34 | 35 | /* NIST API begin */ 36 | typedef struct { 37 | uint32_t chaining[SIZE512/sizeof(uint32_t)]; /* actual state */ 38 | uint32_t block_counter1, 39 | block_counter2; /* message block counter(s) */ 40 | BitSequence buffer[SIZE512]; /* data buffer */ 41 | int buf_ptr; /* data buffer pointer */ 42 | int bits_in_last_byte; /* no. of message bits in last byte of 43 | data buffer */ 44 | } hashState; 45 | 46 | /*void Init(hashState*); 47 | void Update(hashState*, const BitSequence*, DataLength); 48 | void Final(hashState*, BitSequence*); */ 49 | void groestl(const BitSequence*, DataLength, BitSequence*); 50 | /* NIST API end */ 51 | 52 | /* 53 | int crypto_hash(unsigned char *out, 54 | const unsigned char *in, 55 | unsigned long long len); 56 | */ 57 | -------------------------------------------------------------------------------- /algo/groestl.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "sha3/sph_groestl.h" 9 | 10 | // static __thread sph_groestl512_context ctx; 11 | 12 | void groestlhash(void *output, const void *input) 13 | { 14 | uint32_t _ALIGN(32) hash[16]; 15 | sph_groestl512_context ctx; 16 | 17 | // memset(&hash[0], 0, sizeof(hash)); 18 | 19 | sph_groestl512_init(&ctx); 20 | sph_groestl512(&ctx, input, 80); 21 | sph_groestl512_close(&ctx, hash); 22 | 23 | //sph_groestl512_init(&ctx); 24 | sph_groestl512(&ctx, hash, 64); 25 | sph_groestl512_close(&ctx, hash); 26 | 27 | memcpy(output, hash, 32); 28 | } 29 | 30 | int scanhash_groestl(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 31 | { 32 | uint32_t _ALIGN(128) hash[8]; 33 | uint32_t _ALIGN(128) endiandata[20]; 34 | uint32_t *pdata = work->data; 35 | uint32_t *ptarget = work->target; 36 | 37 | const uint32_t Htarg = ptarget[7]; 38 | const uint32_t first_nonce = pdata[19]; 39 | uint32_t nonce = first_nonce; 40 | 41 | if (opt_benchmark) 42 | ptarget[7] = 0x00ff; 43 | 44 | for (int k=0; k < 19; k++) 45 | be32enc(&endiandata[k], pdata[k]); 46 | 47 | do { 48 | be32enc(&endiandata[19], nonce); 49 | groestlhash(hash, endiandata); 50 | 51 | if (hash[7] <= Htarg && fulltest(hash, ptarget)) { 52 | work_set_target_ratio(work, hash); 53 | pdata[19] = nonce; 54 | *hashes_done = pdata[19] - first_nonce; 55 | return 1; 56 | } 57 | nonce++; 58 | 59 | } while (nonce < max_nonce && !work_restart[thr_id].restart); 60 | 61 | pdata[19] = nonce; 62 | *hashes_done = pdata[19] - first_nonce + 1; 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /scryptjane/scrypt-jane-mix_chacha.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_CHACHA_INCLUDED) 2 | 3 | #undef SCRYPT_MIX 4 | #define SCRYPT_MIX "ChaCha20/8 Ref" 5 | 6 | #undef SCRYPT_CHACHA_INCLUDED 7 | #define SCRYPT_CHACHA_INCLUDED 8 | #define SCRYPT_CHACHA_BASIC 9 | 10 | static void 11 | chacha_core_basic(uint32_t state[16]) { 12 | size_t rounds = 8; 13 | uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,t; 14 | 15 | x0 = state[0]; 16 | x1 = state[1]; 17 | x2 = state[2]; 18 | x3 = state[3]; 19 | x4 = state[4]; 20 | x5 = state[5]; 21 | x6 = state[6]; 22 | x7 = state[7]; 23 | x8 = state[8]; 24 | x9 = state[9]; 25 | x10 = state[10]; 26 | x11 = state[11]; 27 | x12 = state[12]; 28 | x13 = state[13]; 29 | x14 = state[14]; 30 | x15 = state[15]; 31 | 32 | #define quarter(a,b,c,d) \ 33 | a += b; t = d^a; d = ROTL32(t,16); \ 34 | c += d; t = b^c; b = ROTL32(t,12); \ 35 | a += b; t = d^a; d = ROTL32(t, 8); \ 36 | c += d; t = b^c; b = ROTL32(t, 7); 37 | 38 | for (; rounds; rounds -= 2) { 39 | quarter( x0, x4, x8,x12) 40 | quarter( x1, x5, x9,x13) 41 | quarter( x2, x6,x10,x14) 42 | quarter( x3, x7,x11,x15) 43 | quarter( x0, x5,x10,x15) 44 | quarter( x1, x6,x11,x12) 45 | quarter( x2, x7, x8,x13) 46 | quarter( x3, x4, x9,x14) 47 | } 48 | 49 | state[0] += x0; 50 | state[1] += x1; 51 | state[2] += x2; 52 | state[3] += x3; 53 | state[4] += x4; 54 | state[5] += x5; 55 | state[6] += x6; 56 | state[7] += x7; 57 | state[8] += x8; 58 | state[9] += x9; 59 | state[10] += x10; 60 | state[11] += x11; 61 | state[12] += x12; 62 | state[13] += x13; 63 | state[14] += x14; 64 | state[15] += x15; 65 | 66 | #undef quarter 67 | } 68 | 69 | #endif -------------------------------------------------------------------------------- /scryptjane/scrypt-jane-mix_salsa.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA_INCLUDED) 2 | 3 | #undef SCRYPT_MIX 4 | #define SCRYPT_MIX "Salsa20/8 Ref" 5 | 6 | #undef SCRYPT_SALSA_INCLUDED 7 | #define SCRYPT_SALSA_INCLUDED 8 | #define SCRYPT_SALSA_BASIC 9 | 10 | static void 11 | salsa_core_basic(uint32_t state[16]) { 12 | size_t rounds = 8; 13 | uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,t; 14 | 15 | x0 = state[0]; 16 | x1 = state[1]; 17 | x2 = state[2]; 18 | x3 = state[3]; 19 | x4 = state[4]; 20 | x5 = state[5]; 21 | x6 = state[6]; 22 | x7 = state[7]; 23 | x8 = state[8]; 24 | x9 = state[9]; 25 | x10 = state[10]; 26 | x11 = state[11]; 27 | x12 = state[12]; 28 | x13 = state[13]; 29 | x14 = state[14]; 30 | x15 = state[15]; 31 | 32 | #define quarter(a,b,c,d) \ 33 | t = a+d; t = ROTL32(t, 7); b ^= t; \ 34 | t = b+a; t = ROTL32(t, 9); c ^= t; \ 35 | t = c+b; t = ROTL32(t, 13); d ^= t; \ 36 | t = d+c; t = ROTL32(t, 18); a ^= t; \ 37 | 38 | for (; rounds; rounds -= 2) { 39 | quarter( x0, x4, x8,x12) 40 | quarter( x5, x9,x13, x1) 41 | quarter(x10,x14, x2, x6) 42 | quarter(x15, x3, x7,x11) 43 | quarter( x0, x1, x2, x3) 44 | quarter( x5, x6, x7, x4) 45 | quarter(x10,x11, x8, x9) 46 | quarter(x15,x12,x13,x14) 47 | } 48 | 49 | state[0] += x0; 50 | state[1] += x1; 51 | state[2] += x2; 52 | state[3] += x3; 53 | state[4] += x4; 54 | state[5] += x5; 55 | state[6] += x6; 56 | state[7] += x7; 57 | state[8] += x8; 58 | state[9] += x9; 59 | state[10] += x10; 60 | state[11] += x11; 61 | state[12] += x12; 62 | state[13] += x13; 63 | state[14] += x14; 64 | state[15] += x15; 65 | 66 | #undef quarter 67 | } 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /algo/myr-groestl.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "sha3/sph_groestl.h" 9 | #include "sha3/sph_sha2.h" 10 | 11 | void myriadhash(void *output, const void *input) 12 | { 13 | uint32_t _ALIGN(32) hash[16]; 14 | sph_groestl512_context ctx; 15 | sph_sha256_context sha_ctx; 16 | 17 | // memset(&hash[0], 0, sizeof(hash)); 18 | 19 | sph_groestl512_init(&ctx); 20 | sph_groestl512(&ctx, input, 80); 21 | sph_groestl512_close(&ctx, hash); 22 | 23 | sph_sha256_init(&sha_ctx); 24 | sph_sha256(&sha_ctx, hash, 64); 25 | sph_sha256_close(&sha_ctx, hash); 26 | 27 | memcpy(output, hash, 32); 28 | } 29 | 30 | int scanhash_myriad(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 31 | { 32 | uint32_t _ALIGN(128) hash[8]; 33 | uint32_t _ALIGN(128) endiandata[20]; 34 | uint32_t *pdata = work->data; 35 | uint32_t *ptarget = work->target; 36 | 37 | const uint32_t Htarg = ptarget[7]; 38 | const uint32_t first_nonce = pdata[19]; 39 | uint32_t nonce = first_nonce; 40 | 41 | if (opt_benchmark) 42 | ptarget[7] = 0x0000ff; 43 | 44 | for (int i=0; i < 19; i++) { 45 | be32enc(&endiandata[i], pdata[i]); 46 | } 47 | 48 | do { 49 | be32enc(&endiandata[19], nonce); 50 | myriadhash(hash, endiandata); 51 | 52 | if (hash[7] <= Htarg && fulltest(hash, ptarget)) { 53 | work_set_target_ratio(work, hash); 54 | pdata[19] = nonce; 55 | *hashes_done = pdata[19] - first_nonce; 56 | return 1; 57 | } 58 | nonce++; 59 | 60 | } while (nonce < max_nonce && !work_restart[thr_id].restart); 61 | 62 | pdata[19] = nonce; 63 | *hashes_done = pdata[19] - first_nonce + 1; 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /crypto/c_groestl.h: -------------------------------------------------------------------------------- 1 | #ifndef __hash_h 2 | #define __hash_h 3 | /* 4 | #include "crypto_uint8.h" 5 | #include "crypto_uint32.h" 6 | #include "crypto_uint64.h" 7 | #include "crypto_hash.h" 8 | 9 | typedef crypto_uint8 uint8_t; 10 | typedef crypto_uint32 uint32_t; 11 | typedef crypto_uint64 uint64_t; 12 | */ 13 | #include 14 | 15 | #include "hash.h" 16 | 17 | /* some sizes (number of bytes) */ 18 | #define ROWS 8 19 | #define LENGTHFIELDLEN ROWS 20 | #define COLS512 8 21 | 22 | #define SIZE512 (ROWS*COLS512) 23 | 24 | #define ROUNDS512 10 25 | #define HASH_BIT_LEN 256 26 | 27 | #define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff)) 28 | 29 | 30 | #define li_32(h) 0x##h##u 31 | #define EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n))) 32 | #define u32BIG(a) \ 33 | ((ROTL32(a,8) & li_32(00FF00FF)) | \ 34 | (ROTL32(a,24) & li_32(FF00FF00))) 35 | 36 | 37 | /* NIST API begin */ 38 | typedef struct { 39 | uint32_t chaining[SIZE512/sizeof(uint32_t)]; /* actual state */ 40 | uint32_t block_counter1, 41 | block_counter2; /* message block counter(s) */ 42 | BitSequence buffer[SIZE512]; /* data buffer */ 43 | int buf_ptr; /* data buffer pointer */ 44 | int bits_in_last_byte; /* no. of message bits in last byte of 45 | data buffer */ 46 | } groestlHashState; 47 | 48 | /*void Init(hashState*); 49 | void Update(hashState*, const BitSequence*, DataLength); 50 | void Final(hashState*, BitSequence*); */ 51 | void groestl(const BitSequence*, DataLength, BitSequence*); 52 | /* NIST API end */ 53 | 54 | /* 55 | int crypto_hash(unsigned char *out, 56 | const unsigned char *in, 57 | unsigned long long len); 58 | */ 59 | 60 | #endif /* __hash_h */ 61 | -------------------------------------------------------------------------------- /secp256k1/src/java/org/bitcoin/NativeSecp256k1Util.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the libsecp256k1 contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.bitcoin; 18 | 19 | public class NativeSecp256k1Util{ 20 | 21 | public static void assertEquals( int val, int val2, String message ) throws AssertFailException{ 22 | if( val != val2 ) 23 | throw new AssertFailException("FAIL: " + message); 24 | } 25 | 26 | public static void assertEquals( boolean val, boolean val2, String message ) throws AssertFailException{ 27 | if( val != val2 ) 28 | throw new AssertFailException("FAIL: " + message); 29 | else 30 | System.out.println("PASS: " + message); 31 | } 32 | 33 | public static void assertEquals( String val, String val2, String message ) throws AssertFailException{ 34 | if( !val.equals(val2) ) 35 | throw new AssertFailException("FAIL: " + message); 36 | else 37 | System.out.println("PASS: " + message); 38 | } 39 | 40 | public static class AssertFailException extends Exception { 41 | public AssertFailException(String message) { 42 | super( message ); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cryptonote/crypto/hash-ops.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2013 The Cryptonote developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #pragma once 6 | 7 | #if !defined(__cplusplus) 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "int-util.h" 15 | 16 | static inline void *padd(void *p, size_t i) { 17 | return (char *) p + i; 18 | } 19 | 20 | static inline const void *cpadd(const void *p, size_t i) { 21 | return (const char *) p + i; 22 | } 23 | 24 | static inline void place_length(uint8_t *buffer, size_t bufsize, size_t length) { 25 | if (sizeof(size_t) == 4) { 26 | *(uint32_t *) padd(buffer, bufsize - 4) = swap32be(length); 27 | } else { 28 | *(uint64_t *) padd(buffer, bufsize - 8) = swap64be(length); 29 | } 30 | } 31 | 32 | #pragma pack(push, 1) 33 | union hash_state { 34 | uint8_t b[200]; 35 | uint64_t w[25]; 36 | }; 37 | #pragma pack(pop) 38 | 39 | void hash_permutation(union hash_state *state); 40 | void hash_process(union hash_state *state, const uint8_t *buf, size_t count); 41 | 42 | #endif 43 | 44 | enum { 45 | HASH_SIZE = 32, 46 | HASH_DATA_AREA = 136 47 | }; 48 | 49 | void cn_fast_hash(const void *data, size_t length, char *hash); 50 | void cn_slow_hash(const void *data, size_t length, char *hash); 51 | 52 | void hash_extra_blake(const void *data, size_t length, char *hash); 53 | void hash_extra_groestl(const void *data, size_t length, char *hash); 54 | void hash_extra_jh(const void *data, size_t length, char *hash); 55 | void hash_extra_skein(const void *data, size_t length, char *hash); 56 | 57 | void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash); 58 | -------------------------------------------------------------------------------- /crypto/hash-ops.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2013 The Cryptonote developers 2 | // Distributed under the MIT/X11 software license, see the accompanying 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #pragma once 6 | 7 | #if !defined(__cplusplus) 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "int-util.h" 15 | 16 | #if 0 17 | static inline void *padd(void *p, size_t i) { 18 | return (char *) p + i; 19 | } 20 | 21 | static inline const void *cpadd(const void *p, size_t i) { 22 | return (const char *) p + i; 23 | } 24 | 25 | static inline void place_length(uint8_t *buffer, size_t bufsize, size_t length) { 26 | if (sizeof(size_t) == 4) { 27 | *(uint32_t*) padd(buffer, bufsize - 4) = swap32be(length); 28 | } else { 29 | *(uint64_t*) padd(buffer, bufsize - 8) = swap64be(length); 30 | } 31 | } 32 | #endif 33 | 34 | #pragma pack(push, 1) 35 | union hash_state { 36 | uint8_t b[200]; 37 | uint64_t w[25]; 38 | }; 39 | #pragma pack(pop) 40 | 41 | void hash_permutation(union hash_state *state); 42 | void hash_process(union hash_state *state, const uint8_t *buf, int count); 43 | 44 | #endif 45 | 46 | enum { 47 | HASH_SIZE = 32, 48 | HASH_DATA_AREA = 136 49 | }; 50 | 51 | void cn_fast_hash(const void *data, int len, char *hash); 52 | void cn_slow_hash(const void *data, size_t length, char *hash); 53 | 54 | void hash_extra_blake(const void *data, size_t length, char *hash); 55 | void hash_extra_groestl(const void *data, size_t length, char *hash); 56 | void hash_extra_jh(const void *data, size_t length, char *hash); 57 | void hash_extra_skein(const void *data, size_t length, char *hash); 58 | 59 | void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash); 60 | -------------------------------------------------------------------------------- /secp256k1/src/java/org/bitcoin/Secp256k1Context.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 the libsecp256k1 contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.bitcoin; 18 | 19 | /** 20 | * This class holds the context reference used in native methods 21 | * to handle ECDSA operations. 22 | */ 23 | public class Secp256k1Context { 24 | private static final boolean enabled; //true if the library is loaded 25 | private static final long context; //ref to pointer to context obj 26 | 27 | static { //static initializer 28 | boolean isEnabled = true; 29 | long contextRef = -1; 30 | try { 31 | System.loadLibrary("secp256k1"); 32 | contextRef = secp256k1_init_context(); 33 | } catch (UnsatisfiedLinkError e) { 34 | System.out.println("UnsatisfiedLinkError: " + e.toString()); 35 | isEnabled = false; 36 | } 37 | enabled = isEnabled; 38 | context = contextRef; 39 | } 40 | 41 | public static boolean isEnabled() { 42 | return enabled; 43 | } 44 | 45 | public static long getContext() { 46 | if(!enabled) return -1; //sanity check 47 | return context; 48 | } 49 | 50 | private static native long secp256k1_init_context(); 51 | } 52 | -------------------------------------------------------------------------------- /scryptjane/scrypt-jane-hash.h: -------------------------------------------------------------------------------- 1 | #if defined(SCRYPT_BLAKE512) 2 | #include "scrypt-jane-hash_blake512.h" 3 | #elif defined(SCRYPT_BLAKE256) 4 | #include "scrypt-jane-hash_blake256.h" 5 | #elif defined(SCRYPT_SHA512) 6 | #include "scrypt-jane-hash_sha512.h" 7 | #elif defined(SCRYPT_SHA256) 8 | #include "scrypt-jane-hash_sha256.h" 9 | #elif defined(SCRYPT_SKEIN512) 10 | #include "scrypt-jane-hash_skein512.h" 11 | #elif defined(SCRYPT_KECCAK512) || defined(SCRYPT_KECCAK256) 12 | #include "scrypt-jane-hash_keccak.h" 13 | #else 14 | #define SCRYPT_HASH "ERROR" 15 | #define SCRYPT_HASH_BLOCK_SIZE 64 16 | #define SCRYPT_HASH_DIGEST_SIZE 64 17 | typedef struct scrypt_hash_state_t { size_t dummy; } scrypt_hash_state; 18 | typedef uint8_t scrypt_hash_digest[SCRYPT_HASH_DIGEST_SIZE]; 19 | static void scrypt_hash_init(scrypt_hash_state *S) {} 20 | static void scrypt_hash_update(scrypt_hash_state *S, const uint8_t *in, size_t inlen) {} 21 | static void scrypt_hash_finish(scrypt_hash_state *S, uint8_t *hash) {} 22 | static const uint8_t scrypt_test_hash_expected[SCRYPT_HASH_DIGEST_SIZE] = {0}; 23 | #error must define a hash function! 24 | #endif 25 | 26 | #include "scrypt-jane-pbkdf2.h" 27 | 28 | #define SCRYPT_TEST_HASH_LEN 257 /* (2 * largest block size) + 1 */ 29 | 30 | static int 31 | scrypt_test_hash() { 32 | scrypt_hash_state st; 33 | scrypt_hash_digest hash, final; 34 | uint8_t msg[SCRYPT_TEST_HASH_LEN]; 35 | size_t i; 36 | 37 | for (i = 0; i < SCRYPT_TEST_HASH_LEN; i++) 38 | msg[i] = (uint8_t)i; 39 | 40 | scrypt_hash_init(&st); 41 | for (i = 0; i < SCRYPT_TEST_HASH_LEN + 1; i++) { 42 | scrypt_hash(hash, msg, i); 43 | scrypt_hash_update(&st, hash, sizeof(hash)); 44 | } 45 | scrypt_hash_finish(&st, final); 46 | return scrypt_verify(final, scrypt_test_hash_expected, SCRYPT_HASH_DIGEST_SIZE); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /secp256k1/src/bench_sign.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #include "include/secp256k1.h" 8 | #include "util.h" 9 | #include "bench.h" 10 | 11 | typedef struct { 12 | secp256k1_context* ctx; 13 | unsigned char msg[32]; 14 | unsigned char key[32]; 15 | } bench_sign_t; 16 | 17 | static void bench_sign_setup(void* arg) { 18 | int i; 19 | bench_sign_t *data = (bench_sign_t*)arg; 20 | 21 | for (i = 0; i < 32; i++) { 22 | data->msg[i] = i + 1; 23 | } 24 | for (i = 0; i < 32; i++) { 25 | data->key[i] = i + 65; 26 | } 27 | } 28 | 29 | static void bench_sign(void* arg) { 30 | int i; 31 | bench_sign_t *data = (bench_sign_t*)arg; 32 | 33 | unsigned char sig[74]; 34 | for (i = 0; i < 20000; i++) { 35 | size_t siglen = 74; 36 | int j; 37 | secp256k1_ecdsa_signature signature; 38 | CHECK(secp256k1_ecdsa_sign(data->ctx, &signature, data->msg, data->key, NULL, NULL)); 39 | CHECK(secp256k1_ecdsa_signature_serialize_der(data->ctx, sig, &siglen, &signature)); 40 | for (j = 0; j < 32; j++) { 41 | data->msg[j] = sig[j]; 42 | data->key[j] = sig[j + 32]; 43 | } 44 | } 45 | } 46 | 47 | int main(void) { 48 | bench_sign_t data; 49 | 50 | data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); 51 | 52 | run_benchmark("ecdsa_sign", bench_sign, bench_sign_setup, NULL, &data, 10, 20000); 53 | 54 | secp256k1_context_destroy(data.ctx); 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /secp256k1/src/bench_ecdh.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #include 8 | 9 | #include "include/secp256k1.h" 10 | #include "include/secp256k1_ecdh.h" 11 | #include "util.h" 12 | #include "bench.h" 13 | 14 | typedef struct { 15 | secp256k1_context *ctx; 16 | secp256k1_pubkey point; 17 | unsigned char scalar[32]; 18 | } bench_ecdh_t; 19 | 20 | static void bench_ecdh_setup(void* arg) { 21 | int i; 22 | bench_ecdh_t *data = (bench_ecdh_t*)arg; 23 | const unsigned char point[] = { 24 | 0x03, 25 | 0x54, 0x94, 0xc1, 0x5d, 0x32, 0x09, 0x97, 0x06, 26 | 0xc2, 0x39, 0x5f, 0x94, 0x34, 0x87, 0x45, 0xfd, 27 | 0x75, 0x7c, 0xe3, 0x0e, 0x4e, 0x8c, 0x90, 0xfb, 28 | 0xa2, 0xba, 0xd1, 0x84, 0xf8, 0x83, 0xc6, 0x9f 29 | }; 30 | 31 | /* create a context with no capabilities */ 32 | data->ctx = secp256k1_context_create(SECP256K1_FLAGS_TYPE_CONTEXT); 33 | for (i = 0; i < 32; i++) { 34 | data->scalar[i] = i + 1; 35 | } 36 | CHECK(secp256k1_ec_pubkey_parse(data->ctx, &data->point, point, sizeof(point)) == 1); 37 | } 38 | 39 | static void bench_ecdh(void* arg) { 40 | int i; 41 | unsigned char res[32]; 42 | bench_ecdh_t *data = (bench_ecdh_t*)arg; 43 | 44 | for (i = 0; i < 20000; i++) { 45 | CHECK(secp256k1_ecdh(data->ctx, res, &data->point, data->scalar) == 1); 46 | } 47 | } 48 | 49 | int main(void) { 50 | bench_ecdh_t data; 51 | 52 | run_benchmark("ecdh", bench_ecdh, bench_ecdh_setup, NULL, &data, 10, 20000); 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /secp256k1/src/hash.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_HASH_H 8 | #define SECP256K1_HASH_H 9 | 10 | #include 11 | #include 12 | 13 | typedef struct { 14 | uint32_t s[8]; 15 | uint32_t buf[16]; /* In big endian */ 16 | size_t bytes; 17 | } secp256k1_sha256_t; 18 | 19 | static void secp256k1_sha256_initialize(secp256k1_sha256_t *hash); 20 | static void secp256k1_sha256_write(secp256k1_sha256_t *hash, const unsigned char *data, size_t size); 21 | static void secp256k1_sha256_finalize(secp256k1_sha256_t *hash, unsigned char *out32); 22 | 23 | typedef struct { 24 | secp256k1_sha256_t inner, outer; 25 | } secp256k1_hmac_sha256_t; 26 | 27 | static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256_t *hash, const unsigned char *key, size_t size); 28 | static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256_t *hash, const unsigned char *data, size_t size); 29 | static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256_t *hash, unsigned char *out32); 30 | 31 | typedef struct { 32 | unsigned char v[32]; 33 | unsigned char k[32]; 34 | int retry; 35 | } secp256k1_rfc6979_hmac_sha256_t; 36 | 37 | static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256_t *rng, const unsigned char *key, size_t keylen); 38 | static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256_t *rng, unsigned char *out, size_t outlen); 39 | static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256_t *rng); 40 | 41 | #endif /* SECP256K1_HASH_H */ 42 | -------------------------------------------------------------------------------- /algo/blake.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include "sha3/sph_blake.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | static __thread sph_blake256_context blake_mid; 10 | static __thread bool ctx_midstate_done = false; 11 | 12 | void blakehash(void *state, const void *input) 13 | { 14 | sph_blake256_context ctx; 15 | 16 | uint8_t *ending = (uint8_t*) input; 17 | ending += 64; 18 | 19 | // do one memcopy to get a fresh context 20 | if (!ctx_midstate_done) { 21 | sph_blake256_init(&blake_mid); 22 | sph_blake256(&blake_mid, input, 64); 23 | ctx_midstate_done = true; 24 | } 25 | memcpy(&ctx, &blake_mid, sizeof(blake_mid)); 26 | 27 | sph_blake256(&ctx, ending, 16); 28 | sph_blake256_close(&ctx, state); 29 | } 30 | 31 | int scanhash_blake(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 32 | { 33 | uint32_t _ALIGN(128) hash32[8]; 34 | uint32_t _ALIGN(128) endiandata[20]; 35 | uint32_t *pdata = work->data; 36 | uint32_t *ptarget = work->target; 37 | 38 | const uint32_t first_nonce = pdata[19]; 39 | const uint32_t HTarget = opt_benchmark ? 0x7f : ptarget[7]; 40 | 41 | uint32_t n = first_nonce; 42 | 43 | ctx_midstate_done = false; 44 | 45 | // we need big endian data... 46 | for (int kk=0; kk < 19; kk++) { 47 | be32enc(&endiandata[kk], pdata[kk]); 48 | } 49 | 50 | #ifdef DEBUG_ALGO 51 | applog(LOG_DEBUG,"[%d] Target=%08x %08x", thr_id, ptarget[6], ptarget[7]); 52 | #endif 53 | 54 | do { 55 | be32enc(&endiandata[19], n); 56 | blakehash(hash32, endiandata); 57 | 58 | if (hash32[7] <= HTarget && fulltest(hash32, ptarget)) { 59 | work_set_target_ratio(work, hash32); 60 | *hashes_done = n - first_nonce + 1; 61 | return 1; 62 | } 63 | 64 | n++; pdata[19] = n; 65 | 66 | } while (n < max_nonce && !work_restart[thr_id].restart); 67 | 68 | *hashes_done = n - first_nonce + 1; 69 | pdata[19] = n; 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /api/websocket.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Simple WebSocket call sample 6 | 7 | 8 |
9 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /secp256k1/src/field_5x52.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_FIELD_REPR_H 8 | #define SECP256K1_FIELD_REPR_H 9 | 10 | #include 11 | 12 | typedef struct { 13 | /* X = sum(i=0..4, elem[i]*2^52) mod n */ 14 | uint64_t n[5]; 15 | #ifdef VERIFY 16 | int magnitude; 17 | int normalized; 18 | #endif 19 | } secp256k1_fe; 20 | 21 | /* Unpacks a constant into a overlapping multi-limbed FE element. */ 22 | #define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \ 23 | (d0) | (((uint64_t)(d1) & 0xFFFFFUL) << 32), \ 24 | ((uint64_t)(d1) >> 20) | (((uint64_t)(d2)) << 12) | (((uint64_t)(d3) & 0xFFUL) << 44), \ 25 | ((uint64_t)(d3) >> 8) | (((uint64_t)(d4) & 0xFFFFFFFUL) << 24), \ 26 | ((uint64_t)(d4) >> 28) | (((uint64_t)(d5)) << 4) | (((uint64_t)(d6) & 0xFFFFUL) << 36), \ 27 | ((uint64_t)(d6) >> 16) | (((uint64_t)(d7)) << 16) \ 28 | } 29 | 30 | #ifdef VERIFY 31 | #define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1} 32 | #else 33 | #define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))} 34 | #endif 35 | 36 | typedef struct { 37 | uint64_t n[4]; 38 | } secp256k1_fe_storage; 39 | 40 | #define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ \ 41 | (d0) | (((uint64_t)(d1)) << 32), \ 42 | (d2) | (((uint64_t)(d3)) << 32), \ 43 | (d4) | (((uint64_t)(d5)) << 32), \ 44 | (d6) | (((uint64_t)(d7)) << 32) \ 45 | }} 46 | 47 | #endif /* SECP256K1_FIELD_REPR_H */ 48 | -------------------------------------------------------------------------------- /res/banner.h: -------------------------------------------------------------------------------- 1 | static void show_credits() 2 | { 3 | printf(CL_LGR" ##### #### # # ## ## ### ## # ##### #### \n"); 4 | printf(CL_LGR" # # # # # # # # # # # # # # # #\n"); 5 | printf(CL_LGR" # # # # # # # # # # # # # # # #\n"); 6 | printf(CL_LGR" # ##### # # # ## # # # # # ##### #####\n"); 7 | printf(CL_LGR" # # # # # # # # # # # # #\n"); 8 | printf(CL_LGR" # # # # # # # # # # # # #\n"); 9 | printf(CL_LGR" ##### # #### ## ## ### # ## ###### # ###\n"); 10 | printf("\n"); 11 | printf(CL_N" " CL_LYL2"++ MULTI ALGO ++" CL_N"\n"); 12 | printf("\n"); 13 | printf(CL_LCY" **"PACKAGE_NAME""CL_LYL" "PACKAGE_VERSION CL_LCY" by wong-fi-hung@github**\n"); 14 | printf(CL_LYL" Based Originaly from cpuminer-multi by tpruvot\n"); 15 | printf(CL_N"######################################################################\n\n"); 16 | printf(CL_LCY" Author "CL_LYL" : wong-fi-hung\n"); 17 | printf(CL_LCY" Telagram"CL_LYL" : @Aminudin1 (Wong Fi Hung)\n"); 18 | printf(CL_LCY" Youtube Channel"CL_LYL" : CHANNEL CRYPTO\n"); 19 | printf(CL_LCY" Git repo"CL_LYL" : https:" "/" "/" "github.com" "/" "wong-fi-hung" "/" "termux-miner\n"); 20 | printf(CL_LCY" Original git repo"CL_LYL" : https:" "/" "/" "github.com" "/" "tpruvot" "/" "cpuminer-multi\n"); 21 | printf(CL_LCY" DGB donation addr"CL_LYL" : DFnEipdeXYkUnvSby8pQ7jr8WJhQ4Rj9is (wong-fi-hung)\n"); 22 | printf(CL_LCY" BTC donation addr "CL_LYL" : 1FhDPLPpw18X4srecguG3MxJYe4a1JsZnd (tpruvot)\n"); 23 | printf(CL_N"######################################################################\n"); 24 | } 25 | -------------------------------------------------------------------------------- /cryptonote/crypto/c_skein.h: -------------------------------------------------------------------------------- 1 | #ifndef _SKEIN_H_ 2 | #define _SKEIN_H_ 1 3 | /************************************************************************** 4 | ** 5 | ** Interface declarations and internal definitions for Skein hashing. 6 | ** 7 | ** Source code author: Doug Whiting, 2008. 8 | ** 9 | ** This algorithm and source code is released to the public domain. 10 | ** 11 | *************************************************************************** 12 | ** 13 | ** The following compile-time switches may be defined to control some 14 | ** tradeoffs between speed, code size, error checking, and security. 15 | ** 16 | ** The "default" note explains what happens when the switch is not defined. 17 | ** 18 | ** SKEIN_DEBUG -- make callouts from inside Skein code 19 | ** to examine/display intermediate values. 20 | ** [default: no callouts (no overhead)] 21 | ** 22 | ** SKEIN_ERR_CHECK -- how error checking is handled inside Skein 23 | ** code. If not defined, most error checking 24 | ** is disabled (for performance). Otherwise, 25 | ** the switch value is interpreted as: 26 | ** 0: use assert() to flag errors 27 | ** 1: return SKEIN_FAIL to flag errors 28 | ** 29 | ***************************************************************************/ 30 | #include "skein_port.h" /* get platform-specific definitions */ 31 | #include "hash.h" 32 | 33 | typedef enum 34 | { 35 | SKEIN_SUCCESS = 0, /* return codes from Skein calls */ 36 | SKEIN_FAIL = 1, 37 | SKEIN_BAD_HASHLEN = 2 38 | } 39 | SkeinHashReturn; 40 | 41 | /* "all-in-one" call */ 42 | SkeinHashReturn c_skein_hash(int hashbitlen, const BitSequence *data, 43 | DataLength databitlen, BitSequence *hashval); 44 | 45 | #endif /* ifndef _SKEIN_H_ */ 46 | -------------------------------------------------------------------------------- /sha3/sph_fugue.h: -------------------------------------------------------------------------------- 1 | #ifndef SPH_FUGUE_H__ 2 | #define SPH_FUGUE_H__ 3 | 4 | #include 5 | #include "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 -------------------------------------------------------------------------------- /algo/yescrypt.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "yescrypt/yescrypt.h" 10 | 11 | int do_scanhash(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done, void (*hash_func)(const char *, char *, uint32_t)) 12 | { 13 | uint32_t _ALIGN(64) vhash[8]; 14 | uint32_t _ALIGN(64) endiandata[20]; 15 | uint32_t *pdata = work->data; 16 | uint32_t *ptarget = work->target; 17 | 18 | const uint32_t Htarg = ptarget[7]; 19 | const uint32_t first_nonce = pdata[19]; 20 | 21 | uint32_t n = first_nonce; 22 | 23 | for (int i=0; i < 19; i++) { 24 | be32enc(&endiandata[i], pdata[i]); 25 | } 26 | 27 | do { 28 | be32enc(&endiandata[19], n); 29 | hash_func((char*) endiandata, (char*) vhash, 80); 30 | if (vhash[7] < Htarg && fulltest(vhash, ptarget)) { 31 | work_set_target_ratio(work, vhash); 32 | *hashes_done = n - first_nonce + 1; 33 | pdata[19] = n; 34 | return true; 35 | } 36 | n++; 37 | 38 | } while (n < max_nonce && !work_restart[thr_id].restart); 39 | 40 | *hashes_done = n - first_nonce + 1; 41 | pdata[19] = n; 42 | 43 | return 0; 44 | } 45 | 46 | int scanhash_yescrypt(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 47 | { 48 | return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash)); 49 | } 50 | 51 | int scanhash_yescryptr8(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 52 | { 53 | return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash_r8)); 54 | } 55 | 56 | int scanhash_yescryptr16(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 57 | { 58 | return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash_r16)); 59 | } 60 | 61 | int scanhash_yescryptr32(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 62 | { 63 | return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash_r32)); 64 | } 65 | -------------------------------------------------------------------------------- /algo/power2b.c: -------------------------------------------------------------------------------- 1 | #include "cpuminer-config.h" 2 | #include "miner.h" 3 | 4 | #include "yespower-1.0.1-power2b/yespower-p2b.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | void power2b_hash( const char *input, char *output, uint32_t len ) 11 | { 12 | static const yespower_params_t v1 = {YESPOWER_1_0, 2048, 8, NULL, 0}; 13 | yespower_tls_p2b( (yespower_binary_t_p2b*)input, len, &v1, (yespower_binary_t_p2b*)output ); 14 | static yespower_params_t params = { 15 | .version = YESPOWER_1_0_BLAKE2B, 16 | .N = 2048, 17 | .r = 32, 18 | .pers = (const uint8_t *)"Now I am become Death, the destroyer of worlds", 19 | .perslen = 46 20 | }; 21 | yespower_tls_p2b( (yespower_binary_t_p2b*)input, len, ¶ms, (yespower_binary_t_p2b*)output ); 22 | } 23 | 24 | int scanhash_power2b( int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done ) 25 | { 26 | uint32_t _ALIGN(64) vhash[8]; 27 | uint32_t _ALIGN(64) endiandata[20]; 28 | uint32_t *pdata = work->data; 29 | uint32_t *ptarget = work->target; 30 | 31 | const uint32_t Htarg = ptarget[7]; 32 | const uint32_t first_nonce = pdata[19]; 33 | uint32_t n = first_nonce; 34 | 35 | for (int k = 0; k < 19; k++) 36 | be32enc(&endiandata[k], pdata[k]); 37 | 38 | do { 39 | be32enc(&endiandata[19], n); 40 | power2b_hash((char*) endiandata, (char*) vhash, 80); 41 | if (vhash[7] < Htarg && fulltest(vhash, ptarget)) { 42 | work_set_target_ratio( work, vhash ); 43 | *hashes_done = n - first_nonce + 1; 44 | pdata[19] = n; 45 | return true; 46 | } 47 | n++; 48 | } while (n < max_nonce && !work_restart[thr_id].restart); 49 | 50 | *hashes_done = n - first_nonce + 1; 51 | pdata[19] = n; 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /secp256k1/src/bench.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_BENCH_H 8 | #define SECP256K1_BENCH_H 9 | 10 | #include 11 | #include 12 | #include "sys/time.h" 13 | 14 | static double gettimedouble(void) { 15 | struct timeval tv; 16 | gettimeofday(&tv, NULL); 17 | return tv.tv_usec * 0.000001 + tv.tv_sec; 18 | } 19 | 20 | void print_number(double x) { 21 | double y = x; 22 | int c = 0; 23 | if (y < 0.0) { 24 | y = -y; 25 | } 26 | while (y > 0 && y < 100.0) { 27 | y *= 10.0; 28 | c++; 29 | } 30 | printf("%.*f", c, x); 31 | } 32 | 33 | void run_benchmark(char *name, void (*benchmark)(void*), void (*setup)(void*), void (*teardown)(void*), void* data, int count, int iter) { 34 | int i; 35 | double min = HUGE_VAL; 36 | double sum = 0.0; 37 | double max = 0.0; 38 | for (i = 0; i < count; i++) { 39 | double begin, total; 40 | if (setup != NULL) { 41 | setup(data); 42 | } 43 | begin = gettimedouble(); 44 | benchmark(data); 45 | total = gettimedouble() - begin; 46 | if (teardown != NULL) { 47 | teardown(data); 48 | } 49 | if (total < min) { 50 | min = total; 51 | } 52 | if (total > max) { 53 | max = total; 54 | } 55 | sum += total; 56 | } 57 | printf("%s: min ", name); 58 | print_number(min * 1000000.0 / iter); 59 | printf("us / avg "); 60 | print_number((sum / count) * 1000000.0 / iter); 61 | printf("us / max "); 62 | print_number(max * 1000000.0 / iter); 63 | printf("us\n"); 64 | } 65 | 66 | #endif /* SECP256K1_BENCH_H */ 67 | -------------------------------------------------------------------------------- /algo/axiom.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "sha3/sph_shabal.h" 7 | 8 | static __thread uint32_t _ALIGN(128) M[65536][8]; 9 | 10 | void axiomhash(void *output, const void *input) 11 | { 12 | sph_shabal256_context ctx; 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(128) 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(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 47 | { 48 | uint32_t _ALIGN(128) hash32[8]; 49 | uint32_t _ALIGN(128) endiandata[20]; 50 | uint32_t *pdata = work->data; 51 | uint32_t *ptarget = work->target; 52 | 53 | const uint32_t Htarg = ptarget[7]; 54 | const uint32_t first_nonce = pdata[19]; 55 | 56 | uint32_t n = first_nonce; 57 | 58 | for (int i=0; i < 19; i++) { 59 | be32enc(&endiandata[i], pdata[i]); 60 | } 61 | 62 | do { 63 | be32enc(&endiandata[19], n); 64 | axiomhash(hash32, endiandata); 65 | if (hash32[7] < Htarg && fulltest(hash32, ptarget)) { 66 | work_set_target_ratio(work, hash32); 67 | *hashes_done = n - first_nonce + 1; 68 | pdata[19] = n; 69 | return true; 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 | -------------------------------------------------------------------------------- /algo/lyra2v3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "sha3/sph_blake.h" 4 | #include "sha3/sph_cubehash.h" 5 | #include "sha3/sph_bmw.h" 6 | 7 | #include "lyra2/Lyra2.h" 8 | 9 | #include "miner.h" 10 | 11 | void lyra2v3_hash(void *state, const void *input) 12 | { 13 | uint32_t _ALIGN(128) hash[8], hashB[8]; 14 | 15 | sph_blake256_context ctx_blake; 16 | sph_cubehash256_context ctx_cubehash; 17 | sph_bmw256_context ctx_bmw; 18 | 19 | //sph_blake256_set_rounds(14); 20 | 21 | sph_blake256_init(&ctx_blake); 22 | sph_blake256(&ctx_blake, input, 80); 23 | sph_blake256_close(&ctx_blake, hash); 24 | 25 | LYRA2_3(hashB, 32, hash, 32, hash, 32, 1, 4, 4); 26 | 27 | sph_cubehash256_init(&ctx_cubehash); 28 | sph_cubehash256(&ctx_cubehash, hashB, 32); 29 | sph_cubehash256_close(&ctx_cubehash, hash); 30 | 31 | LYRA2_3(hashB, 32, hash, 32, hash, 32, 1, 4, 4); 32 | 33 | sph_bmw256_init(&ctx_bmw); 34 | sph_bmw256(&ctx_bmw, hashB, 32); 35 | sph_bmw256_close(&ctx_bmw, hash); 36 | 37 | memcpy(state, hash, 32); 38 | } 39 | 40 | int scanhash_lyra2v3(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 41 | { 42 | uint32_t _ALIGN(128) hash[8]; 43 | uint32_t _ALIGN(128) endiandata[20]; 44 | uint32_t *pdata = work->data; 45 | uint32_t *ptarget = work->target; 46 | 47 | const uint32_t Htarg = ptarget[7]; 48 | const uint32_t first_nonce = pdata[19]; 49 | uint32_t nonce = first_nonce; 50 | 51 | if (opt_benchmark) 52 | ptarget[7] = 0x0000ff; 53 | 54 | for (int i=0; i < 19; i++) { 55 | be32enc(&endiandata[i], pdata[i]); 56 | } 57 | 58 | do { 59 | be32enc(&endiandata[19], nonce); 60 | lyra2v3_hash(hash, endiandata); 61 | 62 | if (hash[7] <= Htarg && fulltest(hash, ptarget)) { 63 | work_set_target_ratio(work, hash); 64 | pdata[19] = nonce; 65 | *hashes_done = pdata[19] - first_nonce; 66 | return 1; 67 | } 68 | nonce++; 69 | 70 | } while (nonce < max_nonce && !work_restart[thr_id].restart); 71 | 72 | pdata[19] = nonce; 73 | *hashes_done = pdata[19] - first_nonce + 1; 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /algo/blakecoin.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #define BLAKE32_ROUNDS 8 4 | #include "sha3/sph_blake.h" 5 | 6 | void blakecoin_init(void *cc); 7 | void blakecoin(void *cc, const void *data, size_t len); 8 | void blakecoin_close(void *cc, void *dst); 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | static __thread sph_blake256_context blake_mid; 15 | static __thread bool ctx_midstate_done = false; 16 | 17 | void blakecoinhash(void *state, const void *input) 18 | { 19 | sph_blake256_context ctx; 20 | 21 | uint8_t *ending = (uint8_t*) input; 22 | ending += 64; 23 | 24 | // do one memcopy to get a fresh context 25 | if (!ctx_midstate_done) { 26 | blakecoin_init(&blake_mid); 27 | blakecoin(&blake_mid, input, 64); 28 | ctx_midstate_done = true; 29 | } 30 | memcpy(&ctx, &blake_mid, sizeof(blake_mid)); 31 | 32 | blakecoin(&ctx, ending, 16); 33 | blakecoin_close(&ctx, state); 34 | } 35 | 36 | int scanhash_blakecoin(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 37 | { 38 | uint32_t _ALIGN(128) hash32[8]; 39 | uint32_t _ALIGN(128) endiandata[20]; 40 | uint32_t *pdata = work->data; 41 | uint32_t *ptarget = work->target; 42 | 43 | const uint32_t first_nonce = pdata[19]; 44 | const uint32_t HTarget = opt_benchmark ? 0x7f : ptarget[7]; 45 | uint32_t n = first_nonce; 46 | 47 | ctx_midstate_done = false; 48 | 49 | // we need big endian data... 50 | for (int kk=0; kk < 19; kk++) { 51 | be32enc(&endiandata[kk], pdata[kk]); 52 | } 53 | 54 | #ifdef DEBUG_ALGO 55 | applog(LOG_DEBUG,"[%d] Target=%08x %08x", thr_id, ptarget[6], ptarget[7]); 56 | #endif 57 | 58 | do { 59 | be32enc(&endiandata[19], n); 60 | blakecoinhash(hash32, endiandata); 61 | 62 | if (hash32[7] <= HTarget && fulltest(hash32, ptarget)) { 63 | work_set_target_ratio(work, hash32); 64 | *hashes_done = n - first_nonce + 1; 65 | return 1; 66 | } 67 | 68 | n++; pdata[19] = n; 69 | 70 | } while (n < max_nonce && !work_restart[thr_id].restart); 71 | 72 | *hashes_done = n - first_nonce + 1; 73 | pdata[19] = n; 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /yespower-1.0.1/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, ...) = ae f1 32 91 87 0f 55 70 47 f4 2e 9b ef a6 16 df e5 f1 96 77 e1 3f 8b a6 92 f7 c5 97 55 a0 f5 0e 16 | XOR of yespower(10, ...) = 8d 13 c5 fb 07 30 96 75 d1 b8 48 92 77 ba 4b e4 40 33 be df ae 7a 60 43 8a 9b e2 1f 3a 7b 12 37 17 | -------------------------------------------------------------------------------- /crypto/c_skein.h: -------------------------------------------------------------------------------- 1 | #ifndef _SKEIN_H_ 2 | #define _SKEIN_H_ 1 3 | /************************************************************************** 4 | ** 5 | ** Interface declarations and internal definitions for Skein hashing. 6 | ** 7 | ** Source code author: Doug Whiting, 2008. 8 | ** 9 | ** This algorithm and source code is released to the public domain. 10 | ** 11 | *************************************************************************** 12 | ** 13 | ** The following compile-time switches may be defined to control some 14 | ** tradeoffs between speed, code size, error checking, and security. 15 | ** 16 | ** The "default" note explains what happens when the switch is not defined. 17 | ** 18 | ** SKEIN_DEBUG -- make callouts from inside Skein code 19 | ** to examine/display intermediate values. 20 | ** [default: no callouts (no overhead)] 21 | ** 22 | ** SKEIN_ERR_CHECK -- how error checking is handled inside Skein 23 | ** code. If not defined, most error checking 24 | ** is disabled (for performance). Otherwise, 25 | ** the switch value is interpreted as: 26 | ** 0: use assert() to flag errors 27 | ** 1: return SKEIN_FAIL to flag errors 28 | ** 29 | ***************************************************************************/ 30 | #include "skein_port.h" /* get platform-specific definitions */ 31 | 32 | typedef enum 33 | { 34 | SKEIN_SUCCESS = 0, /* return codes from Skein calls */ 35 | SKEIN_FAIL = 1, 36 | SKEIN_BAD_HASHLEN = 2 37 | } 38 | SkeinHashReturn; 39 | 40 | typedef size_t SkeinDataLength; /* bit count type */ 41 | typedef u08b_t SkeinBitSequence; /* bit stream type */ 42 | 43 | /* "all-in-one" call */ 44 | SkeinHashReturn skein_hash(int hashbitlen, const SkeinBitSequence *data, 45 | SkeinDataLength databitlen, SkeinBitSequence *hashval); 46 | 47 | #endif /* ifndef _SKEIN_H_ */ 48 | -------------------------------------------------------------------------------- /yespower-1.0.1-power2b/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, ...) = ae f1 32 91 87 0f 55 70 47 f4 2e 9b ef a6 16 df e5 f1 96 77 e1 3f 8b a6 92 f7 c5 97 55 a0 f5 0e 16 | XOR of yespower(10, ...) = 8d 13 c5 fb 07 30 96 75 d1 b8 48 92 77 ba 4b e4 40 33 be df ae 7a 60 43 8a 9b e2 1f 3a 7b 12 37 17 | -------------------------------------------------------------------------------- /secp256k1/src/field_10x26.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_FIELD_REPR_H 8 | #define SECP256K1_FIELD_REPR_H 9 | 10 | #include 11 | 12 | typedef struct { 13 | /* X = sum(i=0..9, elem[i]*2^26) mod n */ 14 | uint32_t n[10]; 15 | #ifdef VERIFY 16 | int magnitude; 17 | int normalized; 18 | #endif 19 | } secp256k1_fe; 20 | 21 | /* Unpacks a constant into a overlapping multi-limbed FE element. */ 22 | #define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \ 23 | (d0) & 0x3FFFFFFUL, \ 24 | (((uint32_t)d0) >> 26) | (((uint32_t)(d1) & 0xFFFFFUL) << 6), \ 25 | (((uint32_t)d1) >> 20) | (((uint32_t)(d2) & 0x3FFFUL) << 12), \ 26 | (((uint32_t)d2) >> 14) | (((uint32_t)(d3) & 0xFFUL) << 18), \ 27 | (((uint32_t)d3) >> 8) | (((uint32_t)(d4) & 0x3UL) << 24), \ 28 | (((uint32_t)d4) >> 2) & 0x3FFFFFFUL, \ 29 | (((uint32_t)d4) >> 28) | (((uint32_t)(d5) & 0x3FFFFFUL) << 4), \ 30 | (((uint32_t)d5) >> 22) | (((uint32_t)(d6) & 0xFFFFUL) << 10), \ 31 | (((uint32_t)d6) >> 16) | (((uint32_t)(d7) & 0x3FFUL) << 16), \ 32 | (((uint32_t)d7) >> 10) \ 33 | } 34 | 35 | #ifdef VERIFY 36 | #define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1} 37 | #else 38 | #define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))} 39 | #endif 40 | 41 | typedef struct { 42 | uint32_t n[8]; 43 | } secp256k1_fe_storage; 44 | 45 | #define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }} 46 | #define SECP256K1_FE_STORAGE_CONST_GET(d) d.n[7], d.n[6], d.n[5], d.n[4],d.n[3], d.n[2], d.n[1], d.n[0] 47 | 48 | #endif /* SECP256K1_FIELD_REPR_H */ 49 | -------------------------------------------------------------------------------- /algo/lyra2re.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "sha3/sph_blake.h" 4 | #include "sha3/sph_groestl.h" 5 | #include "sha3/sph_skein.h" 6 | #include "sha3/sph_keccak.h" 7 | 8 | #include "lyra2/Lyra2.h" 9 | 10 | #include "miner.h" 11 | 12 | void lyra2_hash(void *state, const void *input) 13 | { 14 | sph_blake256_context ctx_blake; 15 | sph_keccak256_context ctx_keccak; 16 | sph_skein256_context ctx_skein; 17 | sph_groestl256_context ctx_groestl; 18 | 19 | uint32_t hashA[8], hashB[8]; 20 | 21 | sph_blake256_init(&ctx_blake); 22 | sph_blake256(&ctx_blake, input, 80); 23 | sph_blake256_close(&ctx_blake, hashA); 24 | 25 | sph_keccak256_init(&ctx_keccak); 26 | sph_keccak256(&ctx_keccak, hashA, 32); 27 | sph_keccak256_close(&ctx_keccak, hashB); 28 | 29 | LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8); 30 | 31 | sph_skein256_init(&ctx_skein); 32 | sph_skein256(&ctx_skein, hashA, 32); 33 | sph_skein256_close(&ctx_skein, hashB); 34 | 35 | sph_groestl256_init(&ctx_groestl); 36 | sph_groestl256(&ctx_groestl, hashB, 32); 37 | sph_groestl256_close(&ctx_groestl, hashA); 38 | 39 | memcpy(state, hashA, 32); 40 | } 41 | 42 | int scanhash_lyra2(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 43 | { 44 | uint32_t _ALIGN(128) hash[8]; 45 | uint32_t _ALIGN(128) endiandata[20]; 46 | uint32_t *pdata = work->data; 47 | uint32_t *ptarget = work->target; 48 | 49 | const uint32_t Htarg = ptarget[7]; 50 | const uint32_t first_nonce = pdata[19]; 51 | uint32_t nonce = first_nonce; 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 | do { 61 | be32enc(&endiandata[19], nonce); 62 | lyra2_hash(hash, endiandata); 63 | 64 | if (hash[7] <= Htarg && fulltest(hash, ptarget)) { 65 | work_set_target_ratio(work, hash); 66 | pdata[19] = nonce; 67 | *hashes_done = pdata[19] - first_nonce; 68 | return 1; 69 | } 70 | nonce++; 71 | 72 | } while (nonce < max_nonce && !work_restart[thr_id].restart); 73 | 74 | pdata[19] = nonce; 75 | *hashes_done = pdata[19] - first_nonce + 1; 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /crypto/oaes_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * --------------------------------------------------------------------------- 3 | * OpenAES License 4 | * --------------------------------------------------------------------------- 5 | * Copyright (c) 2012, Nabil S. Al Ramli, www.nalramli.com 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * - Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * - Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | * POSSIBILITY OF SUCH DAMAGE. 28 | * --------------------------------------------------------------------------- 29 | */ 30 | 31 | #ifndef _OAES_CONFIG_H 32 | #define _OAES_CONFIG_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | //#ifndef OAES_HAVE_ISAAC 39 | //#define OAES_HAVE_ISAAC 1 40 | //#endif // OAES_HAVE_ISAAC 41 | 42 | //#ifndef OAES_DEBUG 43 | //#define OAES_DEBUG 0 44 | //#endif // OAES_DEBUG 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif // _OAES_CONFIG_H 51 | -------------------------------------------------------------------------------- /cryptonote/crypto/oaes_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * --------------------------------------------------------------------------- 3 | * OpenAES License 4 | * --------------------------------------------------------------------------- 5 | * Copyright (c) 2012, Nabil S. Al Ramli, www.nalramli.com 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * - Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * - Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | * POSSIBILITY OF SUCH DAMAGE. 28 | * --------------------------------------------------------------------------- 29 | */ 30 | 31 | #ifndef _OAES_CONFIG_H 32 | #define _OAES_CONFIG_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | //#ifndef OAES_HAVE_ISAAC 39 | //#define OAES_HAVE_ISAAC 1 40 | //#endif // OAES_HAVE_ISAAC 41 | 42 | //#ifndef OAES_DEBUG 43 | //#define OAES_DEBUG 0 44 | //#endif // OAES_DEBUG 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif // _OAES_CONFIG_H 51 | -------------------------------------------------------------------------------- /secp256k1/src/modules/ecdh/main_impl.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2015 Andrew Poelstra * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_MODULE_ECDH_MAIN_H 8 | #define SECP256K1_MODULE_ECDH_MAIN_H 9 | 10 | #include "include/secp256k1_ecdh.h" 11 | #include "ecmult_const_impl.h" 12 | 13 | int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *result, const secp256k1_pubkey *point, const unsigned char *scalar) { 14 | int ret = 0; 15 | int overflow = 0; 16 | secp256k1_gej res; 17 | secp256k1_ge pt; 18 | secp256k1_scalar s; 19 | VERIFY_CHECK(ctx != NULL); 20 | ARG_CHECK(result != NULL); 21 | ARG_CHECK(point != NULL); 22 | ARG_CHECK(scalar != NULL); 23 | 24 | secp256k1_pubkey_load(ctx, &pt, point); 25 | secp256k1_scalar_set_b32(&s, scalar, &overflow); 26 | if (overflow || secp256k1_scalar_is_zero(&s)) { 27 | ret = 0; 28 | } else { 29 | unsigned char x[32]; 30 | unsigned char y[1]; 31 | secp256k1_sha256_t sha; 32 | 33 | secp256k1_ecmult_const(&res, &pt, &s); 34 | secp256k1_ge_set_gej(&pt, &res); 35 | /* Compute a hash of the point in compressed form 36 | * Note we cannot use secp256k1_eckey_pubkey_serialize here since it does not 37 | * expect its output to be secret and has a timing sidechannel. */ 38 | secp256k1_fe_normalize(&pt.x); 39 | secp256k1_fe_normalize(&pt.y); 40 | secp256k1_fe_get_b32(x, &pt.x); 41 | y[0] = 0x02 | secp256k1_fe_is_odd(&pt.y); 42 | 43 | secp256k1_sha256_initialize(&sha); 44 | secp256k1_sha256_write(&sha, y, sizeof(y)); 45 | secp256k1_sha256_write(&sha, x, sizeof(x)); 46 | secp256k1_sha256_finalize(&sha, result); 47 | ret = 1; 48 | } 49 | 50 | secp256k1_scalar_clear(&s); 51 | return ret; 52 | } 53 | 54 | #endif /* SECP256K1_MODULE_ECDH_MAIN_H */ 55 | -------------------------------------------------------------------------------- /algo/blake2.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Blake2-S Implementation 3 | * tpruvot@github 2015-2016 4 | */ 5 | 6 | #include "miner.h" 7 | 8 | #include 9 | #include 10 | 11 | #include "crypto/blake2s.h" 12 | 13 | static __thread blake2s_state s_midstate; 14 | static __thread blake2s_state s_ctx; 15 | #define MIDLEN 76 16 | #define A 64 17 | 18 | void blake2s_hash(void *output, const void *input) 19 | { 20 | uint8_t _ALIGN(A) hash[BLAKE2S_OUTBYTES]; 21 | blake2s_state blake2_ctx; 22 | 23 | blake2s_init(&blake2_ctx, BLAKE2S_OUTBYTES); 24 | blake2s_update(&blake2_ctx, input, 80); 25 | blake2s_final(&blake2_ctx, hash, BLAKE2S_OUTBYTES); 26 | 27 | memcpy(output, hash, 32); 28 | } 29 | 30 | static void blake2s_hash_end(uint32_t *output, const uint32_t *input) 31 | { 32 | s_ctx.buflen = MIDLEN; 33 | memcpy(&s_ctx, &s_midstate, 32 + 16 + MIDLEN); 34 | blake2s_update(&s_ctx, (uint8_t*) &input[MIDLEN/4], 80 - MIDLEN); 35 | blake2s_final(&s_ctx, (uint8_t*) output, BLAKE2S_OUTBYTES); 36 | } 37 | 38 | int scanhash_blake2s(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 39 | { 40 | uint32_t _ALIGN(A) vhashcpu[8]; 41 | uint32_t _ALIGN(A) endiandata[20]; 42 | uint32_t *pdata = work->data; 43 | uint32_t *ptarget = work->target; 44 | 45 | const uint32_t Htarg = ptarget[7]; 46 | const uint32_t first_nonce = pdata[19]; 47 | 48 | uint32_t n = first_nonce; 49 | 50 | for (int i=0; i < 19; i++) { 51 | be32enc(&endiandata[i], pdata[i]); 52 | } 53 | 54 | // midstate 55 | blake2s_init(&s_midstate, BLAKE2S_OUTBYTES); 56 | blake2s_update(&s_midstate, (uint8_t*) endiandata, MIDLEN); 57 | memcpy(&s_ctx, &s_midstate, sizeof(blake2s_state)); 58 | 59 | do { 60 | be32enc(&endiandata[19], n); 61 | blake2s_hash_end(vhashcpu, endiandata); 62 | 63 | //blake2s_hash(vhashcpu, endiandata); 64 | if (vhashcpu[7] < Htarg && fulltest(vhashcpu, ptarget)) { 65 | work_set_target_ratio(work, vhashcpu); 66 | *hashes_done = n - first_nonce + 1; 67 | pdata[19] = n; 68 | return 1; 69 | } 70 | n++; 71 | 72 | } while (n < max_nonce && !work_restart[thr_id].restart); 73 | 74 | *hashes_done = n - first_nonce + 1; 75 | pdata[19] = n; 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /secp256k1/src/bench_recover.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2014-2015 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #include "include/secp256k1.h" 8 | #include "include/secp256k1_recovery.h" 9 | #include "util.h" 10 | #include "bench.h" 11 | 12 | typedef struct { 13 | secp256k1_context *ctx; 14 | unsigned char msg[32]; 15 | unsigned char sig[64]; 16 | } bench_recover_t; 17 | 18 | void bench_recover(void* arg) { 19 | int i; 20 | bench_recover_t *data = (bench_recover_t*)arg; 21 | secp256k1_pubkey pubkey; 22 | unsigned char pubkeyc[33]; 23 | 24 | for (i = 0; i < 20000; i++) { 25 | int j; 26 | size_t pubkeylen = 33; 27 | secp256k1_ecdsa_recoverable_signature sig; 28 | CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(data->ctx, &sig, data->sig, i % 2)); 29 | CHECK(secp256k1_ecdsa_recover(data->ctx, &pubkey, &sig, data->msg)); 30 | CHECK(secp256k1_ec_pubkey_serialize(data->ctx, pubkeyc, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED)); 31 | for (j = 0; j < 32; j++) { 32 | data->sig[j + 32] = data->msg[j]; /* Move former message to S. */ 33 | data->msg[j] = data->sig[j]; /* Move former R to message. */ 34 | data->sig[j] = pubkeyc[j + 1]; /* Move recovered pubkey X coordinate to R (which must be a valid X coordinate). */ 35 | } 36 | } 37 | } 38 | 39 | void bench_recover_setup(void* arg) { 40 | int i; 41 | bench_recover_t *data = (bench_recover_t*)arg; 42 | 43 | for (i = 0; i < 32; i++) { 44 | data->msg[i] = 1 + i; 45 | } 46 | for (i = 0; i < 64; i++) { 47 | data->sig[i] = 65 + i; 48 | } 49 | } 50 | 51 | int main(void) { 52 | bench_recover_t data; 53 | 54 | data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY); 55 | 56 | run_benchmark("ecdsa_recover", bench_recover, bench_recover_setup, NULL, &data, 10, 20000); 57 | 58 | secp256k1_context_destroy(data.ctx); 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /lyra2/Lyra2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Header file for the Lyra2 Password Hashing Scheme (PHS). 3 | * 4 | * Author: The Lyra PHC team (http://www.lyra-kdf.net/) -- 2014. 5 | * 6 | * This software is hereby placed in the public domain. 7 | * 8 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 9 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 10 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 11 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 12 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 13 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 14 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 15 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 16 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 17 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 18 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 19 | */ 20 | #ifndef LYRA2_H_ 21 | #define LYRA2_H_ 22 | 23 | #include 24 | 25 | typedef unsigned char byte; 26 | 27 | //Block length required so Blake2's Initialization Vector (IV) is not overwritten (THIS SHOULD NOT BE MODIFIED) 28 | #define BLOCK_LEN_BLAKE2_SAFE_INT64 8 //512 bits (=64 bytes, =8 uint64_t) 29 | #define BLOCK_LEN_BLAKE2_SAFE_BYTES (BLOCK_LEN_BLAKE2_SAFE_INT64 * 8) //same as above, in bytes 30 | 31 | 32 | #ifdef BLOCK_LEN_BITS 33 | #define BLOCK_LEN_INT64 (BLOCK_LEN_BITS/64) //Block length: 768 bits (=96 bytes, =12 uint64_t) 34 | #define BLOCK_LEN_BYTES (BLOCK_LEN_BITS/8) //Block length, in bytes 35 | #else //default block lenght: 768 bits 36 | #define BLOCK_LEN_INT64 12 //Block length: 768 bits (=96 bytes, =12 uint64_t) 37 | #define BLOCK_LEN_BYTES (BLOCK_LEN_INT64 * 8) //Block length, in bytes 38 | #endif 39 | 40 | int LYRA2(void *K, int64_t kLen, const void *pwd, int32_t pwdlen, const void *salt, int32_t saltlen, int64_t timeCost, const int16_t nRows, const int16_t nCols); 41 | 42 | int LYRA2_3(void *K, int64_t kLen, const void *pwd, int32_t pwdlen, const void *salt, int32_t saltlen, int64_t timeCost, const int16_t nRows, const int16_t nCols); 43 | 44 | #endif /* LYRA2_H_ */ 45 | -------------------------------------------------------------------------------- /algo/skunk.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "sha3/sph_skein.h" 9 | #include "sha3/sph_cubehash.h" 10 | #include "sha3/sph_fugue.h" 11 | #include "sha3/gost_streebog.h" 12 | 13 | void skunk_hash(const char *input, char* output, uint32_t len) 14 | { 15 | uint32_t _ALIGN(64) hash[16]; 16 | 17 | sph_skein512_context ctx_skein; 18 | sph_cubehash512_context ctx_cube; 19 | sph_fugue512_context ctx_fugue; 20 | sph_gost512_context ctx_gost; 21 | 22 | sph_skein512_init(&ctx_skein); 23 | sph_skein512(&ctx_skein, input, 80); 24 | sph_skein512_close(&ctx_skein, (void*) hash); 25 | 26 | sph_cubehash512_init(&ctx_cube); 27 | sph_cubehash512(&ctx_cube, hash, 64); 28 | sph_cubehash512_close(&ctx_cube, hash); 29 | 30 | sph_fugue512_init (&ctx_fugue); 31 | sph_fugue512(&ctx_fugue, hash, 64); 32 | sph_fugue512_close(&ctx_fugue, hash); 33 | 34 | sph_gost512_init(&ctx_gost); 35 | sph_gost512(&ctx_gost, (const void*) hash, 64); 36 | sph_gost512_close(&ctx_gost, (void*) hash); 37 | 38 | memcpy(output, hash, 32); 39 | } 40 | 41 | int scanhash_skunk(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 42 | { 43 | uint32_t _ALIGN(64) vhash[8]; 44 | uint32_t _ALIGN(64) endiandata[20]; 45 | uint32_t *pdata = work->data; 46 | uint32_t *ptarget = work->target; 47 | 48 | const uint32_t Htarg = ptarget[7]; 49 | const uint32_t first_nonce = pdata[19]; 50 | uint32_t n = first_nonce; 51 | 52 | for (int k = 0; k < 19; k++) 53 | be32enc(&endiandata[k], pdata[k]); 54 | 55 | do { 56 | be32enc(&endiandata[19], n); 57 | skunk_hash((char*) endiandata, (char*) vhash, 80); 58 | if (vhash[7] < Htarg && fulltest(vhash, ptarget)) { 59 | work_set_target_ratio( work, vhash ); 60 | *hashes_done = n - first_nonce + 1; 61 | pdata[19] = n; 62 | return true; 63 | } 64 | n++; 65 | } while (n < max_nonce && !work_restart[thr_id].restart); 66 | 67 | *hashes_done = n - first_nonce + 1; 68 | pdata[19] = n; 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /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.3\" 45 | 46 | sph_files:=$(call all-c-files-under,sha3) 47 | 48 | LOCAL_SRC_FILES=\ 49 | cpu-miner.c util.c \ 50 | api.c sysinfos.c \ 51 | $(call all-c-files-under,algo) \ 52 | $(filter-out sha3/md_helper.c,$(sph_files)) \ 53 | $(call all-c-files-under,crypto) \ 54 | $(call all-c-files-under,lyra2) \ 55 | asm/sha2-$(TARGET_ARCH).S \ 56 | asm/scrypt-$(TARGET_ARCH).S \ 57 | asm/neoscrypt_asm.S 58 | 59 | LOCAL_STATIC_LIBRARIES := libm cpuminer-jansson 60 | LOCAL_STATIC_LIBRARIES += libz libcrypto_static 61 | LOCAL_STATIC_LIBRARIES += libssl_static 62 | 63 | # Require curl config changes and an addional 64 | # module definition in external/curl(_static?) 65 | #LOCAL_FORCE_STATIC_EXECUTABLE := true 66 | 67 | ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) 68 | LOCAL_CFLAGS += -DCURL_STATICLIB # -DHTTP_ONLY 69 | LOCAL_STATIC_LIBRARIES += libcurl_static libc 70 | else 71 | LOCAL_SHARED_LIBRARIES := libssl libcrypto 72 | LOCAL_SHARED_LIBRARIES += libcurl 73 | #LOCAL_STATIC_LIBRARIES += libcurl_static 74 | endif 75 | 76 | include $(BUILD_EXECUTABLE) 77 | 78 | -------------------------------------------------------------------------------- /compat/gettimeofday.c: -------------------------------------------------------------------------------- 1 | #include < time.h > 2 | #include //I've ommited this line. 3 | #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) 4 | #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 5 | #else 6 | #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL 7 | #endif 8 | 9 | struct timezone 10 | { 11 | int tz_minuteswest; /* minutes W of Greenwich */ 12 | int tz_dsttime; /* type of dst correction */ 13 | }; 14 | 15 | int gettimeofday(struct timeval *tv, struct timezone *tz) 16 | { 17 | FILETIME ft; 18 | unsigned __int64 tmpres = 0; 19 | static int tzflag; 20 | 21 | if (NULL != tv) 22 | { 23 | GetSystemTimeAsFileTime(&ft); 24 | 25 | tmpres |= ft.dwHighDateTime; 26 | tmpres <<= 32; 27 | tmpres |= ft.dwLowDateTime; 28 | 29 | /*converting file time to unix epoch*/ 30 | tmpres /= 10; /*convert into microseconds*/ 31 | tmpres -= DELTA_EPOCH_IN_MICROSECS; 32 | tv->tv_sec = (long)(tmpres / 1000000UL); 33 | tv->tv_usec = (long)(tmpres % 1000000UL); 34 | } 35 | 36 | if (NULL != tz) 37 | { 38 | if (!tzflag) 39 | { 40 | _tzset(); 41 | tzflag++; 42 | } 43 | tz->tz_minuteswest = _timezone / 60; 44 | tz->tz_dsttime = _daylight; 45 | } 46 | 47 | return 0; 48 | } 49 | 50 | void usleep(__int64 waitTime) 51 | { 52 | if (waitTime > 0) 53 | { 54 | if (waitTime > 100) 55 | { 56 | // use a waitable timer for larger intervals > 0.1ms 57 | 58 | HANDLE timer; 59 | LARGE_INTEGER ft; 60 | 61 | ft.QuadPart = -(10*waitTime); // Convert to 100 nanosecond interval, negative value indicates relative time 62 | 63 | timer = CreateWaitableTimer(NULL, TRUE, NULL); 64 | SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); 65 | WaitForSingleObject(timer, INFINITE); 66 | CloseHandle(timer); 67 | } 68 | else 69 | { 70 | // use a polling loop for short intervals <= 100ms 71 | 72 | LARGE_INTEGER perfCnt, start, now; 73 | __int64 elapsed; 74 | 75 | QueryPerformanceFrequency(&perfCnt); 76 | QueryPerformanceCounter(&start); 77 | do { 78 | QueryPerformanceCounter((LARGE_INTEGER*) &now); 79 | elapsed = (__int64)((now.QuadPart - start.QuadPart) / (float)perfCnt.QuadPart * 1000 * 1000); 80 | } while ( elapsed < waitTime ); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /secp256k1/src/ecmult_gen.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014 Pieter Wuille * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #ifndef SECP256K1_ECMULT_GEN_H 8 | #define SECP256K1_ECMULT_GEN_H 9 | 10 | #include "scalar.h" 11 | #include "group.h" 12 | 13 | typedef struct { 14 | /* For accelerating the computation of a*G: 15 | * To harden against timing attacks, use the following mechanism: 16 | * * Break up the multiplicand into groups of 4 bits, called n_0, n_1, n_2, ..., n_63. 17 | * * Compute sum(n_i * 16^i * G + U_i, i=0..63), where: 18 | * * U_i = U * 2^i (for i=0..62) 19 | * * U_i = U * (1-2^63) (for i=63) 20 | * where U is a point with no known corresponding scalar. Note that sum(U_i, i=0..63) = 0. 21 | * For each i, and each of the 16 possible values of n_i, (n_i * 16^i * G + U_i) is 22 | * precomputed (call it prec(i, n_i)). The formula now becomes sum(prec(i, n_i), i=0..63). 23 | * None of the resulting prec group elements have a known scalar, and neither do any of 24 | * the intermediate sums while computing a*G. 25 | */ 26 | secp256k1_ge_storage (*prec)[64][16]; /* prec[j][i] = 16^j * i * G + U_i */ 27 | secp256k1_scalar blind; 28 | secp256k1_gej initial; 29 | } secp256k1_ecmult_gen_context; 30 | 31 | static void secp256k1_ecmult_gen_context_init(secp256k1_ecmult_gen_context* ctx); 32 | static void secp256k1_ecmult_gen_context_build(secp256k1_ecmult_gen_context* ctx, const secp256k1_callback* cb); 33 | static void secp256k1_ecmult_gen_context_clone(secp256k1_ecmult_gen_context *dst, 34 | const secp256k1_ecmult_gen_context* src, const secp256k1_callback* cb); 35 | static void secp256k1_ecmult_gen_context_clear(secp256k1_ecmult_gen_context* ctx); 36 | static int secp256k1_ecmult_gen_context_is_built(const secp256k1_ecmult_gen_context* ctx); 37 | 38 | /** Multiply with the generator: R = a*G */ 39 | static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context* ctx, secp256k1_gej *r, const secp256k1_scalar *a); 40 | 41 | static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32); 42 | 43 | #endif /* SECP256K1_ECMULT_GEN_H */ 44 | -------------------------------------------------------------------------------- /algo/allium.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Allium algo Implementation 3 | */ 4 | 5 | #include 6 | 7 | #include "sha3/sph_blake.h" 8 | #include "sha3/sph_keccak.h" 9 | #include "sha3/sph_cubehash.h" 10 | #include "sha3/sph_skein.h" 11 | #include "sha3/sph_groestl.h" 12 | 13 | #include "lyra2/Lyra2.h" 14 | 15 | #include "miner.h" 16 | 17 | void allium_hash(void *state, const void *input) 18 | { 19 | uint32_t hashA[8], hashB[8]; 20 | 21 | sph_blake256_context ctx_blake; 22 | sph_keccak256_context ctx_keccak; 23 | sph_skein256_context ctx_skein; 24 | sph_groestl256_context ctx_groestl; 25 | sph_cubehash256_context ctx_cube; 26 | 27 | // sph_blake256_set_rounds(14); 28 | 29 | sph_blake256_init(&ctx_blake); 30 | sph_blake256(&ctx_blake, input, 80); 31 | sph_blake256_close(&ctx_blake, hashA); 32 | 33 | sph_keccak256_init(&ctx_keccak); 34 | sph_keccak256(&ctx_keccak, hashA, 32); 35 | sph_keccak256_close(&ctx_keccak, hashB); 36 | 37 | LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8); 38 | 39 | sph_cubehash256_init(&ctx_cube); 40 | sph_cubehash256(&ctx_cube, hashA, 32); 41 | sph_cubehash256_close(&ctx_cube, hashB); 42 | 43 | LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8); 44 | 45 | sph_skein256_init(&ctx_skein); 46 | sph_skein256(&ctx_skein, hashA, 32); 47 | sph_skein256_close(&ctx_skein, hashB); 48 | 49 | sph_groestl256_init(&ctx_groestl); 50 | sph_groestl256(&ctx_groestl, hashB, 32); 51 | sph_groestl256_close(&ctx_groestl, hashA); 52 | 53 | memcpy(state, hashA, 32); 54 | } 55 | 56 | int scanhash_allium(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 57 | { 58 | uint32_t _ALIGN(128) hash[8]; 59 | uint32_t _ALIGN(128) endiandata[20]; 60 | uint32_t *pdata = work->data; 61 | uint32_t *ptarget = work->target; 62 | 63 | const uint32_t Htarg = ptarget[7]; 64 | const uint32_t first_nonce = pdata[19]; 65 | uint32_t n = first_nonce; 66 | 67 | if(opt_benchmark){ 68 | ptarget[7] = 0x00ff; 69 | } 70 | 71 | for (int i=0; i < 19; i++) { 72 | be32enc(&endiandata[i], pdata[i]); 73 | } 74 | 75 | do { 76 | be32enc(&endiandata[19], n); 77 | allium_hash(hash, endiandata); 78 | 79 | if (hash[7] < Htarg && fulltest(hash, ptarget)) { 80 | work_set_target_ratio(work, hash); 81 | *hashes_done = n - first_nonce + 1; 82 | pdata[19] = n; 83 | return 1; 84 | } 85 | n++; 86 | 87 | } while (n < max_nonce && !work_restart[thr_id].restart); 88 | 89 | *hashes_done = n - first_nonce + 1; 90 | pdata[19] = n; 91 | 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /algo/decred.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include "sha3/sph_blake.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | static __thread sph_blake256_context blake_mid; 10 | static __thread bool ctx_midstate_done = false; 11 | 12 | void decred_hash(void *state, const void *input) 13 | { 14 | #define MIDSTATE_LEN 128 15 | sph_blake256_context ctx; 16 | 17 | uint8_t *ending = (uint8_t*) input; 18 | ending += MIDSTATE_LEN; 19 | 20 | if (!ctx_midstate_done) { 21 | sph_blake256_init(&blake_mid); 22 | sph_blake256(&blake_mid, input, MIDSTATE_LEN); 23 | ctx_midstate_done = true; 24 | } 25 | memcpy(&ctx, &blake_mid, sizeof(blake_mid)); 26 | 27 | sph_blake256(&ctx, ending, (180 - MIDSTATE_LEN)); 28 | sph_blake256_close(&ctx, state); 29 | } 30 | 31 | void decred_hash_simple(void *state, const void *input) 32 | { 33 | sph_blake256_context ctx; 34 | sph_blake256_init(&ctx); 35 | sph_blake256(&ctx, input, 180); 36 | sph_blake256_close(&ctx, state); 37 | } 38 | 39 | int scanhash_decred(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 40 | { 41 | uint32_t _ALIGN(128) endiandata[48]; 42 | uint32_t _ALIGN(128) hash32[8]; 43 | uint32_t *pdata = work->data; 44 | uint32_t *ptarget = work->target; 45 | 46 | #define DCR_NONCE_OFT32 35 47 | 48 | const uint32_t first_nonce = pdata[DCR_NONCE_OFT32]; 49 | const uint32_t HTarget = opt_benchmark ? 0x7f : ptarget[7]; 50 | 51 | uint32_t n = first_nonce; 52 | 53 | ctx_midstate_done = false; 54 | 55 | #if 1 56 | memcpy(endiandata, pdata, 180); 57 | #else 58 | for (int k=0; k < (180/4); k++) 59 | be32enc(&endiandata[k], pdata[k]); 60 | #endif 61 | 62 | #ifdef DEBUG_ALGO 63 | if (!thr_id) applog(LOG_DEBUG,"[%d] Target=%08x %08x", thr_id, ptarget[6], ptarget[7]); 64 | #endif 65 | 66 | do { 67 | //be32enc(&endiandata[DCR_NONCE_OFT32], n); 68 | endiandata[DCR_NONCE_OFT32] = n; 69 | decred_hash(hash32, endiandata); 70 | 71 | if (hash32[7] <= HTarget && fulltest(hash32, ptarget)) { 72 | work_set_target_ratio(work, hash32); 73 | *hashes_done = n - first_nonce + 1; 74 | #ifdef DEBUG_ALGO 75 | applog(LOG_BLUE, "Nonce : %08x %08x", n, swab32(n)); 76 | applog_hash(ptarget); 77 | applog_compare_hash(hash32, ptarget); 78 | #endif 79 | pdata[DCR_NONCE_OFT32] = n; 80 | return 1; 81 | } 82 | 83 | n++; 84 | 85 | } while (n < max_nonce && !work_restart[thr_id].restart); 86 | 87 | *hashes_done = n - first_nonce + 1; 88 | pdata[DCR_NONCE_OFT32] = n; 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /algo/lyra2rev2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "sha3/sph_blake.h" 4 | #include "sha3/sph_cubehash.h" 5 | #include "sha3/sph_keccak.h" 6 | #include "sha3/sph_skein.h" 7 | #include "sha3/sph_bmw.h" 8 | 9 | #include "lyra2/Lyra2.h" 10 | 11 | #include "miner.h" 12 | 13 | void lyra2rev2_hash(void *state, const void *input) 14 | { 15 | uint32_t _ALIGN(128) hashA[8], hashB[8]; 16 | 17 | sph_blake256_context ctx_blake; 18 | sph_keccak256_context ctx_keccak; 19 | sph_cubehash256_context ctx_cubehash; 20 | sph_skein256_context ctx_skein; 21 | sph_bmw256_context ctx_bmw; 22 | 23 | sph_blake256_init(&ctx_blake); 24 | sph_blake256(&ctx_blake, input, 80); 25 | sph_blake256_close(&ctx_blake, hashA); 26 | 27 | sph_keccak256_init(&ctx_keccak); 28 | sph_keccak256(&ctx_keccak, hashA, 32); 29 | sph_keccak256_close(&ctx_keccak, hashB); 30 | 31 | sph_cubehash256_init(&ctx_cubehash); 32 | sph_cubehash256(&ctx_cubehash, hashB, 32); 33 | sph_cubehash256_close(&ctx_cubehash, hashA); 34 | 35 | LYRA2(hashB, 32, hashA, 32, hashA, 32, 1, 4, 4); 36 | 37 | sph_skein256_init(&ctx_skein); 38 | sph_skein256(&ctx_skein, hashB, 32); 39 | sph_skein256_close(&ctx_skein, hashA); 40 | 41 | sph_cubehash256_init(&ctx_cubehash); 42 | sph_cubehash256(&ctx_cubehash, hashA, 32); 43 | sph_cubehash256_close(&ctx_cubehash, hashB); 44 | 45 | sph_bmw256_init(&ctx_bmw); 46 | sph_bmw256(&ctx_bmw, hashB, 32); 47 | sph_bmw256_close(&ctx_bmw, hashA); 48 | 49 | memcpy(state, hashA, 32); 50 | } 51 | 52 | int scanhash_lyra2rev2(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 53 | { 54 | uint32_t _ALIGN(128) hash[8]; 55 | uint32_t _ALIGN(128) endiandata[20]; 56 | uint32_t *pdata = work->data; 57 | uint32_t *ptarget = work->target; 58 | 59 | const uint32_t Htarg = ptarget[7]; 60 | const uint32_t first_nonce = pdata[19]; 61 | uint32_t nonce = first_nonce; 62 | 63 | if (opt_benchmark) 64 | ptarget[7] = 0x0000ff; 65 | 66 | for (int i=0; i < 19; i++) { 67 | be32enc(&endiandata[i], pdata[i]); 68 | } 69 | 70 | do { 71 | be32enc(&endiandata[19], nonce); 72 | lyra2rev2_hash(hash, endiandata); 73 | 74 | if (hash[7] <= Htarg && fulltest(hash, ptarget)) { 75 | work_set_target_ratio(work, hash); 76 | pdata[19] = nonce; 77 | *hashes_done = pdata[19] - first_nonce; 78 | return 1; 79 | } 80 | nonce++; 81 | 82 | } while (nonce < max_nonce && !work_restart[thr_id].restart); 83 | 84 | pdata[19] = nonce; 85 | *hashes_done = pdata[19] - first_nonce + 1; 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /algo/phi1612.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Phi1612 algo Implementation (initial LUX algo) 3 | */ 4 | 5 | #include 6 | 7 | #include "sha3/sph_skein.h" 8 | #include "sha3/sph_jh.h" 9 | #include "sha3/sph_cubehash.h" 10 | #include "sha3/sph_fugue.h" 11 | #include "sha3/gost_streebog.h" 12 | #include "sha3/sph_echo.h" 13 | 14 | #include "miner.h" 15 | 16 | void phi1612_hash(void *state, const void *input) 17 | { 18 | sph_skein512_context ctx_skein; 19 | sph_jh512_context ctx_jh; 20 | sph_cubehash512_context ctx_cubehash; 21 | sph_fugue512_context ctx_fugue; 22 | sph_gost512_context ctx_gost; 23 | sph_echo512_context ctx_echo; 24 | 25 | uint8_t _ALIGN(128) hash[64]; 26 | 27 | sph_skein512_init(&ctx_skein); 28 | sph_skein512(&ctx_skein, input, 80); 29 | sph_skein512_close(&ctx_skein, (void*) hash); 30 | 31 | sph_jh512_init(&ctx_jh); 32 | sph_jh512(&ctx_jh, (const void*) hash, 64); 33 | sph_jh512_close(&ctx_jh, (void*) hash); 34 | 35 | sph_cubehash512_init(&ctx_cubehash); 36 | sph_cubehash512(&ctx_cubehash, (const void*) hash, 64); 37 | sph_cubehash512_close(&ctx_cubehash, (void*) hash); 38 | 39 | sph_fugue512_init(&ctx_fugue); 40 | sph_fugue512(&ctx_fugue, (const void*) hash, 64); 41 | sph_fugue512_close(&ctx_fugue, (void*) hash); 42 | 43 | sph_gost512_init(&ctx_gost); 44 | sph_gost512(&ctx_gost, (const void*) hash, 64); 45 | sph_gost512_close(&ctx_gost, (void*) hash); 46 | 47 | sph_echo512_init(&ctx_echo); 48 | sph_echo512(&ctx_echo, (const void*) hash, 64); 49 | sph_echo512_close(&ctx_echo, (void*) hash); 50 | 51 | memcpy(state, hash, 32); 52 | } 53 | 54 | int scanhash_phi1612(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 55 | { 56 | uint32_t _ALIGN(128) hash[8]; 57 | uint32_t _ALIGN(128) endiandata[20]; 58 | uint32_t *pdata = work->data; 59 | uint32_t *ptarget = work->target; 60 | 61 | const uint32_t Htarg = ptarget[7]; 62 | const uint32_t first_nonce = pdata[19]; 63 | uint32_t n = first_nonce; 64 | 65 | if(opt_benchmark){ 66 | ptarget[7] = 0x00ff; 67 | } 68 | 69 | for (int i=0; i < 19; i++) { 70 | be32enc(&endiandata[i], pdata[i]); 71 | } 72 | 73 | do { 74 | be32enc(&endiandata[19], n); 75 | phi1612_hash(hash, endiandata); 76 | 77 | if (hash[7] < Htarg && fulltest(hash, ptarget)) { 78 | work_set_target_ratio(work, hash); 79 | *hashes_done = n - first_nonce + 1; 80 | pdata[19] = n; 81 | return 1; 82 | } 83 | n++; 84 | 85 | } while (n < max_nonce && !work_restart[thr_id].restart); 86 | 87 | *hashes_done = n - first_nonce + 1; 88 | pdata[19] = n; 89 | 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /secp256k1/build-aux/m4/bitcoin_secp.m4: -------------------------------------------------------------------------------- 1 | dnl libsecp25k1 helper checks 2 | AC_DEFUN([SECP_INT128_CHECK],[ 3 | has_int128=$ac_cv_type___int128 4 | ]) 5 | 6 | dnl escape "$0x" below using the m4 quadrigaph @S|@, and escape it again with a \ for the shell. 7 | AC_DEFUN([SECP_64BIT_ASM_CHECK],[ 8 | AC_MSG_CHECKING(for x86_64 assembly availability) 9 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 10 | #include ]],[[ 11 | uint64_t a = 11, tmp; 12 | __asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx"); 13 | ]])],[has_64bit_asm=yes],[has_64bit_asm=no]) 14 | AC_MSG_RESULT([$has_64bit_asm]) 15 | ]) 16 | 17 | dnl 18 | AC_DEFUN([SECP_OPENSSL_CHECK],[ 19 | has_libcrypto=no 20 | m4_ifdef([PKG_CHECK_MODULES],[ 21 | PKG_CHECK_MODULES([CRYPTO], [libcrypto], [has_libcrypto=yes],[has_libcrypto=no]) 22 | if test x"$has_libcrypto" = x"yes"; then 23 | TEMP_LIBS="$LIBS" 24 | LIBS="$LIBS $CRYPTO_LIBS" 25 | AC_CHECK_LIB(crypto, main,[AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed])],[has_libcrypto=no]) 26 | LIBS="$TEMP_LIBS" 27 | fi 28 | ]) 29 | if test x$has_libcrypto = xno; then 30 | AC_CHECK_HEADER(openssl/crypto.h,[ 31 | AC_CHECK_LIB(crypto, main,[ 32 | has_libcrypto=yes 33 | CRYPTO_LIBS=-lcrypto 34 | AC_DEFINE(HAVE_LIBCRYPTO,1,[Define this symbol if libcrypto is installed]) 35 | ]) 36 | ]) 37 | LIBS= 38 | fi 39 | if test x"$has_libcrypto" = x"yes" && test x"$has_openssl_ec" = x; then 40 | AC_MSG_CHECKING(for EC functions in libcrypto) 41 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 42 | #include 43 | #include 44 | #include ]],[[ 45 | EC_KEY *eckey = EC_KEY_new_by_curve_name(NID_secp256k1); 46 | ECDSA_sign(0, NULL, 0, NULL, NULL, eckey); 47 | ECDSA_verify(0, NULL, 0, NULL, 0, eckey); 48 | EC_KEY_free(eckey); 49 | ECDSA_SIG *sig_openssl; 50 | sig_openssl = ECDSA_SIG_new(); 51 | (void)sig_openssl->r; 52 | ECDSA_SIG_free(sig_openssl); 53 | ]])],[has_openssl_ec=yes],[has_openssl_ec=no]) 54 | AC_MSG_RESULT([$has_openssl_ec]) 55 | fi 56 | ]) 57 | 58 | dnl 59 | AC_DEFUN([SECP_GMP_CHECK],[ 60 | if test x"$has_gmp" != x"yes"; then 61 | CPPFLAGS_TEMP="$CPPFLAGS" 62 | CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS" 63 | LIBS_TEMP="$LIBS" 64 | LIBS="$GMP_LIBS $LIBS" 65 | AC_CHECK_HEADER(gmp.h,[AC_CHECK_LIB(gmp, __gmpz_init,[has_gmp=yes; GMP_LIBS="$GMP_LIBS -lgmp"; AC_DEFINE(HAVE_LIBGMP,1,[Define this symbol if libgmp is installed])])]) 66 | CPPFLAGS="$CPPFLAGS_TEMP" 67 | LIBS="$LIBS_TEMP" 68 | fi 69 | ]) 70 | -------------------------------------------------------------------------------- /scryptjane/scrypt-jane-romix-basic.h: -------------------------------------------------------------------------------- 1 | #if !defined(SCRYPT_CHOOSE_COMPILETIME) 2 | /* function type returned by scrypt_getROMix, used with cpu detection */ 3 | typedef void (FASTCALL *scrypt_ROMixfn)(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); 4 | #endif 5 | 6 | /* romix pre/post nop function */ 7 | static void /* asm_calling_convention */ 8 | scrypt_romix_nop(scrypt_mix_word_t *blocks, size_t nblocks) { 9 | } 10 | 11 | /* romix pre/post endian conversion function */ 12 | static void /* asm_calling_convention */ 13 | scrypt_romix_convert_endian(scrypt_mix_word_t *blocks, size_t nblocks) { 14 | #if !defined(CPU_LE) 15 | static const union { uint8_t b[2]; uint16_t w; } endian_test = {{1,0}}; 16 | size_t i; 17 | if (endian_test.w == 0x100) { 18 | nblocks *= SCRYPT_BLOCK_WORDS; 19 | for (i = 0; i < nblocks; i++) { 20 | SCRYPT_WORD_ENDIAN_SWAP(blocks[i]); 21 | } 22 | } 23 | #endif 24 | } 25 | 26 | /* chunkmix test function */ 27 | typedef void (*chunkmixfn)(scrypt_mix_word_t *Bout/*[chunkWords]*/, scrypt_mix_word_t *Bin/*[chunkWords]*/, scrypt_mix_word_t *Bxor/*[chunkWords]*/, uint32_t r); 28 | typedef void (*blockfixfn)(scrypt_mix_word_t *blocks, size_t nblocks); 29 | 30 | static int 31 | scrypt_test_mix_instance(chunkmixfn mixfn, blockfixfn prefn, blockfixfn postfn, const uint8_t expected[16]) { 32 | /* r = 2, (2 * r) = 4 blocks in a chunk, 4 * SCRYPT_BLOCK_WORDS total */ 33 | const uint32_t r = 2, blocks = 2 * r, words = blocks * SCRYPT_BLOCK_WORDS; 34 | scrypt_mix_word_t MM16 chunk[2][4 * SCRYPT_BLOCK_WORDS], v; 35 | uint8_t final[16]; 36 | size_t i; 37 | 38 | for (i = 0; i < words; i++) { 39 | v = (scrypt_mix_word_t)i; 40 | v = (v << 8) | v; 41 | v = (v << 16) | v; 42 | chunk[0][i] = v; 43 | } 44 | 45 | prefn(chunk[0], blocks); 46 | mixfn(chunk[1], chunk[0], NULL, r); 47 | postfn(chunk[1], blocks); 48 | 49 | /* grab the last 16 bytes of the final block */ 50 | for (i = 0; i < 16; i += sizeof(scrypt_mix_word_t)) { 51 | SCRYPT_WORDTO8_LE(final + i, chunk[1][words - (16 / sizeof(scrypt_mix_word_t)) + (i / sizeof(scrypt_mix_word_t))]); 52 | } 53 | 54 | return scrypt_verify(expected, final, 16); 55 | } 56 | 57 | /* returns a pointer to item i, where item is len scrypt_mix_word_t's long */ 58 | static scrypt_mix_word_t * 59 | scrypt_item(scrypt_mix_word_t *base, scrypt_mix_word_t i, scrypt_mix_word_t len) { 60 | return base + (i * len); 61 | } 62 | 63 | /* returns a pointer to block i */ 64 | static scrypt_mix_word_t * 65 | scrypt_block(scrypt_mix_word_t *base, scrypt_mix_word_t i) { 66 | return base + (i * SCRYPT_BLOCK_WORDS); 67 | } 68 | -------------------------------------------------------------------------------- /secp256k1/src/gen_context.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2013, 2014, 2015 Thomas Daede, Cory Fields * 3 | * Distributed under the MIT software license, see the accompanying * 4 | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* 5 | **********************************************************************/ 6 | 7 | #define USE_BASIC_CONFIG 1 8 | 9 | #include "basic-config.h" 10 | #include "include/secp256k1.h" 11 | #include "field_impl.h" 12 | #include "scalar_impl.h" 13 | #include "group_impl.h" 14 | #include "ecmult_gen_impl.h" 15 | 16 | static void default_error_callback_fn(const char* str, void* data) { 17 | (void)data; 18 | fprintf(stderr, "[libsecp256k1] internal consistency check failed: %s\n", str); 19 | abort(); 20 | } 21 | 22 | static const secp256k1_callback default_error_callback = { 23 | default_error_callback_fn, 24 | NULL 25 | }; 26 | 27 | int main(int argc, char **argv) { 28 | secp256k1_ecmult_gen_context ctx; 29 | int inner; 30 | int outer; 31 | FILE* fp; 32 | 33 | (void)argc; 34 | (void)argv; 35 | 36 | fp = fopen("src/ecmult_static_context.h","w"); 37 | if (fp == NULL) { 38 | fprintf(stderr, "Could not open src/ecmult_static_context.h for writing!\n"); 39 | return -1; 40 | } 41 | 42 | fprintf(fp, "#ifndef _SECP256K1_ECMULT_STATIC_CONTEXT_\n"); 43 | fprintf(fp, "#define _SECP256K1_ECMULT_STATIC_CONTEXT_\n"); 44 | fprintf(fp, "#include \"group.h\"\n"); 45 | fprintf(fp, "#define SC SECP256K1_GE_STORAGE_CONST\n"); 46 | fprintf(fp, "static const secp256k1_ge_storage secp256k1_ecmult_static_context[64][16] = {\n"); 47 | 48 | secp256k1_ecmult_gen_context_init(&ctx); 49 | secp256k1_ecmult_gen_context_build(&ctx, &default_error_callback); 50 | for(outer = 0; outer != 64; outer++) { 51 | fprintf(fp,"{\n"); 52 | for(inner = 0; inner != 16; inner++) { 53 | fprintf(fp," SC(%uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu, %uu)", SECP256K1_GE_STORAGE_CONST_GET((*ctx.prec)[outer][inner])); 54 | if (inner != 15) { 55 | fprintf(fp,",\n"); 56 | } else { 57 | fprintf(fp,"\n"); 58 | } 59 | } 60 | if (outer != 63) { 61 | fprintf(fp,"},\n"); 62 | } else { 63 | fprintf(fp,"}\n"); 64 | } 65 | } 66 | fprintf(fp,"};\n"); 67 | secp256k1_ecmult_gen_context_clear(&ctx); 68 | 69 | fprintf(fp, "#undef SC\n"); 70 | fprintf(fp, "#endif\n"); 71 | fclose(fp); 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /secp256k1/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | addons: 4 | apt: 5 | packages: libgmp-dev 6 | compiler: 7 | - clang 8 | - gcc 9 | cache: 10 | directories: 11 | - src/java/guava/ 12 | env: 13 | global: 14 | - FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no RECOVERY=no EXPERIMENTAL=no 15 | - GUAVA_URL=https://search.maven.org/remotecontent?filepath=com/google/guava/guava/18.0/guava-18.0.jar GUAVA_JAR=src/java/guava/guava-18.0.jar 16 | matrix: 17 | - SCALAR=32bit RECOVERY=yes 18 | - SCALAR=32bit FIELD=32bit ECDH=yes EXPERIMENTAL=yes 19 | - SCALAR=64bit 20 | - FIELD=64bit RECOVERY=yes 21 | - FIELD=64bit ENDOMORPHISM=yes 22 | - FIELD=64bit ENDOMORPHISM=yes ECDH=yes EXPERIMENTAL=yes 23 | - FIELD=64bit ASM=x86_64 24 | - FIELD=64bit ENDOMORPHISM=yes ASM=x86_64 25 | - FIELD=32bit ENDOMORPHISM=yes 26 | - BIGNUM=no 27 | - BIGNUM=no ENDOMORPHISM=yes RECOVERY=yes EXPERIMENTAL=yes 28 | - BIGNUM=no STATICPRECOMPUTATION=no 29 | - BUILD=distcheck 30 | - EXTRAFLAGS=CPPFLAGS=-DDETERMINISTIC 31 | - EXTRAFLAGS=CFLAGS=-O0 32 | - BUILD=check-java ECDH=yes EXPERIMENTAL=yes 33 | matrix: 34 | fast_finish: true 35 | include: 36 | - compiler: clang 37 | env: HOST=i686-linux-gnu ENDOMORPHISM=yes 38 | addons: 39 | apt: 40 | packages: 41 | - gcc-multilib 42 | - libgmp-dev:i386 43 | - compiler: clang 44 | env: HOST=i686-linux-gnu 45 | addons: 46 | apt: 47 | packages: 48 | - gcc-multilib 49 | - compiler: gcc 50 | env: HOST=i686-linux-gnu ENDOMORPHISM=yes 51 | addons: 52 | apt: 53 | packages: 54 | - gcc-multilib 55 | - compiler: gcc 56 | env: HOST=i686-linux-gnu 57 | addons: 58 | apt: 59 | packages: 60 | - gcc-multilib 61 | - libgmp-dev:i386 62 | before_install: mkdir -p `dirname $GUAVA_JAR` 63 | install: if [ ! -f $GUAVA_JAR ]; then wget $GUAVA_URL -O $GUAVA_JAR; fi 64 | before_script: ./autogen.sh 65 | script: 66 | - if [ -n "$HOST" ]; then export USE_HOST="--host=$HOST"; fi 67 | - if [ "x$HOST" = "xi686-linux-gnu" ]; then export CC="$CC -m32"; fi 68 | - ./configure --enable-experimental=$EXPERIMENTAL --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR --enable-ecmult-static-precomputation=$STATICPRECOMPUTATION --enable-module-ecdh=$ECDH --enable-module-recovery=$RECOVERY $EXTRAFLAGS $USE_HOST && make -j2 $BUILD 69 | os: linux 70 | -------------------------------------------------------------------------------- /sha3/sph_hefty1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HEFTY1 cryptographic hash function 3 | * 4 | * Copyright (c) 2014, dbcc14 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are those 28 | * of the authors and should not be interpreted as representing official policies, 29 | * either expressed or implied, of the FreeBSD Project. 30 | */ 31 | 32 | #ifndef __HEFTY1_H__ 33 | #define __HEFTY1_H__ 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #ifndef WIN32 40 | #include 41 | #endif 42 | 43 | #include 44 | 45 | #define HEFTY1_DIGEST_BYTES 32 46 | #define HEFTY1_BLOCK_BYTES 64 47 | #define HEFTY1_STATE_WORDS 8 48 | #define HEFTY1_SPONGE_WORDS 4 49 | 50 | typedef struct HEFTY1_CTX { 51 | uint32_t h[HEFTY1_STATE_WORDS]; 52 | uint8_t block[HEFTY1_BLOCK_BYTES]; 53 | uint64_t written; 54 | uint32_t sponge[HEFTY1_SPONGE_WORDS]; 55 | } HEFTY1_CTX; 56 | 57 | void HEFTY1_Init(HEFTY1_CTX *cxt); 58 | void HEFTY1_Update(HEFTY1_CTX *cxt, const void *data, size_t len); 59 | void HEFTY1_Final(unsigned char *digest, HEFTY1_CTX *cxt); 60 | unsigned char* HEFTY1(const unsigned char *data, size_t len, unsigned char *digest); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* __HEFTY1_H__ */ -------------------------------------------------------------------------------- /yescrypt/sha256_Y.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2005,2007,2009 Colin Percival 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/lib/libmd/sha256_Y.h,v 1.2 2006/01/17 15:35:56 phk Exp $ 27 | */ 28 | 29 | #ifndef _SHA256_H_ 30 | #define _SHA256_H_ 31 | 32 | #include 33 | 34 | #include 35 | 36 | typedef struct SHA256Context { 37 | uint32_t state[8]; 38 | uint32_t count[2]; 39 | unsigned char buf[64]; 40 | } SHA256_CTX_Y; 41 | 42 | typedef struct HMAC_SHA256Context { 43 | SHA256_CTX_Y ictx; 44 | SHA256_CTX_Y octx; 45 | } HMAC_SHA256_CTX_Y; 46 | 47 | void SHA256_Init_Y(SHA256_CTX_Y *); 48 | void SHA256_Update_Y(SHA256_CTX_Y *, const void *, size_t); 49 | void SHA256_Final_Y(unsigned char [32], SHA256_CTX_Y *); 50 | void HMAC_SHA256_Init_Y(HMAC_SHA256_CTX_Y *, const void *, size_t); 51 | void HMAC_SHA256_Update_Y(HMAC_SHA256_CTX_Y *, const void *, size_t); 52 | void HMAC_SHA256_Final_Y(unsigned char [32], HMAC_SHA256_CTX_Y *); 53 | 54 | /** 55 | * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): 56 | * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and 57 | * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1). 58 | */ 59 | void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t, 60 | uint64_t, uint8_t *, size_t); 61 | 62 | #endif /* !_SHA256_H_ */ 63 | -------------------------------------------------------------------------------- /algo/veltor.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /* Move init out of loop, so init once externally, and then use one single memcpy with that bigger memory block */ 14 | typedef struct { 15 | sph_skein512_context skein1; 16 | sph_shavite512_context shavite1; 17 | sph_shabal512_context shabal1; 18 | sph_gost512_context gost1; 19 | } Xhash_context_holder; 20 | 21 | static __thread Xhash_context_holder base_contexts; 22 | static __thread bool init = false; 23 | 24 | static void init_Xhash_contexts() 25 | { 26 | sph_skein512_init(&base_contexts.skein1); 27 | sph_shavite512_init(&base_contexts.shavite1); 28 | sph_shabal512_init(&base_contexts.shabal1); 29 | sph_gost512_init(&base_contexts.gost1); 30 | init = true; 31 | } 32 | 33 | void veltor_hash(void *output, const void *input) 34 | { 35 | Xhash_context_holder ctx; 36 | 37 | uint32_t hashA[16]; 38 | 39 | if (!init) init_Xhash_contexts(); 40 | 41 | memcpy(&ctx, &base_contexts, sizeof(base_contexts)); 42 | 43 | sph_skein512(&ctx.skein1, input, 80); 44 | sph_skein512_close(&ctx.skein1, hashA); 45 | 46 | sph_shavite512(&ctx.shavite1, hashA, 64); 47 | sph_shavite512_close(&ctx.shavite1, hashA); 48 | 49 | sph_shabal512(&ctx.shabal1, hashA, 64); 50 | sph_shabal512_close(&ctx.shabal1, hashA); 51 | 52 | sph_gost512(&ctx.gost1, hashA, 64); 53 | sph_gost512_close(&ctx.gost1, hashA); 54 | 55 | memcpy(output, hashA, 32); 56 | } 57 | 58 | int scanhash_veltor(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 59 | { 60 | uint32_t _ALIGN(128) hash[8]; 61 | uint32_t _ALIGN(128) endiandata[20]; 62 | uint32_t *pdata = work->data; 63 | uint32_t *ptarget = work->target; 64 | 65 | const uint32_t Htarg = ptarget[7]; 66 | const uint32_t first_nonce = pdata[19]; 67 | uint32_t nonce = first_nonce; 68 | volatile uint8_t *restart = &(work_restart[thr_id].restart); 69 | 70 | if (opt_benchmark) 71 | ptarget[7] = 0x0cff; 72 | 73 | // we need bigendian data... 74 | for (int i=0; i < 19; i++) { 75 | be32enc(&endiandata[i], pdata[i]); 76 | } 77 | do { 78 | be32enc(&endiandata[19], nonce); 79 | veltor_hash(hash, endiandata); 80 | 81 | if (hash[7] <= Htarg && fulltest(hash, ptarget)) { 82 | work_set_target_ratio(work, hash); 83 | pdata[19] = nonce; 84 | *hashes_done = pdata[19] - first_nonce; 85 | return 1; 86 | } 87 | nonce++; 88 | 89 | } while (nonce < max_nonce && !(*restart)); 90 | 91 | pdata[19] = nonce; 92 | *hashes_done = pdata[19] - first_nonce + 1; 93 | return 0; 94 | } 95 | -------------------------------------------------------------------------------- /algo/lbry.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Lbry sph Implementation 3 | * tpruvot@github July 2016 4 | */ 5 | 6 | #include "miner.h" 7 | 8 | #include 9 | #include 10 | 11 | #include "sha3/sph_sha2.h" 12 | #include "sha3/sph_ripemd.h" 13 | 14 | #define A 64 15 | 16 | typedef struct { 17 | sph_sha256_context sha256; 18 | sph_sha512_context sha512; 19 | sph_ripemd160_context ripemd; 20 | } lbryhash_context_holder; 21 | 22 | static __thread lbryhash_context_holder ctx; 23 | static __thread bool ctx_init = false; 24 | 25 | static void lbry_initstate() 26 | { 27 | sph_sha256_init(&ctx.sha256); 28 | sph_sha512_init(&ctx.sha512); 29 | sph_ripemd160_init(&ctx.ripemd); 30 | ctx_init = true; 31 | } 32 | 33 | void lbry_hash(void* output, const void* input) 34 | { 35 | uint32_t _ALIGN(A) hashA[16]; 36 | uint32_t _ALIGN(A) hashB[8]; 37 | uint32_t _ALIGN(A) hashC[8]; 38 | 39 | //memset(&hashA[8], 0, 32); 40 | 41 | // sha256d 42 | sph_sha256(&ctx.sha256, input, 112); 43 | sph_sha256_close(&ctx.sha256, hashA); 44 | sph_sha256(&ctx.sha256, hashA, 32); 45 | sph_sha256_close(&ctx.sha256, hashA); 46 | 47 | sph_sha512(&ctx.sha512, hashA, 32); 48 | sph_sha512_close(&ctx.sha512, hashA); 49 | 50 | sph_ripemd160(&ctx.ripemd, hashA, 32); 51 | sph_ripemd160_close(&ctx.ripemd, hashB); 52 | 53 | sph_ripemd160(&ctx.ripemd, &hashA[8], 32); // weird 54 | sph_ripemd160_close(&ctx.ripemd, hashC); 55 | 56 | sph_sha256(&ctx.sha256, hashB, 20); 57 | sph_sha256(&ctx.sha256, hashC, 20); 58 | sph_sha256_close(&ctx.sha256, hashA); 59 | 60 | sph_sha256(&ctx.sha256, hashA, 32); 61 | sph_sha256_close(&ctx.sha256, hashA); 62 | 63 | memcpy(output, hashA, 32); 64 | } 65 | 66 | int scanhash_lbry(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 67 | { 68 | uint32_t _ALIGN(A) vhashcpu[8]; 69 | uint32_t _ALIGN(A) endiandata[28]; 70 | uint32_t *pdata = work->data; 71 | uint32_t *ptarget = work->target; 72 | 73 | const uint32_t Htarg = ptarget[7]; 74 | const uint32_t first_nonce = pdata[27]; 75 | 76 | uint32_t n = first_nonce; 77 | 78 | for (int i=0; i < 27; i++) { 79 | be32enc(&endiandata[i], pdata[i]); 80 | } 81 | 82 | if (!ctx_init) lbry_initstate(); 83 | 84 | do { 85 | be32enc(&endiandata[27], n); 86 | lbry_hash(vhashcpu, endiandata); 87 | 88 | if (vhashcpu[7] <= Htarg && fulltest(vhashcpu, ptarget)) { 89 | work_set_target_ratio(work, vhashcpu); 90 | *hashes_done = n - first_nonce + 1; 91 | work->resnonce = pdata[27] = n; // to check 92 | return 1; 93 | } 94 | n++; 95 | 96 | } while (n < max_nonce && !work_restart[thr_id].restart); 97 | 98 | *hashes_done = n - first_nonce + 1; 99 | pdata[27] = n; 100 | 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /crypto/cpu-features.c: -------------------------------------------------------------------------------- 1 | // CPU features set 2 | #include "cpu-features.h" 3 | 4 | #if defined(_M_X64) || defined(__x86_64__) 5 | static void cpuid(int cpuinfo[4], int info_type) 6 | { 7 | __asm__ __volatile__( 8 | "cpuid" : "=a"(cpuinfo[0]), 9 | "=b"(cpuinfo[1]), 10 | "=c"(cpuinfo[2]), 11 | "=d"(cpuinfo[3]) : "a"(info_type), "c"(0)); 12 | } 13 | 14 | void get_cpu_features(cpu_features_t *f) 15 | { 16 | int info[4]; 17 | cpuid(info, 0); 18 | int nIds = info[0]; 19 | 20 | cpuid(info, 0x80000000); 21 | unsigned nExIds = info[0]; 22 | 23 | // Detect Features 24 | if (nIds >= 0x00000001) 25 | { 26 | cpuid(info, 0x00000001); 27 | f->HW_MMX = (info[3] & ((int)1 << 23)) != 0; 28 | f->HW_SSE = (info[3] & ((int)1 << 25)) != 0; 29 | f->HW_SSE2 = (info[3] & ((int)1 << 26)) != 0; 30 | f->HW_SSE3 = (info[2] & ((int)1 << 0)) != 0; 31 | 32 | f->HW_SSSE3 = (info[2] & ((int)1 << 9)) != 0; 33 | f->HW_SSE41 = (info[2] & ((int)1 << 19)) != 0; 34 | f->HW_SSE42 = (info[2] & ((int)1 << 20)) != 0; 35 | f->HW_AES = (info[2] & ((int)1 << 25)) != 0; 36 | 37 | f->HW_AVX = (info[2] & ((int)1 << 28)) != 0; 38 | f->HW_FMA3 = (info[2] & ((int)1 << 12)) != 0; 39 | 40 | f->HW_RDRAND = (info[2] & ((int)1 << 30)) != 0; 41 | } 42 | if (nIds >= 0x00000007) 43 | { 44 | cpuid(info, 0x00000007); 45 | f->HW_AVX2 = (info[1] & ((int)1 << 5)) != 0; 46 | 47 | f->HW_BMI1 = (info[1] & ((int)1 << 3)) != 0; 48 | f->HW_BMI2 = (info[1] & ((int)1 << 8)) != 0; 49 | f->HW_ADX = (info[1] & ((int)1 << 19)) != 0; 50 | f->HW_SHA = (info[1] & ((int)1 << 29)) != 0; 51 | f->HW_PREFETCHWT1 = (info[2] & ((int)1 << 0)) != 0; 52 | 53 | f->HW_AVX512F = (info[1] & ((int)1 << 16)) != 0; 54 | f->HW_AVX512CD = (info[1] & ((int)1 << 28)) != 0; 55 | f->HW_AVX512PF = (info[1] & ((int)1 << 26)) != 0; 56 | f->HW_AVX512ER = (info[1] & ((int)1 << 27)) != 0; 57 | f->HW_AVX512VL = (info[1] & ((int)1 << 31)) != 0; 58 | f->HW_AVX512BW = (info[1] & ((int)1 << 30)) != 0; 59 | f->HW_AVX512DQ = (info[1] & ((int)1 << 17)) != 0; 60 | f->HW_AVX512IFMA = (info[1] & ((int)1 << 21)) != 0; 61 | f->HW_AVX512VBMI = (info[2] & ((int)1 << 1)) != 0; 62 | } 63 | if (nExIds >= 0x80000001) 64 | { 65 | cpuid(info, 0x80000001); 66 | f->HW_x64 = (info[3] & ((int)1 << 29)) != 0; 67 | f->HW_ABM = (info[2] & ((int)1 << 5)) != 0; 68 | f->HW_SSE4a = (info[2] & ((int)1 << 6)) != 0; 69 | f->HW_FMA4 = (info[2] & ((int)1 << 16)) != 0; 70 | f->HW_XOP = (info[2] & ((int)1 << 11)) != 0; 71 | } 72 | } 73 | #endif 74 | -------------------------------------------------------------------------------- /algo/tribus.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "sha3/sph_jh.h" 9 | #include "sha3/sph_keccak.h" 10 | #include "sha3/sph_echo.h" 11 | 12 | void tribus_hash(void *state, const void *input) 13 | { 14 | uint8_t _ALIGN(128) hash[64]; 15 | 16 | sph_jh512_context ctx_jh; 17 | sph_keccak512_context ctx_keccak; 18 | sph_echo512_context ctx_echo; 19 | 20 | sph_jh512_init(&ctx_jh); 21 | sph_jh512(&ctx_jh, input, 80); 22 | sph_jh512_close(&ctx_jh, (void*) hash); 23 | 24 | sph_keccak512_init(&ctx_keccak); 25 | sph_keccak512(&ctx_keccak, (const void*) hash, 64); 26 | sph_keccak512_close(&ctx_keccak, (void*) hash); 27 | 28 | sph_echo512_init(&ctx_echo); 29 | sph_echo512(&ctx_echo, (const void*) hash, 64); 30 | sph_echo512_close(&ctx_echo, (void*) hash); 31 | 32 | memcpy(state, hash, 32); 33 | } 34 | 35 | int scanhash_tribus(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 36 | { 37 | uint32_t _ALIGN(128) hash32[8]; 38 | uint32_t _ALIGN(128) endiandata[20]; 39 | uint32_t *pdata = work->data; 40 | uint32_t *ptarget = work->target; 41 | const uint32_t first_nonce = pdata[19]; 42 | const uint32_t Htarg = ptarget[7]; 43 | uint32_t n = pdata[19] - 1; 44 | 45 | uint64_t htmax[] = { 46 | 0, 47 | 0xF, 48 | 0xFF, 49 | 0xFFF, 50 | 0xFFFF, 51 | 0x10000000 52 | }; 53 | uint32_t masks[] = { 54 | 0xFFFFFFFF, 55 | 0xFFFFFFF0, 56 | 0xFFFFFF00, 57 | 0xFFFFF000, 58 | 0xFFFF0000, 59 | 0 60 | }; 61 | 62 | // we need bigendian data... 63 | for (int i=0; i < 19; i++) { 64 | be32enc(&endiandata[i], pdata[i]); 65 | } 66 | 67 | #ifdef DEBUG_ALGO 68 | printf("[%d] Htarg=%X\n", thr_id, Htarg); 69 | #endif 70 | for (int m=0; m < 6; m++) { 71 | if (Htarg <= htmax[m]) { 72 | uint32_t mask = masks[m]; 73 | do { 74 | pdata[19] = ++n; 75 | be32enc(&endiandata[19], n); 76 | tribus_hash(hash32, endiandata); 77 | #ifndef DEBUG_ALGO 78 | if ((!(hash32[7] & mask)) && fulltest(hash32, ptarget)) { 79 | work_set_target_ratio(work, hash32); 80 | *hashes_done = n - first_nonce + 1; 81 | return 1; 82 | } 83 | #else 84 | if (!(n % 0x1000) && !thr_id) printf("."); 85 | if (!(hash32[7] & mask)) { 86 | printf("[%d]",thr_id); 87 | if (fulltest(hash32, ptarget)) { 88 | work_set_target_ratio(work, hash32); 89 | *hashes_done = n - first_nonce + 1; 90 | return 1; 91 | } 92 | } 93 | #endif 94 | } while (n < max_nonce && !work_restart[thr_id].restart); 95 | // see blake.c if else to understand the loop on htmax => mask 96 | break; 97 | } 98 | } 99 | 100 | *hashes_done = n - first_nonce + 1; 101 | pdata[19] = n; 102 | return 0; 103 | } 104 | -------------------------------------------------------------------------------- /res/cpuminer.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_ICON1 ICON "cpuminer.ico" 56 | 57 | ///////////////////////////////////////////////////////////////////////////// 58 | // 59 | // Version 60 | // 61 | 62 | VS_VERSION_INFO VERSIONINFO 63 | FILEVERSION 1,3,6,0 64 | PRODUCTVERSION 1,3,6,0 65 | FILEFLAGSMASK 0x3fL 66 | #ifdef _DEBUG 67 | FILEFLAGS 0x21L 68 | #else 69 | FILEFLAGS 0x20L 70 | #endif 71 | FILEOS 0x40004L 72 | FILETYPE 0x1L 73 | FILESUBTYPE 0x0L 74 | BEGIN 75 | BLOCK "StringFileInfo" 76 | BEGIN 77 | BLOCK "040904e4" 78 | BEGIN 79 | VALUE "FileVersion", "1.3.6" 80 | VALUE "LegalCopyright", "Copyright (C) 2019" 81 | VALUE "ProductName", "cpuminer-multi" 82 | VALUE "ProductVersion", "1.3.6" 83 | END 84 | END 85 | BLOCK "VarFileInfo" 86 | BEGIN 87 | VALUE "Translation", 0x409, 1252 88 | END 89 | END 90 | 91 | #endif // English (United States) resources 92 | ///////////////////////////////////////////////////////////////////////////// 93 | 94 | 95 | 96 | #ifndef APSTUDIO_INVOKED 97 | ///////////////////////////////////////////////////////////////////////////// 98 | // 99 | // Generated from the TEXTINCLUDE 3 resource. 100 | // 101 | 102 | 103 | ///////////////////////////////////////////////////////////////////////////// 104 | #endif // not APSTUDIO_INVOKED 105 | 106 | -------------------------------------------------------------------------------- /algo/s3.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "sha3/sph_skein.h" 9 | #include "sha3/sph_shavite.h" 10 | #include "sha3/sph_simd.h" 11 | 12 | void s3hash(void *output, const void *input) 13 | { 14 | sph_shavite512_context ctx_shavite; 15 | sph_simd512_context ctx_simd; 16 | sph_skein512_context ctx_skein; 17 | 18 | unsigned char _ALIGN(128) hash[64]; 19 | 20 | sph_shavite512_init(&ctx_shavite); 21 | sph_shavite512(&ctx_shavite, input, 80); 22 | sph_shavite512_close(&ctx_shavite, (void*)hash); 23 | 24 | sph_simd512_init(&ctx_simd); 25 | sph_simd512(&ctx_simd, (const void*)hash, 64); 26 | sph_simd512_close(&ctx_simd, (void*)hash); 27 | 28 | sph_skein512_init(&ctx_skein); 29 | sph_skein512(&ctx_skein, (const void*)hash, 64); 30 | sph_skein512_close(&ctx_skein, (void*)hash); 31 | 32 | memcpy(output, hash, 32); 33 | } 34 | 35 | int scanhash_s3(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 36 | { 37 | uint32_t _ALIGN(128) hash32[8]; 38 | uint32_t _ALIGN(128) endiandata[20]; 39 | uint32_t *pdata = work->data; 40 | uint32_t *ptarget = work->target; 41 | 42 | uint32_t n = pdata[19] - 1; 43 | const uint32_t first_nonce = pdata[19]; 44 | const uint32_t Htarg = ptarget[7]; 45 | 46 | uint64_t htmax[] = { 47 | 0, 48 | 0xF, 49 | 0xFF, 50 | 0xFFF, 51 | 0xFFFF, 52 | 0x10000000 53 | }; 54 | uint32_t masks[] = { 55 | 0xFFFFFFFF, 56 | 0xFFFFFFF0, 57 | 0xFFFFFF00, 58 | 0xFFFFF000, 59 | 0xFFFF0000, 60 | 0 61 | }; 62 | 63 | // we need bigendian data... 64 | for (int i=0; i < 19; i++) { 65 | be32enc(&endiandata[i], pdata[i]); 66 | } 67 | 68 | #ifdef DEBUG_ALGO 69 | printf("[%d] Htarg=%X\n", thr_id, Htarg); 70 | #endif 71 | for (int m=0; m < 6; m++) { 72 | if (Htarg <= htmax[m]) { 73 | uint32_t mask = masks[m]; 74 | do { 75 | pdata[19] = ++n; 76 | be32enc(&endiandata[19], n); 77 | s3hash(hash32, endiandata); 78 | #ifndef DEBUG_ALGO 79 | if ((!(hash32[7] & mask)) && fulltest(hash32, ptarget)) { 80 | work_set_target_ratio(work, hash32); 81 | *hashes_done = n - first_nonce + 1; 82 | return true; 83 | } 84 | #else 85 | if (!(n % 0x1000) && !thr_id) printf("."); 86 | if (!(hash32[7] & mask)) { 87 | printf("[%d]",thr_id); 88 | if (fulltest(hash32, ptarget)) { 89 | work_set_target_ratio(work, hash32); 90 | *hashes_done = n - first_nonce + 1; 91 | return true; 92 | } 93 | } 94 | #endif 95 | } while (n < max_nonce && !work_restart[thr_id].restart); 96 | // see blake.c if else to understand the loop on htmax => mask 97 | break; 98 | } 99 | } 100 | 101 | *hashes_done = n - first_nonce + 1; 102 | pdata[19] = n; 103 | return 0; 104 | } 105 | -------------------------------------------------------------------------------- /compat.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMPAT_H__ 2 | #define __COMPAT_H__ 3 | 4 | #ifdef WIN32 5 | 6 | #include 7 | #include 8 | 9 | #ifndef localtime_r 10 | #define localtime_r(src, dst) localtime_s(dst, src) 11 | #endif 12 | 13 | #define sleep(secs) Sleep((secs) * 1000) 14 | 15 | enum { 16 | PRIO_PROCESS = 0, 17 | }; 18 | 19 | extern int opt_priority; 20 | static __inline int setpriority(int which, int who, int prio) 21 | { 22 | switch (opt_priority) { 23 | case 5: 24 | prio = THREAD_PRIORITY_TIME_CRITICAL; 25 | break; 26 | case 4: 27 | prio = THREAD_PRIORITY_HIGHEST; 28 | break; 29 | case 3: 30 | prio = THREAD_PRIORITY_ABOVE_NORMAL; 31 | break; 32 | case 2: 33 | prio = THREAD_PRIORITY_NORMAL; 34 | break; 35 | case 1: 36 | prio = THREAD_PRIORITY_BELOW_NORMAL; 37 | break; 38 | case 0: 39 | default: 40 | prio = THREAD_PRIORITY_IDLE; 41 | } 42 | return -!SetThreadPriority(GetCurrentThread(), prio); 43 | } 44 | 45 | #ifdef _MSC_VER 46 | #define snprintf(...) _snprintf(__VA_ARGS__) 47 | #define strdup(...) _strdup(__VA_ARGS__) 48 | #define strncasecmp(x,y,z) _strnicmp(x,y,z) 49 | #define strcasecmp(x,y) _stricmp(x,y) 50 | #define __func__ __FUNCTION__ 51 | #define __thread __declspec(thread) 52 | #define _ALIGN(x) __declspec(align(x)) 53 | typedef int ssize_t; 54 | 55 | __inline int msver(void) { 56 | switch (_MSC_VER) { 57 | case 1500: return 2008; 58 | case 1600: return 2010; 59 | case 1700: return 2012; 60 | case 1800: return 2013; 61 | case 1900: return 2015; 62 | default: return (_MSC_VER/100); 63 | } 64 | } 65 | 66 | #include 67 | // This static var is made to be compatible with linux/mingw (no free on string result) 68 | // This is not thread safe but we only use that once on process start 69 | static char dirname_buffer[_MAX_PATH] = { 0 }; 70 | static __inline char * dirname(char *file) { 71 | char drive[_MAX_DRIVE] = { 0 }; 72 | char dir[_MAX_DIR] = { 0 }; 73 | char fname[_MAX_FNAME], ext[_MAX_EXT]; 74 | _splitpath_s(file, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT); 75 | if (dir && strlen(dir) && dir[strlen(dir)-1] == '\\') { 76 | dir[strlen(dir) - 1] = '\0'; 77 | } 78 | sprintf(dirname_buffer, "%s%s", drive, dir); 79 | return &dirname_buffer[0]; 80 | } 81 | #endif 82 | 83 | #endif /* WIN32 */ 84 | 85 | #ifndef _MSC_VER 86 | #define _ALIGN(x) __attribute__ ((aligned(x))) 87 | #endif 88 | 89 | #undef unlikely 90 | #undef likely 91 | #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) 92 | #define unlikely(expr) (__builtin_expect(!!(expr), 0)) 93 | #define likely(expr) (__builtin_expect(!!(expr), 1)) 94 | #else 95 | #define unlikely(expr) (expr) 96 | #define likely(expr) (expr) 97 | #endif 98 | 99 | #ifndef WIN32 100 | #define MAX_PATH PATH_MAX 101 | #endif 102 | 103 | #endif /* __COMPAT_H__ */ 104 | -------------------------------------------------------------------------------- /compat/jansson/jansson_private.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 JANSSON_PRIVATE_H 9 | #define JANSSON_PRIVATE_H 10 | 11 | #include 12 | #include "jansson.h" 13 | #include "hashtable.h" 14 | #include "strbuffer.h" 15 | 16 | #define container_of(ptr_, type_, member_) \ 17 | ((type_ *)((char *)ptr_ - offsetof(type_, member_))) 18 | 19 | /* On some platforms, max() may already be defined */ 20 | #ifndef max 21 | #define max(a, b) ((a) > (b) ? (a) : (b)) 22 | #endif 23 | 24 | /* va_copy is a C99 feature. In C89 implementations, it's sometimes 25 | available as __va_copy. If not, memcpy() should do the trick. */ 26 | #ifndef va_copy 27 | #ifdef __va_copy 28 | #define va_copy __va_copy 29 | #else 30 | #define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) 31 | #endif 32 | #endif 33 | 34 | typedef struct { 35 | json_t json; 36 | hashtable_t hashtable; 37 | size_t serial; 38 | int visited; 39 | } json_object_t; 40 | 41 | typedef struct { 42 | json_t json; 43 | size_t size; 44 | size_t entries; 45 | json_t **table; 46 | int visited; 47 | } json_array_t; 48 | 49 | typedef struct { 50 | json_t json; 51 | char *value; 52 | } json_string_t; 53 | 54 | typedef struct { 55 | json_t json; 56 | double value; 57 | } json_real_t; 58 | 59 | typedef struct { 60 | json_t json; 61 | json_int_t value; 62 | } json_integer_t; 63 | 64 | #define json_to_object(json_) container_of(json_, json_object_t, json) 65 | #define json_to_array(json_) container_of(json_, json_array_t, json) 66 | #define json_to_string(json_) container_of(json_, json_string_t, json) 67 | #define json_to_real(json_) container_of(json_, json_real_t, json) 68 | #define json_to_integer(json_) container_of(json_, json_integer_t, json) 69 | 70 | void jsonp_error_init(json_error_t *error, const char *source); 71 | void jsonp_error_set_source(json_error_t *error, const char *source); 72 | void jsonp_error_set(json_error_t *error, int line, int column, 73 | size_t position, const char *msg, ...); 74 | void jsonp_error_vset(json_error_t *error, int line, int column, 75 | size_t position, const char *msg, va_list ap); 76 | 77 | /* Locale independent string<->double conversions */ 78 | int jsonp_strtod(strbuffer_t *strbuffer, double *out); 79 | int jsonp_dtostr(char *buffer, size_t size, double value); 80 | 81 | /* Wrappers for custom memory functions */ 82 | void* jsonp_malloc(size_t size); 83 | void jsonp_free(void *ptr); 84 | char *jsonp_strndup(const char *str, size_t length); 85 | char *jsonp_strdup(const char *str); 86 | 87 | /* Windows compatibility */ 88 | #ifdef _WIN32 89 | #define snprintf _snprintf 90 | #define vsnprintf _vsnprintf 91 | #endif 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /algo/pentablake.c: -------------------------------------------------------------------------------- 1 | #include "miner.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "sha3/sph_blake.h" 9 | 10 | //#define DEBUG_ALGO 11 | 12 | extern void pentablakehash(void *output, const void *input) 13 | { 14 | unsigned char _ALIGN(32) hash[128]; 15 | // same as uint32_t hashA[16], hashB[16]; 16 | #define hashB hash+64 17 | 18 | sph_blake512_context ctx_blake; 19 | 20 | sph_blake512_init(&ctx_blake); 21 | sph_blake512(&ctx_blake, input, 80); 22 | sph_blake512_close(&ctx_blake, hash); 23 | 24 | sph_blake512(&ctx_blake, hash, 64); 25 | sph_blake512_close(&ctx_blake, hashB); 26 | 27 | sph_blake512(&ctx_blake, hashB, 64); 28 | sph_blake512_close(&ctx_blake, hash); 29 | 30 | sph_blake512(&ctx_blake, hash, 64); 31 | sph_blake512_close(&ctx_blake, hashB); 32 | 33 | sph_blake512(&ctx_blake, hashB, 64); 34 | sph_blake512_close(&ctx_blake, hash); 35 | 36 | memcpy(output, hash, 32); 37 | } 38 | 39 | int scanhash_pentablake(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) 40 | { 41 | uint32_t _ALIGN(128) hash32[8]; 42 | uint32_t _ALIGN(128) endiandata[20]; 43 | uint32_t *pdata = work->data; 44 | uint32_t *ptarget = work->target; 45 | 46 | uint32_t n = pdata[19] - 1; 47 | const uint32_t first_nonce = pdata[19]; 48 | const uint32_t Htarg = ptarget[7]; 49 | 50 | uint64_t htmax[] = { 51 | 0, 52 | 0xF, 53 | 0xFF, 54 | 0xFFF, 55 | 0xFFFF, 56 | 0x10000000 57 | }; 58 | uint32_t masks[] = { 59 | 0xFFFFFFFF, 60 | 0xFFFFFFF0, 61 | 0xFFFFFF00, 62 | 0xFFFFF000, 63 | 0xFFFF0000, 64 | 0 65 | }; 66 | 67 | // we need bigendian data... 68 | for (int i=0; i < 19; i++) { 69 | be32enc(&endiandata[i], pdata[i]); 70 | } 71 | 72 | #ifdef DEBUG_ALGO 73 | if (Htarg != 0) 74 | printf("[%d] Htarg=%X\n", thr_id, Htarg); 75 | #endif 76 | for (int m=0; m < 6; m++) { 77 | if (Htarg <= htmax[m]) { 78 | uint32_t mask = masks[m]; 79 | do { 80 | pdata[19] = ++n; 81 | be32enc(&endiandata[19], n); 82 | pentablakehash(hash32, endiandata); 83 | #ifndef DEBUG_ALGO 84 | if ((!(hash32[7] & mask)) && fulltest(hash32, ptarget)) { 85 | work_set_target_ratio(work, hash32); 86 | *hashes_done = n - first_nonce + 1; 87 | return 1; 88 | } 89 | #else 90 | if (!(n % 0x1000) && !thr_id) printf("."); 91 | if (!(hash32[7] & mask)) { 92 | printf("[%d]",thr_id); 93 | if (fulltest(hash32, ptarget)) { 94 | work_set_target_ratio(work, hash32); 95 | *hashes_done = n - first_nonce + 1; 96 | return 1; 97 | } 98 | } 99 | #endif 100 | } while (n < max_nonce && !work_restart[thr_id].restart); 101 | // see blake.c if else to understand the loop on htmax => mask 102 | break; 103 | } 104 | } 105 | 106 | *hashes_done = n - first_nonce + 1; 107 | pdata[19] = n; 108 | return 0; 109 | } 110 | --------------------------------------------------------------------------------