Bit by Bitcoin
Watch the video below on how bitcoin, a âcryptocurrency,â works, up through 00:21:54.
-
(2 points.) What, in your own words, is a blockchain? How does bitcoin use a blockchain?
-
(2 points.) What, in your own words, is a cryptographic hash function?
-
(2 points.) Consider the hash function, below, which calls
ord
. Assume thats
is a string of length 1 or greater.def hash(s): return ord(s[0]) % 50
Why is this implementation of
hash
unsuitable as a cryptographic hash function?
- (4 points.) Although a block in an actual blockchain represents multiple transactions, assume for simplicity that a block represents only one and that each block thus has, among other fields:
- a unique identifier for the transaction itself,
- a unique identifier for the transactionâs sender,
- a unique identifier for the transactionâs recipient,
- the transactionâs amount,
- a digital signature from the sender, and
- a proof of work.
Suppose we have a type
blockchain
defined astypedef block *blockchain;
where a
blockchain
is a pointer to a value of typeblock
.Implement a type called
block
in a manner consistent with the video and specifications above. Assume thatdigest
is a type with which you can represent SHA256 digests.