Skip to content

Commit 3cd2cbc

Browse files
committed
Fixed header digest in zip_0244
1 parent 63962a3 commit 3cd2cbc

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

zcash_test_vectors/transaction.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,18 +417,18 @@ def __bytes__(self):
417417

418418

419419
class TransactionV5(object):
420-
def __init__(self, rand, consensus_branch_id, version_group_id):
420+
def __init__(self, rand, consensus_branch_id):
421421
# Decide which transaction parts will be generated.
422422
flip_coins = rand.u8()
423423

424-
self.init_header(consensus_branch_id, version_group_id, rand)
424+
self.init_header(consensus_branch_id, rand)
425425
self.init_transparent(rand, flip_coins)
426426
self.init_sapling(rand, flip_coins)
427427
self.init_orchard(rand, flip_coins)
428428

429-
def init_header(self, consensus_branch_id, version_group_id, rand):
429+
def init_header(self, consensus_branch_id, rand):
430430
# Common Transaction Fields
431-
self.nVersionGroupId = version_group_id
431+
self.nVersionGroupId = NU5_VERSION_GROUP_ID
432432
self.nConsensusBranchId = consensus_branch_id
433433
self.nLockTime = rand.u32()
434434
self.nExpiryHeight = rand.u32() % TX_EXPIRY_HEIGHT_THRESHOLD
@@ -592,9 +592,9 @@ def orchard_bytes(self):
592592
return ret
593593

594594
class TransactionV6(TransactionV5):
595-
def init_header(self, consensus_branch_id, version_group_id, rand):
595+
def init_header(self, consensus_branch_id, rand):
596596
# Common Transaction Fields
597-
self.nVersionGroupId = version_group_id
597+
self.nVersionGroupId = V6_VERSION_GROUP_ID
598598
self.nConsensusBranchId = consensus_branch_id
599599
self.nLockTime = rand.u32()
600600
self.nExpiryHeight = rand.u32() % TX_EXPIRY_HEIGHT_THRESHOLD
@@ -615,10 +615,10 @@ class Transaction(object):
615615
def __init__(self, rand, version, consensus_branch_id=None):
616616
if version == NU5_TX_VERSION:
617617
assert consensus_branch_id is not None
618-
self.inner = TransactionV5(rand, consensus_branch_id, NU5_VERSION_GROUP_ID)
618+
self.inner = TransactionV5(rand, consensus_branch_id)
619619
elif version == V6_TX_VERSION:
620620
assert consensus_branch_id is not None
621-
self.inner = TransactionV6(rand, consensus_branch_id, V6_VERSION_GROUP_ID)
621+
self.inner = TransactionV6(rand, consensus_branch_id)
622622
else:
623623
self.inner = LegacyTransaction(rand, version)
624624

zcash_test_vectors/zip_0233.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
from hashlib import blake2b
55
import struct
66

7-
from .transaction import (
8-
V6_VERSION_GROUP_ID,
9-
TransactionV6,
10-
)
7+
from .transaction import TransactionV6
118
from .output import render_args, render_tv, Some
129
from .rand import Rand
1310
from .zip_0143 import (
@@ -35,7 +32,7 @@ def randbytes(l):
3532

3633
test_vectors = []
3734
for _ in range(10):
38-
tx = TransactionV6(rand, consensusBranchId, V6_VERSION_GROUP_ID)
35+
tx = TransactionV6(rand, consensusBranchId)
3936

4037
# Generate amounts and scriptCodes for each non-dummy transparent input.
4138
if tx.is_coinbase():

zcash_test_vectors/zip_0244.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
from .transaction import (
88
MAX_MONEY,
9-
NU5_TX_VERSION,
10-
NU5_VERSION_GROUP_ID,
119
Script,
1210
TransactionV5,
1311
)
@@ -191,8 +189,6 @@ def header_digest(tx):
191189
digest.update(struct.pack('<I', tx.nExpiryHeight))
192190
if hasattr(tx, 'zip233Amount'):
193191
digest.update(struct.pack('<Q', tx.zip233Amount))
194-
else:
195-
digest.update(struct.pack('<Q', 0))
196192

197193
return digest.digest()
198194

@@ -357,7 +353,7 @@ def randbytes(l):
357353

358354
test_vectors = []
359355
for _ in range(10):
360-
tx = TransactionV5(rand, consensusBranchId, NU5_VERSION_GROUP_ID)
356+
tx = TransactionV5(rand, consensusBranchId)
361357
txid = txid_digest(tx)
362358
auth = auth_digest(tx)
363359

0 commit comments

Comments
 (0)