bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 35쪽 중 20쪽
created (by setting enableOutputsOrchard to0). This has two primary purposes. First, the value of
the enableSpendsOrchard flag is required to be 0 in version 5coinbase transactionsto ensure that they cannot
spend from existing Orchard-pool outputs. This maintains a restriction present incoinbase transactions
for Transparent-pool, Sprout-pool, or Sapling-pool funds, which would not otherwise be enforceable in the
combinedAction transferdesign. Second, if a security vulnerability were found that affected only the input
side, or only the output side of theAction circuit, it would be possible to use these flags in a soft fork (i.e.
a strictly contracting consensus change) to effectively “switch off” non-zero-valued transfers only on the
relevant side. Setting either of these flags to0 does not affect the presence or validation ofspend authorization
signatures, or other consensus rules associated withAction descriptions. Thesenotespending and creation
consensus rules are specified as part of the OrchardAction statement( §4.18.4 ‘Action Statement (Orchard)’
on p.66).
• [ NU5 onward] Because enableSpendsOrchard is set to 0 in version 5coinbase transactions–which disables
non-zero-valued Orchard-pool spends– the valueBalanceOrchard field of acoinbase transactionmust have a
negative or zero value. The negative case can only occur fortransactionswith [ZIP-213]shielded outputs.
• [ NU5 onward] The rule that nSpendsSapling, nOutputsSapling, and nActionsOrchard MUSTall be less than
216, is technically redundant because atransactionthat could violate this rule would not fit within the 2 MB
blocksize limit. It is included in order to simplify the security argument for balance preservation.
• [ NU5 onward] The rule that from NU5 activation, the nExpiryHeight field of acoinbase transactionMUST be
equal to theblock height, is needed to maintain the property that alltransactionshave uniquetransaction
IDs. All non-coinbasetransactionsnecessarily have some effecting data that is unique across alltransactions
in avalid block chain: either a tx_in referring to a previous unique tx_out, or aSpend descriptionorAction
descriptionreferring to a uniquenullifier. However,coinbase transactionsdo not necessarily have any such
unique effecting data; theblock heightencoded in the coinbase script is unique in avalid block chain, but for
v5transactions, it is not included in thetransaction IDhash specified by [ZIP-244]. Requiring nExpiryHeight
to be set to theblock heightensures that the effecting data that contributes to thetransaction IDis unique,
131
even for v5coinbase transactions. In order to avoid theblock heightbeing limited to 499999999, we also
remove that bound on nExpiryHeight forcoinbase transactions. For consistency, these changes apply to all
coinbase transactions, not just v5coinbase transactions.
The changes relative toBitcoinversion 1transactionsas described in [Bitcoin-Format] are:
•Transaction version0 is not supported.
•A version 1transactionis equivalent to a version 2transactionwith nJoinSplit = 0.
•The fields nJoinSplit, vJoinSplit, joinSplitPubKey, and joinSplitSig have been added.
•[Overwinteronward] The field nVersionGroupId has been added.
• [ Sapling onward] The following fields have been added: nSpendsSapling, vSpendsSapling, nOutputsSapling,
vOutputsSapling, and bindingSigSapling.
• [ NU5 onward] In version 5transactions, these fields have been added: nConsensusBranchId, nActionsOrchard,
vActionsOrchard, flagsOrchard, valueBalanceOrchard, anchorOrchard, sizeProofsOrchard, proofsOrchard,
bindingSigOrchard, and vSpendAuthSigsOrchard.
• [ NU5 onward] In version 6transactions, these fields have been added: nActionsIronwood, vActionsIronwood,
flagsIronwood, valueBalanceIronwood, anchorIronwood, sizeProofsIronwood, proofsIronwood, bindingSigIronwood,
and vSpendAuthSigsIronwood.
• InZcashit is permitted for atransactionto have notransparent inputs, provided that there could beshielded
inputs.
• A consensus rule limitingtransactionsize has been added. InBitcointhere is a corresponding standard rule
but no consensus rule.
132
7.2 JoinSplit Description Encoding and Consensus #joinsplitencodingandconsensus
An abstractJoinSplit description, as described in §3.5 ‘JoinSplit Transfers and Descriptions’ on p. 20, is encoded
in atransactionas an instance of a JoinSplitDescription type:
Bytes Name Data Type Description
8 vpub_old uint64 A value voldpub that theJoinSplit transferremoves from the
transparent transaction value pool.
8 vpub_new uint64 A valuev newpub that theJoinSplit transferinserts into the
transparent transaction value pool.
32 anchor byte[32] Arootrt SproutPool of theSprout-poolnote commitment
treeat someblock heightin the past, or theroot
produced by a previousJoinSplit transferin this
transaction.
64 nullifiers byte[32][Nold] A sequence ofnullifiersof the inputnotesnf old1..Nold.
64 commitments byte[32][Nnew] A sequence ofnote commitmentsfor the outputnotes
cmnew1..Nnew.
32 ephemeralKey byte[32] ACurve25519public keyepk.
32 randomSeed byte[32] A256-bit seed that must be chosen independently at
random for eachJoinSplit description.
64 vmacs byte[32][Nold] A sequence of message authentication tagsh 1..Nold
bindingh Sig to eacha sk of theJoinSplit description,
computed as described in §4.11
‘Non-malleability (Sprout)’ on p.54.
296† zkproof byte[296] An encoding of thezk-SNARK proof𝜋 ZKJoinSplit (see
§5.4.10.1 ‘BCTV14’ on p.113).
192‡ zkproof byte[192] An encoding of thezk-SNARK proof𝜋 ZKJoinSplit (see
§5.4.10.2 ‘Groth16’ on p.114).
1202 encCiphertexts byte[601][Nnew] A sequence of ciphertext components for the
encrypted outputnotes,C enc1..Nnew.
†BCTV14proofs are used when thetransaction versionis2or3, i.e. before Saplingactivation.
‡Groth16proofs are used when thetransaction versionis≥4, i.e. after Saplingactivation.
The ephemeralKey and encCiphertexts fields together form thetransmitted notes ciphertext, which is computed
as described in §4.19 ‘In-band secret distribution (Sprout)’ on p.68.
Consensus rules applying to aJoinSplit descriptionare given in §4.3 ‘JoinSplit Descriptions’ on p.41.
7.3 Spend Description Encoding and Consensus #spendencodingandconsensus
LetLEBS2OSPbe as defined in §5.1 ‘Integers, Bit Sequences, and Endianness’ on p.76.
Letrepr J and𝑞 J be as defined in §5.4.9.3 ‘Jubjub’ on p.105.
Let spendAuthSig be thespend authorization signaturefor thisSpend transfer, and let 𝜋ZKSpend be thezk-SNARK
proofof the correspondingSpend statement. In a version 4transactionthese are encoded in the spendAuthSig
field and zkproof field respectively of theSpend description. In a version 5transaction,spend authorization
signaturesin vSpendAuthSigsSapling and proofs in vSpendProofsSapling are in one-to-one correspondence with
Spend descriptionsin vSpendsSapling.
133
An abstractSpend description, as described in §3.6 ‘Spend Transfers, Output Transfers, and their Descriptions’
on p.21, is encoded in atransactionas an instance of a SpendDescriptionV4 or SpendDescriptionV5Onward type:
Bytes Name Data Type Description
32 cv byte[32] Avalue commitmentto the value of the inputnote,
LEBS2OSP256
(︀
reprJ(cv)
)︀
.
32† anchor byte[32] Arootof theSapling-poolnote commitment treeat someblock
heightin the past,LEBS2OSP 256
(︀
rtSaplingPool)︀.
32 nullifier byte[32] Thenullifierof the inputnote,nf.
32 rk byte[32] The randomizedvalidating keyforspendAuthSig,
LEBS2OSP256
(︀
reprJ(rk)
)︀
.
192† zkproof byte[192] An encoding of thezk-SNARK proof𝜋 ZKSpend (see §5.4.10.2
‘Groth16’ on p.114).
64† spendAuthSig byte[64] A signature authorizing this Spend.
† The anchor, zkproof, and spendAuthSig fields are only present in aSpend descriptionif thetransaction version
is 4. For version 5transactions, allSpend descriptionsshare the sameanchor, which is encoded once as the
anchorSapling field of thetransactionas described in §7.1 ‘Transaction Encoding and Consensus’ on p. 125. The
zkproof and spendAuthSig fields have been moved into vSpendProofsSapling and vSpendAuthSigsSapling respec-
tively for v5.
Consensus rule:LEOS2IP 256(anchorSapling), if present,MUSTbe less than𝑞 J.
Other consensus rules applying to aSpend descriptionare given in §4.4 ‘Spend Descriptions’ on p.42.
7.4 Output Description Encoding and Consensus #outputencodingandconsensus
LetLEBS2OSPbe as defined in §5.1 ‘Integers, Bit Sequences, and Endianness’ on p.76.
Let reprJ and 𝑞J be as in §5.4.9.3 ‘Jubjub’ on p. 105, and ExtractJ(𝑟) as in §5.4.9.4 ‘Coordinate Extractor for Jubjub’ on
p.107.
Let 𝜋ZKOutput be thezk-SNARK proofof theOutput statementfor thisOutput statement. In a version 4transaction
this is encoded in thezkproof field of theSpend description. In a version 5transaction, proofs invOutputProofsSapling
are in one-to-one correspondence withOutput descriptionsin vOutputsSapling.
An abstractOutput description, described in §3.6 ‘Spend Transfers, Output Transfers, and their Descriptions’
on p. 21, is encoded in atransactionas an instance of an OutputDescriptionV4 or OutputDescriptionV5Onward type:
Bytes Name Data Type Description
32 cv byte[32] Avalue commitmentto the value of the outputnote,
LEBS2OSP256
(︀
reprJ(cv)
)︀
.
32 cmu byte[32] The 𝑢-coordinate of thenote commitmentfor the outputnote,
LEBS2OSP256(cm𝑢)wherecm 𝑢 =Extract J(𝑟)(cm).
32 ephemeralKey byte[32] An encoding of an ephemeralJubjubpublic key,
LEBS2OSP256
(︀
reprJ(epk)
)︀
.
580 encCiphertext byte[580] A ciphertext component for the encrypted outputnote,C enc.
80 outCiphertext byte[80] A ciphertext component that allows the holder of theoutgoing
cipher keyto recover thediversified transmission keypk d and
ephemeral private keyesk, hence the entirenote plaintext.
192† zkproof byte[192] An encoding of thezk-SNARK proof𝜋 ZKOutput (see §5.4.10.2
‘Groth16’ on p.114).
† The zkproof field is only present in aSpend descriptionif thetransaction versionis 4. This field has been moved
into the vOutputProofsSapling field of version 5transactions.
134
The ephemeralKey, encCiphertext, and outCiphertext fields together form thetransmitted note ciphertext, which
is computed as described in §4.20 ‘In-band secret distribution (Sapling and Orchard)’ on p.70.
Consensus rule:LEOS2IP 256(cmu)MUSTbe less than𝑞 J.
Other consensus rules applying to anOutput descriptionare given in §4.5 ‘Output Descriptions’ on p.43.
7.5 Action Description Encoding and Consensus #actionencodingandconsensus
LetLEBS2OSPbe as defined in §5.1 ‘Integers, Bit Sequences, and Endianness’ on p.76.
Letrepr P and𝑞 P be as defined in §5.4.9.6 ‘Pallas and Vesta’ on p.108.
Let spendAuthSig be thespend authorization signaturefor thisAction transferfrom vSpendAuthSigsOrchard, and
let 𝜋OrchardPoolZKAction be thezk-SNARK proofof the correspondingAction statement.Spend authorization signaturesin
the vSpendAuthSigsOrchard field of a version 5transactionand aggregated proofs in the proofsOrchard field are in
one-to-one correspondence withAction descriptionsin vActionsOrchard.
An abstractAction description, as described in §3.7 ‘Action Transfers and their Descriptions’ on p. 22, is encoded
in atransactionas an instance of an ActionDescription type:
Bytes Name Data Type Description
32 cv byte[32] Avalue commitmentto the net value of the inputnoteminus
the outputnote,LEBS2OSP 256
(︀
reprP(cv)
)︀
.
32 nullifier byte[32] Thenullifierof the inputnote,nf.
32 rk byte[32] The randomizedvalidating keyforspendAuthSig,
LEBS2OSP256
(︀
reprP(rk)
)︀
.
32 cmx byte[32] The 𝑥-coordinate of thenote commitmentfor the outputnote,
LEBS2OSP256(cm𝑥)wherecm 𝑥 =Extract P(cm).
32 ephemeralKey byte[32] An encoding of an ephemeralPallaspublic key,
LEBS2OSP256
(︀
reprP(epk)
)︀
.
580 encCiphertext byte[580] A ciphertext component for the encrypted outputnote,C enc.
80 outCiphertext byte[80] A ciphertext component that allows the holder of theoutgoing
cipher key(which can be derived from afull viewing key) to
recover the recipientdiversified transmission keypk d and the
ephemeral private keyesk, hence the entirenote plaintext.
The ephemeralKey, encCiphertext, and outCiphertext fields together form thetransmitted note ciphertext, which
is computed as described in §4.20 ‘In-band secret distribution (Sapling and Orchard)’ on p.70.
Consensus rules:
•LEOS2IP 256(cmx)MUSTbe less than𝑞 P.
• [ NU6.2 onward] The proofsOrchard fieldMUSThave the canonical length of 2720 + 2272· nActionsOrchard
bytes.
Other consensus rules applying to anAction descriptionare given in §4.6 ‘Action Descriptions’ on p.44.
135
Non-normative notes:
• Before NU6.2, the length of the proofsOrchard field was not enforced as a consensus rule. The canonical
length is determined by the circuit, and is the same for the pre- NU6.2 and post- NU6.2 circuits. See §5.4.10.3
‘Encoding of Halo 2 Proofs’ on p.115, where aHalo 2proof is encoded as the proof byte sequence itself.
• An OrchardAction descriptionwith ephemeralKey encoding the zero point, or any other 32-byte string that
does not encode a validPallas curvepoint, was accepted by zcashd but rejected byzebra as required by §4.6
‘Action Descriptions’ on p. 44, a potential consensus split. zcashd now requires ephemeralKey to decode to a
valid non-zeroPallas curvepoint. This was partially fixed in zcashd v6.12.1 (rejecting the zeroPallas curve
point encoding), and extended to all invalid encodings in zcashd v6.12.2.
136
7.6 Block Header Encoding and Consensus #blockheader
TheZcashblock headerformat is as follows (this should be read in the context of consensus rules later in the
section):
Bytes Name Data Type Description
4 nVersion int32 Theblock version numberindicates which set of
blockvalidation rules to follow. The current and
only definedblock version numberforZcashis4.
32 hashPrevBlock byte[32] ASHA-256dhash in internal byte order of the
previousblock’sheader. This ensures no previous
blockcan be changed without also changing this
block’sheader.
32 hashMerkleRoot byte[32] A SHA-256d hash in internal byte order. The merkle
root is derived from the hashes of alltransactions
included in thisblock, ensuring that none of those
transactionscan be modified without modifying
theheader.
32 hashReserved /
hashFinalSaplingRoot /
hashLightClientRoot /
hashBlockCommitments
byte[32] [Pre- Sapling] A reserved field, to be ignored.
[ SaplingandBlossomonly, pre-Heartwood] The
rootLEBS2OSP 256
(︀
rtSaplingPool)︀ of theSapling pool
note commitment treecorresponding to the final
Sapling-pooltreestateof thisblock.
[HeartwoodandCanopyonly, pre- NU5] The
hashChainHistoryRoot of thisblock[ZIP-221].
[ NU5onward] The hashBlockCommitments of this
block[ZIP-244].
4 nTime uint32 Theblock timestampis a Unix epoch time (UTC)
when the miner started hashing theheader
(according to the miner).
4 nBits uint32 An encoded version of thetarget thresholdthis
block’sheaderhash must be less than or equal to,
in the same nBits format used byBitcoin.
[Bitcoin-nBits]
32 nNonce byte[32] An arbitrary field that miners can change to modify
theheaderhash in order to produce a hash less
than or equal to thetarget threshold.
3 solutionSize compactSize The size of anEquihashsolution in bytes (always
1344).
1344 solution byte[1344] TheEquihashsolution.
Ablockconsists of ablock headerand a sequence oftransactions. How transactions are encoded in ablockis part
of the Zcashpeer-to-peer protocolbut not part of the consensus protocol.
Let ThresholdBits be as defined in §7.7.3 ‘Difficulty adjustment’ on p. 140, and let PoWMedianBlockSpan be the
constant defined in §5.3 ‘Constants’ on p.77.
Define themedian-time-pastof ablockto be the median (as defined in §7.7.3 ‘Difficulty adjustment’ on p. 140)
of the nTime fields of the preceding PoWMedianBlockSpan blocks(or all precedingblocksif there are fewer than
PoWMedianBlockSpan). Themedian-time-pastof agenesis blockis not defined.
137
Consensus rules:
•Theblock version numberMUSTbe greater than or equal to4.
•For ablockatblock heightheight, nBits MUSTbe equal toThresholdBits(height).
•TheblockMUSTpass the difficulty filter defined in §7.7.2 ‘Difficulty filter’ on p.140.
• solution MUSTrepresent avalid Equihash solutionas defined in §7.7.1 ‘Equihash’ on p.139.
• For eachblockother than thegenesis block, nTime MUSTbe strictly greater than themedian-time-pastof
thatblock.
• For eachblockatblock height 2 or greater onMainnet, orblock height 653606 or greater onTestnet, nTime
MUSTbe less than or equal to themedian-time-pastof thatblockplus90·60seconds.
•The size of ablockMUSTbe less than or equal to2000000bytes.
• [ Sapling andBlossomonly, pre-Heartwood] hashLightClientRoot MUSTbe LEBS2OSP256
(︀
rtSaplingPool)︀ where
rtSaplingPool is therootof the Sapling-pool note commitment treefor the final Sapling-pool treestateof theblock.
• [HeartwoodandCanopyonly, pre- NU5] hashLightClientRoot MUSTbe set to the hashChainHistoryRoot
for theblock, as specified in [ZIP-221].
• [ NU5 onward] hashBlockCommitments MUSTbe set to the value of hashBlockCommitments for theblock, as
specified in [ZIP-244].
•AblockMUSThave at least onetransaction.
• The firsttransactionin ablockMUSTbe acoinbase transaction, and subsequenttransactionsMUST NOTbe
coinbase transactions.
•{TODO: Other rules inherited fromBitcoin.}
In addition, afull validatorMUST NOTacceptblockswith nTime more than two hours in the future according to its
clock. This is not strictly a consensus rule because it is nondeterministic, and clock time varies between nodes.
Also note that ablockthat is rejected by this rule at a given point in time may later be accepted.
Notes:
• The semantics of blocks withblock version numbernot equal to 4 is not currently defined. MinersMUST
NOTcreate suchblocks.
• The exclusion ofblockswithblock version number greater than 4 is not a consensus rule; suchblocksmay
exist in theblock chainandMUSTbe treated identically to version 4blocksbyfull validators. Note that a
future upgrade might useblock version numbereither greater than or less than 4. It is likely that such an
upgrade will change theblockheader and/ortransactionformat, and software that parsesblocksSHOULD
take this into account.
• The nVersion field is a signed integer. (It was specified as unsigned in a previous version of this specification.)
A future upgrade might use negative values for this field, or otherwise change its interpretation.
• There is no relation between the values of the version field of atransaction, and the nVersion field of ablock
header.
• Like other serialized fields of type compactSize, the solutionSize fieldMUSTbe encoded with the minimum
number of bytes (3 in this case), and other encodingsMUSTbe rejected. This is necessary to avoid a potential
attack in which a miner could test several distinct encodings of eachEquihashsolution against the difficulty
filter, rather than only the single intended encoding.
• As inBitcoin, the nTime fieldMUSTrepresent a time strictly greater than the median of the timestamps
of the past PoWMedianBlockSpan blocks. The Bitcoin Developer Reference [Bitcoin-Block] was previously in
error on this point, but has now been corrected.
• The rule limiting nTime to be no later than 90·60 seconds after themedian-time-pastis a retrospective
consensus change, applied as a soft fork in zcashd v2.1.1-1. It had not been violated by anyblockfrom the
givenblock heightsin the consensusblock chainsof eitherMainnetorTestnet.
•There are no changes to theblock version numberor format forOverwinter.
138
• Although theblock version numberdoes not change for Sapling, the previously reserved (and ignored) field
hashReserved has been repurposed for hashFinalSaplingRoot. There are no other format changes.
•There are no changes to theblock version numberor format forBlossom.
• ForHeartwood, the hashFinalSaplingRoot field is renamed to hashLightClientRoot. OnceHeartwoodacti-
vates, the meaning of this field changes according to [ZIP-221].
•There are no changes to theblock version numberor format forCanopy.
• For NU5, the hashLightClientRoot field is renamed to hashBlockCommitments. Once NU5 activates, the
meaning of this field changes according to [ZIP-244].프로젝트로 돌아가기