From ff64cde0e81222972b8a73f8c8e7547481678c86 Mon Sep 17 00:00:00 2001 From: Vivek Arte Date: Thu, 19 Sep 2024 17:03:22 +0530 Subject: [PATCH] based on review comments --- zcash_test_vectors/orchard_zsa/digests.py | 2 +- zcash_test_vectors/transaction.py | 3 ++- zcash_test_vectors/transaction_zsa.py | 4 ++-- zcash_test_vectors/zip_0244.py | 29 ++++++++++------------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/zcash_test_vectors/orchard_zsa/digests.py b/zcash_test_vectors/orchard_zsa/digests.py index e488de6..6452b13 100755 --- a/zcash_test_vectors/orchard_zsa/digests.py +++ b/zcash_test_vectors/orchard_zsa/digests.py @@ -6,7 +6,7 @@ NU7_VERSION_GROUP_ID = 0x124A69F8 NU7_TX_VERSION = 6 - +NU7_TX_VERSION_BYTES = NU7_TX_VERSION | (1 << 31) def orchard_zsa_burn_digest(tx): digest = blake2b(digest_size=32, person=b'ZTxIdOrcBurnHash') diff --git a/zcash_test_vectors/transaction.py b/zcash_test_vectors/transaction.py index 0ec4ff4..87b0801 100644 --- a/zcash_test_vectors/transaction.py +++ b/zcash_test_vectors/transaction.py @@ -25,6 +25,7 @@ NU5_VERSION_GROUP_ID = 0x26A7270A NU5_TX_VERSION = 5 +NU5_TX_VERSION_BYTES = NU5_TX_VERSION | (1 << 31) # Sapling note magic values, copied from src/zcash/Zcash.h NOTEENCRYPTION_AUTH_BYTES = 16 @@ -561,7 +562,7 @@ def __init__(self, rand, consensus_branch_id): @staticmethod def version_bytes(): - return NU5_TX_VERSION | (1 << 31) + return NU5_TX_VERSION_BYTES def __bytes__(self): ret = b'' diff --git a/zcash_test_vectors/transaction_zsa.py b/zcash_test_vectors/transaction_zsa.py index 795bc42..0dde3a2 100644 --- a/zcash_test_vectors/transaction_zsa.py +++ b/zcash_test_vectors/transaction_zsa.py @@ -4,7 +4,7 @@ from .orchard.key_components import FullViewingKey, SpendingKey from .orchard.pallas import Point from .orchard_zsa.key_components import IssuanceKeys -from .orchard_zsa.digests import NU7_VERSION_GROUP_ID, NU7_TX_VERSION +from .orchard_zsa.digests import NU7_VERSION_GROUP_ID, NU7_TX_VERSION_BYTES from .orchard_zsa.asset_base import zsa_value_base, asset_digest, encode_asset_id, get_random_unicode_bytes from .zc_utils import write_compact_size from .transaction import ( @@ -123,7 +123,7 @@ def __init__(self, rand, consensus_branch_id, have_orchard_zsa=True, have_burn=T @staticmethod def version_bytes(): - return NU7_TX_VERSION | (1 << 31) + return NU7_TX_VERSION_BYTES def orchard_zsa_burn_field_bytes(self): ret = b'' diff --git a/zcash_test_vectors/zip_0244.py b/zcash_test_vectors/zip_0244.py index 3961386..d20a3fb 100755 --- a/zcash_test_vectors/zip_0244.py +++ b/zcash_test_vectors/zip_0244.py @@ -4,14 +4,15 @@ assert sys.version_info[0] >= 3, "Python 3 required." from hashlib import blake2b +from collections import namedtuple import struct -from .orchard_zsa.digests import NU7_TX_VERSION, orchard_zsa_burn_digest, issuance_digest, issuance_auth_digest +from .orchard_zsa.digests import NU7_TX_VERSION_BYTES, orchard_zsa_burn_digest, issuance_digest, issuance_auth_digest from .transaction import ( MAX_MONEY, Script, TransactionV5, - NU5_TX_VERSION, + NU5_TX_VERSION_BYTES, ) from .output import render_args, render_tv from .rand import Rand @@ -138,7 +139,7 @@ def orchard_digest(tx): digest.update(orchard_actions_compact_digest(tx)) digest.update(orchard_actions_memos_digest(tx)) digest.update(orchard_actions_noncompact_digest(tx)) - if tx.version_bytes() == NU7_TX_VERSION | (1 << 31): + if tx.version_bytes() == NU7_TX_VERSION_BYTES: digest.update(orchard_zsa_burn_digest(tx)) digest.update(struct.pack('