Digital Keys
What’s important to understand is that these digital keys are created and managed by digital wallets. Each wallet runs a digital (public) address, similar to the beneficiary name on a traditional paper cheque. It consists of a public key (similar to a credit card number) and a private key (similar to a credit card PIN number). In the conventional, non-digital world, the safety of your underlying funds is not compromised by having the beneficiary name printed on a cheque or entering full credit card numbers when making an online purchase. Similarly with public key cryptography, the public key and digital address are shared and exposed. However the private key, is just like your PIN on a bank card, so it should never be shared. Private keys should be kept as secret and safe as PIN numbers because they authorise the spending of your money.
Bitcoin Address
To get to the bitcoin address, the public key is fed into a cryptographic algorithm known as SHA (Secure Hash Algorithm), designed by the Unites States National Security Agency (NSA). The SHA-256 algorithm takes an input string of any size and converts it to exactly 256 bits. After this, the resulting 256-bit long string is fed again to the SHA algorithm, and more specifically to RIPEMD-160, another family of cryptographic algorithms.
Public Keys
Public keys are created from private keys using a mathematical concept known as “elliptic curve multiplication”, which can generate a unique public key from a private key but more importantly, not the other way around. In this way, a private key is used to digitally sign (or authenticate) a transaction to spend a number of bitcoins. By publicising the signature and the public key, anyone can infer that the transaction is valid without needing to actually see the private key. In other words, they can see that: The transaction was indeed sent by the private key holder, i.e. the legitimate owner of the bitcoins, and At the time of the transaction, the owner owned the amount of bitcoins that appears on the transaction Public keys can be either 520 bits (65 bytes) long, or 264 bits (33 bytes) long if the key is compressed.