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

Do Kwon’s Detention Prolonged Until 2024 As Montenegro Responds To Extradition Requests

Sam Bankman-Fried Trial Begins Tomorrow: 3 Reasons Ex-SEC Official Foresees Conviction

April’s Crypto Game-Changers: 7 Events Set To Drastically Impact The Course Of Digital Currencies