Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions ports/stm32/boards/Passport/modules/psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,9 @@ def __init__(self):
self.hashOutputs = None

# taproot additions to reused segwit hashes
self.tap_hashPrevouts = None
self.tap_hashSequence = None
self.tap_hashOutputs = None
self.hashAmounts = None
self.hashScriptPubkeys = None

Expand Down Expand Up @@ -1678,7 +1681,7 @@ def make_txn_taproot_sighash(self, input_idx, sighash_type, annex=None, ext_flag

assert sighash_type == SIGHASH_DEFAULT

if self.hashPrevouts is None:
if self.tap_hashPrevouts is None:
# First time thru, we'll need to hash up this stuff.

prevouts = trezorcrypto.sha256()
Expand All @@ -1694,10 +1697,10 @@ def make_txn_taproot_sighash(self, input_idx, sighash_type, annex=None, ext_flag
script_pubkeys.update(ser_string(utxo.scriptPubKey))
sequences.update(pack("<I", txi.nSequence))

self.hashPrevouts = prevouts.digest()
self.tap_hashPrevouts = prevouts.digest()
self.hashAmounts = amounts.digest()
self.hashScriptPubkeys = script_pubkeys.digest()
self.hashSequence = sequences.digest()
self.tap_hashSequence = sequences.digest()

del prevouts, amounts, script_pubkeys, sequences, txi

Expand All @@ -1706,19 +1709,19 @@ def make_txn_taproot_sighash(self, input_idx, sighash_type, annex=None, ext_flag
for out_idx, txo in self.output_iter():
outputs.update(txo.serialize())

self.hashOutputs = outputs.digest()
self.tap_hashOutputs = outputs.digest()

del outputs, txo
gc.collect()

data = bytes([sighash_type])
data += pack('<i', self.txn_version)
data += pack('<I', self.lock_time)
data += self.hashPrevouts
data += self.tap_hashPrevouts
data += self.hashAmounts
data += self.hashScriptPubkeys
data += self.hashSequence
data += self.hashOutputs
data += self.tap_hashSequence
data += self.tap_hashOutputs

spend_type = (2 * ext_flag) + (1 if annex is not None else 0)
data += pack('B', spend_type)
Expand Down
Loading