Title: argone based algo implemenation
Post by: mraksoll on April 03, 2024, 06:12:32 PM
what do you think about this algo implementation ? + and - ? uint256 CBlockHeader::GetArgon2idPoWHash() const { uint256 hash; uint256 hash2; CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << *this; // Hashing the data using SHA-512 (two rounds) std::vector<unsigned char> salt_sha512(CSHA512::OUTPUT_SIZE); CSHA512().Write((unsigned char*)&ss[0], ss.size()).Finalize(salt_sha512.data()); CSHA512().Write(salt_sha512.data(), salt_sha512.size()).Finalize(salt_sha512.data()); // Preparing data for hashing const void* pwd = &ss[0]; size_t pwdlen = ss.size(); const void* salt = salt_sha512.data(); size_t saltlen = salt_sha512.size(); // Calling the argon2id_hash_raw function for the first round int rc = argon2id_hash_raw(2, 262144, 4, pwd, pwdlen, salt, saltlen, &hash, 32); if (rc != ARGON2_OK) { printf("Error: Failed to compute Argon2id hash\n"); exit(1); } // Hashing the result of the first round using SHA-512 (two rounds) std::vector<unsigned char> salt_sha512_round2(CSHA512::OUTPUT_SIZE); CSHA512().Write((unsigned char*)&hash, 32).Finalize(salt_sha512_round2.data()); CSHA512().Write(salt_sha512_round2.data(), salt_sha512_round2.size()).Finalize(salt_sha512_round2.data()); // Calling the argon2id_hash_raw function for the second round rc = argon2id_hash_raw(2, 524288, 4, &hash, 32, salt_sha512_round2.data(), salt_sha512_round2.size(), &hash2, 32); if (rc != ARGON2_OK) { printf("Error: Failed to compute Argon2id hash for the second round\n"); exit(1); } return hash2; }
Title: Re: argone based algo implemenation
Post by: mraksoll on April 04, 2024, 09:04:55 PM
what you are think about the next idea ? static bool CheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true) { // Check POW's bool powResult1 = fCheckPOW ? CheckProofOfWork(block.GetArgon2idPoWHash(), block.nBits, consensusParams) : true; bool powResult2 = fCheckPOW ? CheckProofOfWork(block.GetSomeOtherPOW(), block.nBits, consensusParams) : true;
// Checking if both POW's are valid if (!powResult1 || !powResult2) { return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "high-hash", "proof of work failed"); }
return true; }
|