Bitcoin Forum
June 30, 2024, 01:23:43 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: argone based algo implemenation  (Read 79 times)
mraksoll (OP)
Jr. Member
*
Offline Offline

Activity: 88
Merit: 1


View Profile
April 03, 2024, 06:12:32 PM
 #1

what do you think about this algo implementation ? + and - ?

Code:
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;
}
mraksoll (OP)
Jr. Member
*
Offline Offline

Activity: 88
Merit: 1


View Profile
April 04, 2024, 09:04:55 PM
 #2

what you are think about the next idea ?

Code:
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;
}
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!