latest-revision | original-author | created | status | title | contributors | type | description | discussions-to | category |
---|---|---|---|---|---|---|---|---|---|
2019-01-27T00:00:00.000Z |
Ryan Shea (ryan-shea) |
2019-01-01T00:00:00.000Z |
Accepted |
Hash |
Ryan Shea (ryan-shea); Gareth James (gjradar) |
article |
GitHub URL |
bitcoin-basics |
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.
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.
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.
[1] https://en.bitcoin.it/wiki/Hash
[2] https://en.wikipedia.org/wiki/Cryptographic_hash_function