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 that
sis a string of length 1 or greater.
def hash(s): return ord(s) % 50
Why is this implementation of
hashunsuitable 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
typedef block *blockchain;
blockchainis a pointer to a value of type
Implement a type called
blockin a manner consistent with the video and specifications above. Assume that
digestis a type with which you can represent SHA256 digests.