diff --git a/test-vectors/rust/zip_0244.rs b/test-vectors/rust/zip_0244.rs index 0225db5..97e6a06 100644 --- a/test-vectors/rust/zip_0244.rs +++ b/test-vectors/rust/zip_0244.rs @@ -69,7 +69,7 @@ ], transparent_input: None, sighash_shielded: [ - 0xf2, 0x89, 0x61, 0x8d, 0x7f, 0x61, 0x53, 0x29, 0x3c, 0x4e, 0x24, 0xc2, 0x76, 0xa0, 0xa1, 0x5d, 0x56, 0x2d, 0x4e, 0x6c, 0x91, 0xde, 0x3e, 0x93, 0x10, 0x4d, 0x31, 0x65, 0x4e, 0x5d, 0x71, 0xc5 + 0x2f, 0x95, 0xe5, 0xa9, 0x5d, 0x20, 0x9e, 0x0a, 0x27, 0xd1, 0xfe, 0x66, 0x9a, 0x46, 0xf4, 0xa6, 0x44, 0xa3, 0x27, 0xd7, 0x9b, 0x84, 0x6e, 0x97, 0x92, 0x64, 0x18, 0x6a, 0xde, 0x04, 0x9b, 0xa0 ], sighash_all: None, sighash_none: None, @@ -119,7 +119,7 @@ ], transparent_input: None, sighash_shielded: [ - 0x6a, 0x58, 0x74, 0x54, 0xbd, 0x03, 0x12, 0x4b, 0x38, 0xe8, 0x0b, 0x46, 0xe4, 0x57, 0xcd, 0x7d, 0x5a, 0x0e, 0x8c, 0x92, 0x9b, 0x27, 0x56, 0xc1, 0xd6, 0x81, 0x7e, 0x7b, 0x53, 0xdb, 0xf3, 0x63 + 0x83, 0xc8, 0xe3, 0x41, 0x04, 0xf1, 0x8b, 0xdb, 0xe8, 0xbb, 0xf6, 0xf0, 0xb9, 0xba, 0x53, 0xb5, 0xc6, 0x69, 0x40, 0x61, 0x0c, 0x89, 0x4b, 0xc0, 0xa8, 0x4a, 0x16, 0xdc, 0x99, 0x51, 0x24, 0x74 ], sighash_all: None, sighash_none: None, diff --git a/zcash_test_vectors/transaction.py b/zcash_test_vectors/transaction.py index 2d88d0c..b71a0d3 100644 --- a/zcash_test_vectors/transaction.py +++ b/zcash_test_vectors/transaction.py @@ -423,6 +423,10 @@ class TransactionV5(object): def version_bytes(self): return NU5_TX_VERSION | (1 << 31) + def is_coinbase(self): + # + return len(self.vin) == 1 and bytes(self.vin[0].prevout.txid) == b'\x00'*32 and self.vin[0].prevout.n == 0xFFFFFFFF + # TODO: Update ZIP 225 to document endianness def __bytes__(self): ret = b'' diff --git a/zcash_test_vectors/zip_0244.py b/zcash_test_vectors/zip_0244.py index d89740a..23fe2d5 100755 --- a/zcash_test_vectors/zip_0244.py +++ b/zcash_test_vectors/zip_0244.py @@ -240,9 +240,15 @@ def signature_digest(tx, t_inputs, nHashType, txin): return digest.digest() def transparent_sig_digest(tx, t_inputs, nHashType, txin): - digest = blake2b(digest_size=32, person=b'ZTxIdTranspaHash') + # If we are producing a hash for either a coinbase transaction, or a + # non-coinbase transaction that has no transparent inputs, the value of + # ``transparent_sig_digest`` is identical to the value specified in section + # T.2 . - if len(tx.vin) + len(tx.vout) > 0: + if tx.is_coinbase() or len(tx.vin) == 0: + return transparent_digest(tx) + else: + digest = blake2b(digest_size=32, person=b'ZTxIdTranspaHash') digest.update(hash_type(tx, nHashType, txin)) digest.update(prevouts_sig_digest(tx, nHashType)) digest.update(amounts_sig_digest(t_inputs, nHashType)) @@ -251,7 +257,7 @@ def transparent_sig_digest(tx, t_inputs, nHashType, txin): digest.update(outputs_sig_digest(tx, nHashType, txin)) digest.update(txin_sig_digest(tx, txin)) - return digest.digest() + return digest.digest() def hash_type(tx, nHashType, txin): if txin is None: