-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linux seems working. Needs to verify windows.
- Loading branch information
Showing
16 changed files
with
740 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/*- | ||
* Copyright 2014 James Lovejoy | ||
* Copyright 2014 phm | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "miner.h" | ||
|
||
#include <stdlib.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
#include "sph/sph_blake.h" | ||
#include "sph/sph_groestl.h" | ||
#include "sph/sph_skein.h" | ||
#include "sph/sph_keccak.h" | ||
#include "sph/sph_bmw.h" | ||
#include "sph/sph_cubehash.h" | ||
#include "lyra2.h" | ||
|
||
|
||
void lyra2Zzhash(void *state, const void *input) | ||
{ | ||
sph_blake256_context ctx_blake; | ||
|
||
uint32_t hashA[8], hashB[8]; | ||
|
||
sph_blake256_init(&ctx_blake); | ||
sph_blake256 (&ctx_blake, input, 112); | ||
sph_blake256_close (&ctx_blake, hashA); | ||
|
||
LYRA2(hashB, 32, hashA, 32, hashA, 32, 8, 8, 8); | ||
|
||
memcpy(state, hashB, 32); | ||
} | ||
|
||
static const uint32_t diff1targ = 0x0000ffff; | ||
|
||
|
||
/* Used externally as confirmation of correct OCL code */ | ||
int lyra2Zz_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce) | ||
{ | ||
uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]); | ||
uint32_t data[28], ohash[8]; | ||
|
||
be32enc_vect(data, (const uint32_t *)pdata, 28); | ||
data[19] = htobe32(nonce); | ||
lyra2Zzhash(ohash, data); | ||
tmp_hash7 = be32toh(ohash[7]); | ||
|
||
applog(LOG_DEBUG, "htarget %08lx diff1 %08lx hash %08lx", | ||
(long unsigned int)Htarg, | ||
(long unsigned int)diff1targ, | ||
(long unsigned int)tmp_hash7); | ||
if (tmp_hash7 > diff1targ) | ||
return -1; | ||
if (tmp_hash7 > Htarg) | ||
return 0; | ||
return 1; | ||
} | ||
|
||
void lyra2Zz_regenhash(struct work *work) | ||
{ | ||
uint32_t data[28]; | ||
uint32_t *nonce = (uint32_t *)(work->data + 76); | ||
uint32_t *ohash = (uint32_t *)(work->hash); | ||
|
||
be32enc_vect(data, (const uint32_t *)work->data, 28); | ||
data[19] = htobe32(*nonce); | ||
lyra2Zzhash(ohash, data); | ||
} | ||
|
||
bool scanhash_lyra2Zz(struct thr_info *thr, const unsigned char __maybe_unused *pmidstate, | ||
unsigned char *pdata, unsigned char __maybe_unused *phash1, | ||
unsigned char __maybe_unused *phash, const unsigned char *ptarget, | ||
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n) | ||
{ | ||
uint32_t *nonce = (uint32_t *)(pdata + 76); | ||
uint32_t data[28]; | ||
uint32_t tmp_hash7; | ||
uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]); | ||
bool ret = false; | ||
|
||
be32enc_vect(data, (const uint32_t *)pdata, 28); | ||
|
||
while(1) { | ||
uint32_t ostate[8]; | ||
|
||
*nonce = ++n; | ||
data[19] = (n); | ||
lyra2Zzhash(ostate, data); | ||
tmp_hash7 = (ostate[7]); | ||
|
||
applog(LOG_INFO, "data7 %08lx", | ||
(long unsigned int)data[7]); | ||
|
||
if (unlikely(tmp_hash7 <= Htarg)) { | ||
((uint32_t *)pdata)[19] = htobe32(n); | ||
*last_nonce = n; | ||
ret = true; | ||
break; | ||
} | ||
|
||
if (unlikely((n >= max_nonce) || thr->work_restart)) { | ||
*last_nonce = n; | ||
break; | ||
} | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef LYRA2ZZ_H | ||
#define LYRA2ZZ_H | ||
|
||
#include "miner.h" | ||
//#define LYRA2Z_SCRATCHBUF_SIZE (24576) // matrix size [12][4][4] uint64_t or equivalent | ||
#define LYRA2ZZ_SCRATCHBUF_SIZE (12*8*8) | ||
// #define LYRA_SCRATCHBUF_SIZE (1536) | ||
#define LYRA_SECBUF_SIZE (4) // (not used) | ||
extern int lyra2Zz_test(unsigned char *pdata, const unsigned char *ptarget, | ||
uint32_t nonce); | ||
extern void lyra2Zz_regenhash(struct work *work); | ||
|
||
#endif /* LYRA2ZZ_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.