BIP39's checksum generation

From what i've read, the checksum is just a basic SHA-256 hashed string, when only taking (Bitlen/32) bits of the hashed string.

Yet when I do it, I get incorrect values (resulting in incorrect last words) This is my implementation of the checksum calculator. I've implemented the hashing algorithm by myself, but there shouldnt be any issues with it.

std::string BIP39SeedMaker::checksum(cpp_int v)
{
    int binSize = binary(v).size();
    std::string hash = sha.digest(v.str());
    std::string hashBin = binary(cpp_int("0x"+hash));
    return hashBin.substr(0, binSize/32);
}

Please let me know if you see anything wrong, im really confused



from Recent Questions - Bitcoin Stack Exchange https://ift.tt/Ng9L4Tb
via IFTTT

Popular posts from this blog

Bitwise Clients Pour $69M Into Solana as Bulls Fight to Reclaim $200 Resistance Zone

The XRP Roadmap: Ripple President Reveals The Next Big Steps

How to compute MAST commit bytes in bitcoin payment?