Hash

Overview

A hash algorithm turns an arbitrary amount of data into a unique fixed-length hash. A hash is a fingerprint of the input data, and the same fingerprint can always be produced from the same input data. Hashes are essential to cryptographic functions not only on Bitcoin but also on the Lightning Network.

Details

Bitcoin Hashes

Cryptographic hash functions are used extensively in Bitcoin: in bitcoin addresses, in script addresses, and in the mining Proof-of-Work algorithm. Bitcoin uses the SHA-256 algorithm to generate hashes.

Private and Public Keys

Public-key cryptography involves a key pair: a public key and a private key. Each entity has their own. The public key can be shared around, the private key is secret.

They allow doing two things:

  • Encrypt a message with the public key, decrypt it with the private key

  • Sign a message with the private key, verify it with the public key

Some common algorithms are RSA (used for both) and ECDSA (only for signatures).

In the bitcoin protocol, a one-way cryptographic hash function is used to generate a bitcoin address.

Resources

SHA-256 Hash Generator

References

[1] https://en.bitcoin.it/wiki/Hash

[2] https://en.wikipedia.org/wiki/Cryptographic_hash_function