static void metis4_close(sph_metis_context *sc, unsigned ub, unsigned n, void *dst) { int i; CLOSE_ENTRY(36, 12, metis4_core) for (i = 0; i < 32; i ++) { ROR(3, 36); CMIX36(S[0], S[1], S[2], S[4], S[5], S[6], S[18], S[19], S[20]); SMIX(S[0], S[1], S[2], S[3]); } for (i = 0; i < 13; i ++) { S[4] ^= S[0]; S[9] ^= S[0]; S[18] ^= S[0]; S[27] ^= S[0]; ROR(9, 36); SMIX(S[0], S[1], S[2], S[3]); S[4] ^= S[0]; S[10] ^= S[0]; S[18] ^= S[0]; S[27] ^= S[0]; ROR(9, 36); SMIX(S[0], S[1], S[2], S[3]); S[4] ^= S[0]; S[10] ^= S[0]; S[19] ^= S[0]; S[27] ^= S[0]; ROR(9, 36); SMIX(S[0], S[1], S[2], S[3]); S[4] ^= S[0]; S[10] ^= S[0]; S[19] ^= S[0]; S[28] ^= S[0]; ROR(8, 36); SMIX(S[0], S[1], S[2], S[3]); } S[4] ^= S[0]; S[9] ^= S[0]; S[18] ^= S[0]; S[27] ^= S[0]; out = dst; sph_enc32be(out + 0, S[ 1]); sph_enc32be(out + 4, S[ 2]); sph_enc32be(out + 8, S[ 3]); sph_enc32be(out + 12, S[ 4]); sph_enc32be(out + 16, S[ 9]); sph_enc32be(out + 20, S[10]); sph_enc32be(out + 24, S[11]); sph_enc32be(out + 28, S[12]); sph_enc32be(out + 32, S[18]); sph_enc32be(out + 36, S[19]); sph_enc32be(out + 40, S[20]); sph_enc32be(out + 44, S[21]); sph_enc32be(out + 48, S[27]); sph_enc32be(out + 52, S[28]); sph_enc32be(out + 56, S[29]); sph_enc32be(out + 60, S[30]); sph_metis512_init(sc); }
void init_metishash_contexts() { sph_keccak512_init(&base_contexts.keccak1); sph_shavite512_init(&base_contexts.shavite1); sph_metis512_init(&base_contexts.metis1); }
void metiscoin_process(minerMetiscoinBlock_t* block) { sph_keccak512_context ctx_keccak; sph_shavite512_context ctx_shavite; sph_metis512_context ctx_metis; static unsigned char pblank[1]; block->nonce = 0; uint32 target = *(uint32*)(block->targetShare+28); uint64 hash0[8]; uint64 hash1[8]; uint64 hash2[8]; for(uint32 n=0; n<0x1000; n++) { if( block->height != monitorCurrentBlockHeight ) break; for(uint32 f=0; f<0x8000; f++) { sph_keccak512_init(&ctx_keccak); sph_shavite512_init(&ctx_shavite); sph_metis512_init(&ctx_metis); sph_keccak512(&ctx_keccak, &block->version, 80); sph_keccak512_close(&ctx_keccak, hash0); sph_shavite512(&ctx_shavite, hash0, 64); sph_shavite512_close(&ctx_shavite, hash1); sph_metis512(&ctx_metis, hash1, 64); sph_metis512_close(&ctx_metis, hash2); if( *(uint32*)((uint8*)hash2+28) <= target ) { totalShareCount++; xptMiner_submitShare(block); } block->nonce++; } totalCollisionCount += 0x8000; } }