a. b. c. d.
COMP90088 (2022) Tutorial Week 3 Solutions
UTXO-based transactions
The values controlled are: {A: 16, B: 13, C: 1, D: 9, E: 7}.
Copyright By PowCoder代写 加微信 powcoder
The set of UTXOs is {2[0], 2[2], 3[0], 3[1], 3[3], 4[0], 4[1], 4[3], 4[4], 5[0], 5[1], 5[2]}. 4 coins in total are given as transaction fees.
6.1 Invalid since input valid is less than output value.
6.2 Valid.
6.3 Invalid since input UTXO 1[2] does not exist.
6.4 Valid, even though B sends coins to themselves.
6.5 Invalid, since input TXO 4[2] was already spent in transaction 5.
A given transaction consumes UTXOs as inputs, and generates a new UTXO for each output. Thus the size of the UTXO set increases after a transaction with more outputs than inputs, and decreases after a transaction with more inputs than outputs. An appropriate fee structure for minimising the UTXO set size might be to charge fees per transaction output, with possible discounts for each transaction input.
Bitcoin blocks
• Version # rarely changes; only on protocol updates.
• Previous block hash changes every block but can be computed from the previous block.
• The Merkle root of transactions changes with every block.
• Timestamp changes with every block, but is on average 600 seconds greater than the previous block’s timestamp.
• Difficulty changes every 2016 blocks.
• Nonce is unpredictable and changes every block.
• Version # can be omitted.
• Previous block hash can be omitted since it can be recomputed, as all blocks are stored
by this client.
• Timestamp can be stored as seconds since previous block using 2 bytes (since blocks are 600 seconds apart on average), rather than storing Unix time.
• Difficulty can be omitted as it can be recomputed from timestamps.
Thus, 4 + 32 + 2 + 4 = 42 bytes can be saved, so a compressed block header can be stored in
Bitcoin script
• The ScriptSig for P2PKH scripts is
• The ScriptSig for P2PK scripts is
b. With P2PKH, the ScriptPubKey contains a 160-bit hash of the public key. With P2PK, a 257-bit compressed public key is included. The extra opcodes are only 1 byte each, so P2PKH results in smaller UTXOs. Thus P2PKH is preferred when aiming to minimise the size of the UTXO set.
This also means that senders only need to know the 160-bit hash of the public key in order to send money, so it is easier to post these addresses on a website, via QR code, etc.
There are security benefits as well: the public key is not revealed until a P2PKH TXO is spent. This gives an attacker less time to try to attack a public key cryptographically (e.g. with a quantum computer) as there is only a small time window (perhaps an hour) where it is visible publicly before the transaction it is used in has been confirmed and it is too late to attack.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com