Zcash 백서

Zcash

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 35쪽 중 22쪽

ibed wayto the address represented by that recipient identifier; • [ NU6.1 onward] if theblock heightis ZIP271ActivationHeight, ZIP271DisbursementChunks equal outputs paying a total of ZIP271DisbursementAmount zatoshiin theprescribed wayto the Key-Holder Organizations’ P2SH multisig address represented byZIP271DisbursementAddress, as specified by [ZIP-271]. The term “prescribed way” is defined as follows: • Theprescribed wayto pay atransparent P2SH addressis to use astandard P2SH scriptof the form OP_HASH160 fs.RedeemScriptHash(height) OP_EQUAL as the scriptPubKey. Here fs.RedeemScriptHash(height) is thestandard redeem scripthash for the recipient address forfs.Recipient(height)inBase58Checkform. Standard redeem scripthashes are defined in [ZIP-48] forP2SH multisig addresses, or [Bitcoin-P2SH] for otherP2SH addresses. • Theprescribed wayto pay a Saplingor Orchardpayment addressis defined in [ZIP-213], using the post- Heartwoodconsensus rules specified for the Sapling-pool and Orchard-pool shielded outputsofcoinbase transactionsin §7.1.2 ‘Transaction Consensus Rules’ on p.128. Notes: • Thefunding streamaddresses are not treated specially in any other way, and there can be other outputs to them, incoinbase transactionsor otherwise. In particular, it is valid for acoinbase transactionto have other outputs, possibly to the same address, that do not meet the criterion in the above consensus rule, as long as there is at least the given number of distinct outputs that meet it, disjointly for each funding item. • For clarification, if there are multiple activefunding streamsorlockbox disbursementswith the same recipient identifier and/or value, thereMUSTbe at least the given number of distinct outputs for each of them. • Up to and including NU6.1 there have been nofunding streamsorlockbox disbursementsdefined with a shielded payment addressas a recipient. That might change in future, so implementations are encouraged to support Saplingand Orchardshielded payment addressesas recipients, as permitted by [ZIP-213] and [ZIP-207]. 7.10.1 ZIP 214 Funding Streams #zip214fundingstreams LetCanopyActivationHeightbe as defined in §5.3 ‘Constants’ on p.77. [ZIP-214] Revision 0 defines thesefunding streamsforMainnet: 146 Stream Numerator Denominator Start height End height FS_ZIP214_BP 7 100 1046400 2726400 FS_ZIP214_ZF 5 100 1046400 2726400 FS_ZIP214_MG 8 100 1046400 2726400 It also defines thesefunding streamsforTestnet: Stream Numerator Denominator Start height End height FS_ZIP214_BP 7 100 1028500 2796000 FS_ZIP214_ZF 5 100 1028500 2796000 FS_ZIP214_MG 8 100 1028500 2796000 Notes: • Theblock heightsofhalvingsare different betweenTestnetandMainnet, as a result of differentactivation block heightsfor theBlossomnetwork upgrade(which changed theblock target spacing). The end height of thesefunding streamscorresponds to the secondhalvingon eachnetwork. • OnTestnet, theactivation block heightofCanopyis before the firsthalving. Therefore, the consequence of the above rules forTestnetis that the amount sent to eachZcashDevelopment Fund recipient address will initially (beforeTestnet block height 1116000) be double the number of currency units as the corresponding initial amount onMainnet. This reduces to the same number of currency units as onMainnet, fromTestnet block heights1116000(inclusive) to2796000(exclusive). [ NU6onward] [ZIP-214] Revision 1 defines thesefunding streamsforMainnet: Stream Numerator Denominator Start height End height FS_FPF_ZCG 8 100 2726400 3146400 FS_DEFERRED 12 100 2726400 3146400 It also defines thesefunding streamsforTestnet: Stream Numerator Denominator Start height End height FS_FPF_ZCG 8 100 2976000 3396000 FS_DEFERRED 12 100 2976000 3396000 Note:The new funding streams begin at the second halving for Mainnet, but the second halving on Testnet occurred prior to the introduction of the new funding streams. For both new funding streams on each network, the associated duration corresponds to approximately one year’s worth of blocks. [ NU6.1onward] [ZIP-214] Revision 2 defines thesefunding streamsforMainnet: Stream Numerator Denominator Start height End height FS_FPF_ZCG_H3 8 100 3146400 4406400 FS_CCF_H3 12 100 3146400 4406400 It also defines thesefunding streamsforTestnet: Stream Numerator Denominator Start height End height FS_FPF_ZCG_H3 8 100 3536500 4476000 FS_CCF_H3 12 100 3536500 4476000 147 7.11 Changes to the Script System #scripts The OP_CODESEPARATOR opcode has been disabled. This opcode also no longer affects the calculation ofSIGHASH transaction hashes. 7.12 Bitcoin Improvement Proposals #bips In general, Bitcoin Improvement Proposals (BIPs) do not apply toZcashunless otherwise specified in this section. All of the BIPs referenced below should be interpreted by replacing “BTC” , or “bitcoin” used as a currency unit, with “ZEC”; and “satoshi” with “zatoshi” . The following BIPs apply, otherwise unchanged, toZcash: [BIP-11], [BIP-14], [BIP-31], [BIP-35], [BIP-37], [BIP-61]. The following BIPs apply starting from theZcashgenesis block, i.e. any activation rules or exceptions for particular blocksin theBitcoinblock chainare to be ignored: [BIP-16], [BIP-30], [BIP-65], [BIP-66]. The effect of [BIP-34] has been incorporated into the consensus rules ( §7.1.2 ‘Transaction Consensus Rules’ on p. 128). This excludes theMainnetandTestnet genesis blocks, for which the “height in coinbase” was inadvertently omitted. [BIP-13] applies with the changes to address version bytes described in §5.6.1.1 ‘Transparent Addresses’ on p.116. [BIP-111] applies frompeer-to-peer protocolversion170004onward; that is: •references to protocol version70002are to be replaced by170003; •references to protocol version70011are to be replaced by170004; • the reference to protocol version 70000 is to be ignored (Zcashnodes have supported Bloom-filtered connec- tions since launch). 8 Differences from the Zerocash paper #differences 8.1 Transaction Structure #trstructure Zerocashintroduces two new operations, which are described in the paper as new transaction types, in addition to the original transaction type of the cryptocurrency on which it is based (e.g.Bitcoin). InZcash, there is only the originalBitcointransaction type, which is extended to contain a sequence of zero or moreZcash-specific operations. This allows for the possibility of chaining transfers ofshieldedvalue in a singleZcashtransaction, e.g. to spend a shielded notethat has just been created. (InZcash, we refer to value stored inUTXOsastransparent, and value stored in outputnotesofJoinSplit transfersorOutput transfers) asshielded.) This was not possible in theZerocash design without using multiple transactions. It also allowstransparentandshieldedtransfers to happen atomically — possibly under the control of nontrivial script conditions, at some cost in distinguishability. Computation ofSIGHASH transaction hashes, as described in §4.10 ‘SIGHASH Transaction Hashing’ on p. 53, was changed to clean up handling of an error case for SIGHASH_SINGLE, to remove the special treatment of OP_CODESEPARATOR, and to includeZcash-specific fields in the hash [ZIP-76]. 8.2 Memo Fields #memodiffs Zcashadds amemo fieldsent from the creator of aJoinSplit descriptionto the recipient of each outputnote. This feature is described in more detail in §3.2.1 ‘Note Plaintexts and Memo Fields’ on p.16. 148 8.3 Unification of Mints and Pours #mintsandpours In the originalZerocashprotocol, there were two kinds of transaction relating toshielded notes: • a “Mint” transaction takes value fromUTXOs (unspent transaction outputs)as input and produces a new shielded noteas output. • a “Pour” transaction takes up to Nold shielded notesas input, and produces up to Nnew shielded notesand a UTXOas output. Only “Pour” transactions included azk-SNARKproof. [Pre- Sapling] InZcash, the sequence of operations added to atransaction(see §8.1 ‘Transaction Structure’ on p. 148) consists only ofJoinSplit transfers. AJoinSplit transferis a Pour operation generalized to take aUTXOas input, allowingJoinSplit transfersto subsume the functionality of Mints. An advantage of this is that aZcashtransaction that takes input from aUTXOcan produce up to Nnew outputnotes, improving the indistinguishability properties of the protocol. A related change conceals the input arity of theJoinSplit transfer: an unused (zero-valued) input is indistinguishable from an input that takes value from anote. This unification also simplifies the fix to the Faerie Gold attack described below, since no special case is needed for Mints. [ Sapling onward] In Sapling, there are still no “Mint” transactions. Instead ofJoinSplit transfers, there areSpend transfersandOutput transfers. These make use ofPedersen value commitmentsto represent the shielded values that are transferred. Because these commitments are additively homomorphic, it is possible to check that allSpend transfersandOutput transfersbalance; see §4.13 ‘Balance and Binding Signature (Sapling)’ on p. 55 for detail. This reduces the granularity of the circuit, allowing a substantial performance improvement (orthogonal to other Saplingcircuit improvements) when the numbers ofshieldedinputs and outputs are significantly different. This comes at the cost of revealing the exact number ofshieldedinputs and outputs, butdummy(zero-valued) outputs are still possible. 8.4 Faerie Gold attack and fix #faeriegold When ashielded noteis created inZerocash, the creator is supposed to choose a new ρ value at random. The nullifierof thenoteis derived from itsspending key( ask) and ρ. Thenote commitmentis derived from the recipient address component apk, the value v, and thecommitment trapdoor rcm, as well as ρ. However nothing prevents creating multiplenoteswith differentvandrcm(hence differentnote commitments) but the sameρ. An adversary can use this to mislead anoterecipient, by sending twonotesboth of which are verified as valid by Receive(as defined in [BCGGMTV2014, Figure 2]), but only one of which can be spent. We call this a “Faerie Gold” attack — referring to various Celtic legends in which faeries pay mortals in what appears to be gold, but which soon after reveals itself to be leaves, gorse blossoms, gingerbread cakes, or other less valuable things [LG2004]. This attack does not violate the security definitions given in [BCGGMTV2014]. The issue could be framed as a problem either with the definition of Completeness, or the definition of Balance: • The Completeness property asserts that a validly receivednotecan be spent provided that itsnullifierdoes not appear on the ledger. This does not take into account the possibility that distinctnotes, which are validly received, could have the samenullifier. That is, the security definition depends on a protocol detail –nullifiers– that is not part of the intended abstract security property, and that could be implemented incorrectly. • The Balance property only asserts that an adversary cannot obtain more funds than they have minted or received via payments. It does not prevent an adversary from causing others’ funds to decrease. In a Faerie Gold attack, an adversary can cause spending of anoteto reduce (to zero) the effective value of anothernote for which the adversary does not know thespending key, which violates an intuitive conception of global balance. 149 These problems with the security definitions need to be repaired; how to do so is discussed in[Hopwood2022], but that is outside the scope of this specification. Here we only describe howZcashaddresses the immediate attack. It would be possible to address the attack by requiring that a recipient remember all of theρ values for allnotesthey have ever received, and reject duplicates (as proposed in [GGM2016]). However, this requirement would interfere with the intendedZcashfeature that a holder of aspending keycan recover access to (and be sure that they are able to spend) all of their funds, even if they have forgotten everything but thespending key. [ Sprout] Instead,Zcashenforces that an adversary must choose distinct values for each ρ, by making use of the fact that all of thenullifiersinJoinSplit descriptionsthat appear in avalid block chainmust be distinct. This is true regardless of whether thenullifierscorresponded to real ordummy notes(see §4.8.1 ‘Dummy Notes (Sprout)’ on p. 49). Thenullifiersare used as input to hSigCRH to derive a public value hSig which uniquely identifies the transaction, as described in §4.3 ‘JoinSplit Descriptions’ on p. 41. (hSig was already used inZerocashin a way that requires it to be unique in order to maintain indistinguishability ofJoinSplit descriptions; adding thenullifiers to the input of the hash used to calculate it has the effect of making this uniqueness property robust even if the transactioncreator is an adversary.) [ Sprout] The ρ value for each outputnoteis then derived from a random private seed φ and hSig using PRFρφ. The correct construction of ρ for each outputnoteis enforced by §4.18.1 ‘JoinSplit Statement (Sprout)’ on p. 63 in the JoinSplit statement. [ Sprout] Now even if the creator of aJoinSplit descriptiondoes not choose φ randomly, uniqueness ofnullifiers andcollision resistanceof both hSigCRH and PRFρ will ensure that the derived ρ values are unique, at least for any twoJoinSplit descriptionsthat get into avalid block chain. This is sufficient to prevent the Faerie Gold attack. A variation on the attack attempts to cause thenullifierof a sentnoteto be repeated, without repeating ρ. However, since thenullifieris computed as PRFnfSproutask (ρ) or PRFnfSaplingnk (ρ⋆) (for Orchard, see below); this is only possible if the adversary finds a collision across both inputs on PRFnfSprout or PRFnfSapling, which is assumed to be infeasible — see §4.1.2 ‘Pseudo Random Functions’ on p.26. [ Sprout] Crucially, “nullifierintegrity” is enforced whether or not the enforceMerklePath𝑖 flag is set for an input note( §4.18.1 ‘JoinSplit Statement (Sprout)’ on p. 63). If this were not the case then an adversary could perform the attack by creating a zero-valuednotewith a repeatednullifier, since thenullifierwould not depend on the value. [ Sprout]Nullifierintegrity also prevents a “roadblock attack” in which the adversary sees a victim’stransaction, and is able to publish anothertransactionthat is mined first and blocks the victim’stransaction. This attack would be possible if the public value(s) used to enforce uniqueness of ρ could be chosen arbitrarily by thetransaction creator: the victim’stransaction, rather than the adversary’s, would be considered to be repeating these values. In the chosen solution that usesnullifiersfor these public values, they are enforced to be dependent onspending keyscontrolled by the originaltransactioncreator (whether or not each inputnoteis adummy), and so a roadblock attack cannot be performed by another party who does not know these keys. [ Sapling onward] In Sapling, uniqueness of ρ is ensured by making it dependent on the position of thenote commitmentin the Sapling pool note commitment tree. Specifically, ρ=cm+[pos]𝒥 Sapling, where𝒥 Sapling is a generator independent of the generators used in NoteCommitSapling. Therefore, ρ commits uniquely to thenoteand its position, and this commitment iscollision-resistantby the same argument used to provecollision resistanceof Pedersen hashes. Note that it is possible for two distinctSapling-pool positioned notes(having different ρ values and nullifiers, but differentnote positions) to have the samenote commitment, but this causes no security problem. Roadblock attacks are not possible because a givennote positiondoes not repeat for outputs of differenttrans- actionsin the sameblock chain. Note that this depends on the fact that the value is bound by thenote commitment: it could be the case that the adversary uses adummy notethat is not required to have anote commitmentin the note commitment treewhen it is spent. If this happens and the victim’snoteis not adummy, thenote commitments will differ and so will thenullifiers. If bothnotesare dummies, the adversary cannot know the inputs to thenote commitmentsince they are generated at random for the victim’s spend, regardless of the adversary’s potential knowledge of viewing keys. [ NU5 onward] In Orchard, thenullifieris computed using a construction that combines elliptic curve cryptography and the Poseidon-based PRFnfOrchard in a way that, for privacy, aims to provide defence in depth against potential weaknesses in either (see [Zcash-Orchard, Section 3.5 Nullifiers] and §4.16 ‘Computingρvalues and Nullifiers’ on p.60). 150 Resistance to Faerie Gold attacks, on the other hand, depends entirely on hardness of theDiscrete Logarithm Problem. The ρ value of anotecreated in a givenAction transferis obtained from thenullifierof thenotespent in thatAction transfer; this ensures (without any cryptographic assumption) that all ρ values ofnotesadded to thenote commitment treeare unique. Then, thenullifierderivation can be considered as computing a vector Pedersen commitment on input that includes ρ, so that thebindingproperty of thatcommitment schemeensures that Orchard-pool nullifierswill be unique. (Specifically, this is a Sinsemilla commitment with an additional term having base𝒦 Orchard, truncated to its𝑥-coordinate. The𝑥-coordinate truncation cannot harmcollision resistance because, assuming hardness of theDiscrete Logarithm Problemon thePallas curve, §5.4.1.9 ‘Security argument’ on p. 85 covers the case where the additional term is added.) Roadblock attacks are not possible because ρ does not repeat fornotesin thenote commitment tree, and by a corresponding argument to Saplingfordummy notes. 8.5 Internal hash collision attack and fix #internalh TheZerocashsecurity proof requires that the composition of COMMrcm and COMMs is a computationallybinding commitment to its inputs apk, v, and ρ. However, the instantiation of COMMrcm and COMMs in section 5.1 of the paper did not meet the definition of abindingcommitment at a 128-bit security level. Specifically, the internal hash of apk and ρ is truncated to 128 bits (motivated by providing statisticalhidingsecurity). This allows an attacker, with a work factor on the order of 264, to find distinct pairs (apk,ρ) and (apk′,ρ′) with colliding outputs of the truncated hash, and therefore the samenote commitment. This would have allowed such an attacker to break the Balance property bydouble-spending notes, potentially creating arbitrary amounts of currency for themself [HW2016]. Zcashuses a simpler construction with a single hash evaluation for the commitment: SHA-256 for Sprout-pool notes, PedersenHashToPoint for Sapling-pool notes, and SinsemillaHashToPoint for Orchard-pool notes. The motivation for the nested construction inZerocashwas to allow Mint transactions to be publically verified without requiring zk-SNARK proofs( [BCGGMTV2014, section 1.3, under step 3]). SinceZcashcombines “Mint” and “Pour” transactions into generalizedJoinSplit transfers(for Sprout), orSpend transfersandOutput transfers(for Sapling), orAction transfers(for Orchard), and each transfer always uses azk-SNARK proof,Zcashdoes not require the nesting. A side benefit is that this reduces the cost of computing thenote commitments: for Sproutit reduces the number of SHA256Compress evaluations needed to compute eachnote commitmentfrom three to two, saving a total of four SHA256Compressevaluations in theJoinSplit statement. [ Sprout]Note:The full SHA-256 algorithm is used for NoteCommitSprout, with randomness appended after the commitment input. The commitment input can be split into two blocks, call them 𝑥 of length 64 bytes, and 𝑦 of the remaining length (9 bytes). Let COMM′𝑟(𝑧 BY Y[41]) be thecommitment schemethat applies SHA256Compress with the first 32 bytes of 𝑧 in the IV, and the rest of 𝑧 (9 bytes), the randomness 𝑟 (32 bytes), and padding up to 64 bytes in the SHA256Compress input block. Then we have NoteCommitSprout𝑟 (𝑥||𝑦) =C
프로젝트로 돌아가기