示例#1
0
void lyra2re3_hash(const char* input, char* output)
{
    sph_blake256_context ctx_blake;
    sph_cubehash256_context ctx_cubehash;
    sph_bmw256_context ctx_bmw;

    uint32_t hashA[8], hashB[8];

    sph_blake256_init(&ctx_blake);
    sph_blake256(&ctx_blake, input, 80);
    sph_blake256_close (&ctx_blake, hashA);	

    LYRA2_3(hashB, 32, hashA, 32, hashA, 32, 1, 4, 4);
    
    sph_cubehash256_init(&ctx_cubehash);
    sph_cubehash256(&ctx_cubehash, hashB, 32);
    sph_cubehash256_close(&ctx_cubehash, hashA);
    
    LYRA2_3(hashB, 32, hashA, 32, hashA, 32, 1, 4, 4);
    
    sph_bmw256_init(&ctx_bmw);
    sph_bmw256(&ctx_bmw, hashB, 32);
    sph_bmw256_close(&ctx_bmw, hashA);
    
    memcpy(output, hashA, 32);
}
示例#2
0
void lyra2re_hash(const char* input, char* output)
{
    sph_blake256_context     ctx_blake;
    sph_groestl256_context   ctx_groestl;
    sph_keccak256_context    ctx_keccak;
    sph_skein256_context     ctx_skein;

    uint32_t hashA[8], hashB[8];

    sph_blake256_init(&ctx_blake);
    sph_blake256 (&ctx_blake, input, 80);
    sph_blake256_close (&ctx_blake, hashA);

    sph_keccak256_init(&ctx_keccak);
    sph_keccak256 (&ctx_keccak,hashA, 32);
    sph_keccak256_close(&ctx_keccak, hashB);

	LYRA2((void*)hashA, 32, (const void*)hashB, 32, (const void*)hashB, 32, 1, 8, 8);

	sph_skein256_init(&ctx_skein);
    sph_skein256 (&ctx_skein, hashA, 32);
    sph_skein256_close(&ctx_skein, hashB);

    sph_groestl256_init(&ctx_groestl);
    sph_groestl256 (&ctx_groestl, hashB, 32);
    sph_groestl256_close(&ctx_groestl, hashA);

	memcpy(output, hashA, 32);
}
示例#3
0
void lyra2z_hash(uint64_t* wholeMatrix, void *state, const void *input)
{
#ifdef VERBOSE_HASH_TIMING
	struct timespec spec;
    clock_gettime(CLOCK_REALTIME, &spec);
    double start = spec.tv_sec + spec.tv_nsec / 1.0e9;
#endif

	sph_blake256_context     ctx_blake;

	uint32_t hashA[8], hashB[8];

	sph_blake256_init(&ctx_blake);
	sph_blake256(&ctx_blake, input, 80);
	sph_blake256_close(&ctx_blake, hashA);

//	LYRA2(0, hashB, 32, hashA, 32, hashA, 32, 2, 8, 8);

	LYRA2(wholeMatrix, hashB, 32, hashA, 32, hashA, 32, 8, 8, 8);

#ifdef VERBOSE_HASH_TIMING
    if (hash[0] % 32 == 0) {
    	clock_gettime(CLOCK_REALTIME, &spec);
    	double end = spec.tv_sec + spec.tv_nsec / 1.0e9;
    	printf("Hash time: %f ms\n", (end - start) * 1000);
    }
#endif

	memcpy(state, hashB, 32);
}
示例#4
0
文件: lyra2re.c 项目: bbr25/twlv
void lyra2_hash(void *state, const void *input)
{
	sph_blake256_context     ctx_blake;
	sph_keccak256_context    ctx_keccak;
	sph_skein256_context     ctx_skein;
	sph_groestl256_context   ctx_groestl;

	uint32_t hashA[8], hashB[8];

	sph_blake256_init(&ctx_blake);
	sph_blake256(&ctx_blake, input, 80);
	sph_blake256_close(&ctx_blake, hashA);

	sph_keccak256_init(&ctx_keccak);
	sph_keccak256(&ctx_keccak, hashA, 32);
	sph_keccak256_close(&ctx_keccak, hashB);

	LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);

	sph_skein256_init(&ctx_skein);
	sph_skein256(&ctx_skein, hashA, 32);
	sph_skein256_close(&ctx_skein, hashB);

	sph_groestl256_init(&ctx_groestl);
	sph_groestl256(&ctx_groestl, hashB, 32);
	sph_groestl256_close(&ctx_groestl, hashA);

	memcpy(state, hashA, 32);
}
示例#5
0
void blake256_regenhash(struct work *work)
{
	uint32_t data[45];
	uint32_t *nonce = (uint32_t *)(work->data + 140);
	uint32_t *ohash = (uint32_t *)(work->hash);

	be32enc_vect(data, (const uint32_t *)work->data, 45);
	data[35] = *nonce; //htobe32(*nonce);
        
	applog(LOG_DEBUG, "timestamp %x", data[34]);
	applog(LOG_DEBUG, "lucky nonce %x", data[35]);
        
        applog(LOG_DEBUG, "Dat0: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9],
            data[10], data[11], data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19]);
        applog(LOG_DEBUG, "Dat1: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x", data[20], data[21], data[22], data[23], data[24], data[25], data[26], data[27], data[28], data[29],
            data[30], data[31], data[32], data[33], data[34], data[35], data[36], data[37], data[38], data[39]);
        applog(LOG_DEBUG, "Dat2: %x %x %x %x %x\n", data[40], data[41], data[42], data[43], data[44]);


	uint32_t swap[45];
	flip180(swap, data);
	int i;
	for (i=0; i<45; ++i) {
		data[i] = swap[i];
	}
		
    sph_blake256_context     ctx_blake;
    sph_blake256_init(&ctx_blake);
    sph_blake256 (&ctx_blake, (unsigned char *)data, 180);
    sph_blake256_close(&ctx_blake, (unsigned char *)ohash);
	
	applog(LOG_DEBUG, "Hash produced: %x %x %x %x %x %x %x %x", ohash[0], ohash[1], ohash[2], ohash[3], ohash[4], ohash[5], ohash[6], ohash[7]);
    
    uint32_t *o = ohash;
}
示例#6
0
文件: blake256.c 项目: Jtl12/sgminer
void blake256hash(void *state, const void *input)
{
  sph_blake256_context ctx_blake;
  sph_blake256_init(&ctx_blake);
  sph_blake256(&ctx_blake, input, 80);
  sph_blake256_close(&ctx_blake, state);
}
示例#7
0
void decred_hash_simple(void *state, const void *input)
{
        sph_blake256_context ctx;
        sph_blake256_init(&ctx);
        sph_blake256(&ctx, input, 180);
        sph_blake256_close(&ctx, state);
}
示例#8
0
/* Used externally as confirmation of correct OCL code */
int blake256_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[20], ohash[8];

	be32enc_vect(data, (const uint32_t *)pdata, 19);
	data[19] = nonce;
    
        applog(LOG_DEBUG, "Dat0: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9],
            data[10], data[11], data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19]);
    
    sph_blake256_context     ctx_blake;
    static unsigned char pblank[1];
    sph_blake256_init(&ctx_blake);
    sph_blake256 (&ctx_blake, (unsigned char *)data, 80);
    sph_blake256_close(&ctx_blake, (unsigned char *)ohash);

	flip32(ohash, ohash); // Not needed for scrypt-chacha - mikaelh
    uint32_t *o = ohash;
	applog(LOG_DEBUG, "Nonce: %x, Output buffe0: %x %x %x %x %x %x %x %x", nonce, o[0], o[1], o[2], o[3], o[4], o[5], o[6], o[7]);
    
	tmp_hash7 = ohash[7];

	applog(LOG_DEBUG, "Nonce %x harget %08lx diff1 %08lx hash %08lx",
                                nonce,
				(long unsigned int)Htarg,
				(long unsigned int)diff1targ_blake256,
				(long unsigned int)tmp_hash7);
	if (tmp_hash7 > diff1targ_blake256)
		return -1;
	if (tmp_hash7 > Htarg)
		return 0;
	return 1;
}
示例#9
0
void lyra2re_hash(void *state, const void *input)
{
        lyra2re_ctx_holder ctx;
        memcpy(&ctx, &lyra2re_ctx, sizeof(lyra2re_ctx));

//        uint32_t _ALIGN(128) hashA[8], hashB[8];
	uint32_t _ALIGN(128) hash[32];
        #define hashA hash
        #define hashB hash+16

	sph_blake256(&ctx.blake, input, 80);
	sph_blake256_close(&ctx.blake, hashA);

	sph_keccak256(&ctx.keccak, hashA, 32);
	sph_keccak256_close(&ctx.keccak, hashB);

	LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);

	sph_skein256(&ctx.skein, hashA, 32);
	sph_skein256_close(&ctx.skein, hashB);

