The way Bitcoin checks a public address is using what is called Base58Check. While the Bitcoin Wiki covers Base58Check, I'll outline how it works in both abstract and technical terms.
The whole idea of Base58Check is to prevent invalid addresses. This is done by adding digits to the start (00) and end of the Base58 value (4 bytes of double SHA256 hash).
Yes, exactly 1/2^32.
There isn't much more to say about it. Hashes of distinct values are uniformly randomly distributed. The chance for two independently uniformly randomly distributed hash to match in 32 bits is 1/2^32.
Rosetta Code has several example implementations in multiple languages.
Python 2 & 3
from hashlib import sha256
digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def to_bytes(n, length):
s = '%x' % n
s = s.rjust(length*2, '0')
s = codecs.decode(s.encode("UTF-8"), 'hex_codec')
I am assuming that you are talking about BIP 39 here.
A BIP 39 mnemonic can have any number of words with the most common being 12, 18, and 24 words. There is a checksum encoded into this mnemonic. This checksum is actually just a "part of" the last word, i.e. the last word encodes some of the actual initial entropy, and some of the checksum, depending on ...
Sometimes these terms are used more or less interchangeably. Traditionally, a checksum is used to detect corruption and a hash is used to map large elements into slots randomly. In Bitcoin-land we're often concerned with "cryptographic hashes" which are hashes that have special security properties.
Things called checksums are usually designed to have ...
If it is the format and the checksum then that can be easily done. Specifically you can use steps 4 to 9 in the technical description of Addresses to check for typos. Beyond that however it gets difficult
If you want to access blockchain information such as the current balance you cannot unless you have a copy of the blockchain somewhere, and on a phone or ...
it seems like the process to calculate a checksum for an extended key is to decode the base58 string to data,
If raw_xpub = version + depth + fingerprint + child + chain + DATA
than to make the checksum you need to do doublehash of xpriv/xpub (sha256), in python:
hashed_xpub = hashlib.sha256(raw_xpub).digest()
hashed_xpub = hashlib.sha256(hashed_xpub)....
A checksum is an application of a hash function.
From wikipedia - cryptographic hash function:
A cryptographic hash... is a mathematical algorithm that maps data of arbitrary size to a bit string of a fixed size (a hash) and is designed to be a one-way function, that is, a function which is infeasible to invert.
From wikipedia - checksum:
A checksum ...
The SHA-256 hash of the hex string is 5355d54a3d673c4b1ac20b839ead09af3c6fea6dc24199b477f6ff64e7a68262. The first 4 bits of that are represented by the first hex character, 5, which in binary is 0101.
You need to take the shasum of the raw binary, not the hex string:
$ echo "...