Example #1
0
void grs80(const char* input, char* output)
{
	uint32_t hashA[16],hashB[16];	
	sph_groestl512_context	ctx_groestl[2];

	sph_groestl512_init(&ctx_groestl[0]);
	sph_groestl512 (&ctx_groestl[0], input, 80); 
	sph_groestl512_close(&ctx_groestl[0], hashA); 

	sph_groestl512_init(&ctx_groestl[1]);
	sph_groestl512 (&ctx_groestl[1], hashA, 64); 
	sph_groestl512_close(&ctx_groestl[1], hashB); 

	memcpy(output, hashB, 32);
}
BinaryData BtcUtils::getGroestlHash(uint8_t const * strToHash, uint32_t nBytes) {
    sph_groestl512_context  ctx_gr[2];
    static unsigned char pblank[1];
    uint8_t hash1[64];
	
    sph_groestl512_init(&ctx_gr[0]);
    sph_groestl512 (&ctx_gr[0], strToHash ? strToHash : pblank, nBytes);
    sph_groestl512_close(&ctx_gr[0], hash1);
	
	uint8_t hash2[64];
	sph_groestl512_init(&ctx_gr[1]);
	sph_groestl512(&ctx_gr[1], hash1, 64);
	sph_groestl512_close(&ctx_gr[1], hash2);

	return BinaryData(hash2, 32);
}
Example #3
0
static void GroestlCoinHash(const char *input, int length, char *output)
{
    uint32_t hashA[16], hashB[16];
    
    sph_groestl512_context ctx_groestl[2];

    sph_groestl512_init(&ctx_groestl[0]);
    sph_groestl512 (&ctx_groestl[0], input, length); 
    sph_groestl512_close(&ctx_groestl[0], hashA); 
    
    sph_groestl512_init(&ctx_groestl[1]);
    sph_groestl512 (&ctx_groestl[1], hashA, 64); 
    sph_groestl512_close(&ctx_groestl[1], hashB); 
    
    memcpy(output, hashB, 32);
}
Example #4
0
void nist5_hash(const char* input, char* output)
{
    sph_blake512_context     ctx_blake;
    sph_groestl512_context   ctx_groestl;
    sph_skein512_context     ctx_skein;
    sph_jh512_context        ctx_jh;
    sph_keccak512_context    ctx_keccak;

    //these uint512 in the c++ source of the client are backed by an array of uint32
	uint32_t hash[16];	

    sph_blake512_init(&ctx_blake);
    sph_blake512 (&ctx_blake, input, 80);
    sph_blake512_close (&ctx_blake, hash);
    
    sph_groestl512_init(&ctx_groestl);
    sph_groestl512 (&ctx_groestl, hash, 64);
    sph_groestl512_close(&ctx_groestl, hash);

    sph_jh512_init(&ctx_jh);
    sph_jh512 (&ctx_jh, hash, 64);
    sph_jh512_close(&ctx_jh, hash);

    sph_keccak512_init(&ctx_keccak);
    sph_keccak512 (&ctx_keccak, hash, 64);
    sph_keccak512_close(&ctx_keccak, hash);

    sph_skein512_init(&ctx_skein);
    sph_skein512 (&ctx_skein, hash, 64);
    sph_skein512_close (&ctx_skein, hash);
	
    memcpy(output, hash, 32);	
}
Example #5
0
inline void nist5_hash(void *output, const void *input)
{
    sph_blake512_context     ctx_blake;
    sph_groestl512_context   ctx_groestl;
    sph_skein512_context     ctx_skein;
    sph_jh512_context        ctx_jh;
    sph_keccak512_context    ctx_keccak;
    
    uint32_t hash[16];
    
    sph_blake512_init(&ctx_blake);
    sph_blake512 (&ctx_blake, input, 80);
    sph_blake512_close (&ctx_blake, hash);

    sph_groestl512_init(&ctx_groestl);
    sph_groestl512 (&ctx_groestl, hash, 64);
    sph_groestl512_close(&ctx_groestl, hash);

    sph_jh512_init(&ctx_jh);
    sph_jh512 (&ctx_jh, hash, 64);
    sph_jh512_close(&ctx_jh, hash);

    sph_keccak512_init(&ctx_keccak);
    sph_keccak512 (&ctx_keccak, hash, 64);
    sph_keccak512_close(&ctx_keccak, hash);
    
    sph_skein512_init(&ctx_skein);
    sph_skein512 (&ctx_skein, hash, 64);
    sph_skein512_close (&ctx_skein, hash);

    memcpy(output, hash, 32);
}
Example #6
0
File: nist5.c Project: bitbandi/dm
inline void nist5_hash(void *state, const void *input)
{
    init_N5hash_contexts();
    
    X5hash_context_holder ctx;
    
    uint32_t hashA[16], hashB[16];  
    //blake-bmw-groestl-sken-jh-meccak-luffa-cubehash-shivite-simd-echo
    memcpy(&ctx, &base_contexts5, sizeof(base_contexts5));
    
    sph_blake512 (&ctx.blake1, input, 80);
    sph_blake512_close (&ctx.blake1, hashA);        
  
    sph_groestl512 (&ctx.groestl1, hashA, 64); 
    sph_groestl512_close(&ctx.groestl1, hashB);
   
    sph_jh512 (&ctx.jh1, hashB, 64); 
    sph_jh512_close(&ctx.jh1, hashA);
  
    sph_keccak512 (&ctx.keccak1, hashA, 64); 
    sph_keccak512_close(&ctx.keccak1, hashB);
    
    sph_skein512 (&ctx.skein1, hashB, 64); 
    sph_skein512_close(&ctx.skein1, hashA); 

    memcpy(state, hashA, 32);

}
Example #7
0
// CPU-groestl
extern "C" void groestlhash(void *state, const void *input)
{
    sph_groestl512_context ctx_groestl;

    //these uint512 in the c++ source of the client are backed by an array of uint32
    uint32_t hashA[16], hashB[16];

    sph_groestl512_init(&ctx_groestl);
    sph_groestl512 (&ctx_groestl, input, 80); //6
    sph_groestl512_close(&ctx_groestl, hashA); //7

    sph_groestl512_init(&ctx_groestl);
    sph_groestl512 (&ctx_groestl, hashA, 64); //6
    sph_groestl512_close(&ctx_groestl, hashB); //7

    memcpy(state, hashB, 32);
}
Example #8
0
int crypto_hash(unsigned char *out,const unsigned char *in,unsigned long long inlen)
{
  sph_groestl512_context mc;
  sph_groestl512_init(&mc);
  sph_groestl512(&mc, in, inlen);
  sph_groestl512_close(&mc,out);
  return 0;
}
void groestlcoin_hash(const char* input, char* output)
{
    sph_groestl512_context ctx_groestl, ctx_groestlb;
    //sph_sha256_context ctx_sha2;

    uint32_t hash[16], hashb[16];

    sph_groestl512_init(&ctx_groestl);
    sph_groestl512(&ctx_groestl, input, 80);
    sph_groestl512_close(&ctx_groestl, (void*) hash);

    sph_groestl512_init(&ctx_groestlb);
    sph_groestl512(&ctx_groestlb, hash, 64);
    sph_groestl512_close(&ctx_groestlb, (void*) hashb);

    memcpy(output, hashb, 32);
}
Example #10
0
inline void bitblockhash(void *state, const void *input)
{
    init_Bhash_contexts();

    Xhash_context_holder ctx;

    uint32_t hashA[16], hashB[16];

    memcpy(&ctx, &base_contexts, sizeof(base_contexts));

    sph_blake512 (&ctx.blake1, input, 80);
    sph_blake512_close (&ctx.blake1, hashA);

    sph_bmw512 (&ctx.bmw1, hashA, 64);
    sph_bmw512_close(&ctx.bmw1, hashB);

    sph_groestl512 (&ctx.groestl1, hashB, 64);
    sph_groestl512_close(&ctx.groestl1, hashA);

    sph_skein512 (&ctx.skein1, hashA, 64);
    sph_skein512_close(&ctx.skein1, hashB);

    sph_jh512 (&ctx.jh1, hashB, 64);
    sph_jh512_close(&ctx.jh1, hashA);

    sph_keccak512 (&ctx.keccak1, hashA, 64);
    sph_keccak512_close(&ctx.keccak1, hashB);

    sph_luffa512 (&ctx.luffa1, hashB, 64);
    sph_luffa512_close (&ctx.luffa1, hashA);

    sph_cubehash512 (&ctx.cubehash1, hashA, 64);
    sph_cubehash512_close(&ctx.cubehash1, hashB);

    sph_shavite512 (&ctx.shavite1, hashB, 64);
    sph_shavite512_close(&ctx.shavite1, hashA);

    sph_simd512 (&ctx.simd1, hashA, 64);
    sph_simd512_close(&ctx.simd1, hashB);

    sph_echo512 (&ctx.echo1, hashB, 64);
    sph_echo512_close(&ctx.echo1, hashA);

    sph_hamsi512 (&ctx.hamsi1, hashA, 64);
    sph_hamsi512_close(&ctx.hamsi1, hashB);

    sph_fugue512 (&ctx.fugue1, hashB, 64);
    sph_fugue512_close(&ctx.fugue1, hashA);

    sph_shabal512 (&ctx.shabal1, (const unsigned char*)hashA, 64);
    sph_shabal512_close(&ctx.shabal1, hashB);

    sph_whirlpool (&ctx.whirlpool1, hashB, 64);
    sph_whirlpool_close(&ctx.whirlpool1, hashA);

    memcpy(state, hashA, 32);

}
Example #11
0
void jha_hash(void *output, const void *input)
{
	uint8_t _ALIGN(128) hash[64];

#ifdef NO_AES_NI
	sph_groestl512_context ctx_groestl;
#else
        hashState_groestl      ctx_groestl;
#endif
        sph_blake512_context ctx_blake;
	sph_jh512_context ctx_jh;
	sph_keccak512_context ctx_keccak;
	sph_skein512_context ctx_skein;

        memcpy( &ctx_keccak, &jha_kec_mid, sizeof jha_kec_mid );
        sph_keccak512(&ctx_keccak, input+64, 16 );
	sph_keccak512_close(&ctx_keccak, hash );

	// Heavy & Light Pair Loop
	for (int round = 0; round < 3; round++)
	{
	   if (hash[0] & 0x01)
           {
#ifdef NO_AES_NI
		sph_groestl512_init(&ctx_groestl);
		sph_groestl512(&ctx_groestl, hash, 64 );
		sph_groestl512_close(&ctx_groestl, hash );
#else
                init_groestl( &ctx_groestl, 64 );
                update_and_final_groestl( &ctx_groestl, (char*)hash,
                                          (char*)hash, 512 );
#endif
	    }
            else
            {
		sph_skein512_init(&ctx_skein);
		sph_skein512(&ctx_skein, hash, 64);
		sph_skein512_close(&ctx_skein, hash );
	    }

	    if (hash[0] & 0x01)
            {
		sph_blake512_init(&ctx_blake);
		sph_blake512(&ctx_blake, hash, 64);
		sph_blake512_close(&ctx_blake, hash );
	    }
            else
            {
		sph_jh512_init(&ctx_jh);
		sph_jh512(&ctx_jh, hash, 64 );
		sph_jh512_close(&ctx_jh, hash );
	    }
	}

	memcpy(output, hash, 32);
}
Example #12
0
void x15hash(void *output, const void *input)
{
	uint32_t hash[16];

	memset(hash, 0, 16 * sizeof(uint32_t));

	sph_blake512(&ctx.blake, input, 80);
	sph_blake512_close(&ctx.blake, hash);

	sph_bmw512(&ctx.bmw, hash, 64);
	sph_bmw512_close(&ctx.bmw, hash);

	sph_groestl512(&ctx.groestl, hash, 64);
	sph_groestl512_close(&ctx.groestl, hash);

	sph_skein512(&ctx.skein, hash, 64);
	sph_skein512_close(&ctx.skein, hash);

	sph_jh512(&ctx.jh, hash, 64);
	sph_jh512_close(&ctx.jh, hash);

	sph_keccak512(&ctx.keccak, hash, 64);
	sph_keccak512_close(&ctx.keccak, hash);

	sph_luffa512(&ctx.luffa, hash, 64);
	sph_luffa512_close(&ctx.luffa, hash);

	sph_cubehash512(&ctx.cubehash, hash, 64);
	sph_cubehash512_close(&ctx.cubehash, hash);

	sph_shavite512(&ctx.shavite, hash, 64);
	sph_shavite512_close(&ctx.shavite, hash);

	sph_simd512(&ctx.simd, hash, 64);
	sph_simd512_close(&ctx.simd, hash);

	sph_echo512(&ctx.echo, hash, 64);
	sph_echo512_close(&ctx.echo, hash);

	sph_hamsi512(&ctx.hamsi, hash, 64);
	sph_hamsi512_close(&ctx.hamsi, hash);

	sph_fugue512(&ctx.fugue, hash, 64);
	sph_fugue512_close(&ctx.fugue, hash);

	sph_shabal512(&ctx.shabal, hash, 64);
	sph_shabal512_close(&ctx.shabal, hash);

	sph_whirlpool(&ctx.whirlpool, hash, 64);
	sph_whirlpool_close(&ctx.whirlpool, hash);

	memcpy(output, hash, 32);
}
Example #13
0
static void myriadcoin_groestlhash(void *output, const void *input)
{
	uint32_t hash[16];

	memset(hash, 0, 16 * sizeof(uint32_t));

	sph_groestl512(&ctx.groestl, input, 80);
	sph_groestl512_close(&ctx.groestl, hash);

	sph_sha256(&ctx.sha2, hash, 64);
	sph_sha256_close(&ctx.sha2, hash);

	memcpy(output, hash, 32);
}
Example #14
0
void heavycoin_hash(const char* input, int len, char* output)
{
    unsigned char hash1[32];
    HEFTY1((unsigned char *)input, len, hash1);

    /* HEFTY1 is new, so take an extra security measure to eliminate
     * the possiblity of collisions:
     *
     *     Hash(x) = SHA256(x + HEFTY1(x))
     *
     * N.B. '+' is concatenation.
     */
    unsigned char hash2[32];;

    sha256_ctx ctx;
    sha256_init(&ctx);
    sha256_update(&ctx, (const unsigned char *)input, len);
    sha256_update(&ctx, hash1, sizeof(hash1));
    sha256_final(&ctx, hash2);

    /* Additional security: Do not rely on a single cryptographic hash
     * function.  Instead, combine the outputs of 4 of the most secure
     * cryptographic hash functions-- SHA256, KECCAK512, GROESTL512
     * and BLAKE512.
     */

    uint32_t hash3[16];
    sph_keccak512_context keccakCtx;
    sph_keccak512_init(&keccakCtx);
    sph_keccak512(&keccakCtx, input, len);
    sph_keccak512(&keccakCtx, hash1, sizeof(hash1));
    sph_keccak512_close(&keccakCtx, (void *)&hash3);

    uint32_t hash4[16];
    sph_groestl512_context groestlCtx;
    sph_groestl512_init(&groestlCtx);
    sph_groestl512(&groestlCtx, input, len);
    sph_groestl512(&groestlCtx, hash1, sizeof(hash1));
    sph_groestl512_close(&groestlCtx, (void *)&hash4);

    uint32_t hash5[16];
    sph_blake512_context blakeCtx;
    sph_blake512_init(&blakeCtx);
    sph_blake512(&blakeCtx, input, len);
    sph_blake512(&blakeCtx, (unsigned char *)&hash1, sizeof(hash1));
    sph_blake512_close(&blakeCtx, (void *)&hash5);

    uint32_t *final = (uint32_t *)output;
    combine_hashes(final, (uint32_t *)hash2, hash3, hash4, hash5);
}
Example #15
0
void groestlmyriad_hash(const char* input, char* output, uint32_t len)
{
    char temp[64];
    
    sph_groestl512_context ctx_groestl;
    sph_groestl512_init(&ctx_groestl);
    sph_groestl512(&ctx_groestl, input, len);
    sph_groestl512_close(&ctx_groestl, &temp);
    
    SHA256_CTX ctx_sha256;
    SHA256_Init(&ctx_sha256);
    SHA256_Update(&ctx_sha256, &temp, 64);
    SHA256_Final((unsigned char*) output, &ctx_sha256);
}
Example #16
0
static inline void xhash(void *state, const void *input)
{
    init_Xhash_contexts();

    Xhash_context_holder ctx;

    uint32_t hashA[16], hashB[16];
    //blake-bmw-groestl-sken-jh-meccak-luffa-cubehash-shivite-simd-echo
    memcpy(&ctx, &base_contexts, sizeof(base_contexts));

    sph_blake512 (&ctx.blake1, input, 80);
    sph_blake512_close (&ctx.blake1, hashA);

    sph_bmw512 (&ctx.bmw1, hashA, 64);
    sph_bmw512_close(&ctx.bmw1, hashB);

    sph_groestl512 (&ctx.groestl1, hashB, 64);
    sph_groestl512_close(&ctx.groestl1, hashA);

    sph_skein512 (&ctx.skein1, hashA, 64);
    sph_skein512_close(&ctx.skein1, hashB);

    sph_jh512 (&ctx.jh1, hashB, 64);
    sph_jh512_close(&ctx.jh1, hashA);

    sph_keccak512 (&ctx.keccak1, hashA, 64);
    sph_keccak512_close(&ctx.keccak1, hashB);

    sph_gost512 (&ctx.gost1, hashB, 64);
    sph_gost512_close(&ctx.gost1, hashA);

    sph_luffa512 (&ctx.luffa1, hashA, 64);
    sph_luffa512_close (&ctx.luffa1, hashB);

    sph_cubehash512 (&ctx.cubehash1, hashB, 64);
    sph_cubehash512_close(&ctx.cubehash1, hashA);

    sph_shavite512 (&ctx.shavite1, hashA, 64);
    sph_shavite512_close(&ctx.shavite1, hashB);

    sph_simd512 (&ctx.simd1, hashB, 64);
    sph_simd512_close(&ctx.simd1, hashA);

    sph_echo512 (&ctx.echo1, hashA, 64);
    sph_echo512_close(&ctx.echo1, hashB);

    memcpy(state, hashB, 32);

}
Example #17
0
static void groestlhash(void *state, const void *input)
{
    // Tryout GPU-groestl

    sph_groestl512_context     ctx_groestl[2];
    static unsigned char pblank[1];
    uint32_t mask = 8;
    uint32_t zero = 0;


    //these uint512 in the c++ source of the client are backed by an array of uint32
    uint32_t hashA[16], hashB[16];    


    sph_groestl512_init(&ctx_groestl[0]);
    sph_groestl512 (&ctx_groestl[0], input, 80); //6
    sph_groestl512_close(&ctx_groestl[0], hashA); //7    

    sph_groestl512_init(&ctx_groestl[1]);
    sph_groestl512 (&ctx_groestl[1], hashA, 64); //6
    sph_groestl512_close(&ctx_groestl[1], hashB); //7

    memcpy(state, hashB, 32);
}
Example #18
0
static void switchHash(const void *input, void *output, int id)
{
	sph_keccak512_context ctx_keccak;
	sph_blake512_context ctx_blake;
	sph_groestl512_context ctx_groestl;
	sph_skein512_context ctx_skein;
	sph_luffa512_context ctx_luffa;
	sph_echo512_context ctx_echo;
	sph_simd512_context ctx_simd;
	sph_cubehash512_context ctx_cubehash;
	sph_fugue512_context ctx_fugue;
	sph_shavite512_context ctx_shavite;

	switch(id) {
	case 0:
		sph_keccak512_init(&ctx_keccak); sph_keccak512(&ctx_keccak, input, 64); sph_keccak512_close(&ctx_keccak, output);
		break;
	case 1:
		sph_blake512_init(&ctx_blake); sph_blake512(&ctx_blake, input, 64); sph_blake512_close(&ctx_blake, output);
		break;
	case 2:
		sph_groestl512_init(&ctx_groestl); sph_groestl512(&ctx_groestl, input, 64); sph_groestl512_close(&ctx_groestl, output);
		break;
	case 3:
		sph_skein512_init(&ctx_skein); sph_skein512(&ctx_skein, input, 64); sph_skein512_close(&ctx_skein, output);
		break;
	case 4:
		sph_luffa512_init(&ctx_luffa); sph_luffa512(&ctx_luffa, input, 64); sph_luffa512_close(&ctx_luffa, output);
		break;
	case 5:
		sph_echo512_init(&ctx_echo); sph_echo512(&ctx_echo, input, 64); sph_echo512_close(&ctx_echo, output);
		break;
	case 6:
		sph_shavite512_init(&ctx_shavite); sph_shavite512(&ctx_shavite, input, 64); sph_shavite512_close(&ctx_shavite, output);
		break;
	case 7:
		sph_fugue512_init(&ctx_fugue); sph_fugue512(&ctx_fugue, input, 64); sph_fugue512_close(&ctx_fugue, output);
		break;
	case 8:
		sph_simd512_init(&ctx_simd); sph_simd512(&ctx_simd, input, 64); sph_simd512_close(&ctx_simd, output);
		break;
	case 9:
		sph_cubehash512_init(&ctx_cubehash); sph_cubehash512(&ctx_cubehash, input, 64); sph_cubehash512_close(&ctx_cubehash, output);
		break;
	default:
		break;
	}
}
Example #19
0
void myriadhash(void *state, const void *input)
{
	uint32_t _ALIGN(64) hash[16];
	sph_groestl512_context ctx_groestl;
	SHA256_CTX sha256;

	sph_groestl512_init(&ctx_groestl);
	sph_groestl512(&ctx_groestl, input, 80);
	sph_groestl512_close(&ctx_groestl, hash);

	SHA256_Init(&sha256);
	SHA256_Update(&sha256,(unsigned char *)hash, 64);
	SHA256_Final((unsigned char *)hash, &sha256);

	memcpy(state, hash, 32);
}
Example #20
0
inline void mghash(void *state, const void *input)
{
    sph_groestl512_context ctx_groestl;
    sph_sha256_context ctx_sha2;

    uint32_t hash[16];

    sph_groestl512_init(&ctx_groestl);
    sph_groestl512(&ctx_groestl, input, 80);
    sph_groestl512_close(&ctx_groestl, (void*) hash);
    
    sph_sha256_init(&ctx_sha2);
    sph_sha256(&ctx_sha2, hash, 64);
    sph_sha256_close(&ctx_sha2, (void*) hash);

    memcpy(state, hash, 32);
}
Example #21
0
int heavycoin_scanhash(unsigned char* output, const unsigned char* input, int len)
{
    DATA_ALIGN64(unsigned char hash1[32]);
    HEFTY1(input, len, hash1);

    DATA_ALIGN64(uint32_t hash5[16]);
    sph_blake512_context blakeCtx;
    sph_blake512_init(&blakeCtx);
    sph_blake512(&blakeCtx, input, len);
    sph_blake512(&blakeCtx, (unsigned char *)&hash1, sizeof(hash1));
    sph_blake512_close(&blakeCtx, (void *)&hash5);
    if ((*((unsigned char *)hash5 + 31) & 0xF0) != 0)
        return 0;

    DATA_ALIGN64(unsigned char hash2[32]);
    SHA256_CTX ctx;
    SHA256_Init(&ctx);
    SHA256_Update(&ctx, input, len);
    SHA256_Update(&ctx, hash1, sizeof(hash1));
    SHA256_Final(hash2, &ctx);
    if ((*((unsigned char *)hash2 + 31) & 0xF0) != 0)
        return 0;

    DATA_ALIGN64(uint32_t hash3[16]);
    sph_keccak512_context keccakCtx;
    sph_keccak512_init(&keccakCtx);
    sph_keccak512(&keccakCtx, input, len);
    sph_keccak512(&keccakCtx, hash1, sizeof(hash1));
    sph_keccak512_close(&keccakCtx, (void *)&hash3);
    if ((*((unsigned char *)hash3 + 31) & 0xF0) != 0)
        return 0;

    DATA_ALIGN64(uint32_t hash4[16]);
    sph_groestl512_context groestlCtx;
    sph_groestl512_init(&groestlCtx);
    sph_groestl512(&groestlCtx, input, len);
    sph_groestl512(&groestlCtx, hash1, sizeof(hash1));
    sph_groestl512_close(&groestlCtx, (void *)&hash4);
    if ((*((unsigned char *)hash4 + 31) & 0xF0) != 0)
        return 0;

    uint32_t *final = (uint32_t *)output;
    combine_hashes(final, (uint32_t *)hash2, hash3, hash4, hash5);

    return 1;
}
Example #22
0
inline void X11_Hash(const void *input, void *state)
{
	init_X11_contexts();
	X11_context_holder ctx;
	
	uint32_t hashA[16], hashB[16];
	//Order: Blake > Bmw > Groestl > Sken > Jh > Meccak > Luffa > Cubehash > Shivite > Simd > Echo
	memcpy(&ctx, &base_contexts, sizeof(base_contexts));
	
	sph_blake512 (&ctx.blake, input, 80);
	sph_blake512_close (&ctx.blake, hashA);
	sph_bmw512 (&ctx.bmw, hashA, 64);    
    sph_bmw512_close(&ctx.bmw, hashB);     
  
    sph_groestl512 (&ctx.groestl, hashB, 64); 
    sph_groestl512_close(&ctx.groestl, hashA);
   
    sph_skein512 (&ctx.skein, hashA, 64); 
    sph_skein512_close(&ctx.skein, hashB); 
   
    sph_jh512 (&ctx.jh, hashB, 64); 
    sph_jh512_close(&ctx.jh, hashA);
  
    sph_keccak512 (&ctx.keccak, hashA, 64); 
    sph_keccak512_close(&ctx.keccak, hashB);
    
    sph_luffa512 (&ctx.luffa, hashB, 64);
    sph_luffa512_close (&ctx.luffa, hashA);    
        
    sph_cubehash512 (&ctx.cubehash, hashA, 64);   
    sph_cubehash512_close(&ctx.cubehash, hashB);  
    
    sph_shavite512 (&ctx.shavite, hashB, 64);   
    sph_shavite512_close(&ctx.shavite, hashA);  
    
    sph_simd512 (&ctx.simd, hashA, 64);   
    sph_simd512_close(&ctx.simd, hashB); 
    
    sph_echo512 (&ctx.echo, hashB, 64);   
    sph_echo512_close(&ctx.echo, hashA);    

    memcpy(state, hashA, 32);

}
Example #23
0
void jha_hash(const char* input, char* output, uint32_t len) {

     sph_blake512_context     ctx_blake;
     sph_groestl512_context   ctx_groestl;
     sph_jh512_context        ctx_jh;
     sph_keccak512_context    ctx_keccak;
     sph_skein512_context     ctx_skein;

     uint32_t hash[16];
     
        sph_keccak512_init(&ctx_keccak);
        sph_keccak512 (&ctx_keccak, input, 80);
        sph_keccak512_close(&ctx_keccak, (&hash));

        //
        // Heavy & Light Pair Loop
        //
        unsigned int round;
        for (round = 0; round < 3; round++) {
            if (hash[0] & 0x01) {
               sph_groestl512_init(&ctx_groestl);
               sph_groestl512 (&ctx_groestl, (&hash), 64);
               sph_groestl512_close(&ctx_groestl, (&hash));
            }
            else {
               sph_skein512_init(&ctx_skein);
               sph_skein512 (&ctx_skein, (&hash), 64);
               sph_skein512_close(&ctx_skein, (&hash));
            }
            if (hash[0] & 0x01) {
               sph_blake512_init(&ctx_blake);
               sph_blake512 (&ctx_blake, (&hash), 64);
               sph_blake512_close(&ctx_blake, (&hash));
            }
            else {
               sph_jh512_init(&ctx_jh);
               sph_jh512 (&ctx_jh, (&hash), 64);
               sph_jh512_close(&ctx_jh, (&hash));
            }
        }

   	    memcpy(output, hash, 32);

}
Example #24
0
inline void sifhash(void *state, const void *input)
{
    sph_blake512_context     ctx_blake;
    sph_bmw512_context       ctx_bmw;
    sph_groestl512_context   ctx_groestl;
    sph_jh512_context        ctx_jh;
    sph_keccak512_context    ctx_keccak;
    sph_skein512_context     ctx_skein;
    
    unsigned char hash[64];

    sph_blake512_init(&ctx_blake);
    // ZBLAKE;
    sph_blake512 (&ctx_blake, input, 80);
    sph_blake512_close(&ctx_blake, (void*) hash);
    
    sph_bmw512_init(&ctx_bmw);
    // ZBMW;
    sph_bmw512 (&ctx_bmw, (const void*) hash, 64);
    sph_bmw512_close(&ctx_bmw, (void*) hash);

    sph_groestl512_init(&ctx_groestl);
    // ZGROESTL;
    sph_groestl512 (&ctx_groestl, (const void*) hash, 64);
    sph_groestl512_close(&ctx_groestl, (void*) hash);

    sph_jh512_init(&ctx_jh);
    // ZJH;
    sph_jh512 (&ctx_jh, (const void*) hash, 64);
    sph_jh512_close(&ctx_jh, (void*) hash);

    sph_keccak512_init(&ctx_keccak);
    // ZKECCAK;
    sph_keccak512 (&ctx_keccak, (const void*) hash, 64);
    sph_keccak512_close(&ctx_keccak, (void*) hash);

    sph_skein512_init(&ctx_skein);
    // SKEIN;
    sph_skein512 (&ctx_skein, (const void*) hash, 64);
    sph_skein512_close(&ctx_skein, (void*) hash);

    memcpy(state, hash, 32);
}
Example #25
0
void jha_hash(void *output, const void *input)
{
	uint8_t _ALIGN(128) hash[64];

	sph_blake512_context ctx_blake;
	sph_groestl512_context ctx_groestl;
	sph_jh512_context ctx_jh;
	sph_keccak512_context ctx_keccak;
	sph_skein512_context ctx_skein;

	// JHA v8 input is 80 bytes
	sph_keccak512_init(&ctx_keccak);
	sph_keccak512(&ctx_keccak, input, 80);
	sph_keccak512_close(&ctx_keccak, (&hash));

	// Heavy & Light Pair Loop
	for (int round = 0; round < 3; round++)
	{
		if (hash[0] & 0x01) {
			sph_groestl512_init(&ctx_groestl);
			sph_groestl512(&ctx_groestl, (&hash), 64);
			sph_groestl512_close(&ctx_groestl, (&hash));
		} else {
			sph_skein512_init(&ctx_skein);
			sph_skein512(&ctx_skein, (&hash), 64);
			sph_skein512_close(&ctx_skein, (&hash));
		}

		if (hash[0] & 0x01) {
			sph_blake512_init(&ctx_blake);
			sph_blake512(&ctx_blake, (&hash), 64);
			sph_blake512_close(&ctx_blake, (&hash));
		} else {
			sph_jh512_init(&ctx_jh);
			sph_jh512(&ctx_jh, (&hash), 64);
			sph_jh512_close(&ctx_jh, (&hash));
		}
	}

	memcpy(output, hash, 32);
}
Example #26
0
static void jackpothash(void *state, const void *input) {

    sph_blake512_context     ctx_blake;
    sph_groestl512_context   ctx_groestl;
    sph_jh512_context        ctx_jh;
    sph_keccak512_context    ctx_keccak;
    sph_skein512_context     ctx_skein;

    uint32_t hash[16];

    sph_keccak512_init(&ctx_keccak);
    sph_keccak512 (&ctx_keccak, input, 80);
    sph_keccak512_close(&ctx_keccak, (&hash));

    unsigned int round;
    for (round = 0; round < 3; round++) {
        if (hash[0] & 0x01) {
           sph_groestl512_init(&ctx_groestl);
           sph_groestl512 (&ctx_groestl, (&hash), 64);
           sph_groestl512_close(&ctx_groestl, (&hash));
        }
        else {
           sph_skein512_init(&ctx_skein);
           sph_skein512 (&ctx_skein, (&hash), 64);
           sph_skein512_close(&ctx_skein, (&hash));
        }
        if (hash[0] & 0x01) {
           sph_blake512_init(&ctx_blake);
           sph_blake512 (&ctx_blake, (&hash), 64);
           sph_blake512_close(&ctx_blake, (&hash));
        }
        else {
           sph_jh512_init(&ctx_jh);
           sph_jh512 (&ctx_jh, (&hash), 64);
           sph_jh512_close(&ctx_jh, (&hash));
        }
    }

	memcpy(state, hash, 32);
}
Example #27
0
void heavy_hash(void* output, const void* input, int len)
{
	uint32_t hash1[16], hash2[16], hash3[16], hash4[16], hash5[16];

	HEFTY1(input, len, (unsigned char *)hash1);

	/* HEFTY1 is new, so take an extra security measure to eliminate
	 * the possiblity of collisions:
	 *
	 *	 Hash(x) = SHA256(x + HEFTY1(x))
	 *
	 * N.B. '+' is concatenation.
	 */
	SHA256_CTX sha256;
	SHA256_Init(&sha256);
	SHA256_Update(&sha256, input, len);
	SHA256_Update(&sha256, hash1, sizeof(hash1));
	SHA256_Final((unsigned char*)hash2, &sha256);

	/* Additional security: Do not rely on a single cryptographic hash
	 * function.  Instead, combine the outputs of 4 of the most secure
	 * cryptographic hash functions-- SHA256, KECCAK512, GROESTL512
	 * and BLAKE512.
	 */

	sph_keccak512(&ctx.keccak, input, len);
	sph_keccak512(&ctx.keccak, hash1, sizeof(hash1));
	sph_keccak512_close(&ctx.keccak, hash3);

	sph_groestl512(&ctx.groestl, input, len);
	sph_groestl512(&ctx.groestl, hash1, sizeof(hash1));
	sph_groestl512_close(&ctx.groestl, hash4);

	sph_blake512(&ctx.blake, input, len);
	sph_blake512(&ctx.blake, hash1, sizeof(hash1));
	sph_blake512_close(&ctx.blake, hash5);

	combine_hashes((uint32_t *)output, hash2, hash3, hash4, hash5);
}
Example #28
0
void x16r_hash(void* output, const void* input)
{
	uint32_t _ALIGN(128) hash[64/4];

	sph_blake512_context     ctx_blake;
	sph_bmw512_context       ctx_bmw;
	sph_groestl512_context   ctx_groestl;
	sph_skein512_context     ctx_skein;
	sph_jh512_context        ctx_jh;
	sph_keccak512_context    ctx_keccak;
	sph_luffa512_context     ctx_luffa1;
	sph_cubehash512_context  ctx_cubehash1;
	sph_shavite512_context   ctx_shavite1;
	sph_simd512_context      ctx_simd1;
	sph_echo512_context      ctx_echo1;
	sph_hamsi512_context     ctx_hamsi1;
	sph_fugue512_context     ctx_fugue1;
	sph_shabal512_context    ctx_shabal1;
	sph_whirlpool_context    ctx_whirlpool1;
	sph_sha512_context       ctx_sha512;

	void *in = (void*) input;
	int size = 80;

	if (s_ntime == UINT32_MAX) {
		const uint8_t* in8 = (uint8_t*) input;
		getAlgoString(&in8[4], hashOrder);
	}

	for (int i = 0; i < 16; i++)
	{
		const char elem = hashOrder[i];
		const uint8_t algo = elem >= 'A' ? elem - 'A' + 10 : elem - '0';

		switch (algo) {
		case BLAKE:
			sph_blake512_init(&ctx_blake);
			sph_blake512(&ctx_blake, in, size);
			sph_blake512_close(&ctx_blake, hash);
			break;
		case BMW:
			sph_bmw512_init(&ctx_bmw);
			sph_bmw512(&ctx_bmw, in, size);
			sph_bmw512_close(&ctx_bmw, hash);
			break;
		case GROESTL:
			sph_groestl512_init(&ctx_groestl);
			sph_groestl512(&ctx_groestl, in, size);
			sph_groestl512_close(&ctx_groestl, hash);
			break;
		case SKEIN:
			sph_skein512_init(&ctx_skein);
			sph_skein512(&ctx_skein, in, size);
			sph_skein512_close(&ctx_skein, hash);
			break;
		case JH:
			sph_jh512_init(&ctx_jh);
			sph_jh512(&ctx_jh, in, size);
			sph_jh512_close(&ctx_jh, hash);
			break;
		case KECCAK:
			sph_keccak512_init(&ctx_keccak);
			sph_keccak512(&ctx_keccak, in, size);
			sph_keccak512_close(&ctx_keccak, hash);
			break;
		case LUFFA:
			sph_luffa512_init(&ctx_luffa1);
			sph_luffa512(&ctx_luffa1, in, size);
			sph_luffa512_close(&ctx_luffa1, hash);
			break;
		case CUBEHASH:
			sph_cubehash512_init(&ctx_cubehash1);
			sph_cubehash512(&ctx_cubehash1, in, size);
			sph_cubehash512_close(&ctx_cubehash1, hash);
			break;
		case SHAVITE:
			sph_shavite512_init(&ctx_shavite1);
			sph_shavite512(&ctx_shavite1, in, size);
			sph_shavite512_close(&ctx_shavite1, hash);
			break;
		case SIMD:
			sph_simd512_init(&ctx_simd1);
			sph_simd512(&ctx_simd1, in, size);
			sph_simd512_close(&ctx_simd1, hash);
			break;
		case ECHO:
			sph_echo512_init(&ctx_echo1);
			sph_echo512(&ctx_echo1, in, size);
			sph_echo512_close(&ctx_echo1, hash);
			break;
		case HAMSI:
			sph_hamsi512_init(&ctx_hamsi1);
			sph_hamsi512(&ctx_hamsi1, in, size);
			sph_hamsi512_close(&ctx_hamsi1, hash);
			break;
		case FUGUE:
			sph_fugue512_init(&ctx_fugue1);
			sph_fugue512(&ctx_fugue1, in, size);
			sph_fugue512_close(&ctx_fugue1, hash);
			break;
		case SHABAL:
			sph_shabal512_init(&ctx_shabal1);
			sph_shabal512(&ctx_shabal1, in, size);
			sph_shabal512_close(&ctx_shabal1, hash);
			break;
		case WHIRLPOOL:
			sph_whirlpool_init(&ctx_whirlpool1);
			sph_whirlpool(&ctx_whirlpool1, in, size);
			sph_whirlpool_close(&ctx_whirlpool1, hash);
			break;
		case SHA512:
			sph_sha512_init(&ctx_sha512);
			sph_sha512(&ctx_sha512,(const void*) in, size);
			sph_sha512_close(&ctx_sha512,(void*) hash);
			break;
		}
		in = (void*) hash;
		size = 64;
	}
	memcpy(output, hash, 32);
}
Example #29
0
static void jackpothash_debug(void *state, const void *input) {
    sph_blake512_context     ctx_blake;
    sph_groestl512_context   ctx_groestl;
    sph_jh512_context        ctx_jh;
    sph_keccak512_context    ctx_keccak;
    sph_skein512_context     ctx_skein;
    static unsigned char pblank[1];

    uint32_t hash[16];

    int ii;
    unsigned char * ptr = (unsigned char *)input;

    printf("Input Hash : ");
    for (ii = 0; ii < 128; ii++) {
        printf("%.2x", ptr[ii]);
    }
    printf("\n");

    sph_keccak512_init(&ctx_keccak);
    sph_keccak512 (&ctx_keccak, input, 80);
    sph_keccak512_close(&ctx_keccak, hash);

    ptr = (unsigned char *)(&hash[0]);

    printf("After keccak : ");
    for (ii = 0; ii < 64; ii++) {
        printf("%.2x", ptr[ii]);
    }
    printf("\n");

    unsigned int round;
    for (round = 0; round < 3; round++) {
        if (hash[0] & 0x01) {
           sph_groestl512_init(&ctx_groestl);
           sph_groestl512 (&ctx_groestl, (&hash), 64);
           sph_groestl512_close(&ctx_groestl, (&hash));
        }
        else {
           sph_skein512_init(&ctx_skein);
           sph_skein512 (&ctx_skein, (&hash), 64);
           sph_skein512_close(&ctx_skein, (&hash));
        }
        if (hash[0] & 0x01) {
           sph_blake512_init(&ctx_blake);
           sph_blake512 (&ctx_blake, (&hash), 64);
           sph_blake512_close(&ctx_blake, (&hash));
        }
        else {
           sph_jh512_init(&ctx_jh);
           sph_jh512 (&ctx_jh, (&hash), 64);
           sph_jh512_close(&ctx_jh, (&hash));
        }
        unsigned char * ptr = (unsigned char *)(&hash[0]);
        int ii;
        printf("round %d : ", round);
        for (ii = 0; ii < 64; ii++) {
            printf("%.2x", (unsigned char)ptr[ii]);
        }
        printf("\n");
    }

	memcpy(state, hash, 32);
}
Example #30
0
static
#endif
inline void hmq1725hash(void *state, const void *input)
{
    sph_blake512_context     ctx_blake;
    sph_bmw512_context       ctx_bmw;
    sph_groestl512_context   ctx_groestl;
    sph_jh512_context        ctx_jh;
    sph_keccak512_context    ctx_keccak;
    sph_skein512_context     ctx_skein;

   sph_luffa512_context     ctx_luffa;
   sph_cubehash512_context  ctx_cubehash;
   sph_shavite512_context   ctx_shavite;
   sph_simd512_context      ctx_simd;
   sph_echo512_context      ctx_echo;
   sph_hamsi512_context     ctx_hamsi;
   sph_fugue512_context     ctx_fugue;
   sph_shabal512_context    ctx_shabal;
   sph_whirlpool_context    ctx_whirlpool;
   sph_sha512_context       ctx_sha2;
   sph_haval256_5_context   ctx_haval;

    uint32_t mask = 24;
    uint32_t zero = 0;

    uint32_t hashA[16], hashB[16];


  sph_bmw512_init(&ctx_bmw);
    sph_bmw512 (&ctx_bmw, input, 80);
    sph_bmw512_close (&ctx_bmw, hashA);  //0


    sph_whirlpool_init(&ctx_whirlpool);
    sph_whirlpool (&ctx_whirlpool, hashA, 64);    //0
    sph_whirlpool_close(&ctx_whirlpool, hashB);   //1


    if ((hashB[0] & mask) != zero)   //1
    {
        sph_groestl512_init(&ctx_groestl);
        sph_groestl512 (&ctx_groestl, hashB, 64); //1
        sph_groestl512_close(&ctx_groestl, hashA); //2
    }
    else
    {
        sph_skein512_init(&ctx_skein);
        sph_skein512 (&ctx_skein, hashB, 64); //1
        sph_skein512_close(&ctx_skein, hashA); //2
    }


    sph_jh512_init(&ctx_jh);
    sph_jh512 (&ctx_jh, hashA, 64); //2
    sph_jh512_close(&ctx_jh, hashB); //3

    sph_keccak512_init(&ctx_keccak);
    sph_keccak512 (&ctx_keccak, hashB, 64); //3
    sph_keccak512_close(&ctx_keccak, hashA); //4

    if ((hashA[0] & mask) != zero) //4
    {
        sph_blake512_init(&ctx_blake);
        sph_blake512 (&ctx_blake, hashA, 64); //
        sph_blake512_close(&ctx_blake, hashB); //5
    }
    else
    {
        sph_bmw512_init(&ctx_bmw);
        sph_bmw512 (&ctx_bmw, hashA, 64); //4
        sph_bmw512_close(&ctx_bmw, hashB);   //5
    }

    sph_luffa512_init(&ctx_luffa);
    sph_luffa512 (&ctx_luffa,hashB, 64); //5
    sph_luffa512_close(&ctx_luffa, hashA); //6

    sph_cubehash512_init(&ctx_cubehash);
    sph_cubehash512 (&ctx_cubehash, hashA, 64); //6
    sph_cubehash512_close(&ctx_cubehash, hashB); //7

    if ((hashB[0] & mask) != zero) //7
    {
        sph_keccak512_init(&ctx_keccak);
        sph_keccak512 (&ctx_keccak, hashB, 64); //
        sph_keccak512_close(&ctx_keccak, hashA); //8
    }
    else
    {
        sph_jh512_init(&ctx_jh);
        sph_jh512 (&ctx_jh, hashB, 64); //7
        sph_jh512_close(&ctx_jh, hashA); //8
    }


    sph_shavite512_init(&ctx_shavite);
    sph_shavite512 (&ctx_shavite,hashA, 64); //5
    sph_shavite512_close(&ctx_shavite, hashB); //6

    sph_simd512_init(&ctx_simd);
    sph_simd512 (&ctx_simd, hashB, 64); //6
    sph_simd512_close(&ctx_simd, hashA); //7

    if ((hashA[0] & mask) != zero) //4
    {
        sph_whirlpool_init(&ctx_whirlpool);
        sph_whirlpool (&ctx_whirlpool, hashA, 64); //
        sph_whirlpool_close(&ctx_whirlpool, hashB); //5
    }
    else
    {
        sph_haval256_5_init(&ctx_haval);
        sph_haval256_5 (&ctx_haval, hashA, 64); //4
        sph_haval256_5_close(&ctx_haval, hashB);   //5
	memset(&hashB[8], 0, 32);
    }

    sph_echo512_init(&ctx_echo);
    sph_echo512 (&ctx_echo,hashB, 64); //5
    sph_echo512_close(&ctx_echo, hashA); //6

    sph_blake512_init(&ctx_blake);
    sph_blake512 (&ctx_blake, hashA, 64); //6
    sph_blake512_close(&ctx_blake, hashB); //7

    if ((hashB[0] & mask) != zero) //7
    {
        sph_shavite512_init(&ctx_shavite);
        sph_shavite512 (&ctx_shavite, hashB, 64); //
        sph_shavite512_close(&ctx_shavite, hashA); //8
    }
    else
    {
        sph_luffa512_init(&ctx_luffa);
        sph_luffa512 (&ctx_luffa, hashB, 64); //7
        sph_luffa512_close(&ctx_luffa, hashA); //8
    }


    sph_hamsi512_init(&ctx_hamsi);
    sph_hamsi512 (&ctx_hamsi,hashA, 64); //5
    sph_hamsi512_close(&ctx_hamsi, hashB); //6

    sph_fugue512_init(&ctx_fugue);
    sph_fugue512 (&ctx_fugue, hashB, 64); //6
    sph_fugue512_close(&ctx_fugue, hashA); //7


    if ((hashA[0] & mask) != zero) //4
    {
        sph_echo512_init(&ctx_echo);
        sph_echo512 (&ctx_echo, hashA, 64); //
        sph_echo512_close(&ctx_echo, hashB); //5
    }
    else
    {
        sph_simd512_init(&ctx_simd);
        sph_simd512 (&ctx_simd, hashA, 64); //4
        sph_simd512_close(&ctx_simd, hashB);   //5
    }

    sph_shabal512_init(&ctx_shabal);
    sph_shabal512 (&ctx_shabal,hashB, 64); //5
    sph_shabal512_close(&ctx_shabal, hashA); //6

    sph_whirlpool_init(&ctx_whirlpool);
    sph_whirlpool (&ctx_whirlpool, hashA, 64); //6
    sph_whirlpool_close(&ctx_whirlpool, hashB); //7

   if ((hashB[0] & mask) != zero) //7
    {
        sph_fugue512_init(&ctx_fugue);
        sph_fugue512 (&ctx_fugue, hashB, 64); //
        sph_fugue512_close(&ctx_fugue, hashA); //8
    }
    else
    {
        sph_sha512_init(&ctx_sha2);
        sph_sha512 (&ctx_sha2, hashB, 64); //7
        sph_sha512_close(&ctx_sha2, hashA); //8
    }

    sph_groestl512_init(&ctx_groestl);
    sph_groestl512 (&ctx_groestl,hashA, 64); //5
    sph_groestl512_close(&ctx_groestl, hashB); //6

    sph_sha512_init(&ctx_sha2);
    sph_sha512 (&ctx_sha2, hashB, 64); //6
    sph_sha512_close(&ctx_sha2, hashA); //7


    if ((hashA[0] & mask) != zero) //4
    {
        sph_haval256_5_init(&ctx_haval);
        sph_haval256_5 (&ctx_haval, hashA, 64); //
        sph_haval256_5_close(&ctx_haval, hashB); //5
	memset(&hashB[8], 0, 32);
    }
    else
    {
        sph_whirlpool_init(&ctx_whirlpool);
        sph_whirlpool (&ctx_whirlpool, hashA, 64); //4
        sph_whirlpool_close(&ctx_whirlpool, hashB);   //5
    }


    sph_bmw512_init(&ctx_bmw);
    sph_bmw512 (&ctx_bmw,hashB, 64); //5
    sph_bmw512_close(&ctx_bmw, hashA); //6


	memcpy(state, hashA, 32);

}