Skip to content

Commit

Permalink
sighash: move burn_amount into header_digest
Browse files Browse the repository at this point in the history
  • Loading branch information
giddie committed Dec 6, 2024
1 parent 8cfdb3e commit 4f02990
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 59 deletions.
1 change: 1 addition & 0 deletions zcash_test_vectors/zip_0244.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def header_digest(tx):
digest.update(struct.pack('<I', tx.nConsensusBranchId))
digest.update(struct.pack('<I', tx.nLockTime))
digest.update(struct.pack('<I', tx.nExpiryHeight))
digest.update(struct.pack('<Q', tx.burnAmount))

return digest.digest()

Expand Down
59 changes: 0 additions & 59 deletions zcash_test_vectors/zip_nsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,65 +19,6 @@

from .zip_0244 import *

def auth_digest(tx):
digest = blake2b(
digest_size=32,
person=b'ZTxAuthHash_' + struct.pack('<I', tx.nConsensusBranchId),
)

digest.update(transparent_scripts_digest(tx))
digest.update(sapling_auth_digest(tx))
digest.update(orchard_auth_digest(tx))
digest.update(burn_amount_digest(tx))

return digest.digest()

# NSM
def burn_amount_digest(tx):
digest = blake2b(digest_size=32, person=b'ZTxBurnAmnt_Hash')

digest.update(struct.pack('<Q', tx.burnAmount))

return digest.digest()

def txid_digest(tx):
digest = blake2b(
digest_size=32,
person=b'ZcashTxHash_' + struct.pack('<I', tx.nConsensusBranchId),
)

digest.update(header_digest(tx))
digest.update(transparent_digest(tx))
digest.update(sapling_digest(tx))
digest.update(orchard_digest(tx))
digest.update(burn_amount_digest(tx))

return digest.digest()

def signature_digest(tx, t_inputs, nHashType, txin):
digest = blake2b(
digest_size=32,
person=b'ZcashTxHash_' + struct.pack('<I', tx.nConsensusBranchId),
)

digest.update(header_digest(tx))
digest.update(transparent_sig_digest(tx, t_inputs, nHashType, txin))
digest.update(sapling_digest(tx))
digest.update(orchard_digest(tx))
digest.update(burn_amount_digest(tx))

return digest.digest()

def txin_sig_digest(tx, txin):
digest = blake2b(digest_size=32, person=b'Zcash___TxInHash')
if txin is not None:
digest.update(bytes(tx.vin[txin.nIn].prevout))
digest.update(struct.pack('<Q', txin.amount))
digest.update(bytes(txin.scriptPubKey))
digest.update(struct.pack('<I', tx.vin[txin.nIn].nSequence))
return digest.digest()


def main():
args = render_args()

Expand Down

0 comments on commit 4f02990

Please sign in to comment.