mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
v3.4.8-dev
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
Release 3.4.7 of cpuminer-opt is available for download with support for
|
||||
Release 3.4.8 of cpuminer-opt is available for download with support for
|
||||
Windows.
|
||||
|
||||
cpuminer-opt now supports 38 algorithms on CPUs with at least SSE2
|
||||
@@ -10,10 +10,10 @@ CPUs with AES_NI for even greater performance, including the Intel
|
||||
Westbridge and newer and AMD equivalent. See the performance
|
||||
comparison below.
|
||||
|
||||
New in 3.4.7
|
||||
New in 3.4.8
|
||||
|
||||
- fixed benchmark, except for x11evo
|
||||
- added CPU temperature to share submission report
|
||||
- fixed API display of diff for cryptonight
|
||||
- cleaned up some cpuminer-multi artifacts
|
||||
|
||||
Users with non-SSE2 CPUs or who want to mine algos not supported by
|
||||
cpuminer-opt may find cpuminer-multi by TPruvot useful.
|
||||
|
@@ -115,7 +115,7 @@ void init_algo_gate( algo_gate_t* gate )
|
||||
gate->wait_for_diff = (void*)&std_wait_for_diff;
|
||||
gate->get_max64 = (void*)&get_max64_0x1fffffLL;
|
||||
gate->gen_merkle_root = (void*)&sha256d_gen_merkle_root;
|
||||
gate->stratum_get_g_work = (void*)&std_stratum_get_g_work;
|
||||
gate->stratum_gen_work = (void*)&std_stratum_gen_work;
|
||||
gate->build_stratum_request = (void*)&std_le_build_stratum_request;
|
||||
gate->set_target = (void*)&std_set_target;
|
||||
gate->submit_getwork_result = (void*)&std_submit_getwork_result;
|
||||
@@ -218,7 +218,7 @@ bool register_json_rpc2( algo_gate_t *gate )
|
||||
gate->wait_for_diff = (void*)&do_nothing;
|
||||
gate->get_new_work = (void*)&jr2_get_new_work;
|
||||
gate->get_nonceptr = (void*)&jr2_get_nonceptr;
|
||||
gate->stratum_get_g_work = (void*)&jr2_stratum_get_g_work;
|
||||
gate->stratum_gen_work = (void*)&jr2_stratum_gen_work;
|
||||
gate->build_stratum_request = (void*)&jr2_build_stratum_request;
|
||||
gate->submit_getwork_result = (void*)&jr2_submit_getwork_result;
|
||||
gate->longpoll_rpc_call = (void*)&jr2_longpoll_rpc_call;
|
||||
|
@@ -115,27 +115,27 @@ void ( *hash_alt ) ( void*, const void*, uint32_t );
|
||||
void ( *hash_suw ) ( void*, const void* );
|
||||
|
||||
//optional, safe to use default in most cases
|
||||
bool ( *miner_thread_init ) ();
|
||||
void ( *stratum_get_g_work ) ( struct stratum_ctx*, struct work*, int );
|
||||
void ( *get_new_work ) ( struct work*, struct work*, int, uint32_t*,
|
||||
bool );
|
||||
uint32_t *( *get_nonceptr ) ( uint32_t* );
|
||||
void ( *display_extra_data ) ( struct work*, uint64_t* );
|
||||
void ( *wait_for_diff ) ( struct stratum_ctx* );
|
||||
int64_t ( *get_max64 ) ();
|
||||
bool ( *work_decode ) ( const struct json_t*, struct work* );
|
||||
void ( *set_target) ( struct work*, double );
|
||||
bool ( *submit_getwork_result ) ( CURL*, struct work* );
|
||||
void ( *gen_merkle_root ) ( char*, struct stratum_ctx* );
|
||||
void ( *build_stratum_request ) ( char*, struct work*, struct stratum_ctx* );
|
||||
void ( *set_work_data_endian ) ( struct work* );
|
||||
void ( *calc_network_diff ) ( struct work* );
|
||||
void ( *build_extraheader ) ( struct work*, struct stratum_ctx* );
|
||||
bool ( *prevent_dupes ) ( struct work*, struct stratum_ctx*, int );
|
||||
void ( *resync_threads ) ( struct work* );
|
||||
bool ( *do_this_thread ) ( int );
|
||||
json_t* (*longpoll_rpc_call) ( CURL*, int*, char* );
|
||||
bool ( *stratum_handle_response ) ( json_t* );
|
||||
bool ( *miner_thread_init ) ();
|
||||
void ( *stratum_gen_work ) ( struct stratum_ctx*, struct work* );
|
||||
void ( *get_new_work ) ( struct work*, struct work*, int, uint32_t*,
|
||||
bool );
|
||||
uint32_t *( *get_nonceptr ) ( uint32_t* );
|
||||
void ( *display_extra_data ) ( struct work*, uint64_t* );
|
||||
void ( *wait_for_diff ) ( struct stratum_ctx* );
|
||||
int64_t ( *get_max64 ) ();
|
||||
bool ( *work_decode ) ( const struct json_t*, struct work* );
|
||||
void ( *set_target) ( struct work*, double );
|
||||
bool ( *submit_getwork_result ) ( CURL*, struct work* );
|
||||
void ( *gen_merkle_root ) ( char*, struct stratum_ctx* );
|
||||
void ( *build_stratum_request ) ( char*, struct work*, struct stratum_ctx* );
|
||||
void ( *set_work_data_endian ) ( struct work* );
|
||||
void ( *calc_network_diff ) ( struct work* );
|
||||
void ( *build_extraheader ) ( struct work*, struct stratum_ctx* );
|
||||
bool ( *prevent_dupes ) ( struct work*, struct stratum_ctx*, int );
|
||||
void ( *resync_threads ) ( struct work* );
|
||||
bool ( *do_this_thread ) ( int );
|
||||
json_t* (*longpoll_rpc_call) ( CURL*, int*, char* );
|
||||
bool ( *stratum_handle_response )( json_t* );
|
||||
set_t optimizations;
|
||||
int ntime_index;
|
||||
int nbits_index;
|
||||
@@ -200,10 +200,8 @@ void std_get_new_work( struct work *work, struct work *g_work, int thr_id,
|
||||
void jr2_get_new_work( struct work *work, struct work *g_work, int thr_id,
|
||||
uint32_t* end_nonce_ptr );
|
||||
|
||||
void std_stratum_get_g_work( struct stratum_ctx *sctx, struct work *work,
|
||||
int thr_id );
|
||||
void jr2_stratum_get_g_work( struct stratum_ctx *sctx, struct work *work,
|
||||
int thr_id );
|
||||
void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *work );
|
||||
void jr2_stratum_gen_work( struct stratum_ctx *sctx, struct work *work );
|
||||
|
||||
void sha256d_gen_merkle_root( char *merkle_root, struct stratum_ctx *sctx );
|
||||
void SHA256_gen_merkle_root ( char *merkle_root, struct stratum_ctx *sctx );
|
||||
|
@@ -1,525 +0,0 @@
|
||||
/* $Id: bmw.c 227 2010-06-16 17:28:38Z tp $ */
|
||||
/*
|
||||
* BMW implementation.
|
||||
*
|
||||
* ==========================(LICENSE BEGIN)============================
|
||||
*
|
||||
* Copyright (c) 2007-2010 Projet RNRT SAPHIR
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ===========================(LICENSE END)=============================
|
||||
*
|
||||
* @author Thomas Pornin <thomas.pornin@cryptolog.com>
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#include "../sph_bmw.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable: 4146)
|
||||
#endif
|
||||
|
||||
static const sph_u64 bmwIV512[] = {
|
||||
SPH_C64(0x8081828384858687), SPH_C64(0x88898A8B8C8D8E8F),
|
||||
SPH_C64(0x9091929394959697), SPH_C64(0x98999A9B9C9D9E9F),
|
||||
SPH_C64(0xA0A1A2A3A4A5A6A7), SPH_C64(0xA8A9AAABACADAEAF),
|
||||
SPH_C64(0xB0B1B2B3B4B5B6B7), SPH_C64(0xB8B9BABBBCBDBEBF),
|
||||
SPH_C64(0xC0C1C2C3C4C5C6C7), SPH_C64(0xC8C9CACBCCCDCECF),
|
||||
SPH_C64(0xD0D1D2D3D4D5D6D7), SPH_C64(0xD8D9DADBDCDDDEDF),
|
||||
SPH_C64(0xE0E1E2E3E4E5E6E7), SPH_C64(0xE8E9EAEBECEDEEEF),
|
||||
SPH_C64(0xF0F1F2F3F4F5F6F7), SPH_C64(0xF8F9FAFBFCFDFEFF)
|
||||
};
|
||||
|
||||
#define XCAT(x, y) XCAT_(x, y)
|
||||
#define XCAT_(x, y) x ## y
|
||||
|
||||
#define LPAR (
|
||||
|
||||
#define I16_16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
|
||||
#define I16_17 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
|
||||
#define I16_18 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
|
||||
#define I16_19 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
|
||||
#define I16_20 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
|
||||
#define I16_21 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
|
||||
#define I16_22 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
|
||||
#define I16_23 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
|
||||
#define I16_24 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
|
||||
#define I16_25 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
|
||||
#define I16_26 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
|
||||
#define I16_27 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26
|
||||
#define I16_28 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27
|
||||
#define I16_29 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
|
||||
#define I16_30 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
|
||||
#define I16_31 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
|
||||
|
||||
#define M16_16 0, 1, 3, 4, 7, 10, 11
|
||||
#define M16_17 1, 2, 4, 5, 8, 11, 12
|
||||
#define M16_18 2, 3, 5, 6, 9, 12, 13
|
||||
#define M16_19 3, 4, 6, 7, 10, 13, 14
|
||||
#define M16_20 4, 5, 7, 8, 11, 14, 15
|
||||
#define M16_21 5, 6, 8, 9, 12, 15, 16
|
||||
#define M16_22 6, 7, 9, 10, 13, 0, 1
|
||||
#define M16_23 7, 8, 10, 11, 14, 1, 2
|
||||
#define M16_24 8, 9, 11, 12, 15, 2, 3
|
||||
#define M16_25 9, 10, 12, 13, 0, 3, 4
|
||||
#define M16_26 10, 11, 13, 14, 1, 4, 5
|
||||
#define M16_27 11, 12, 14, 15, 2, 5, 6
|
||||
#define M16_28 12, 13, 15, 16, 3, 6, 7
|
||||
#define M16_29 13, 14, 0, 1, 4, 7, 8
|
||||
#define M16_30 14, 15, 1, 2, 5, 8, 9
|
||||
#define M16_31 15, 16, 2, 3, 6, 9, 10
|
||||
|
||||
#define ss0(x) (((x) >> 1) ^ SPH_T32((x) << 3) \
|
||||
^ SPH_ROTL32(x, 4) ^ SPH_ROTL32(x, 19))
|
||||
#define ss1(x) (((x) >> 1) ^ SPH_T32((x) << 2) \
|
||||
^ SPH_ROTL32(x, 8) ^ SPH_ROTL32(x, 23))
|
||||
#define ss2(x) (((x) >> 2) ^ SPH_T32((x) << 1) \
|
||||
^ SPH_ROTL32(x, 12) ^ SPH_ROTL32(x, 25))
|
||||
#define ss3(x) (((x) >> 2) ^ SPH_T32((x) << 2) \
|
||||
^ SPH_ROTL32(x, 15) ^ SPH_ROTL32(x, 29))
|
||||
#define ss4(x) (((x) >> 1) ^ (x))
|
||||
#define ss5(x) (((x) >> 2) ^ (x))
|
||||
#define rs1(x) SPH_ROTL32(x, 3)
|
||||
#define rs2(x) SPH_ROTL32(x, 7)
|
||||
#define rs3(x) SPH_ROTL32(x, 13)
|
||||
#define rs4(x) SPH_ROTL32(x, 16)
|
||||
#define rs5(x) SPH_ROTL32(x, 19)
|
||||
#define rs6(x) SPH_ROTL32(x, 23)
|
||||
#define rs7(x) SPH_ROTL32(x, 27)
|
||||
|
||||
#define Ks(j) SPH_T32((sph_u32)(j) * SPH_C32(0x05555555))
|
||||
|
||||
#define add_elt_s(mf, hf, j0m, j1m, j3m, j4m, j7m, j10m, j11m, j16) \
|
||||
(SPH_T32(SPH_ROTL32(mf(j0m), j1m) + SPH_ROTL32(mf(j3m), j4m) \
|
||||
- SPH_ROTL32(mf(j10m), j11m) + Ks(j16)) ^ hf(j7m))
|
||||
|
||||
#define expand1s_inner(qf, mf, hf, i16, \
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, \
|
||||
i9, i10, i11, i12, i13, i14, i15, \
|
||||
i0m, i1m, i3m, i4m, i7m, i10m, i11m) \
|
||||
SPH_T32(ss1(qf(i0)) + ss2(qf(i1)) + ss3(qf(i2)) + ss0(qf(i3)) \
|
||||
+ ss1(qf(i4)) + ss2(qf(i5)) + ss3(qf(i6)) + ss0(qf(i7)) \
|
||||
+ ss1(qf(i8)) + ss2(qf(i9)) + ss3(qf(i10)) + ss0(qf(i11)) \
|
||||
+ ss1(qf(i12)) + ss2(qf(i13)) + ss3(qf(i14)) + ss0(qf(i15)) \
|
||||
+ add_elt_s(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16))
|
||||
|
||||
#define expand1s(qf, mf, hf, i16) \
|
||||
expand1s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16)
|
||||
#define expand1s_(qf, mf, hf, i16, ix, iy) \
|
||||
expand1s_inner LPAR qf, mf, hf, i16, ix, iy)
|
||||
|
||||
#define expand2s_inner(qf, mf, hf, i16, \
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, \
|
||||
i9, i10, i11, i12, i13, i14, i15, \
|
||||
i0m, i1m, i3m, i4m, i7m, i10m, i11m) \
|
||||
SPH_T32(qf(i0) + rs1(qf(i1)) + qf(i2) + rs2(qf(i3)) \
|
||||
+ qf(i4) + rs3(qf(i5)) + qf(i6) + rs4(qf(i7)) \
|
||||
+ qf(i8) + rs5(qf(i9)) + qf(i10) + rs6(qf(i11)) \
|
||||
+ qf(i12) + rs7(qf(i13)) + ss4(qf(i14)) + ss5(qf(i15)) \
|
||||
+ add_elt_s(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16))
|
||||
|
||||
#define expand2s(qf, mf, hf, i16) \
|
||||
expand2s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16)
|
||||
#define expand2s_(qf, mf, hf, i16, ix, iy) \
|
||||
expand2s_inner LPAR qf, mf, hf, i16, ix, iy)
|
||||
|
||||
#if SPH_64
|
||||
|
||||
#define sb0(x) (((x) >> 1) ^ SPH_T64((x) << 3) \
|
||||
^ SPH_ROTL64(x, 4) ^ SPH_ROTL64(x, 37))
|
||||
#define sb1(x) (((x) >> 1) ^ SPH_T64((x) << 2) \
|
||||
^ SPH_ROTL64(x, 13) ^ SPH_ROTL64(x, 43))
|
||||
#define sb2(x) (((x) >> 2) ^ SPH_T64((x) << 1) \
|
||||
^ SPH_ROTL64(x, 19) ^ SPH_ROTL64(x, 53))
|
||||
#define sb3(x) (((x) >> 2) ^ SPH_T64((x) << 2) \
|
||||
^ SPH_ROTL64(x, 28) ^ SPH_ROTL64(x, 59))
|
||||
#define sb4(x) (((x) >> 1) ^ (x))
|
||||
#define sb5(x) (((x) >> 2) ^ (x))
|
||||
#define rb1(x) SPH_ROTL64(x, 5)
|
||||
#define rb2(x) SPH_ROTL64(x, 11)
|
||||
#define rb3(x) SPH_ROTL64(x, 27)
|
||||
#define rb4(x) SPH_ROTL64(x, 32)
|
||||
#define rb5(x) SPH_ROTL64(x, 37)
|
||||
#define rb6(x) SPH_ROTL64(x, 43)
|
||||
#define rb7(x) SPH_ROTL64(x, 53)
|
||||
|
||||
#define Kb(j) SPH_T64((sph_u64)(j) * SPH_C64(0x0555555555555555))
|
||||
|
||||
#if 0
|
||||
|
||||
static const sph_u64 Kb_tab[] = {
|
||||
Kb(16), Kb(17), Kb(18), Kb(19), Kb(20), Kb(21), Kb(22), Kb(23),
|
||||
Kb(24), Kb(25), Kb(26), Kb(27), Kb(28), Kb(29), Kb(30), Kb(31)
|
||||
};
|
||||
|
||||
#define rol_off(mf, j, off) \
|
||||
SPH_ROTL64(mf(((j) + (off)) & 15), (((j) + (off)) & 15) + 1)
|
||||
|
||||
#define add_elt_b(mf, hf, j) \
|
||||
(SPH_T64(rol_off(mf, j, 0) + rol_off(mf, j, 3) \
|
||||
- rol_off(mf, j, 10) + Kb_tab[j]) ^ hf(((j) + 7) & 15))
|
||||
|
||||
#define expand1b(qf, mf, hf, i) \
|
||||
SPH_T64(sb1(qf((i) - 16)) + sb2(qf((i) - 15)) \
|
||||
+ sb3(qf((i) - 14)) + sb0(qf((i) - 13)) \
|
||||
+ sb1(qf((i) - 12)) + sb2(qf((i) - 11)) \
|
||||
+ sb3(qf((i) - 10)) + sb0(qf((i) - 9)) \
|
||||
+ sb1(qf((i) - 8)) + sb2(qf((i) - 7)) \
|
||||
+ sb3(qf((i) - 6)) + sb0(qf((i) - 5)) \
|
||||
+ sb1(qf((i) - 4)) + sb2(qf((i) - 3)) \
|
||||
+ sb3(qf((i) - 2)) + sb0(qf((i) - 1)) \
|
||||
+ add_elt_b(mf, hf, (i) - 16))
|
||||
|
||||
#define expand2b(qf, mf, hf, i) \
|
||||
SPH_T64(qf((i) - 16) + rb1(qf((i) - 15)) \
|
||||
+ qf((i) - 14) + rb2(qf((i) - 13)) \
|
||||
+ qf((i) - 12) + rb3(qf((i) - 11)) \
|
||||
+ qf((i) - 10) + rb4(qf((i) - 9)) \
|
||||
+ qf((i) - 8) + rb5(qf((i) - 7)) \
|
||||
+ qf((i) - 6) + rb6(qf((i) - 5)) \
|
||||
+ qf((i) - 4) + rb7(qf((i) - 3)) \
|
||||
+ sb4(qf((i) - 2)) + sb5(qf((i) - 1)) \
|
||||
+ add_elt_b(mf, hf, (i) - 16))
|
||||
|
||||
#else
|
||||
|
||||
#define add_elt_b(mf, hf, j0m, j1m, j3m, j4m, j7m, j10m, j11m, j16) \
|
||||
(SPH_T64(SPH_ROTL64(mf(j0m), j1m) + SPH_ROTL64(mf(j3m), j4m) \
|
||||
- SPH_ROTL64(mf(j10m), j11m) + Kb(j16)) ^ hf(j7m))
|
||||
|
||||
#define expand1b_inner(qf, mf, hf, i16, \
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, \
|
||||
i9, i10, i11, i12, i13, i14, i15, \
|
||||
i0m, i1m, i3m, i4m, i7m, i10m, i11m) \
|
||||
SPH_T64(sb1(qf(i0)) + sb2(qf(i1)) + sb3(qf(i2)) + sb0(qf(i3)) \
|
||||
+ sb1(qf(i4)) + sb2(qf(i5)) + sb3(qf(i6)) + sb0(qf(i7)) \
|
||||
+ sb1(qf(i8)) + sb2(qf(i9)) + sb3(qf(i10)) + sb0(qf(i11)) \
|
||||
+ sb1(qf(i12)) + sb2(qf(i13)) + sb3(qf(i14)) + sb0(qf(i15)) \
|
||||
+ add_elt_b(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16))
|
||||
|
||||
#define expand1b(qf, mf, hf, i16) \
|
||||
expand1b_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16)
|
||||
#define expand1b_(qf, mf, hf, i16, ix, iy) \
|
||||
expand1b_inner LPAR qf, mf, hf, i16, ix, iy)
|
||||
|
||||
#define expand2b_inner(qf, mf, hf, i16, \
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, \
|
||||
i9, i10, i11, i12, i13, i14, i15, \
|
||||
i0m, i1m, i3m, i4m, i7m, i10m, i11m) \
|
||||
SPH_T64(qf(i0) + rb1(qf(i1)) + qf(i2) + rb2(qf(i3)) \
|
||||
+ qf(i4) + rb3(qf(i5)) + qf(i6) + rb4(qf(i7)) \
|
||||
+ qf(i8) + rb5(qf(i9)) + qf(i10) + rb6(qf(i11)) \
|
||||
+ qf(i12) + rb7(qf(i13)) + sb4(qf(i14)) + sb5(qf(i15)) \
|
||||
+ add_elt_b(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16))
|
||||
|
||||
#define expand2b(qf, mf, hf, i16) \
|
||||
expand2b_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16)
|
||||
#define expand2b_(qf, mf, hf, i16, ix, iy) \
|
||||
expand2b_inner LPAR qf, mf, hf, i16, ix, iy)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define MAKE_W(tt, i0, op01, i1, op12, i2, op23, i3, op34, i4) \
|
||||
tt((M(i0) ^ H(i0)) op01 (M(i1) ^ H(i1)) op12 (M(i2) ^ H(i2)) \
|
||||
op23 (M(i3) ^ H(i3)) op34 (M(i4) ^ H(i4)))
|
||||
|
||||
#define Ws0 MAKE_W(SPH_T32, 5, -, 7, +, 10, +, 13, +, 14)
|
||||
#define Ws1 MAKE_W(SPH_T32, 6, -, 8, +, 11, +, 14, -, 15)
|
||||
#define Ws2 MAKE_W(SPH_T32, 0, +, 7, +, 9, -, 12, +, 15)
|
||||
#define Ws3 MAKE_W(SPH_T32, 0, -, 1, +, 8, -, 10, +, 13)
|
||||
#define Ws4 MAKE_W(SPH_T32, 1, +, 2, +, 9, -, 11, -, 14)
|
||||
#define Ws5 MAKE_W(SPH_T32, 3, -, 2, +, 10, -, 12, +, 15)
|
||||
#define Ws6 MAKE_W(SPH_T32, 4, -, 0, -, 3, -, 11, +, 13)
|
||||
#define Ws7 MAKE_W(SPH_T32, 1, -, 4, -, 5, -, 12, -, 14)
|
||||
#define Ws8 MAKE_W(SPH_T32, 2, -, 5, -, 6, +, 13, -, 15)
|
||||
#define Ws9 MAKE_W(SPH_T32, 0, -, 3, +, 6, -, 7, +, 14)
|
||||
#define Ws10 MAKE_W(SPH_T32, 8, -, 1, -, 4, -, 7, +, 15)
|
||||
#define Ws11 MAKE_W(SPH_T32, 8, -, 0, -, 2, -, 5, +, 9)
|
||||
#define Ws12 MAKE_W(SPH_T32, 1, +, 3, -, 6, -, 9, +, 10)
|
||||
#define Ws13 MAKE_W(SPH_T32, 2, +, 4, +, 7, +, 10, +, 11)
|
||||
#define Ws14 MAKE_W(SPH_T32, 3, -, 5, +, 8, -, 11, -, 12)
|
||||
#define Ws15 MAKE_W(SPH_T32, 12, -, 4, -, 6, -, 9, +, 13)
|
||||
|
||||
#define MAKE_Qas do { \
|
||||
qt[ 0] = SPH_T32(ss0(Ws0 ) + H( 1)); \
|
||||
qt[ 1] = SPH_T32(ss1(Ws1 ) + H( 2)); \
|
||||
qt[ 2] = SPH_T32(ss2(Ws2 ) + H( 3)); \
|
||||
qt[ 3] = SPH_T32(ss3(Ws3 ) + H( 4)); \
|
||||
qt[ 4] = SPH_T32(ss4(Ws4 ) + H( 5)); \
|
||||
qt[ 5] = SPH_T32(ss0(Ws5 ) + H( 6)); \
|
||||
qt[ 6] = SPH_T32(ss1(Ws6 ) + H( 7)); \
|
||||
qt[ 7] = SPH_T32(ss2(Ws7 ) + H( 8)); \
|
||||
qt[ 8] = SPH_T32(ss3(Ws8 ) + H( 9)); \
|
||||
qt[ 9] = SPH_T32(ss4(Ws9 ) + H(10)); \
|
||||
qt[10] = SPH_T32(ss0(Ws10) + H(11)); \
|
||||
qt[11] = SPH_T32(ss1(Ws11) + H(12)); \
|
||||
qt[12] = SPH_T32(ss2(Ws12) + H(13)); \
|
||||
qt[13] = SPH_T32(ss3(Ws13) + H(14)); \
|
||||
qt[14] = SPH_T32(ss4(Ws14) + H(15)); \
|
||||
qt[15] = SPH_T32(ss0(Ws15) + H( 0)); \
|
||||
} while (0)
|
||||
|
||||
#define MAKE_Qbs do { \
|
||||
qt[16] = expand1s(Qs, M, H, 16); \
|
||||
qt[17] = expand1s(Qs, M, H, 17); \
|
||||
qt[18] = expand2s(Qs, M, H, 18); \
|
||||
qt[19] = expand2s(Qs, M, H, 19); \
|
||||
qt[20] = expand2s(Qs, M, H, 20); \
|
||||
qt[21] = expand2s(Qs, M, H, 21); \
|
||||
qt[22] = expand2s(Qs, M, H, 22); \
|
||||
qt[23] = expand2s(Qs, M, H, 23); \
|
||||
qt[24] = expand2s(Qs, M, H, 24); \
|
||||
qt[25] = expand2s(Qs, M, H, 25); \
|
||||
qt[26] = expand2s(Qs, M, H, 26); \
|
||||
qt[27] = expand2s(Qs, M, H, 27); \
|
||||
qt[28] = expand2s(Qs, M, H, 28); \
|
||||
qt[29] = expand2s(Qs, M, H, 29); \
|
||||
qt[30] = expand2s(Qs, M, H, 30); \
|
||||
qt[31] = expand2s(Qs, M, H, 31); \
|
||||
} while (0)
|
||||
|
||||
#define MAKE_Qs do { \
|
||||
MAKE_Qas; \
|
||||
MAKE_Qbs; \
|
||||
} while (0)
|
||||
|
||||
#define Qs(j) (qt[j])
|
||||
|
||||
#define Wb0 MAKE_W(SPH_T64, 5, -, 7, +, 10, +, 13, +, 14)
|
||||
#define Wb1 MAKE_W(SPH_T64, 6, -, 8, +, 11, +, 14, -, 15)
|
||||
#define Wb2 MAKE_W(SPH_T64, 0, +, 7, +, 9, -, 12, +, 15)
|
||||
#define Wb3 MAKE_W(SPH_T64, 0, -, 1, +, 8, -, 10, +, 13)
|
||||
#define Wb4 MAKE_W(SPH_T64, 1, +, 2, +, 9, -, 11, -, 14)
|
||||
#define Wb5 MAKE_W(SPH_T64, 3, -, 2, +, 10, -, 12, +, 15)
|
||||
#define Wb6 MAKE_W(SPH_T64, 4, -, 0, -, 3, -, 11, +, 13)
|
||||
#define Wb7 MAKE_W(SPH_T64, 1, -, 4, -, 5, -, 12, -, 14)
|
||||
#define Wb8 MAKE_W(SPH_T64, 2, -, 5, -, 6, +, 13, -, 15)
|
||||
#define Wb9 MAKE_W(SPH_T64, 0, -, 3, +, 6, -, 7, +, 14)
|
||||
#define Wb10 MAKE_W(SPH_T64, 8, -, 1, -, 4, -, 7, +, 15)
|
||||
#define Wb11 MAKE_W(SPH_T64, 8, -, 0, -, 2, -, 5, +, 9)
|
||||
#define Wb12 MAKE_W(SPH_T64, 1, +, 3, -, 6, -, 9, +, 10)
|
||||
#define Wb13 MAKE_W(SPH_T64, 2, +, 4, +, 7, +, 10, +, 11)
|
||||
#define Wb14 MAKE_W(SPH_T64, 3, -, 5, +, 8, -, 11, -, 12)
|
||||
#define Wb15 MAKE_W(SPH_T64, 12, -, 4, -, 6, -, 9, +, 13)
|
||||
|
||||
#define MAKE_Qab do { \
|
||||
qt[ 0] = SPH_T64(sb0(Wb0 ) + H( 1)); \
|
||||
qt[ 1] = SPH_T64(sb1(Wb1 ) + H( 2)); \
|
||||
qt[ 2] = SPH_T64(sb2(Wb2 ) + H( 3)); \
|
||||
qt[ 3] = SPH_T64(sb3(Wb3 ) + H( 4)); \
|
||||
qt[ 4] = SPH_T64(sb4(Wb4 ) + H( 5)); \
|
||||
qt[ 5] = SPH_T64(sb0(Wb5 ) + H( 6)); \
|
||||
qt[ 6] = SPH_T64(sb1(Wb6 ) + H( 7)); \
|
||||
qt[ 7] = SPH_T64(sb2(Wb7 ) + H( 8)); \
|
||||
qt[ 8] = SPH_T64(sb3(Wb8 ) + H( 9)); \
|
||||
qt[ 9] = SPH_T64(sb4(Wb9 ) + H(10)); \
|
||||
qt[10] = SPH_T64(sb0(Wb10) + H(11)); \
|
||||
qt[11] = SPH_T64(sb1(Wb11) + H(12)); \
|
||||
qt[12] = SPH_T64(sb2(Wb12) + H(13)); \
|
||||
qt[13] = SPH_T64(sb3(Wb13) + H(14)); \
|
||||
qt[14] = SPH_T64(sb4(Wb14) + H(15)); \
|
||||
qt[15] = SPH_T64(sb0(Wb15) + H( 0)); \
|
||||
} while (0)
|
||||
|
||||
#define MAKE_Qbb do { \
|
||||
qt[16] = expand1b(Qb, M, H, 16); \
|
||||
qt[17] = expand1b(Qb, M, H, 17); \
|
||||
qt[18] = expand2b(Qb, M, H, 18); \
|
||||
qt[19] = expand2b(Qb, M, H, 19); \
|
||||
qt[20] = expand2b(Qb, M, H, 20); \
|
||||
qt[21] = expand2b(Qb, M, H, 21); \
|
||||
qt[22] = expand2b(Qb, M, H, 22); \
|
||||
qt[23] = expand2b(Qb, M, H, 23); \
|
||||
qt[24] = expand2b(Qb, M, H, 24); \
|
||||
qt[25] = expand2b(Qb, M, H, 25); \
|
||||
qt[26] = expand2b(Qb, M, H, 26); \
|
||||
qt[27] = expand2b(Qb, M, H, 27); \
|
||||
qt[28] = expand2b(Qb, M, H, 28); \
|
||||
qt[29] = expand2b(Qb, M, H, 29); \
|
||||
qt[30] = expand2b(Qb, M, H, 30); \
|
||||
qt[31] = expand2b(Qb, M, H, 31); \
|
||||
} while (0)
|
||||
|
||||
#define MAKE_Qb do { \
|
||||
MAKE_Qab; \
|
||||
MAKE_Qbb; \
|
||||
} while (0)
|
||||
|
||||
#define Qb(j) (qt[j])
|
||||
|
||||
#define FOLD(type, mkQ, tt, rol, mf, qf, dhf) do { \
|
||||
type qt[32], xl, xh; \
|
||||
mkQ; \
|
||||
xl = qf(16) ^ qf(17) ^ qf(18) ^ qf(19) \
|
||||
^ qf(20) ^ qf(21) ^ qf(22) ^ qf(23); \
|
||||
xh = xl ^ qf(24) ^ qf(25) ^ qf(26) ^ qf(27) \
|
||||
^ qf(28) ^ qf(29) ^ qf(30) ^ qf(31); \
|
||||
dhf( 0) = tt(((xh << 5) ^ (qf(16) >> 5) ^ mf( 0)) \
|
||||
+ (xl ^ qf(24) ^ qf( 0))); \
|
||||
dhf( 1) = tt(((xh >> 7) ^ (qf(17) << 8) ^ mf( 1)) \
|
||||
+ (xl ^ qf(25) ^ qf( 1))); \
|
||||
dhf( 2) = tt(((xh >> 5) ^ (qf(18) << 5) ^ mf( 2)) \
|
||||
+ (xl ^ qf(26) ^ qf( 2))); \
|
||||
dhf( 3) = tt(((xh >> 1) ^ (qf(19) << 5) ^ mf( 3)) \
|
||||
+ (xl ^ qf(27) ^ qf( 3))); \
|
||||
dhf( 4) = tt(((xh >> 3) ^ (qf(20) << 0) ^ mf( 4)) \
|
||||
+ (xl ^ qf(28) ^ qf( 4))); \
|
||||
dhf( 5) = tt(((xh << 6) ^ (qf(21) >> 6) ^ mf( 5)) \
|
||||
+ (xl ^ qf(29) ^ qf( 5))); \
|
||||
dhf( 6) = tt(((xh >> 4) ^ (qf(22) << 6) ^ mf( 6)) \
|
||||
+ (xl ^ qf(30) ^ qf( 6))); \
|
||||
dhf( 7) = tt(((xh >> 11) ^ (qf(23) << 2) ^ mf( 7)) \
|
||||
+ (xl ^ qf(31) ^ qf( 7))); \
|
||||
dhf( 8) = tt(rol(dhf(4), 9) + (xh ^ qf(24) ^ mf( 8)) \
|
||||
+ ((xl << 8) ^ qf(23) ^ qf( 8))); \
|
||||
dhf( 9) = tt(rol(dhf(5), 10) + (xh ^ qf(25) ^ mf( 9)) \
|
||||
+ ((xl >> 6) ^ qf(16) ^ qf( 9))); \
|
||||
dhf(10) = tt(rol(dhf(6), 11) + (xh ^ qf(26) ^ mf(10)) \
|
||||
+ ((xl << 6) ^ qf(17) ^ qf(10))); \
|
||||
dhf(11) = tt(rol(dhf(7), 12) + (xh ^ qf(27) ^ mf(11)) \
|
||||
+ ((xl << 4) ^ qf(18) ^ qf(11))); \
|
||||
dhf(12) = tt(rol(dhf(0), 13) + (xh ^ qf(28) ^ mf(12)) \
|
||||
+ ((xl >> 3) ^ qf(19) ^ qf(12))); \
|
||||
dhf(13) = tt(rol(dhf(1), 14) + (xh ^ qf(29) ^ mf(13)) \
|
||||
+ ((xl >> 4) ^ qf(20) ^ qf(13))); \
|
||||
dhf(14) = tt(rol(dhf(2), 15) + (xh ^ qf(30) ^ mf(14)) \
|
||||
+ ((xl >> 7) ^ qf(21) ^ qf(14))); \
|
||||
dhf(15) = tt(rol(dhf(3), 16) + (xh ^ qf(31) ^ mf(15)) \
|
||||
+ ((xl >> 2) ^ qf(22) ^ qf(15))); \
|
||||
} while (0)
|
||||
|
||||
#define FOLDs FOLD(sph_u32, MAKE_Qs, SPH_T32, SPH_ROTL32, M, Qs, dH)
|
||||
|
||||
#define FOLDb FOLD(sph_u64, MAKE_Qb, SPH_T64, SPH_ROTL64, M, Qb, dH)
|
||||
|
||||
#define DECL_BMW \
|
||||
sph_u64 bmwH[16]; \
|
||||
|
||||
/* load initial constants */
|
||||
#define BMW_I \
|
||||
do { \
|
||||
memcpy(bmwH, bmwIV512, sizeof bmwH); \
|
||||
hashptr = 0; \
|
||||
hashctA = 0; \
|
||||
} while (0)
|
||||
|
||||
/* load hash for loop */
|
||||
#define BMW_U \
|
||||
do { \
|
||||
const void *data = hash; \
|
||||
size_t len = 64; \
|
||||
unsigned char *buf; \
|
||||
\
|
||||
hashctA += (sph_u64)len << 3; \
|
||||
buf = hashbuf; \
|
||||
memcpy(buf, data, 64); \
|
||||
hashptr = 64; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* bmw512 hash loaded */
|
||||
/* hash = blake512(loaded) */
|
||||
#define BMW_C \
|
||||
do { \
|
||||
void *dst = hash; \
|
||||
size_t out_size_w64 = 8; \
|
||||
unsigned char *data; \
|
||||
sph_u64 *dh; \
|
||||
unsigned char *out; \
|
||||
size_t ptr, u, v; \
|
||||
unsigned z; \
|
||||
sph_u64 h1[16], h2[16], *h; \
|
||||
data = hashbuf; \
|
||||
ptr = hashptr; \
|
||||
z = 0x80 >> 0; \
|
||||
data[ptr ++] = ((0 & -z) | z) & 0xFF; \
|
||||
memset(data + ptr, 0, (sizeof(char)*128) - 8 - ptr); \
|
||||
sph_enc64le_aligned(data + (sizeof(char)*128) - 8, \
|
||||
SPH_T64(hashctA + 0)); \
|
||||
/* for break loop */ \
|
||||
/* one copy of inline FOLD */ \
|
||||
/* FOLD uses, */ \
|
||||
/* uint64 *h, data */ \
|
||||
/* uint64 dh, state */ \
|
||||
h = bmwH; \
|
||||
dh = h2; \
|
||||
for (;;) { \
|
||||
FOLDb; \
|
||||
/* dh gets changed for 2nd run */ \
|
||||
if (dh == h1) break; \
|
||||
for (u = 0; u < 16; u ++) \
|
||||
sph_enc64le_aligned(data + 8 * u, h2[u]); \
|
||||
dh = h1; \
|
||||
h = final_b; \
|
||||
} \
|
||||
/* end wrapped for break loop */ \
|
||||
out = dst; \
|
||||
sph_enc64le(out, h1[8]); \
|
||||
sph_enc64le(out + 8, h1[9]); \
|
||||
sph_enc64le(out + 16, h1[10]); \
|
||||
sph_enc64le(out + 24, h1[11]); \
|
||||
sph_enc64le(out + 32, h1[12]); \
|
||||
sph_enc64le(out + 40, h1[13]); \
|
||||
sph_enc64le(out + 48, h1[14]); \
|
||||
sph_enc64le(out + 56, h1[15]); \
|
||||
/* for (u = 0, v = 16 - out_size_w64; u < out_size_w64; u ++, v ++)*/ \
|
||||
/* sph_enc64le(out + 8 * u, h1[v]);*/ \
|
||||
} while (0)
|
||||
|
||||
static void
|
||||
compress_big(const unsigned char *data, const sph_u64 h[16], sph_u64 dh[16])
|
||||
{
|
||||
|
||||
#define M(x) sph_dec64le_aligned(data + 8 * (x))
|
||||
#define H(x) (h[x])
|
||||
#define dH(x) (dh[x])
|
||||
|
||||
FOLDb;
|
||||
|
||||
#undef M
|
||||
#undef H
|
||||
#undef dH
|
||||
}
|
||||
|
||||
static const sph_u64 final_b[16] = {
|
||||
SPH_C64(0xaaaaaaaaaaaaaaa0), SPH_C64(0xaaaaaaaaaaaaaaa1),
|
||||
SPH_C64(0xaaaaaaaaaaaaaaa2), SPH_C64(0xaaaaaaaaaaaaaaa3),
|
||||
SPH_C64(0xaaaaaaaaaaaaaaa4), SPH_C64(0xaaaaaaaaaaaaaaa5),
|
||||
SPH_C64(0xaaaaaaaaaaaaaaa6), SPH_C64(0xaaaaaaaaaaaaaaa7),
|
||||
SPH_C64(0xaaaaaaaaaaaaaaa8), SPH_C64(0xaaaaaaaaaaaaaaa9),
|
||||
SPH_C64(0xaaaaaaaaaaaaaaaa), SPH_C64(0xaaaaaaaaaaaaaaab),
|
||||
SPH_C64(0xaaaaaaaaaaaaaaac), SPH_C64(0xaaaaaaaaaaaaaaad),
|
||||
SPH_C64(0xaaaaaaaaaaaaaaae), SPH_C64(0xaaaaaaaaaaaaaaaf)
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Binary file not shown.
@@ -1,558 +0,0 @@
|
||||
/*
|
||||
* luffa_for_sse2.c
|
||||
* Version 2.0 (Sep 15th 2009)
|
||||
*
|
||||
* Copyright (C) 2008-2009 Hitachi, Ltd. All rights reserved.
|
||||
*
|
||||
* Hitachi, Ltd. is the owner of this software and hereby grant
|
||||
* the U.S. Government and any interested party the right to use
|
||||
* this software for the purposes of the SHA-3 evaluation process,
|
||||
* notwithstanding that this software is copyrighted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <emmintrin.h>
|
||||
#include "luffa_for_sse2.h"
|
||||
|
||||
#ifdef HASH_BIG_ENDIAN
|
||||
# define BYTES_SWAP32(x) x
|
||||
#else
|
||||
# define BYTES_SWAP32(x) \
|
||||
((x << 24) | ((x & 0x0000ff00) << 8) | ((x & 0x00ff0000) >> 8) | (x >> 24))
|
||||
#endif /* HASH_BIG_ENDIAN */
|
||||
|
||||
/* BYTES_SWAP256(x) stores each 32-bit word of 256 bits data in little-endian convention */
|
||||
#define BYTES_SWAP256(x) { \
|
||||
int _i = 8; while(_i--){x[_i] = BYTES_SWAP32(x[_i]);} \
|
||||
}
|
||||
|
||||
#define MULT2(a0,a1,t0,t1)\
|
||||
a0 = _mm_xor_si128( a0, _mm_shuffle_epi32( _mm_and_si128(a1,MASK), 16 ) ); \
|
||||
t0 = a0; \
|
||||
a0 = _mm_or_si128( _mm_srli_si128(a0,4), _mm_slli_si128(a1,12) ); \
|
||||
a1 = _mm_or_si128( _mm_srli_si128(a1,4), _mm_slli_si128(t0,12) );
|
||||
|
||||
|
||||
/*
|
||||
#define MULT2(a0,a1,t0,t1)\
|
||||
t0 = _mm_load_si128(&a1);\
|
||||
t0 = _mm_and_si128(t0,MASK);\
|
||||
t0 = _mm_shuffle_epi32(t0,16);\
|
||||
a0 = _mm_xor_si128(a0,t0);\
|
||||
t0 = _mm_load_si128(&a0);\
|
||||
t1 = _mm_load_si128(&a1);\
|
||||
a0 = _mm_srli_si128(a0,4);\
|
||||
a1 = _mm_srli_si128(a1,4);\
|
||||
t0 = _mm_slli_si128(t0,12);\
|
||||
t1 = _mm_slli_si128(t1,12);\
|
||||
a0 = _mm_or_si128(a0,t1);\
|
||||
a1 = _mm_or_si128(a1,t0);
|
||||
*/
|
||||
|
||||
#define STEP_PART(x,c,t)\
|
||||
SUBCRUMB(*x,*(x+1),*(x+2),*(x+3),*t);\
|
||||
SUBCRUMB(*(x+5),*(x+6),*(x+7),*(x+4),*t);\
|
||||
MIXWORD(*x,*(x+4),*t,*(t+1));\
|
||||
MIXWORD(*(x+1),*(x+5),*t,*(t+1));\
|
||||
MIXWORD(*(x+2),*(x+6),*t,*(t+1));\
|
||||
MIXWORD(*(x+3),*(x+7),*t,*(t+1));\
|
||||
ADD_CONSTANT(*x, *(x+4), *c, *(c+1));
|
||||
|
||||
#define STEP_PART2(a0,a1,t0,t1,c0,c1,tmp0,tmp1)\
|
||||
a1 = _mm_shuffle_epi32(a1,147);\
|
||||
t0 = _mm_load_si128(&a1);\
|
||||
a1 = _mm_unpacklo_epi32(a1,a0);\
|
||||
t0 = _mm_unpackhi_epi32(t0,a0);\
|
||||
t1 = _mm_shuffle_epi32(t0,78);\
|
||||
a0 = _mm_shuffle_epi32(a1,78);\
|
||||
SUBCRUMB(t1,t0,a0,a1,tmp0);\
|
||||
t0 = _mm_unpacklo_epi32(t0,t1);\
|
||||
a1 = _mm_unpacklo_epi32(a1,a0);\
|
||||
a0 = _mm_load_si128(&a1);\
|
||||
a0 = _mm_unpackhi_epi64(a0,t0);\
|
||||
a1 = _mm_unpacklo_epi64(a1,t0);\
|
||||
a1 = _mm_shuffle_epi32(a1,57);\
|
||||
MIXWORD(a0,a1,tmp0,tmp1);\
|
||||
ADD_CONSTANT(a0,a1,c0,c1);
|
||||
|
||||
#define SUBCRUMB(a0,a1,a2,a3,t)\
|
||||
t = _mm_load_si128(&a0);\
|
||||
a0 = _mm_or_si128(a0,a1);\
|
||||
a2 = _mm_xor_si128(a2,a3);\
|
||||
a1 = _mm_andnot_si128(a1,ALLONE);\
|
||||
a0 = _mm_xor_si128(a0,a3);\
|
||||
a3 = _mm_and_si128(a3,t);\
|
||||
a1 = _mm_xor_si128(a1,a3);\
|
||||
a3 = _mm_xor_si128(a3,a2);\
|
||||
a2 = _mm_and_si128(a2,a0);\
|
||||
a0 = _mm_andnot_si128(a0,ALLONE);\
|
||||
a2 = _mm_xor_si128(a2,a1);\
|
||||
a1 = _mm_or_si128(a1,a3);\
|
||||
t = _mm_xor_si128(t,a1);\
|
||||
a3 = _mm_xor_si128(a3,a2);\
|
||||
a2 = _mm_and_si128(a2,a1);\
|
||||
a1 = _mm_xor_si128(a1,a0);\
|
||||
a0 = _mm_load_si128(&t);\
|
||||
|
||||
#define MIXWORD(a,b,t1,t2)\
|
||||
b = _mm_xor_si128(a,b);\
|
||||
t1 = _mm_slli_epi32(a,2);\
|
||||
t2 = _mm_srli_epi32(a,30);\
|
||||
a = _mm_or_si128(t1,t2);\
|
||||
a = _mm_xor_si128(a,b);\
|
||||
t1 = _mm_slli_epi32(b,14);\
|
||||
t2 = _mm_srli_epi32(b,18);\
|
||||
b = _mm_or_si128(t1,t2);\
|
||||
b = _mm_xor_si128(a,b);\
|
||||
t1 = _mm_slli_epi32(a,10);\
|
||||
t2 = _mm_srli_epi32(a,22);\
|
||||
a = _mm_or_si128(t1,t2);\
|
||||
a = _mm_xor_si128(a,b);\
|
||||
t1 = _mm_slli_epi32(b,1);\
|
||||
t2 = _mm_srli_epi32(b,31);\
|
||||
b = _mm_or_si128(t1,t2);
|
||||
|
||||
#define ADD_CONSTANT(a,b,c0,c1)\
|
||||
a = _mm_xor_si128(a,c0);\
|
||||
b = _mm_xor_si128(b,c1);\
|
||||
|
||||
#define NMLTOM768(r0,r1,r2,s0,s1,s2,s3,p0,p1,p2,q0,q1,q2,q3)\
|
||||
s2 = _mm_load_si128(&r1);\
|
||||
q2 = _mm_load_si128(&p1);\
|
||||
r2 = _mm_shuffle_epi32(r2,216);\
|
||||
p2 = _mm_shuffle_epi32(p2,216);\
|
||||
r1 = _mm_unpacklo_epi32(r1,r0);\
|
||||
p1 = _mm_unpacklo_epi32(p1,p0);\
|
||||
s2 = _mm_unpackhi_epi32(s2,r0);\
|
||||
q2 = _mm_unpackhi_epi32(q2,p0);\
|
||||
s0 = _mm_load_si128(&r2);\
|
||||
q0 = _mm_load_si128(&p2);\
|
||||
r2 = _mm_unpacklo_epi64(r2,r1);\
|
||||
p2 = _mm_unpacklo_epi64(p2,p1);\
|
||||
s1 = _mm_load_si128(&s0);\
|
||||
q1 = _mm_load_si128(&q0);\
|
||||
s0 = _mm_unpackhi_epi64(s0,r1);\
|
||||
q0 = _mm_unpackhi_epi64(q0,p1);\
|
||||
r2 = _mm_shuffle_epi32(r2,225);\
|
||||
p2 = _mm_shuffle_epi32(p2,225);\
|
||||
r0 = _mm_load_si128(&s1);\
|
||||
p0 = _mm_load_si128(&q1);\
|
||||
s0 = _mm_shuffle_epi32(s0,225);\
|
||||
q0 = _mm_shuffle_epi32(q0,225);\
|
||||
s1 = _mm_unpacklo_epi64(s1,s2);\
|
||||
q1 = _mm_unpacklo_epi64(q1,q2);\
|
||||
r0 = _mm_unpackhi_epi64(r0,s2);\
|
||||
p0 = _mm_unpackhi_epi64(p0,q2);\
|
||||
s2 = _mm_load_si128(&r0);\
|
||||
q2 = _mm_load_si128(&p0);\
|
||||
s3 = _mm_load_si128(&r2);\
|
||||
q3 = _mm_load_si128(&p2);\
|
||||
|
||||
#define MIXTON768(r0,r1,r2,r3,s0,s1,s2,p0,p1,p2,p3,q0,q1,q2)\
|
||||
s0 = _mm_load_si128(&r0);\
|
||||
q0 = _mm_load_si128(&p0);\
|
||||
s1 = _mm_load_si128(&r2);\
|
||||
q1 = _mm_load_si128(&p2);\
|
||||
r0 = _mm_unpackhi_epi32(r0,r1);\
|
||||
p0 = _mm_unpackhi_epi32(p0,p1);\
|
||||
r2 = _mm_unpackhi_epi32(r2,r3);\
|
||||
p2 = _mm_unpackhi_epi32(p2,p3);\
|
||||
s0 = _mm_unpacklo_epi32(s0,r1);\
|
||||
q0 = _mm_unpacklo_epi32(q0,p1);\
|
||||
s1 = _mm_unpacklo_epi32(s1,r3);\
|
||||
q1 = _mm_unpacklo_epi32(q1,p3);\
|
||||
r1 = _mm_load_si128(&r0);\
|
||||
p1 = _mm_load_si128(&p0);\
|
||||
r0 = _mm_unpackhi_epi64(r0,r2);\
|
||||
p0 = _mm_unpackhi_epi64(p0,p2);\
|
||||
s0 = _mm_unpackhi_epi64(s0,s1);\
|
||||
q0 = _mm_unpackhi_epi64(q0,q1);\
|
||||
r1 = _mm_unpacklo_epi64(r1,r2);\
|
||||
p1 = _mm_unpacklo_epi64(p1,p2);\
|
||||
s2 = _mm_load_si128(&r0);\
|
||||
q2 = _mm_load_si128(&p0);\
|
||||
s1 = _mm_load_si128(&r1);\
|
||||
q1 = _mm_load_si128(&p1);\
|
||||
|
||||
#define NMLTOM1024(r0,r1,r2,r3,s0,s1,s2,s3,p0,p1,p2,p3,q0,q1,q2,q3)\
|
||||
s1 = _mm_load_si128(&r3);\
|
||||
q1 = _mm_load_si128(&p3);\
|
||||
s3 = _mm_load_si128(&r3);\
|
||||
q3 = _mm_load_si128(&p3);\
|
||||
s1 = _mm_unpackhi_epi32(s1,r2);\
|
||||
q1 = _mm_unpackhi_epi32(q1,p2);\
|
||||
s3 = _mm_unpacklo_epi32(s3,r2);\
|
||||
q3 = _mm_unpacklo_epi32(q3,p2);\
|
||||
s0 = _mm_load_si128(&s1);\
|
||||
q0 = _mm_load_si128(&q1);\
|
||||
s2 = _mm_load_si128(&s3);\
|
||||
q2 = _mm_load_si128(&q3);\
|
||||
r3 = _mm_load_si128(&r1);\
|
||||
p3 = _mm_load_si128(&p1);\
|
||||
r1 = _mm_unpacklo_epi32(r1,r0);\
|
||||
p1 = _mm_unpacklo_epi32(p1,p0);\
|
||||
r3 = _mm_unpackhi_epi32(r3,r0);\
|
||||
p3 = _mm_unpackhi_epi32(p3,p0);\
|
||||
s0 = _mm_unpackhi_epi64(s0,r3);\
|
||||
q0 = _mm_unpackhi_epi64(q0,p3);\
|
||||
s1 = _mm_unpacklo_epi64(s1,r3);\
|
||||
q1 = _mm_unpacklo_epi64(q1,p3);\
|
||||
s2 = _mm_unpackhi_epi64(s2,r1);\
|
||||
q2 = _mm_unpackhi_epi64(q2,p1);\
|
||||
s3 = _mm_unpacklo_epi64(s3,r1);\
|
||||
q3 = _mm_unpacklo_epi64(q3,p1);
|
||||
|
||||
#define MIXTON1024(r0,r1,r2,r3,s0,s1,s2,s3,p0,p1,p2,p3,q0,q1,q2,q3)\
|
||||
NMLTOM1024(r0,r1,r2,r3,s0,s1,s2,s3,p0,p1,p2,p3,q0,q1,q2,q3);
|
||||
|
||||
|
||||
static void Update512(hashState_luffa *state, const BitSequence *data, DataLength databitlen);
|
||||
|
||||
static void rnd512(hashState_luffa *state);
|
||||
|
||||
static void finalization512(hashState_luffa *state, uint32 *b);
|
||||
|
||||
|
||||
/* initial values of chaining variables */
|
||||
static const uint32 IV[40] = {
|
||||
0xdbf78465,0x4eaa6fb4,0x44b051e0,0x6d251e69,
|
||||
0xdef610bb,0xee058139,0x90152df4,0x6e292011,
|
||||
0xde099fa3,0x70eee9a0,0xd9d2f256,0xc3b44b95,
|
||||
0x746cd581,0xcf1ccf0e,0x8fc944b3,0x5d9b0557,
|
||||
0xad659c05,0x04016ce5,0x5dba5781,0xf7efc89d,
|
||||
0x8b264ae7,0x24aa230a,0x666d1836,0x0306194f,
|
||||
0x204b1f67,0xe571f7d7,0x36d79cce,0x858075d5,
|
||||
0x7cde72ce,0x14bcb808,0x57e9e923,0x35870c6a,
|
||||
0xaffb4363,0xc825b7c7,0x5ec41e22,0x6c68e9be,
|
||||
0x03e86cea,0xb07224cc,0x0fc688f1,0xf5df3999
|
||||
};
|
||||
|
||||
/* Round Constants */
|
||||
static const uint32 CNS_INIT[128] = {
|
||||
0xb213afa5,0xfc20d9d2,0xb6de10ed,0x303994a6,
|
||||
0xe028c9bf,0xe25e72c1,0x01685f3d,0xe0337818,
|
||||
0xc84ebe95,0x34552e25,0x70f47aae,0xc0e65299,
|
||||
0x44756f91,0xe623bb72,0x05a17cf4,0x441ba90d,
|
||||
0x4e608a22,0x7ad8818f,0x0707a3d4,0x6cc33a12,
|
||||
0x7e8fce32,0x5c58a4a4,0xbd09caca,0x7f34d442,
|
||||
0x56d858fe,0x8438764a,0x1c1e8f51,0xdc56983e,
|
||||
0x956548be,0x1e38e2e7,0xf4272b28,0x9389217f,
|
||||
0x343b138f,0xbb6de032,0x707a3d45,0x1e00108f,
|
||||
0xfe191be2,0x78e38b9d,0x144ae5cc,0xe5a8bce6,
|
||||
0xd0ec4e3d,0xedb780c8,0xaeb28562,0x7800423d,
|
||||
0x3cb226e5,0x27586719,0xfaa7ae2b,0x5274baf4,
|
||||
0x2ceb4882,0xd9847356,0xbaca1589,0x8f5b7882,
|
||||
0x5944a28e,0x36eda57f,0x2e48f1c1,0x26889ba7,
|
||||
0xb3ad2208,0xa2c78434,0x40a46f3e,0x96e1db12,
|
||||
0xa1c4c355,0x703aace7,0xb923c704,0x9a226e9d,
|
||||
0x00000000,0x00000000,0x00000000,0xf0d2e9e3,
|
||||
0x00000000,0x00000000,0x00000000,0x5090d577,
|
||||
0x00000000,0x00000000,0x00000000,0xac11d7fa,
|
||||
0x00000000,0x00000000,0x00000000,0x2d1925ab,
|
||||
0x00000000,0x00000000,0x00000000,0x1bcb66f2,
|
||||
0x00000000,0x00000000,0x00000000,0xb46496ac,
|
||||
0x00000000,0x00000000,0x00000000,0x6f2d9bc9,
|
||||
0x00000000,0x00000000,0x00000000,0xd1925ab0,
|
||||
0x00000000,0x00000000,0x00000000,0x78602649,
|
||||
0x00000000,0x00000000,0x00000000,0x29131ab6,
|
||||
0x00000000,0x00000000,0x00000000,0x8edae952,
|
||||
0x00000000,0x00000000,0x00000000,0x0fc053c3,
|
||||
0x00000000,0x00000000,0x00000000,0x3b6ba548,
|
||||
0x00000000,0x00000000,0x00000000,0x3f014f0c,
|
||||
0x00000000,0x00000000,0x00000000,0xedae9520,
|
||||
0x00000000,0x00000000,0x00000000,0xfc053c31
|
||||
};
|
||||
|
||||
__m128i CNS128[32];
|
||||
__m128i ALLONE;
|
||||
__m128i MASK;
|
||||
|
||||
|
||||
|
||||
HashReturn init_luffa(hashState_luffa *state, int hashbitlen)
|
||||
{
|
||||
int i;
|
||||
state->hashbitlen = hashbitlen;
|
||||
|
||||
/* set the lower 32 bits to '1' */
|
||||
MASK= _mm_set_epi32(0x00000000, 0x00000000, 0x00000000, 0xffffffff);
|
||||
|
||||
/* set all bits to '1' */
|
||||
ALLONE = _mm_set_epi32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
|
||||
|
||||
/* set the 32-bit round constant values to the 128-bit data field */
|
||||
for (i=0;i<32;i++) {
|
||||
CNS128[i] = _mm_loadu_si128((__m128i*)&CNS_INIT[i*4]);
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<10;i++)
|
||||
state->chainv[i] = _mm_loadu_si128((__m128i*)&IV[i*4]);
|
||||
|
||||
|
||||
state->bitlen[0] = 0;
|
||||
state->bitlen[1] = 0;
|
||||
state->rembitlen = 0;
|
||||
|
||||
memset(state->buffer, 0, sizeof state->buffer );
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
HashReturn update_luffa(hashState_luffa *state, const BitSequence *data, DataLength databitlen)
|
||||
{
|
||||
HashReturn ret=SUCCESS;
|
||||
int i;
|
||||
uint8 *p = (uint8*)state->buffer;
|
||||
for (i=0;i<8;i++) state->buffer[i] = BYTES_SWAP32(((uint32*)data)[i]);
|
||||
rnd512(state);
|
||||
data += MSG_BLOCK_BYTE_LEN;
|
||||
state->rembitlen = 0;
|
||||
for (i=0;i<8;i++) state->buffer[i] = BYTES_SWAP32(((uint32*)data)[i]);
|
||||
rnd512(state);
|
||||
data += MSG_BLOCK_BYTE_LEN;
|
||||
memset(p+1, 0, 31*sizeof(uint8));
|
||||
p[0] = 0x80;
|
||||
for (i=0;i<8;i++) state->buffer[i] = BYTES_SWAP32(state->buffer[i]);
|
||||
rnd512(state);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
HashReturn final_luffa(hashState_luffa *state, BitSequence *hashval)
|
||||
{
|
||||
|
||||
finalization512(state, (uint32*) hashval);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/***************************************************/
|
||||
/* Round function */
|
||||
/* state: hash context */
|
||||
|
||||
|
||||
static void rnd512(hashState_luffa *state)
|
||||
{
|
||||
__m128i t[2];
|
||||
__m128i *chainv = state->chainv;
|
||||
__m128i msg[2];
|
||||
__m128i tmp[2];
|
||||
__m128i x[8];
|
||||
int i;
|
||||
|
||||
t[0] = chainv[0];
|
||||
t[1] = chainv[1];
|
||||
|
||||
t[0] = _mm_xor_si128(t[0], chainv[2]);
|
||||
t[1] = _mm_xor_si128(t[1], chainv[3]);
|
||||
t[0] = _mm_xor_si128(t[0], chainv[4]);
|
||||
t[1] = _mm_xor_si128(t[1], chainv[5]);
|
||||
t[0] = _mm_xor_si128(t[0], chainv[6]);
|
||||
t[1] = _mm_xor_si128(t[1], chainv[7]);
|
||||
t[0] = _mm_xor_si128(t[0], chainv[8]);
|
||||
t[1] = _mm_xor_si128(t[1], chainv[9]);
|
||||
|
||||
MULT2( t[0], t[1], tmp[0], tmp[1]);
|
||||
|
||||
msg[0] = _mm_loadu_si128 ( (__m128i*)&state->buffer[0] );
|
||||
msg[1] = _mm_loadu_si128 ( (__m128i*)&state->buffer[4] );
|
||||
msg[0] = _mm_shuffle_epi32( msg[0], 27 );
|
||||
msg[1] = _mm_shuffle_epi32( msg[1], 27 );
|
||||
|
||||
chainv[0] = _mm_xor_si128( chainv[0], t[0] );
|
||||
chainv[1] = _mm_xor_si128( chainv[1], t[1] );
|
||||
chainv[2] = _mm_xor_si128( chainv[2], t[0] );
|
||||
chainv[3] = _mm_xor_si128( chainv[3], t[1] );
|
||||
chainv[4] = _mm_xor_si128( chainv[4], t[0] );
|
||||
chainv[5] = _mm_xor_si128( chainv[5], t[1] );
|
||||
chainv[6] = _mm_xor_si128( chainv[6], t[0] );
|
||||
chainv[7] = _mm_xor_si128( chainv[7], t[1] );
|
||||
chainv[8] = _mm_xor_si128( chainv[8], t[0] );
|
||||
chainv[9] = _mm_xor_si128( chainv[9], t[1] );
|
||||
|
||||
t[0] = chainv[0];
|
||||
t[1] = chainv[1];
|
||||
|
||||
MULT2( chainv[0], chainv[1], tmp[0], tmp[1]);
|
||||
|
||||
chainv[0] = _mm_xor_si128( chainv[0], chainv[2] );
|
||||
chainv[1] = _mm_xor_si128( chainv[1], chainv[3] );
|
||||
|
||||
MULT2( chainv[2], chainv[3], tmp[0], tmp[1]);
|
||||
|
||||
chainv[2] = _mm_xor_si128(chainv[2], chainv[4]);
|
||||
chainv[3] = _mm_xor_si128(chainv[3], chainv[5]);
|
||||
|
||||
MULT2( chainv[4], chainv[5], tmp[0], tmp[1]);
|
||||
|
||||
chainv[4] = _mm_xor_si128(chainv[4], chainv[6]);
|
||||
chainv[5] = _mm_xor_si128(chainv[5], chainv[7]);
|
||||
|
||||
MULT2( chainv[6], chainv[7], tmp[0], tmp[1]);
|
||||
|
||||
chainv[6] = _mm_xor_si128(chainv[6], chainv[8]);
|
||||
chainv[7] = _mm_xor_si128(chainv[7], chainv[9]);
|
||||
|
||||
MULT2( chainv[8], chainv[9], tmp[0], tmp[1]);
|
||||
|
||||
chainv[8] = _mm_xor_si128( chainv[8], t[0] );
|
||||
chainv[9] = _mm_xor_si128( chainv[9], t[1] );
|
||||
|
||||
t[0] = chainv[8];
|
||||
t[1] = chainv[9];
|
||||
|
||||
MULT2( chainv[8], chainv[9], tmp[0], tmp[1]);
|
||||
|
||||
chainv[8] = _mm_xor_si128( chainv[8], chainv[6] );
|
||||
chainv[9] = _mm_xor_si128( chainv[9], chainv[7] );
|
||||
|
||||
MULT2( chainv[6], chainv[7], tmp[0], tmp[1]);
|
||||
|
||||
chainv[6] = _mm_xor_si128( chainv[6], chainv[4] );
|
||||
chainv[7] = _mm_xor_si128( chainv[7], chainv[5] );
|
||||
|
||||
MULT2( chainv[4], chainv[5], tmp[0], tmp[1]);
|
||||
|
||||
chainv[4] = _mm_xor_si128( chainv[4], chainv[2] );
|
||||
chainv[5] = _mm_xor_si128( chainv[5], chainv[3] );
|
||||
|
||||
MULT2( chainv[2], chainv[3], tmp[0], tmp[1] );
|
||||
|
||||
chainv[2] = _mm_xor_si128( chainv[2], chainv[0] );
|
||||
chainv[3] = _mm_xor_si128( chainv[3], chainv[1] );
|
||||
|
||||
MULT2( chainv[0], chainv[1], tmp[0], tmp[1] );
|
||||
|
||||
chainv[0] = _mm_xor_si128( _mm_xor_si128( chainv[0], t[0] ), msg[0] );
|
||||
chainv[1] = _mm_xor_si128( _mm_xor_si128( chainv[1], t[1] ), msg[1] );
|
||||
|
||||
MULT2( msg[0], msg[1], tmp[0], tmp[1]);
|
||||
|
||||
chainv[2] = _mm_xor_si128( chainv[2], msg[0] );
|
||||
chainv[3] = _mm_xor_si128( chainv[3], msg[1] );
|
||||
|
||||
MULT2( msg[0], msg[1], tmp[0], tmp[1]);
|
||||
|
||||
chainv[4] = _mm_xor_si128( chainv[4], msg[0] );
|
||||
chainv[5] = _mm_xor_si128( chainv[5], msg[1] );
|
||||
|
||||
MULT2( msg[0], msg[1], tmp[0], tmp[1]);
|
||||
|
||||
chainv[6] = _mm_xor_si128( chainv[6], msg[0] );
|
||||
chainv[7] = _mm_xor_si128( chainv[7], msg[1] );
|
||||
|
||||
MULT2( msg[0], msg[1], tmp[0], tmp[1]);
|
||||
|
||||
chainv[8] = _mm_xor_si128( chainv[8], msg[0] );
|
||||
chainv[9] = _mm_xor_si128( chainv[9], msg[1] );
|
||||
|
||||
MULT2( msg[0], msg[1], tmp[0], tmp[1]);
|
||||
|
||||
chainv[3] = _mm_or_si128( _mm_slli_epi32(chainv[3], 1),
|
||||
_mm_srli_epi32(chainv[3], 31) );
|
||||
chainv[5] = _mm_or_si128( _mm_slli_epi32(chainv[5], 2),
|
||||
_mm_srli_epi32(chainv[5], 30) );
|
||||
chainv[7] = _mm_or_si128( _mm_slli_epi32(chainv[7], 3),
|
||||
_mm_srli_epi32(chainv[7], 29) );
|
||||
chainv[9] = _mm_or_si128( _mm_slli_epi32(chainv[9], 4),
|
||||
_mm_srli_epi32(chainv[9], 28) );
|
||||
|
||||
|
||||
NMLTOM1024( chainv[0], chainv[2], chainv[4], chainv[6],
|
||||
x[0], x[1], x[2], x[3],
|
||||
chainv[1],chainv[3],chainv[5],chainv[7],
|
||||
x[4], x[5], x[6], x[7] );
|
||||
|
||||
for ( i=0; i<8 ; i++ )
|
||||
{
|
||||
STEP_PART( &x[0], &CNS128[i*2], &tmp[0] );
|
||||
}
|
||||
|
||||
MIXTON1024( x[0], x[1], x[2], x[3],
|
||||
chainv[0], chainv[2], chainv[4],chainv[6],
|
||||
x[4], x[5], x[6], x[7],
|
||||
chainv[1],chainv[3],chainv[5],chainv[7]);
|
||||
|
||||
/* Process last 256-bit block */
|
||||
for ( i=0; i<8; i++ )
|
||||
{
|
||||
STEP_PART2( chainv[8], chainv[9], t[0], t[1], CNS128[16+2*i],
|
||||
CNS128[17+2*i], tmp[0], tmp[1] );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/***************************************************/
|
||||
/* Finalization function */
|
||||
/* state: hash context */
|
||||
/* b[8]: hash values */
|
||||
|
||||
static void finalization512(hashState_luffa *state, uint32 *b)
|
||||
{
|
||||
__m128i t[2];
|
||||
uint32 hash[8];
|
||||
int i;
|
||||
|
||||
/*---- blank round with m=0 ----*/
|
||||
memset(state->buffer, 0, sizeof state->buffer );
|
||||
rnd512(state);
|
||||
|
||||
t[0] = _mm_load_si128(&state->chainv[0]);
|
||||
t[1] = _mm_load_si128(&state->chainv[1]);
|
||||
t[0] = _mm_xor_si128(t[0], state->chainv[2]);
|
||||
t[1] = _mm_xor_si128(t[1], state->chainv[3]);
|
||||
t[0] = _mm_xor_si128(t[0], state->chainv[4]);
|
||||
t[1] = _mm_xor_si128(t[1], state->chainv[5]);
|
||||
t[0] = _mm_xor_si128(t[0], state->chainv[6]);
|
||||
t[1] = _mm_xor_si128(t[1], state->chainv[7]);
|
||||
t[0] = _mm_xor_si128(t[0], state->chainv[8]);
|
||||
t[1] = _mm_xor_si128(t[1], state->chainv[9]);
|
||||
|
||||
t[0] = _mm_shuffle_epi32(t[0], 27);
|
||||
t[1] = _mm_shuffle_epi32(t[1], 27);
|
||||
|
||||
_mm_storeu_si128((__m128i*)&hash[0], t[0]);
|
||||
_mm_storeu_si128((__m128i*)&hash[4], t[1]);
|
||||
|
||||
for (i=0;i<8;i++) b[i] = BYTES_SWAP32(hash[i]);
|
||||
|
||||
memset(state->buffer, 0, sizeof state->buffer );
|
||||
rnd512(state);
|
||||
|
||||
t[0] = _mm_load_si128(&state->chainv[0]);
|
||||
t[1] = _mm_load_si128(&state->chainv[1]);
|
||||
t[0] = _mm_xor_si128(t[0], state->chainv[2]);
|
||||
t[1] = _mm_xor_si128(t[1], state->chainv[3]);
|
||||
t[0] = _mm_xor_si128(t[0], state->chainv[4]);
|
||||
t[1] = _mm_xor_si128(t[1], state->chainv[5]);
|
||||
t[0] = _mm_xor_si128(t[0], state->chainv[6]);
|
||||
t[1] = _mm_xor_si128(t[1], state->chainv[7]);
|
||||
t[0] = _mm_xor_si128(t[0], state->chainv[8]);
|
||||
t[1] = _mm_xor_si128(t[1], state->chainv[9]);
|
||||
|
||||
t[0] = _mm_shuffle_epi32(t[0], 27);
|
||||
t[1] = _mm_shuffle_epi32(t[1], 27);
|
||||
|
||||
_mm_storeu_si128((__m128i*)&hash[0], t[0]);
|
||||
_mm_storeu_si128((__m128i*)&hash[4], t[1]);
|
||||
|
||||
for (i=0;i<8;i++) b[8+i] = BYTES_SWAP32(hash[i]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************************************/
|
434
algo/m7m.c.old
434
algo/m7m.c.old
@@ -1,434 +0,0 @@
|
||||
|
||||
#include "cpuminer-config.h"
|
||||
#include "miner.h"
|
||||
#include "algo-gate-api.h"
|
||||
|
||||
#include <gmp.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include "algo/sha2/sph-sha2.h"
|
||||
#include "algo/keccak/sph_keccak.h"
|
||||
#include "algo/haval/sph-haval.h"
|
||||
#include "algo/tiger/sph_tiger.h"
|
||||
#include "algo/whirlpool/sph_whirlpool.h"
|
||||
#include "algo/ripemd/sph_ripemd.h"
|
||||
|
||||
#define EPS1 DBL_EPSILON
|
||||
#define EPS2 3.0e-11
|
||||
|
||||
inline double exp_n(double xt)
|
||||
{
|
||||
if(xt < -700.0)
|
||||
return 0;
|
||||
else if(xt > 700.0)
|
||||
return 1e200;
|
||||
else if(xt > -0.8e-8 && xt < 0.8e-8)
|
||||
return (1.0 + xt);
|
||||
else
|
||||
return exp(xt);
|
||||
}
|
||||
|
||||
// 1 / (1 + exp(x1-x2))
|
||||
inline double exp_n2(double x1, double x2)
|
||||
{
|
||||
double p1 = -700., p2 = -37., p3 = -0.8e-8, p4 = 0.8e-8, p5 = 37., p6 = 700.;
|
||||
double xt = x1 - x2;
|
||||
if (xt < p1+1.e-200)
|
||||
return 1.;
|
||||
else if (xt > p1 && xt < p2 + 1.e-200)
|
||||
return ( 1. - exp(xt) );
|
||||
else if (xt > p2 && xt < p3 + 1.e-200)
|
||||
return ( 1. / (1. + exp(xt)) );
|
||||
else if (xt > p3 && xt < p4)
|
||||
return ( 1. / (2. + xt) );
|
||||
else if (xt > p4 - 1.e-200 && xt < p5)
|
||||
return ( exp(-xt) / (1. + exp(-xt)) );
|
||||
else if (xt > p5 - 1.e-200 && xt < p6)
|
||||
return ( exp(-xt) );
|
||||
else if (xt > p6 - 1.e-200)
|
||||
return 0.;
|
||||
|
||||
//return(1.0 / (1.0 + exp(x1 - x2)));
|
||||
}
|
||||
|
||||
double swit_(double wvnmb)
|
||||
{
|
||||
return pow( (5.55243*(exp_n(-0.3*wvnmb/15.762) - exp_n(-0.6*wvnmb/15.762)))*wvnmb, 0.5)
|
||||
/ 1034.66 * pow(sin(wvnmb/65.), 2.);
|
||||
}
|
||||
|
||||
double m7mGaussianQuad_N(const double x1, const double x2)
|
||||
{
|
||||
double s=0.0;
|
||||
double x[6], w[6];
|
||||
//gauleg(a2, b2, x, w);
|
||||
|
||||
int m,j;
|
||||
double z1, z, xm, xl, pp, p3, p2, p1;
|
||||
m=3;
|
||||
xm=0.5*(x2+x1);
|
||||
xl=0.5*(x2-x1);
|
||||
for(int i=1;i<=3;i++)
|
||||
{
|
||||
z = (i == 1) ? 0.909632 : -0.0;
|
||||
z = (i == 2) ? 0.540641 : z;
|
||||
do
|
||||
{
|
||||
p1 = z;
|
||||
p2 = 1;
|
||||
p3 = 0;
|
||||
|
||||
p3=1;
|
||||
p2=z;
|
||||
p1=((3.0 * z * z) - 1) / 2;
|
||||
|
||||
p3=p2;
|
||||
p2=p1;
|
||||
p1=((5.0 * z * p2) - (2.0 * z)) / 3;
|
||||
|
||||
p3=p2;
|
||||
p2=p1;
|
||||
p1=((7.0 * z * p2) - (3.0 * p3)) / 4;
|
||||
|
||||
p3=p2;
|
||||
p2=p1;
|
||||
p1=((9.0 * z * p2) - (4.0 * p3)) / 5;
|
||||
|
||||
pp=5*(z*p1-p2)/(z*z-1.0);
|
||||
z1=z;
|
||||
z=z1-p1/pp;
|
||||
} while (fabs(z-z1) > 3.0e-11);
|
||||
|
||||
x[i]=xm-xl*z;
|
||||
x[5+1-i]=xm+xl*z;
|
||||
w[i]=2.0*xl/((1.0-z*z)*pp*pp);
|
||||
w[5+1-i]=w[i];
|
||||
}
|
||||
|
||||
for(int j=1; j<=5; j++) s += w[j]*swit_(x[j]);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
uint32_t m7m_sw_(int nnounce)
|
||||
{
|
||||
double wmax = ((sqrt((double)(nnounce))*(1.+EPS1))/450+100);
|
||||
return ((uint32_t)(m7mGaussianQuad_N(0., wmax)*(1.+EPS1)*1.e6));
|
||||
}
|
||||
|
||||
static void mpz_set_uint256(mpz_t r, uint8_t *u)
|
||||
{
|
||||
mpz_import(r, 32 / sizeof(unsigned long), -1, sizeof(unsigned long), -1, 0, u);
|
||||
}
|
||||
|
||||
static void mpz_get_uint256(mpz_t r, uint8_t *u)
|
||||
{
|
||||
u=0;
|
||||
mpz_export(u, 0, -1, sizeof(unsigned long), -1, 0, r);
|
||||
}
|
||||
|
||||
static void mpz_set_uint512(mpz_t r, uint8_t *u)
|
||||
{
|
||||
mpz_import(r, 64 / sizeof(unsigned long), -1, sizeof(unsigned long), -1, 0, u);
|
||||
}
|
||||
|
||||
static void set_one_if_zero(uint8_t *hash512) {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
if (hash512[i] != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
hash512[0] = 1;
|
||||
}
|
||||
|
||||
static bool fulltest_m7hash(const uint32_t *hash32, const uint32_t *target32)
|
||||
{
|
||||
int i;
|
||||
bool rc = true;
|
||||
|
||||
const unsigned char *hash = (const unsigned char *)hash32;
|
||||
const unsigned char *target = (const unsigned char *)target32;
|
||||
for (i = 31; i >= 0; i--) {
|
||||
if (hash[i] != target[i]) {
|
||||
rc = hash[i] < target[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
sph_sha256_context sha256;
|
||||
sph_sha512_context sha512;
|
||||
sph_keccak512_context keccak;
|
||||
sph_whirlpool_context whirlpool;
|
||||
sph_haval256_5_context haval;
|
||||
sph_tiger_context tiger;
|
||||
sph_ripemd160_context ripemd;
|
||||
} m7m_ctx_holder;
|
||||
|
||||
sph_sha256_context m7m_ctx_final_sha256;
|
||||
m7m_ctx_holder m7m_ctx;
|
||||
|
||||
void init_m7m_ctx()
|
||||
{
|
||||
sph_sha256_init( &m7m_ctx_final_sha256 );
|
||||
sph_sha256_init( &m7m_ctx.sha256 );
|
||||
sph_sha512_init( &m7m_ctx.sha512 );
|
||||
sph_keccak512_init( &m7m_ctx.keccak );
|
||||
sph_whirlpool_init( &m7m_ctx.whirlpool );
|
||||
sph_haval256_5_init( &m7m_ctx.haval );
|
||||
sph_tiger_init( &m7m_ctx.tiger );
|
||||
sph_ripemd160_init( &m7m_ctx.ripemd );
|
||||
}
|
||||
|
||||
#define BITS_PER_DIGIT 3.32192809488736234787
|
||||
#define EPS (DBL_EPSILON)
|
||||
|
||||
#define NM7M 5
|
||||
#define SW_DIVS 5
|
||||
#define M7_MIDSTATE_LEN 76
|
||||
int scanhash_m7m_hash( int thr_id, struct work* work,
|
||||
uint64_t max_nonce, unsigned long *hashes_done )
|
||||
{
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
uint32_t data[32] __attribute__((aligned(128)));
|
||||
uint32_t *data_p64 = data + (M7_MIDSTATE_LEN / sizeof(data[0]));
|
||||
uint32_t hash[8] __attribute__((aligned(32)));
|
||||
uint8_t bhash[7][64] __attribute__((aligned(32)));
|
||||
uint32_t n = pdata[19] - 1;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
char data_str[161], hash_str[65], target_str[65];
|
||||
//uint8_t *bdata = 0;
|
||||
uint8_t bdata[8192];
|
||||
int rc = 0;
|
||||
int bytes, nnNonce2;
|
||||
|
||||
m7m_ctx_holder ctx1, ctx2;
|
||||
memcpy( &ctx1, &m7m_ctx, sizeof(m7m_ctx) );
|
||||
sph_sha256_context ctxf_sha256;
|
||||
memcpy( &ctxf_sha256, &m7m_ctx_final_sha256, sizeof(ctxf_sha256) );
|
||||
|
||||
memcpy(data, pdata, 80);
|
||||
|
||||
sph_sha256( &ctx1.sha256, data, M7_MIDSTATE_LEN );
|
||||
sph_sha512( &ctx1.sha512, data, M7_MIDSTATE_LEN );
|
||||
sph_keccak512( &ctx1.keccak, data, M7_MIDSTATE_LEN );
|
||||
sph_whirlpool( &ctx1.whirlpool, data, M7_MIDSTATE_LEN );
|
||||
sph_haval256_5( &ctx1.haval, data, M7_MIDSTATE_LEN );
|
||||
sph_tiger( &ctx1.tiger, data, M7_MIDSTATE_LEN );
|
||||
sph_ripemd160( &ctx1.ripemd, data, M7_MIDSTATE_LEN );
|
||||
|
||||
mpz_t magipi, magisw, product, bns[8];
|
||||
mpf_t magifpi, mpt1, mpt2, mptmp, mpten;
|
||||
|
||||
mpz_inits( magipi, magisw, bns[0], bns[1], bns[2], bns[3],
|
||||
bns[4], bns[5], bns[6], bns[7], NULL );
|
||||
mpz_init2(product, 512);
|
||||
|
||||
int digits=(int)((sqrt((double)(INT_MAX))*(1.+EPS))/9000+75);
|
||||
mpf_set_default_prec((long int)(digits*BITS_PER_DIGIT+16));
|
||||
|
||||
mpf_init(magifpi);
|
||||
mpf_init(mpt1);
|
||||
mpf_init(mpt2);
|
||||
mpf_init(mptmp);
|
||||
mpf_init_set_ui(mpten, 10);
|
||||
|
||||
do
|
||||
{
|
||||
data[19] = ++n;
|
||||
nnNonce2 = (int)(data[19]/2);
|
||||
memset(bhash, 0, 7 * 64);
|
||||
|
||||
memcpy( &ctx2, &ctx1, sizeof(m7m_ctx) );
|
||||
|
||||
sph_sha256( &ctx2.sha256, data_p64, 80 - M7_MIDSTATE_LEN );
|
||||
sph_sha256_close( &ctx2.sha256, (void*)(bhash[0]) );
|
||||
|
||||
sph_sha512( &ctx2.sha512, data_p64, 80 - M7_MIDSTATE_LEN );
|
||||
sph_sha512_close( &ctx2.sha512, (void*)(bhash[1]) );
|
||||
|
||||
sph_keccak512( &ctx2.keccak, data_p64, 80 - M7_MIDSTATE_LEN );
|
||||
sph_keccak512_close( &ctx2.keccak, (void*)(bhash[2]) );
|
||||
|
||||
sph_whirlpool( &ctx2.whirlpool, data_p64, 80 - M7_MIDSTATE_LEN );
|
||||
sph_whirlpool_close( &ctx2.whirlpool, (void*)(bhash[3]) );
|
||||
|
||||
sph_haval256_5( &ctx2.haval, data_p64, 80 - M7_MIDSTATE_LEN );
|
||||
sph_haval256_5_close( &ctx2.haval, (void*)(bhash[4])) ;
|
||||
|
||||
sph_tiger( &ctx2.tiger, data_p64, 80 - M7_MIDSTATE_LEN );
|
||||
sph_tiger_close( &ctx2.tiger, (void*)(bhash[5]) );
|
||||
|
||||
sph_ripemd160( &ctx2.ripemd, data_p64, 80 - M7_MIDSTATE_LEN );
|
||||
sph_ripemd160_close( &ctx2.ripemd, (void*)(bhash[6]) );
|
||||
|
||||
for( int i=0; i < 7; i++ )
|
||||
{
|
||||
set_one_if_zero(bhash[i]);
|
||||
mpz_set_uint512(bns[i],bhash[i]);
|
||||
}
|
||||
|
||||
//mpz_set_ui(bns[7],0);
|
||||
mpz_set(bns[7], bns[0]);
|
||||
|
||||
for(int i=1; i < 7; i++)
|
||||
mpz_add(bns[7], bns[7], bns[i]);
|
||||
|
||||
//mpz_set_ui(product,1);
|
||||
mpz_set(product, bns[0]);
|
||||
|
||||
for(int i=1; i < 8; i++)
|
||||
mpz_mul(product, product, bns[i]);
|
||||
|
||||
//mpz_pow_ui(product, product, 2);
|
||||
mpz_mul(product, product, product);
|
||||
|
||||
bytes = mpz_sizeinbase(product, 256);
|
||||
//bdata = (uint8_t *)realloc(bdata, bytes);
|
||||
mpz_export((void *)bdata, NULL, -1, 1, 0, 0, product);
|
||||
|
||||
sph_sha256( &ctxf_sha256, bdata, bytes );
|
||||
sph_sha256_close( &ctxf_sha256, (void*)(hash) );
|
||||
|
||||
int digits=(int)((sqrt((double)(nnNonce2))*(1.+EPS))/9000+75);
|
||||
int iterations=20;
|
||||
//mpf_set_default_prec((long int)(digits*BITS_PER_DIGIT+16));
|
||||
mp_bitcnt_t prec = (long int)(digits*BITS_PER_DIGIT+16);
|
||||
mpf_set_prec_raw(magifpi, prec);
|
||||
mpf_set_prec_raw(mptmp, prec);
|
||||
mpf_set_prec_raw(mpt1, prec);
|
||||
mpf_set_prec_raw(mpt2, prec);
|
||||
|
||||
uint32_t usw_ = m7m_sw_(nnNonce2);
|
||||
//if (usw_ < 1) usw_ = 1;
|
||||
usw_ = (usw_ == 0) ? 1 : usw_;
|
||||
mpz_set_ui(magisw, usw_);
|
||||
//uint32_t mpzscale=mpz_size(magisw);
|
||||
|
||||
uint32_t mpzscale = mpz_size(magisw);
|
||||
mpzscale = (mpzscale == 0) ? 1 : ((mpzscale > 1000) ? 1000 : mpzscale);
|
||||
|
||||
for(int i = 0; i < 5; i++)
|
||||
{
|
||||
//mpzscale = (mpzscale < 1) ? 1 : ((mpzscale > 1000) ? 1000 : mpzscale);
|
||||
|
||||
mpf_set_d(mpt2, 0.25*mpzscale);
|
||||
mpf_set_str(mpt1, "0.61f78a9abaa58b4698916152cf7eee1bbdf1f5b4ab3de24c3a3c159062718f716d12d59bba9c4881f@0", 16);
|
||||
mpf_sub(mpt1, mpt2, mpt1);
|
||||
|
||||
mpf_set_str(mpt2, "0.28bb03352962950bc65974466fd2c021e28cc50addfa74e94a3ec525f1887d66104fe025ccb43562b@0", 16);
|
||||
mpf_sub(mpt2, mpt1, mpt2);
|
||||
mpf_swap(mpt1, mpt2);
|
||||
|
||||
mpf_set_str(mpt2, "0.3852f236e8bf02d5c6718fc775e190c575b20b91a45e1338761547573ad5e77e5f61fc760362c231@-1", 16);
|
||||
mpf_sub(mpt2, mpt1, mpt2);
|
||||
mpf_swap(mpt1, mpt2);
|
||||
|
||||
mpf_set_str(mpt2, "0.35da65929531617012a859be186b093a9f835b39b8f14f38ac8ce59915e85f4497b3fe99c7e44e44e@-3", 16);
|
||||
mpf_sub(mpt2, mpt1, mpt2);
|
||||
mpf_swap(mpt1, mpt2);
|
||||
|
||||
mpf_set_str(mpt2, "0.189daa22ce9d43d42f773cc46e4c97fc8f625df4c82a663970a52968d90df7aa3e05294f26eec633@-7", 16);
|
||||
mpf_sub(mpt2, mpt1, mpt2);
|
||||
mpf_swap(mpt1, mpt2);
|
||||
|
||||
mpf_set_str(mpt2, "0.87127377035941932784771446314900974221284468466736176188550809681111589251132779066239512337e-20", 10);
|
||||
mpf_sub(mpt2, mpt1, mpt2);
|
||||
mpf_swap(mpt1, mpt2);
|
||||
|
||||
mpf_abs(mpt1, mpt1);
|
||||
mpf_set_str(magifpi, "0.717770011046129997821193223665779426657129889339984371989763663877269423125849866370161623127786e0", 10);
|
||||
mpf_div(magifpi, magifpi, mpt1);
|
||||
|
||||
mpf_pow_ui(mptmp, mpten, digits >> 1);
|
||||
mpf_mul(magifpi, magifpi, mptmp);
|
||||
|
||||
//mpf_mul_ui(magifpi, magifpi, pow(10.0, (double)(digits >> 1)));
|
||||
|
||||
mpz_set_f(magipi, magifpi);
|
||||
|
||||
mpz_add(product,product,magipi);
|
||||
mpz_add(product,product,magisw);
|
||||
|
||||
mpz_set_uint256(bns[0], (void*)(hash));
|
||||
mpz_add(bns[7], bns[7], bns[0]);
|
||||
|
||||
mpz_mul(product,product,bns[7]);
|
||||
mpz_cdiv_q (product, product, bns[0]);
|
||||
if (mpz_sgn(product) <= 0) mpz_set_ui(product,1);
|
||||
|
||||
bytes = mpz_sizeinbase(product, 256);
|
||||
mpzscale=bytes;
|
||||
//bdata = (uint8_t *)realloc(bdata, bytes);
|
||||
mpz_export(bdata, NULL, -1, 1, 0, 0, product);
|
||||
|
||||
sph_sha256( &ctxf_sha256, bdata, bytes );
|
||||
sph_sha256_close( &ctxf_sha256, (void*)(hash) );
|
||||
}
|
||||
|
||||
rc = fulltest_m7hash(hash, ptarget);
|
||||
if (unlikely(rc)) {
|
||||
if (opt_debug) {
|
||||
bin2hex(hash_str, (unsigned char *)hash, 32);
|
||||
bin2hex(target_str, (unsigned char *)ptarget, 32);
|
||||
bin2hex(data_str, (unsigned char *)data, 80);
|
||||
applog(LOG_DEBUG, "DEBUG: [%d thread] Found share!\ndata %s\nhash %s\ntarget %s", thr_id,
|
||||
data_str,
|
||||
hash_str,
|
||||
target_str);
|
||||
}
|
||||
|
||||
pdata[19] = data[19];
|
||||
|
||||
goto out;
|
||||
}
|
||||
} while (n < max_nonce && !work_restart[thr_id].restart);
|
||||
|
||||
pdata[19] = n;
|
||||
|
||||
out:
|
||||
digits = (int)((sqrt((double)(INT_MAX))*(1.+EPS))/9000+75);
|
||||
mp_bitcnt_t prec = (long int)(digits*BITS_PER_DIGIT+16);
|
||||
mpf_set_prec_raw(magifpi, prec);
|
||||
mpf_set_prec_raw(mptmp, prec);
|
||||
mpf_set_prec_raw(mpt1, prec);
|
||||
mpf_set_prec_raw(mpt2, prec);
|
||||
mpf_clear(magifpi);
|
||||
mpf_clear(mpten);
|
||||
mpf_clear(mptmp);
|
||||
mpf_clear(mpt1);
|
||||
mpf_clear(mpt2);
|
||||
|
||||
mpz_clears(magipi, magisw, product, bns[0], bns[1], bns[2], bns[3], bns[4], bns[5], bns[6], bns[7], NULL);
|
||||
|
||||
//free(bdata);
|
||||
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void m7m_reverse_endian( struct work *work )
|
||||
{
|
||||
swab32_array( work->data, work->data, 20 );
|
||||
}
|
||||
|
||||
bool register_m7m_algo( algo_gate_t *gate )
|
||||
{
|
||||
gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT;
|
||||
init_m7m_ctx();
|
||||
gate->scanhash = (void*)scanhash_m7m_hash;
|
||||
gate->build_stratum_request = (void*)&std_be_build_stratum_request;
|
||||
gate->set_target = (void*)&scrypt_set_target;
|
||||
gate->get_max64 = (void*)&get_max64_0x1ffff;
|
||||
gate->set_work_data_endian = (void*)&m7m_reverse_endian;
|
||||
gate->work_data_size = 80;
|
||||
return true;
|
||||
}
|
||||
|
12
api.c
12
api.c
@@ -135,6 +135,8 @@ static char *getsummary(char *params)
|
||||
time_t ts = time(NULL);
|
||||
double uptime = difftime(ts, startup);
|
||||
double accps = (60.0 * accepted_count) / (uptime ? uptime : 1.0);
|
||||
double diff = net_diff > 0. ? net_diff : stratum_diff;
|
||||
char diff_str[16];
|
||||
|
||||
struct cpu_info cpu = { 0 };
|
||||
#ifdef USE_MONITORING
|
||||
@@ -146,14 +148,20 @@ static char *getsummary(char *params)
|
||||
|
||||
get_currentalgo(algo, sizeof(algo));
|
||||
|
||||
// if diff is integer don't display decimals
|
||||
if ( diff == trunc( diff ) )
|
||||
sprintf( diff_str, "%.0f", diff);
|
||||
else
|
||||
sprintf( diff_str, "%.6f", diff);
|
||||
|
||||
*buffer = '\0';
|
||||
sprintf(buffer, "NAME=%s;VER=%s;API=%s;"
|
||||
"ALGO=%s;CPUS=%d;KHS=%.2f;ACC=%d;REJ=%d;"
|
||||
"ACCMN=%.3f;DIFF=%.6f;TEMP=%.1f;FAN=%d;FREQ=%d;"
|
||||
"ACCMN=%.3f;DIFF=%s;TEMP=%.1f;FAN=%d;FREQ=%d;"
|
||||
"UPTIME=%.0f;TS=%u|",
|
||||
PACKAGE_NAME, PACKAGE_VERSION, APIVERSION,
|
||||
algo, opt_n_threads, (double)global_hashrate / 1000.0,
|
||||
accepted_count, rejected_count, accps, net_diff > 0. ? net_diff : stratum_diff,
|
||||
accepted_count, rejected_count, accps, diff_str,
|
||||
cpu.cpu_temp, cpu.cpu_fan, cpu.cpu_clock,
|
||||
uptime, (uint32_t) ts);
|
||||
return buffer;
|
||||
|
@@ -190,7 +190,7 @@ li span.algo { display: inline-block; width: 100px; max-width: 180px; }
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<p>© 2014 <a href="http://github.com/tpruvot/cpuminer-multi">tpruvot@github</a></p>
|
||||
<p>© 2014 <a href="https://github.com/JayDDee/cpuminer-opt">jayddee246@gmail.com</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
Binary file not shown.
Binary file not shown.
1928
compat/gmp.h.del
1928
compat/gmp.h.del
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
AC_INIT([cpuminer-multi], [1.2-dev])
|
||||
AC_INIT([cpuminer-opt], [4.3.8-dev)
|
||||
|
||||
AC_PREREQ([2.59c])
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
40
cpu-miner.c
40
cpu-miner.c
@@ -1623,7 +1623,6 @@ static void *miner_thread( void *userdata )
|
||||
struct timeval tv_start, tv_end, diff;
|
||||
int64_t max64;
|
||||
int nonce_found = 0;
|
||||
|
||||
if ( algo_gate.do_this_thread( thr_id ) )
|
||||
{
|
||||
if (have_stratum)
|
||||
@@ -2051,8 +2050,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void std_stratum_get_g_work( struct stratum_ctx *sctx, struct work *g_work,
|
||||
int thr_id )
|
||||
void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
|
||||
{
|
||||
unsigned char merkle_root[64] = { 0 };
|
||||
int i;
|
||||
@@ -2092,10 +2090,22 @@ void std_stratum_get_g_work( struct stratum_ctx *sctx, struct work *g_work,
|
||||
}
|
||||
/* set target */
|
||||
algo_gate.set_target( g_work, sctx->job.diff );
|
||||
|
||||
if ( stratum_diff != sctx->job.diff )
|
||||
{
|
||||
char sdiff[32] = { 0 };
|
||||
// store for api stats
|
||||
stratum_diff = sctx->job.diff;
|
||||
if ( opt_showdiff && g_work->targetdiff != stratum_diff )
|
||||
{
|
||||
snprintf( sdiff, 32, " (%.5f)", g_work->targetdiff );
|
||||
applog( LOG_WARNING, "Stratum difficulty set to %g%s", stratum_diff,
|
||||
sdiff );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void jr2_stratum_get_g_work( struct stratum_ctx *sctx, struct work *g_work,
|
||||
int thr_id )
|
||||
void jr2_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
|
||||
{
|
||||
pthread_mutex_lock( &sctx->work_lock );
|
||||
work_free( g_work );
|
||||
@@ -2103,24 +2113,6 @@ void jr2_stratum_get_g_work( struct stratum_ctx *sctx, struct work *g_work,
|
||||
pthread_mutex_unlock( &sctx->work_lock );
|
||||
}
|
||||
|
||||
static void stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work,
|
||||
int thr_id )
|
||||
{
|
||||
algo_gate.stratum_get_g_work( sctx, g_work, thr_id );
|
||||
if ( stratum_diff != sctx->job.diff )
|
||||
{
|
||||
char sdiff[32] = { 0 };
|
||||
// store for api stats
|
||||
stratum_diff = sctx->job.diff;
|
||||
if ( opt_showdiff && g_work->targetdiff != stratum_diff )
|
||||
{
|
||||
snprintf( sdiff, 32, " (%.5f)", g_work->targetdiff );
|
||||
applog( LOG_WARNING, "Stratum difficulty set to %g%s", stratum_diff,
|
||||
sdiff );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void *stratum_thread(void *userdata )
|
||||
{
|
||||
struct thr_info *mythr = (struct thr_info *) userdata;
|
||||
@@ -2180,7 +2172,7 @@ static void *stratum_thread(void *userdata )
|
||||
(!g_work_time || strcmp(stratum.job.job_id, g_work.job_id)) )
|
||||
{
|
||||
pthread_mutex_lock(&g_work_lock);
|
||||
stratum_gen_work(&stratum, &g_work, 0 );
|
||||
algo_gate.stratum_gen_work( &stratum, &g_work );
|
||||
time(&g_work_time);
|
||||
pthread_mutex_unlock(&g_work_lock);
|
||||
|
||||
|
26
util.c
26
util.c
@@ -1622,19 +1622,19 @@ bool rpc2_job_decode(const json_t *job, struct work *work)
|
||||
free(blob);
|
||||
|
||||
jobj_binary(job, "target", &target, 4);
|
||||
if(rpc2_target != target) {
|
||||
double hashrate = 0.0;
|
||||
pthread_mutex_lock(&stats_lock);
|
||||
for (int i = 0; i < opt_n_threads; i++)
|
||||
hashrate += thr_hashrates[i];
|
||||
pthread_mutex_unlock(&stats_lock);
|
||||
double difficulty = (((double) 0xffffffff) / target);
|
||||
if (!opt_quiet) {
|
||||
// xmr pool diff can change a lot...
|
||||
applog(LOG_WARNING, "Stratum difficulty set to %g", difficulty);
|
||||
}
|
||||
stratum_diff = difficulty;
|
||||
rpc2_target = target;
|
||||
if(rpc2_target != target)
|
||||
{
|
||||
double hashrate = 0.0;
|
||||
pthread_mutex_lock(&stats_lock);
|
||||
for (int i = 0; i < opt_n_threads; i++)
|
||||
hashrate += thr_hashrates[i];
|
||||
pthread_mutex_unlock(&stats_lock);
|
||||
double diff = trunc( ( ((double)0xffffffff) / target ) );
|
||||
if (!opt_quiet)
|
||||
// xmr pool diff can change a lot...
|
||||
applog(LOG_WARNING, "Stratum difficulty set to %g", diff);
|
||||
stratum_diff = diff;
|
||||
rpc2_target = target;
|
||||
}
|
||||
|
||||
if (rpc2_job_id) free(rpc2_job_id);
|
||||
|
Reference in New Issue
Block a user