Tangem Wallet Pack of 2 - Secure Crypto Wallet - Trusted Cold Storage for Bitcoin, Ethereum, NFT's &

Tangem Wallet Pack of 2 - Secure Crypto Wallet - Trusted Cold Storage for Bitcoin, Ethereum, NFT's &
Key item features Ultimate Security: Generates a private key that remains on the card, safeguarding crypto and NFTs from hackers with EAL6+ certification and audited firmware. Versatile Compatibility: Manages over 13,000 tokens across 70+ blockchains, supporting DeFi, NFTs, and DeEx without wires, Bluetooth, or USB. Effortless Operation: Utilizes NFC for secure transactions via a mobile device and the Tangem app, enabling buying and selling crypto with various payment methods. Smart Backup: Features a second Tangem Wallet as a backup, eliminating the need for paper, pictures, or seed phrases for recovery. Durable Design: Boasts IP68 protection against environmental conditions, ensuring longevity and robust physical security. Comprehensive Support: Compatible with Bitcoin, Ethereum, Solana, XRP, USDT, and over 6,000 cryptocurrencies, integrating with dApps and WalletConnect.

LBANK

Bitcoin core code (27.99) HashWriter hex strings problem

I'm working on an Altcoin, and I'm getting different hashes for the same hex string when hashed using the HashWriter class of the bitcoin core code (27.99) and when hashed with the bcrypto lib of the JavaScript.

The issue is only with the hex strings, while numbers when hashed their hashes are matching and no problems (this proofs that the same hashing algorithm is used in both bitcoin core code and the bcrypto lib in JS).


For numbers:

C++:

uint32_t timestamp = 1737835291;
HashWriter{} << st.timestamp).GetHash().GetHex(); // results in (85b76e3a3eeff7da605b5de8349aaee931965d611fd903cb33146982e61cbb28)

JavaScript:

bcrypto.hash256(intToBytes(1737835291)).reverse().toString("hex"); // results in (85b76e3a3eeff7da605b5de8349aaee931965d611fd903cb33146982e61cbb28)

For hex strings:

C++:

std::string hexString = "073ff90209cde3a9ce4ccd23598fd1b50e6a1fe34f30bd7240587f0bde6f65af";
(HashWriter{} << hexString ).GetHash().GetHex(); results in (73e21e5a9038727c61aeee89c899bd45d7e935a306ede80388de131a99e14a75)

JavaScript:

bcrypto.hash256(Buffer.from("073ff90209cde3a9ce4ccd23598fd1b50e6a1fe34f30bd7240587f0bde6f65af", "hex")).reverse().toString("hex"); results in (1ec6958d1fae90326d8abe7eb9950de366262ff80a730641a6acdac5dfc4ddfe) which is differs from the result of the C++

I have used an online tool to check the hash of the hex (073ff90209cde3a9ce4ccd23598fd1b50e6a1fe34f30bd7240587f0bde6f65af) and got a result that matches the result of the JavaScript (1ec6958d1fae90326d8abe7eb9950de366262ff80a730641a6acdac5dfc4ddfe)

I have also manipulated the hex strings encoding (hex, utf8/ascii) in both C++ and JavaScript and I couldn't find a matching point between the resulted hashes of the two codes.

I have tried (In the JavaScript code) to reverse the bytes of the hex string before hashing it, and this results in a different hash but still not matching the C++ hash.


Why this happening and how to get the same hash of the hex string in both codes?

Thanks,,,



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

Popular posts from this blog

Crypto Exec Warns Tokenization Is Moving Faster Than Expected

Bitcoin Mining Could Be Strengthening The Ruble, Russian Central Bank Says

Nigerian SEC Partners With Police To Tackle Crypto Ponzi Schemes – Details