#ifdef NO_AES_NI
	sph_groestl256( &ctx.groestl, hashB, 32 );
	sph_groestl256_close( &ctx.groestl, hashA );
#else
        update_groestl256( &ctx.groestl, hashB, 256 );
        final_groestl256( &ctx.groestl, hashA );
#endif

	memcpy(state, hashA, 32);
}
示例#10
0
int crypto_hash(unsigned char *out,const unsigned char *in,unsigned long long inlen)
{
  sph_blake256_context mc;
  sph_blake256_init(&mc);
  sph_blake256(&mc, in, inlen);
  sph_blake256_close(&mc,out);
  return 0;
}
示例#11
0
void blake_hash(const char* input, char* output)
{
    sph_blake256_context ctx_blake;

    sph_blake256_init(&ctx_blake);

    sph_blake256 (&ctx_blake, input, 80);

    sph_blake256_close (&ctx_blake, output);
}
示例#12
0
文件: Lyra2Z.c 项目: kwccoin/zcoin
void lyra2z_hash(const char* input, char* output)
{
    sph_blake256_context     ctx_blake;

    uint32_t hashA[8], hashB[8];

    sph_blake256_init(&ctx_blake);
    sph_blake256 (&ctx_blake, input, 80);
    sph_blake256_close (&ctx_blake, hashA);	
	
	LYRA2(hashB, 32, hashA, 32, hashA, 32, 8, 8, 8);
	
	memcpy(output, hashB, 32);
}
示例#13
0
static void blakehash(void *state, const void *input)
{
    blakehash_context_holder ctx;
//an array of uint32
    uint32_t hashA[8];
	

//do one memcopy to get fresh contexts, its faster even with a larger block then issuing 9 memcopies
    memcpy(&ctx, &base_contexts, sizeof(base_contexts));

    sph_blake256 (&ctx.blake1, input, 80);
    sph_blake256_close (&ctx.blake1, hashA);	 //0
    memcpy(state, hashA, 32);

}
示例#14
0
void blakehash(void *state, const void *input)
{
	sph_blake256_context ctx;

	uint8_t *ending = (uint8_t*) input;
	ending += 64;

	// do one memcopy to get a fresh context
	if (!ctx_midstate_done) {
		sph_blake256_init(&blake_mid);
		sph_blake256(&blake_mid, input, 64);
		ctx_midstate_done = true;
	}
	memcpy(&ctx, &blake_mid, sizeof(blake_mid));

	sph_blake256(&ctx, ending, 16);
	sph_blake256_close(&ctx, state);
}
示例#15
0
void decred_hash(void *state, const void *input)
{
        #define MIDSTATE_LEN 128
        sph_blake256_context ctx;

        uint8_t *ending = (uint8_t*) input;
        ending += MIDSTATE_LEN;

        if (!ctx_midstate_done) {
                sph_blake256_init(&blake_mid);
                sph_blake256(&blake_mid, input, MIDSTATE_LEN);
                ctx_midstate_done = true;
        }
        memcpy(&ctx, &blake_mid, sizeof(blake_mid));

        sph_blake256(&ctx, ending, (180 - MIDSTATE_LEN));
        sph_blake256_close(&ctx, state);
}
示例#16
0
文件: blake.c 项目: bbr25/twlv
void blakehash(void *state, const void *input)
{
	sph_blake256_context ctx;

	uint8_t hash[64];
	uint8_t *ending = (uint8_t*) input;
	ending += 64;

	// do one memcopy to get a fresh context
	if (!ctx_midstate_done) {
		init_blake_hash();
		sph_blake256(&blake_mid, input, 64);
	}
	memcpy(&ctx, &blake_mid, sizeof(blake_mid));

	sph_blake256(&ctx, ending, 16);
	sph_blake256_close(&ctx, hash);

	memcpy(state, hash, 32);
}
示例#17
0
void blake256_regenhash(struct work *work)
{
	uint32_t data[20];
	uint32_t *nonce = (uint32_t *)(work->data + 76);
	uint32_t *ohash = (uint32_t *)(work->hash);

	be32enc_vect(data, (const uint32_t *)work->data, 19);
	data[19] = htobe32(*nonce);
        
	applog(LOG_DEBUG, "timestamp %d", data[17]);
        
        applog(LOG_DEBUG, "Dat0: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9],
            data[10], data[11], data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19]);
        
    sph_blake256_context     ctx_blake;
    sph_blake256_init(&ctx_blake);
    sph_blake256 (&ctx_blake, (unsigned char *)data, 80);
    sph_blake256_close(&ctx_blake, (unsigned char *)ohash);
    
    uint32_t *o = ohash;
}
示例#18
0
inline void lyra2rev2hash(void *state, const void *input)
{
    sph_blake256_context     ctx_blake;
    sph_bmw256_context       ctx_bmw;
    sph_keccak256_context    ctx_keccak;
    sph_skein256_context     ctx_skein;
    sph_cubehash256_context  ctx_cube;
    uint32_t hashA[8], hashB[8];

    sph_blake256_init(&ctx_blake);
    sph_blake256 (&ctx_blake, input, 80);
    sph_blake256_close (&ctx_blake, hashA);

    sph_keccak256_init(&ctx_keccak);
    sph_keccak256 (&ctx_keccak,hashA, 32);
    sph_keccak256_close(&ctx_keccak, hashB);

	sph_cubehash256_init(&ctx_cube);
	sph_cubehash256(&ctx_cube, hashB, 32);
	sph_cubehash256_close(&ctx_cube, hashA);

	LYRA2(hashB, 32, hashA, 32, hashA, 32, 1, 4, 4);

	sph_skein256_init(&ctx_skein);
    sph_skein256 (&ctx_skein, hashB, 32);
    sph_skein256_close(&ctx_skein, hashA);

	sph_cubehash256_init(&ctx_cube);
	sph_cubehash256(&ctx_cube, hashA, 32);
	sph_cubehash256_close(&ctx_cube, hashB);

    sph_bmw256_init(&ctx_bmw);
    sph_bmw256 (&ctx_bmw, hashB, 32);
    sph_bmw256_close(&ctx_bmw, hashA);

//printf("cpu hash %08x %08x %08x %08x\n",hashA[0],hashA[1],hashA[2],hashA[3]);

	memcpy(state, hashA, 32);
}
示例#19
0
void hive_hash(const char* input, char* output)
{
    sph_blake256_context     ctx_blake;
    sph_shabal256_context       ctx_shabal;
    sph_keccak256_context    ctx_keccak;


//    uint32_t hashA[16], hashB[16];
    uint32_t  hashA[8], hashB[8];



    sph_shabal256_init(&ctx_shabal);
    sph_shabal256 (&ctx_shabal, input, 80);
    sph_shabal256_close (&ctx_shabal, hashA);	 //0


    POMELO(hashB, 32, hashA, 32, hashA, 32, 2, 10);


    sph_blake256_init(&ctx_blake);
    sph_blake256 (&ctx_blake, hashA, 32);    //0
    sph_blake256_close(&ctx_blake, hashB);   //1


    sph_keccak256_init(&ctx_keccak);
    sph_keccak256 (&ctx_keccak, hashB, 32); //2
    sph_keccak256_close(&ctx_keccak, hashA); //3



	memcpy(output, hashA, 32);





}
示例#20
0
inline void lyra2rehash(void *state, const void *input)
{
    sph_blake256_context     ctx_blake;
    sph_groestl256_context   ctx_groestl;
    sph_keccak256_context    ctx_keccak;
    sph_skein256_context     ctx_skein;

    uint32_t hashA[8], hashB[8];

    sph_blake256_init(&ctx_blake);
    sph_blake256 (&ctx_blake, input, 80);
    sph_blake256_close (&ctx_blake, hashA);




    sph_keccak256_init(&ctx_keccak);
    sph_keccak256 (&ctx_keccak,hashA, 32);
    sph_keccak256_close(&ctx_keccak, hashB);

	LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);


	sph_skein256_init(&ctx_skein);
    sph_skein256 (&ctx_skein, hashA, 32);
    sph_skein256_close(&ctx_skein, hashB);


    sph_groestl256_init(&ctx_groestl);
    sph_groestl256 (&ctx_groestl, hashB, 32);
    sph_groestl256_close(&ctx_groestl, hashA);

//printf("cpu hash %08x %08x %08x %08x\n",hashA[0],hashA[1],hashA[2],hashA[3]);

	memcpy(state, hashA, 32);
}