Ejemplo n.º 1
0
void axiomhash(void *output, const void *input)
{
	sph_shabal256_context ctx __attribute__ ((aligned (64)));
	const int N = 65536;

	sph_shabal256_init(&ctx);
	sph_shabal256(&ctx, input, 80);
	sph_shabal256_close(&ctx, M[0]);

	for(int i = 1; i < N; i++) {
		sph_shabal256_init(&ctx);
		sph_shabal256(&ctx, M[i-1], 32);
		sph_shabal256_close(&ctx, M[i]);
	}

	for(int b = 0; b < N; b++)
	{
		const int p = b > 0 ? b - 1 : 0xFFFF;
		const int q = M[p][0] % 0xFFFF;
		const int j = (b + q) % N;

		sph_shabal256_init(&ctx);
#if 0
		sph_shabal256(&ctx, M[p], 32);
		sph_shabal256(&ctx, M[j], 32);
#else
		uint8_t _ALIGN(64) hash[64];
		memcpy(hash, M[p], 32);
		memcpy(&hash[32], M[j], 32);
		sph_shabal256(&ctx, hash, 64);
#endif
		sph_shabal256_close(&ctx, M[b]);
	}
	memcpy(output, M[N-1], 32);
}
Ejemplo n.º 2
0
inline uint256 HashAxiom(const T1 pbegin, const T1 pend)
{

    int R = 2;
    int N = 65536;

    std::vector<uint256> M(N);

    static unsigned char pblank[1];
    pblank[0] = 0;

    sph_shabal256_context   ctx_shabal;

    uint256 hash1;
    sph_shabal256_init(&ctx_shabal);
    sph_shabal256 (&ctx_shabal, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0]));
    sph_shabal256_close(&ctx_shabal, static_cast<void*>(&hash1));
    M[0] = hash1;


    for(int i = 1; i < N; i++)
    {
	sph_shabal256_init(&ctx_shabal);
        sph_shabal256 (&ctx_shabal, (unsigned char*)&M[i - 1], sizeof(M[i - 1]));
        sph_shabal256_close(&ctx_shabal, static_cast<void*>((unsigned char*)&M[i]));
    }

    for(int r = 1; r < R; r ++)
    {
	for(int b = 0; b < N; b++)
	{	    
	    int p = (b - 1 + N) % N;
	    int q = M[p].GetInt() % (N - 1);
	    int j = (b + q) % N;
	    std::vector<uint256> pj(2);
	    
	    pj[0] = M[p];
	    pj[1] = M[j];
	    sph_shabal256_init(&ctx_shabal);
            sph_shabal256 (&ctx_shabal, (unsigned char*)&pj[0], 2 * sizeof(pj[0]));
            sph_shabal256_close(&ctx_shabal, static_cast<void*>((unsigned char*)&M[b]));
	}
    }

    return M[N - 1];

}
Ejemplo n.º 3
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);





}