// This is the complete hash reference function. Given the current round parameters, // and the solution, which is a vector of indices, it calculates the proof. The goodness // of the solution is determined by the numerical value of the proof. bigint_t HashReference( const Packet_ServerBeginRound *pParams, unsigned nIndices, const uint32_t *pIndices ){ if(nIndices>pParams->maxIndices) throw std::invalid_argument("HashReference - Too many indices for parameter set."); bigint_t acc; wide_zero(8, acc.limbs); for(unsigned i=0;i<nIndices;i++){ if(i>0){ if(pIndices[i-1] >= pIndices[i]) throw std::invalid_argument("HashReference - Indices are not in monotonically increasing order."); } // Calculate the hash for this specific point bigint_t point=PoolHash(pParams, pIndices[i]); // Combine the hashes of the points together using xor wide_xor(8, acc.limbs, acc.limbs, point.limbs); } return acc; }
// Given the various round parameters, this calculates the hash for a particular index value. // Multiple hashes of different indices will be combined to produce the overall result. bigint_t PoolHash(const Packet_ServerBeginRound *pParams, uint32_t index) { assert(NLIMBS==4*2); // Incorporate the existing block chain data - in a real system this is the // list of transactions we are signing. This is the FNV hash: // http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function hash::fnv<64> hasher; uint64_t chainHash=hasher((const char*)&pParams->chainData[0], pParams->chainData.size()); // The value x is 8 words long (8*32 bits in total) // We build (MSB to LSB) as [ chainHash ; roundSalt ; roundId ; index ] bigint_t x; wide_zero(8, x.limbs); wide_add(8, x.limbs, x.limbs, index); //chosen index goes in at two low limbs wide_add(6, x.limbs+2, x.limbs+2, pParams->roundId); // Round goes in at limbs 3 and 2 wide_add(4, x.limbs+4, x.limbs+4, pParams->roundSalt); // Salt goes in at limbs 5 and 4 wide_add(2, x.limbs+6, x.limbs+6, chainHash); // chainHash at limbs 7 and 6 // Now step forward by the number specified by the server for(unsigned j=0;j<pParams->hashSteps;j++){ PoolHashStep(x, pParams); } return x; }
bitecoin::bigint_t do_gpu_mining(uint32_t microrounds, const bitecoin::Packet_ServerBeginRound *pParams, uint64_t chainHash, cl_instance instance) { bitecoin::bigint_t dummy; wide_zero(8,dummy.limbs); return dummy; }