bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 35쪽 중 19쪽
encoded as in
Bitcoin.
3..4 4 nExpiryHeight uint32 Ablock heightafter which thetransactionwill expire, or
0to disable expiry. [ZIP-203]
4 8 valueBalanceSapling int64 The net value ofSapling-poolspends minus outputs.
4 Varies nSpendsSapling compactSize The number ofSpend descriptionsin vSpendsSapling.
4 384·
nSpendsSapling
vSpendsSapling SpendDescriptionV4
[nSpendsSapling]
A sequence ofSpend descriptions, encoded per §7.3
‘Spend Description Encoding and Consensus’ on
p.133.
4 Varies nOutputsSapling compactSize The number ofOutput descriptionsin vOutputsSapling.
4 948·
nOutputsSapling
vOutputsSapling OutputDescriptionV4
[nOutputsSapling]
A sequence ofOutput descriptions, encoded per §7.4
‘Output Description Encoding and Consensus’ on
p.134.
2..4 Varies nJoinSplit compactSize The number ofJoinSplit descriptionsin vJoinSplit.
2..3 1802·
nJoinSplit
vJoinSplit JSDescriptionBCTV14
[nJoinSplit]
A sequence ofJoinSplit descriptionsusingBCTV14
proofs, encoded per §7.2
‘JoinSplit Description Encoding and Consensus’ on
p.133.
4 1698·
nJoinSplit
vJoinSplit JSDescriptionGroth16
[nJoinSplit]
A sequence ofJoinSplit descriptionsusingGroth16
proofs, encoded per §7.2
‘JoinSplit Description Encoding and Consensus’ on
p.133.
2..4† 32 joinSplitPubKey byte[32] An encoding of aJoinSplitSigpublicvalidating key.
2..4† 64 joinSplitSig byte[64] A signature on a prefix of thetransactionencoding,
validated using joinSplitPubKey as specified in §4.11
‘Non-malleability (Sprout)’ on p.54.
4‡ 64 bindingSigSapling byte[64] ASapling binding signatureon theSIGHASH transaction
hash, validated as specified in §5.4.7.2
‘Binding Signature (Sapling and Orchard)’ on p.98.
* Version constraints apply to the effectiveVersion, which is equal to min(2, version) when fOverwintered = 0 and
to version otherwise. If effectiveVersion≥5 once header has been parsed, the remainder of thetransaction
encodingMUSTbe parsed according to the v5 format described in the next table. The consensus rules later in
this section specify constraints on nVersionGroupId depending oneffectiveVersion.
† The joinSplitPubKey and joinSplitSig fields are present if and only if effectiveVersion≥2 and nJoinSplit >0 .
‡ bindingSigSapling is present if and only ifeffectiveVersion= 4and nSpendsSapling + nOutputsSapling >0.
125
Note that the valueBalanceSapling field is always present for thesetransaction versions.
Several Saplingfields have been renamed from previous versions of this specification:
valueBalance→ valueBalanceSapling; nShieldedSpend→ nSpendsSapling; vShieldedSpend→ vSpendsSapling;
nShieldedOutput→ nOutputsSapling; vShieldedOutput→ vOutputsSapling; bindingSig→ bindingSigSapling.
TheZcashtransactionformat fortransaction version5 is as follows (this should be read in the context of consensus
rules later in the section):
126
Note Bytes Name Data Type Description
4 header uint32 Contains:
· fOverwintered flag (bit31, always set)
· version (bits30..0) –transaction version.
4 nVersionGroupId uint32 Version group ID (nonzero).
4 nConsensusBranchId uint32 Consensus branch ID.
4 lock_time uint32 Unix-epoch UTC time orblock height, encoded as in
Bitcoin.
4 nExpiryHeight uint32 Ablock heightafter which thetransactionwill expire, or
0to disable expiry. [ZIP-203]
Varies tx_in_count compactSize Number oftransparent inputs.
Varies tx_in tx_in Transparentinputs, encoded as inBitcoin.
Varies tx_out_count compactSize Number oftransparent outputs.
Varies tx_out tx_out Transparentoutputs, encoded as inBitcoin.
Varies nSpendsSapling compactSize The number ofSpend descriptionsin vSpendsSapling.
96·
nSpendsSapling
vSpendsSapling SpendDescriptionV5Onward
[nSpendsSapling]
A sequence ofSpend descriptions, encoded per §7.3
‘Spend Description Encoding and Consensus’ on p.133.
Varies nOutputsSapling compactSize The number ofOutput descriptionsin vOutputsSapling.
756·
nOutputsSapling
vOutputsSapling OutputDescriptionV5Onward
[nOutputsSapling]
A sequence ofOutput descriptions, encoded per §7.4
‘Output Description Encoding and Consensus’ on
p.134.
† 8 valueBalanceSapling int64 The net value ofSapling-poolspends minus outputs.
‡ 32 anchorSapling byte[32] Arootof the Sapling-pool note commitment treeat some
block heightin the past,LEBS2OSP 256
(︀
rtSaplingPool)︀.
192·
nSpendsSapling
vSpendProofsSapling byte[192]
[nSpendsSapling]
Encodings of thezk-SNARK proofsfor eachSapling-pool
Spend description.
64·
nSpendsSapling
vSpendAuthSigsSapling byte[64]
[nSpendsSapling]
Authorizing signatures for eachSapling-poolSpend
description.
192·
nOutputsSapling
vOutputProofsSapling byte[192]
[nOutputsSapling]
Encodings of thezk-SNARK proofsfor eachSapling-pool
Output description.
† 64 bindingSigSapling byte[64] ASapling binding signatureon theSIGHASH transaction
hash, validated per §5.4.7.2
‘Binding Signature (Sapling and Orchard)’ on p.98.
Varies nActionsOrchard compactSize The number ofAction descriptionsin vActionsOrchard.
820·
nActionsOrchard
vActionsOrchard ActionDescription
[nActionsOrchard]
A sequence ofAction descriptions, encoded per §7.5
‘Action Description Encoding and Consensus’ on p.135.
S 1 flagsOrchard byte Contains:
· enableSpendsOrchard flag (bit0)
· enableOutputsOrchard flag (bit1)
·Reserved, zeros (bits2..7).
S 8 valueBalanceOrchard int64 The net value ofOrchard-poolspends minus outputs.
S 32 anchorOrchard byte[32] Arootof the Orchard-pool note commitment treeat some
block heightin the past,LEBS2OSP 256
(︀
rtOrchardPool)︀.
S Varies sizeProofsOrchard compactSize The length of the aggregatedzk-SNARK proof𝜋 OrchardPoolZKAction .
Value is2720 + 2272· nActionsOrchard.
S sizeProofsOrchard proofsOrchard byte[sizeProofsOrchard] The aggregatedzk-SNARK proof𝜋 OrchardPoolZKAction (see §5.4.10.3
‘Halo 2’ on p.115).
64·
nActionsOrchard
vSpendAuthSigsOrchard byte[64]
[nActionsOrchard]
Authorizing signatures for each spend of anOrchard-pool
Action description.
S 64 bindingSigOrchard byte[64] AnOrchard binding signatureon theSIGHASH
transaction hash, validated per §5.4.7.2
‘Binding Signature (Sapling and Orchard)’ on p.98.
Varies nActionsIronwood compactSize The number ofAction descriptionsin vActionsIronwood.
820·
nActionsIronwood
vActionsIronwood ActionDescription
[nActionsIronwood]
A sequence ofAction descriptions, encoded per §7.5
‘Action Description Encoding and Consensus’ on p.135.
S 1 flagsIronwood byte Contains:
· enableSpendsIronwood flag (bit0)
· enableOutputsIronwood flag (bit1)
·Reserved, zeros (bits2..7).
S 8 valueBalanceIronwood int64 The net value ofIronwood-poolspends minus outputs.
S 32 anchorIronwood byte[32] Arootof theIronwood-poolnote commitment treeat
someblock heightin the past, LEBS2OSP256
(︀
rtIronwoodPool)︀.
S Varies sizeProofsIronwood compactSize The length of the aggregatedzk-SNARK proof 𝜋IronwoodPoolZKAction .
Value is2720 + 2272· nActionsIronwood.
S sizeProofsIronwood proofsIronwood byte[sizeProofsIronwood] The aggregatedzk-SNARK proof 𝜋IronwoodPoolZKAction (see §5.4.10.3
‘Halo 2’ on p.115).
64·
nActionsIronwood
vSpendAuthSigsIronwood byte[64]
[nActionsIronwood]
Authorizing signatures for each spend of an Ironwood-pool
Action description.
S 64 bindingSigIronwood byte[64] AnIronwood binding signatureon theSIGHASH
transaction hash, validated per §5.4.7.2
‘Binding Signature (Sapling and Orchard)’ on p.98.
127
† The fields valueBalanceSapling and bindingSigSapling are present if and only if nSpendsSapling + nOutputsSapling >0 . If
valueBalanceSapling is not present, thenv SaplingPoolBalance is defined to be0.
‡The field anchorSapling is present if and only if nSpendsSapling >0.
S The fields flagsOrchard, valueBalanceOrchard, anchorOrchard, sizeProofsOrchard, proofsOrchard, and bindingSigOrchard are
present if and only if nActionsOrchard >0. If valueBalanceOrchard is not present, thenv OrchardPoolBalance is defined to be0.
Transaction version5 does not supportJoinSplit transfers. Several fields are reordered and/or renamed relative to prior versions.
7.1.1 Transaction Identifiers #txnidentifiers
Thetransaction IDof a version 4 or earliertransactionis the SHA-256d hash of thetransactionencoding in the
pre-v5 format described above.
Thetransaction IDof a version 5transactionis as defined in [ZIP-244].
A version 5transactionalso has awtxid(used for example in thepeer-to-peer protocol) as defined in [ZIP-239].
7.1.2 Transaction Consensus Rules #txnconsensus
Consensus rules:
•Thetransaction version numberMUSTbe greater than or equal to1.
•[Pre-Overwinter] The fOverwintered flagMUST NOTbe set.
•[Overwinteronward] The fOverwintered flagMUSTbe set.
•[Overwinteronward] Theversion group IDMUSTbe recognized.
• [Overwinteronly, pre- Sapling] Thetransaction version numberMUSTbe 3, and theversion group IDMUST
be 0x03C48270.
•[ SaplingtoCanopyinclusive, pre- NU5] Thetransaction version numberMUSTbe4.
•[ NU5onward] Thetransaction version numberMUSTbe4or5.
•[ Saplingonward] If thetransaction version numberis4then theversion group IDMUSTbe 0x892F2085.
•[ NU5onward] If thetransaction version numberis5then theversion group IDMUSTbe 0x26A7270A.
• [ NU5 onward] If effectiveVersion≥5 , the nConsensusBranchId fieldMUSTmatch theconsensus branch ID
used forSIGHASH transaction hashes, as specified in [ZIP-244].
•[Pre- Sapling] The encoded size of thetransactionMUSTbe less than or equal to100000bytes.
• [ NU5 onward] nSpendsSapling, nOutputsSapling, and (if effectiveVersion≥5 ) nActionsOrchard MUSTall be
less than2 16.
• [Pre- Sapling] If effectiveVersion= 1 or nJoinSplit = 0, then both tx_in_count and tx_out_count MUSTbe
nonzero.
• [ Sapling onward] If effectiveVersion<5 , then at least one of tx_in_count, nSpendsSapling, and nJoinSplit
MUSTbe nonzero.
• [ Sapling onward] If effectiveVersion<5 , then at least one of tx_out_count, nOutputsSapling, and nJoinSplit
MUSTbe nonzero.
• [ NU5 onward] If effectiveVersion= 5 then this conditionMUSThold: tx_in_count >0 or nSpendsSapling >0
or( nActionsOrchard >0and enableSpendsOrchard = 1).
• [ NU5 onward] If effectiveVersion= 5 then this conditionMUSThold: tx_out_count >0 or nOutputsSapling >0
or( nActionsOrchard >0and enableOutputsOrchard = 1).
• [ NU5 onward] If effectiveVersion≥5 and nActionsOrchard >0 , then at least one of enableSpendsOrchard and
enableOutputsOrchard MUSTbe1.
128
• [Pre- NU6.2] Fromblock height 3363426 (Mainnet) or 4048500 (Testnet) onward, until the activation of NU6.2 on
eachnetwork, if effectiveVersion≥5 then thetransactionMUST NOTcontain any OrchardAction descriptions,
i.e. nActionsOrchard = 0.
• Atransactionwith one or moretransparent inputsfromcoinbase transactionsMUSThave notransparent
outputs(i.e. tx_out_count MUSTbe 0). Inputs fromcoinbase transactionsincludeFounders’ Rewardoutputs
andfunding streamoutputs.
•IfeffectiveVersion≥2and nJoinSplit >0, then:
– joinSplitPubKey MUSTbe a valid encoding (see §5.4.6 ‘Ed25519’ on p.93) of anEd25519validating key.
– joinSplitSig MUSTrepresent a valid signature under joinSplitPubKey of dataToBeSigned, as defined
in §4.11 ‘Non-malleability (Sprout)’ on p.54.
•[ Saplingonward] IfeffectiveVersion≥4and nSpendsSapling + nOutputsSapling >0, then:
–letbvk Sapling andSigHashbe as defined in §4.13 ‘Balance and Binding Signature (Sapling)’ on p.55;
– bindingSigSapling MUSTrepresent a valid signature under thetransaction binding validating key
bvkSapling of SigHash — i.e. BindingSigSapling.ValidatebvkSapling(SigHash, bindingSigSapling) = 1. [ NU5 onward]
As specified in §5.4.7 ‘RedDSA,RedJubjub, andRedPallas’ on p. 95, the validation of the 𝑅 component
of the signature changes to prohibitnon-canonicalencodings. This change is also retrospectively valid
onMainnetandTestnetbefore NU5.
• [ Sapling onward] If effectiveVersion= 4 and there are noSpend descriptionsorOutput descriptions, then
valueBalanceSapling MUSTbe0. 14
•[ NU5onward] IfeffectiveVersion≥5and nActionsOrchard >0, then:
–letbvk Orchard andSigHashbe as defined in §4.14 ‘Balance and Binding Signature (Orchard)’ on p.57;
– bindingSigOrchard MUSTrepresent a valid signature under thetransaction binding validating key
bvkOrchard of SigHash — i.e. BindingSigOrchard.ValidatebvkOrchard(SigHash, bindingSigOrchard) = 1. As specified
in §5.4.7 ‘RedDSA,RedJubjub, andRedPallas’ on p. 95, validation of the 𝑅 component of the signature
prohibitsnon-canonicalencodings.
• Let totalDeferredOutput and totalDeferredInput be as defined in §7.8 on p. 142. For theblockatblock height
height:
– define thetotal output valueof itscoinbase transactionto be the total value inzatoshiof itstransparent
outputs, minusv SaplingPoolBalance, minusv OrchardPoolBalance, plustotalDeferredOutput(height);
– define thetotal input valueof itscoinbase transactionto be the value inzatoshiof theblock subsidy,
plus thetransaction feespaid bytransactionsin theblock, plustotalDeferredInput(height).
[Pre- NU6] Thetotal output valueof acoinbase transactionMUST NOTbe greater than itstotal input value.
[ NU6onward] Thetotal output valueof acoinbase transactionMUSTbe equal to itstotal input value.
•Acoinbase transactionMUST NOThave anyJoinSplit descriptions.
•Acoinbase transactionMUST NOThave anySpend descriptions.
•[Pre-Heartwood] Acoinbase transactionMUST NOThave anyOutput descriptions.
•[ NU5onward] In a version 5coinbase transaction, the enableSpendsOrchard flagMUSTbe0.
• [ NU5 onward] In a version 5transaction, the reserved bits 2..7 of the flagsOrchard fieldMUSTbe zero.
{TODO: Is bit 2 reserved after NU6.3?}
• Acoinbase transactionfor ablockatblock heightgreater than 0 MUSThave a script that, as its first item,
encodes theblock height height as follows. For height in the range{1..16} , the encoding is a single byte of
14Prior to zcashd v6.12.1, zcashd misimplemented the rule that requires valueBalanceSapling = 0 for a v4transactionwith noSpend
descriptionsand noOutput descriptions. It incorrectly normalized the value to 0 when noSpend descriptionsorOutput descriptions
were present, with the consequence that the failure case for this rule was never reached. For clarification, valueBalanceSapling refers to
the value as encoded in thetransaction, which is not normalized in this way; it does not refer tov
SaplingPoolBalance
.
129
value 0x50 +height . Otherwise, let heightBytes be the signedlittle-endianrepresentation of height, using the
minimum nonzero number of bytes such that the most significant byte is < 0x80. The length of heightBytes
MUSTbe in the range{1..5} . Then the encoding is the length of heightBytes encoded as one byte, followed
by heightBytes itself. This matches the encoding used byBitcoinin the implementation of [BIP-34] (but the
description here is to be considered normative).
•Acoinbase transactionscriptMUSThave length in{2..100}bytes.
•Atransparent inputin a non-coinbasetransactionMUST NOThave a nullprevout.
• Every non-nullprevoutMUSTpoint to a uniqueUTXOin either a precedingblock, or a previous transaction
in the sameblock.
• AtransactionMUST NOTspend atransparent outputof acoinbase transactionfrom ablockless than 100
blocksprior to the spend. Note thattransparent outputsofcoinbase transactionsincludeFounders’ Reward
outputs,transparent funding streamoutputs [ZIP-207], andlockbox disbursementoutputs [ZIP-271].
• AtransactionMUST NOTspend an output of thegenesis block coinbase transaction. (There is one such
zero-valued output, on each ofTestnetandMainnet.)
•[OverwintertoCanopyinclusive, pre- NU5] nExpiryHeight MUSTbe less than or equal to499999999.
•[ NU5onward] nExpiryHeight MUSTbe less than or equal to499999999for non-coinbasetransactions.
• [Overwinteronward] If atransactionis not acoinbase transactionand its nExpiryHeight field is nonzero,
then itMUST NOTbe mined at ablock heightgreater than its nExpiryHeight.
•[ NU5onward] The nExpiryHeight field of acoinbase transactionMUSTbe equal to itsblock height.
• [ Sapling onward] valueBalanceSapling, if it exists,MUSTbe in the range {−MAX_MONEY..MAX_MONEY} .
•[ NU5onward] valueBalanceOrchard, if it exists,MUSTbe in the range{−MAX_MONEY..MAX_MONEY}.
• [Heartwoodonward] All Sapling pool and Orchard pool outputs incoinbase transactionsMUSTdecrypt to a
note plaintext, i.e. §4.20.3 ‘Decryption using an Outgoing Viewing Key (Sapling and Orchard)’ on p. 73 does
not return⊥, using a sequence of 32 zero bytes as theoutgoing viewing key. (This implies that beforeCanopy
activation, Sapling-pool outputs of acoinbase transactionMUSThavenote plaintext lead byteequal to 0x01.)
• [Canopyonward] Any Sapling-pool or Orchard-pool output of acoinbase transactiondecrypted to anote
plaintextaccording to the preceding ruleMUSThavenote plaintext lead byteequal to 0x02. (This applies
even during the “grace period” specified in [ZIP-212].)
•{TODO: Other rules inherited fromBitcoin.}
The types specified in §7.1 ‘Transaction Encoding and Consensus’ on p.125 are part of the consensus rules.
Consensus rules associated with eachJoinSplit description( §7.2 ‘JoinSplit Description Encoding and Consensus’
on p. 133), eachSpend description( §7.3 ‘Spend Description Encoding and Consensus’ on p. 133), eachOutput
description( §7.4 ‘Output Description Encoding and Consensus’ on p. 134), and eachAction description( §7.5
‘Action Description Encoding and Consensus’ on p.135)MUSTalso be followed.
Notes:
• Previous versions of this specification defined what is now the header field as a signed int32 field which was
required to be positive. The consensus rule that the fOverwintered flagMUST NOTbe set beforeOverwinter
has activated, has the same effect.
•The semantics oftransactionswithversion numbernot any of{1,2,3,4,5}is not currently defined.
• The exclusion oftransactionswithtransaction version number greater than 2 is not a consensus rule before
Overwinteractivation. Suchtransactionsmay exist in theblock chainandMUSTbe treated identically to
version 2transactions.
• [Overwinteronward] OnceOverwinterhas activated, limits on the maximumtransaction version number
are consensus rules.
130
• Thetransaction version number 0x7FFFFFFF, and theversion group ID 0xFFFFFFFF, are reserved for use in
experimental extensions totransactionformat or semantics on private testnets. TheyMUST NOTbe used on
theZcashMainnetorTestnet.
• Note that a future upgrade might use any transaction version numberorversion group ID. It is likely that an
upgrade that changes thetransaction version numberorversion group IDwill also change thetransaction
format, and software that parsestransactionsSHOULDtake this into account.
• [Overwinteronward] The purpose ofversion group IDis to allow unambiguous parsing of “loose”transactions,
independent of the context of ablock chain. Code that parsestransactionsis likely to be reused between
consensus branchesas defined in [ZIP-200], and in that case the fOverwintered and version fields alone may
be insufficient to determine the format to be used for parsing.
• Atransaction version numberof 2 does not have the same meaning as inBitcoin, where it is associated with
support for OP_CHECKSEQUENCEVERIFY as specified in [BIP-68].Zcashwas forked from BitcoinCore v0.11.2 and
does not currently support BIP 68.
• [ Sapling onward] Becausecoinbase transactionshave noSpend descriptions, the valueBalanceSapling field
of acoinbase transactionmust have a negative or zero value. The negative case can only occur afterHeartwood
activation, fortransactionswith [ZIP-213]shielded outputs.
• Prior to theHeartwoodnetwork upgrade, it was not possible forcoinbase transactionsto haveshielded
outputs, and therefore the “coinbase maturity” rule and the requirement to spend coinbase outputs only in
transactionswith notransparent outputs, applied to all coinbase outputs.
• [Canopyonward] The rule that Sapling-pool outputs incoinbase transactionsMUSTdecrypt to anote plaintext
with lead byte 0x02, also applies tofunding streamoutputs that specify Saplingshielded payment addresses, if
there are any.
• [ NU5 onward] The flags in flagsOrchard allow a version 5transactionto declare that no funds are spent from
Orchard-pool notes(by setting enableSpendsOrchard to 0), or that no new Orchard-pool noteswith nonzero
values are프로젝트로 돌아가기