Zcash 백서

Zcash

원문

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

g of aCurve25519private key[Bernstein2006]. skenc MUSTbe “clamped” using KASprout.FormatPrivate as specified in §4.2.1 ‘Sprout Key Components’ on p. 38. That is, a decodedincoming viewing keyMUSTbe considered invalid ifsk enc̸=KA Sprout.FormatPrivate(skenc). KASprout.FormatPrivateis defined in §5.4.5.1 ‘Sprout Key Agreement’ on p.91. Note:For addresses onMainnet, the lead bytes and encoded length cause the first four characters of the Base58Checkencoding to be fixed as“ ZiVK”. ForTestnet, the first four characters are fixed as“ ZiVt”. 5.6.2.3SproutSpending Keys #sproutspendingkeyencoding A Sproutspending keyconsists of ask, which is a sequence of 252 bits (see §4.2.1 ‘Sprout Key Components’ on p. 38). Theraw encodingof a Sproutspending keyconsists of: 8-bit 0xAB 8-bit 0x36 [0]4 252-bita sk • Two bytes [0xAB, 0x36], indicating this version of theraw encodingof aZcashspending keyonMainnet. (Addresses onTestnetuse[ 0xAC, 0x08]instead.) •32bytes:4zero padding bits and252bits specifyinga sk. The zero padding occupies the most significant4bits of the third byte. Notes: • If an implementation represents ask internally as a sequence of 32 bytes with the 4 bits of zero padding intact, it will be in the correct form for use as an input toPRFaddr, PRFnfSprout, and PRFpk without need for bit-shifting. • For addresses onMainnet, the lead bytes and encoded length cause the first two characters of theBase58Check encoding to be fixed as“ SK”. ForTestnet, the first two characters are fixed as“ ST”. 118 5.6.3SaplingEncodings #saplingencodings 5.6.3.1SaplingPayment Addresses #saplingpaymentaddrencoding LetKA Sapling be as defined in §5.4.5.3 ‘Sapling Key Agreement’ on p.92. Letℓ d be as defined in §5.3 ‘Constants’ on p.77. LetJ (𝑟),abst J, andrepr J be as defined in §5.4.9.3 ‘Jubjub’ on p.105. Let LEBS2OSP (ℓ N)×B [ℓ]→B Y Y[ceiling(ℓ/8)] be as defined in §5.1 ‘Integers, Bit Sequences, and Endianness’ on p.76. A Saplingshielded payment addressconsists ofd B[ℓd] andpk d KASapling.PublicPrimeOrder. pkd is an encoding of a KASapling public keyof type KASapling.PublicPrimeOrder, for use with the encryption scheme defined in §4.20 ‘In-band secret distribution (Sapling and Orchard)’ on p. 70. d is adiversifier. These components are derived as described in §4.2.2 ‘Sapling Key Components’ on p.38. Theraw encodingof a Saplingshielded payment addressconsists of: LEBS2OSP88(d) LEBS2OSP256 (︀ reprJ(pkd) )︀ •11bytes specifyingd. •32bytes specifying thectEdwards compressed encodingofpk d (see §5.4.9.3 ‘Jubjub’ on p.105). When decoding the representation ofpkd, the addressMUSTbe considered invalid if abstJ returns⊥, or the encoding of pkd is anon-canonicalencoding as defined in §4.1.9 ‘Represented Group’ on p. 34, or the resulting pkd is not in J(𝑟)*. Non-normative notes: •There are nonon-canonicalencodings ofJubjub curvepoints inJ (𝑟)*. • The restriction onpkd reflects its current typeKASapling.PublicPrimeOrder=J (𝑟)*. In versions of this specification prior to v2025.6.0, pkd had type KASapling.PublicPrimeSubgroup=J (𝑟), i.e. including𝒪J. Implementations of consumers for this encoding may need to be updated to exclude𝒪J, and should be checked for consistency with the current version of [ZIP-216]. For addresses onMainnet, theHuman-Readable Part(as defined in [ZIP-173]) is“ zs”. For addresses onTestnet, the Human-Readable Partis“ ztestsapling”. 5.6.3.2SaplingIncoming Viewing Keys #saplinginviewingkeyencoding LetKA Sapling be as defined in §5.4.5.3 ‘Sapling Key Agreement’ on p.92. Letℓ Saplingivk be as defined in §5.3 ‘Constants’ on p.77. A Saplingincoming viewing keyconsists ofivk {1..2 ℓSaplingivk −1}. ivk is a KASapling.Private key (restricted to ℓSaplingivk bits), derived as described in §4.2.2 ‘Sapling Key Components’ on p. 38. It is used with the encryption scheme defined in §4.20 ‘In-band secret distribution (Sapling and Orchard)’ on p.70. 119 Theraw encodingof a Saplingincoming viewing keyconsists of: 256-bitivk •32bytes (little-endian) specifyingivk, padded with zeros in the most significant bits. ivk MUSTbe in the range{1..2 ℓSaplingivk −1} as specified in §4.2.2 ‘Sapling Key Components’ on p. 38. That is, a decoded incoming viewing keyMUSTbe considered invalid ifivkis not in this range. Forincoming viewing keysonMainnet, theHuman-Readable Partis“ zivks”. Forincoming viewing keysonTestnet, theHuman-Readable Partis“ zivktestsapling”. Non-normative notes: • Thediversifier keyis not present in this encoding, so it does not provide sufficient information to decrypt the diversifierto obtain adiversifier index. This encoding is therefore deprecated: the preferred way to encode a Saplingincoming viewing keyis as a component of aunified incoming viewing keyusing theIVK Encoding specified in [ZIP-316], which does include thediversifier key. • In versions of this specification prior to v2025.6.0, the range of ivk was defined as{0..2 ℓSaplingivk −1}, i.e. including 0. Implementations of consumers for this encoding may need to be updated to exclude0. 5.6.3.3SaplingFull Viewing Keys #saplingfullviewingkeyencoding LetKA Sapling be as defined in §5.4.5.3 ‘Sapling Key Agreement’ on p.92. A Saplingfull viewing keyconsists ofak J(𝑟)*,nk J(𝑟), andovk BY Y[ℓovk/8]. ak and nk are points on theJubjub curve(see §5.4.9.3 ‘Jubjub’ on p. 105). They are derived as described in §4.2.2 ‘Sapling Key Components’ on p.38. Theraw encodingof a Saplingfull viewing keyconsists of: LEBS2OSP256 (︀ reprJ(ak) )︀ LEBS2OSP256 (︀ reprJ(nk) )︀ 32-byteovk •32bytes specifying thectEdwards compressed encodingofak(see §5.4.9.3 ‘Jubjub’ on p.105). •32bytes specifying thectEdwards compressed encodingofnk. •32bytes specifying theoutgoing viewing keyovk. When decoding this representation, the keyMUSTbe considered invalid if abstJ returns⊥ for either ak or nk, or if ak/∈J(𝑟)*, or ifnk/∈J (𝑟). Forfull viewing keysonMainnet, theHuman-Readable Partis“ zviews”. Forfull viewing keysonTestnet, the Human-Readable Partis“ zviewtestsapling”. 5.6.3.4SaplingSpending Keys #saplingspendingkeyencoding A Saplingspending keyconsists ofsk B[ℓsk] (see §4.2.2 ‘Sapling Key Components’ on p.38). Theraw encodingof a Saplingspending keyconsists of: LEBS2OSP256(sk) •32bytes specifyingsk. Forspending keysonMainnet, theHuman-Readable Partis“ secret-spending-key-main”. Forspending keyson Testnet, theHuman-Readable Partis“ secret-spending-key-test”. 120 5.6.4 Unified andOrchardEncodings #orchardencodings 5.6.4.1 Unified Payment Addresses and Viewing Keys #unifiedencodings Rather than defining aBech32string encoding of Orchardshielded payment addresses, we instead define, in [ZIP-316], aunified payment addressformat that is able to encode a set ofpayment addressesof different types. This enables the consumer of an address to choose the best address type it supports, providing a better user experience as new formats are added in the future. Similarly,unified incoming viewing keysandunified full viewing keysare defined to encode sets ofincoming viewing keysandfull viewing keysrespectively. Since [ZIP-316] includes a full specification of encoding, decoding, and other processing ofunified payment addresses,unified incoming viewing keys, andunified full viewing keys, we give only a summary here. Aunified payment addressincludes zero or one address of each type in the following Priority List: •typecode 0x03 – §5.6.4.2 ‘Orchard Raw Payment Addresses’ on p.121; •typecode 0x02 – §5.6.3.1 ‘Sapling Payment Addresses’ on p.119; •typecode 0x01 –transparent P2SH address, or typecode 0x00 –transparent P2PKH address. with the restrictions that thereMUSTbe at least oneshielded payment address(typecodes ≥ 0x02), and that both P2SHandP2PKHcannot be present. When sending a payment, the consumer of aunified payment addressMUSTuse the most preferred address type that it supports from the set, i.e. the first in the above list. See [ZIP-316] for additional requirements, and for discussion ofunified incoming viewing keysandunified full viewing keys. Note that there is intentionally no typecode defined for a Sproutshielded payment address(or Sproutviewing keys). Since it is no longer possible (since activation of [ZIP-211] in theCanopynetwork upgrade) to send funds into the Sprout pool, this would not be generally useful. The format usesBech32m [BIP-350] (ignoring any length restrictions) for the checksum algorithm and string encoding. This is chosen overBech32in order for the checksum to better handle variable-length inputs. A “jumbling” algorithm is used in order to mitigate address replacement attacks given that a user might only check part of the address. See [ZIP-316] for full details. 5.6.4.2OrchardRaw Payment Addresses #orchardpaymentaddrencoding LetKA Orchard be as defined in §5.4.5.5 ‘Orchard Key Agreement’ on p.93. An Orchardshielded payment addressconsists ofd B[ℓd] andpk d KAOrchard.PublicPrimeOrder. pkd is an encoding of aKA Orchard public keyof typeKA Orchard.PublicPrimeOrder, for use with the encryption scheme defined in §4.20 ‘In-band secret distribution (Sapling and Orchard)’ on p. 70. d is a sequence of 11 bytes. These components are derived as described in §4.2.3 ‘Orchard Key Components’ on p.40. Theraw encodingof an Orchardshielded payment addressconsists of: LEBS2OSP88(d) LEBS2OSP256 (︀ reprP(pkd) )︀ •11bytes specifyingd. •32 bytes specifying theshort Weierstrass compressed encodingof pkd (see §5.4.9.6 ‘Pallas and Vesta’ on p. 108). When decoding the representation ofpk d, the addressMUSTbe considered invalid ifabst P returns⊥or𝒪 P. There is noBech32[m]encoding defined for an individual Orchardshielded payment address; instead use aunified payment addressas defined in [ZIP-316]. 121 5.6.4.3OrchardRaw Incoming Viewing Keys #orchardinviewingkeyencoding LetKA Orchard be as defined in §5.4.5.5 ‘Orchard Key Agreement’ on p.93. An Orchardincoming viewing keyconsists of adiversifier key dk, and a KAOrchard.Private key ivk restricted to the range {1.. 𝑞P−1} . It is derived as described in §4.2.3 ‘Orchard Key Components’ on p. 40, and is used with the encryption scheme defined in §4.20 ‘In-band secret distribution (Sapling and Orchard)’ on p.70. LetI2LEOSPbe as defined in §5.1 ‘Integers, Bit Sequences, and Endianness’ on p.76. Theraw encodingof an Orchardincoming viewing keyconsists of: dk I2LEOSP256(ivk) •32bytes specifyingdk. •32bytes (little-endian) specifyingivk. ivk MUSTbe in the range{1.. 𝑞P−1} as specified in §4.2.3 ‘Orchard Key Components’ on p. 40. That is, a decoded incoming viewing keyMUSTbe considered invalid ifivkis not in this range. There is noBech32[m]encoding defined for an individual Orchardincoming viewing key; instead use aunified incoming viewing keyas defined in [ZIP-316]. 5.6.4.4OrchardRaw Full Viewing Keys #orchardfullviewingkeyencoding LetKA Orchard be as defined in §5.4.5.5 ‘Orchard Key Agreement’ on p.93. LetExtract P be as defined in §5.4.9.7 ‘Coordinate Extractor for Pallas’ on p.109. An Orchardfull viewing keyconsists ofak {0.. 𝑞P−1},nk F𝑞P, andrivk F𝑟P. ak is theSpend validating key, a result of applyingExtractP to a point on thePallas curve(see §5.4.9.6 ‘Pallas and Vesta’ on p. 108). nk is thenullifier deriving key, a field element in F𝑞P. rivk is the Commitivk randomness, a field element in F𝑟P. They are derived as described in §4.2.3 ‘Orchard Key Components’ on p.40. LetI2LEOSPbe as defined in §5.1 ‘Integers, Bit Sequences, and Endianness’ on p.76. Theraw encodingof an Orchardfull viewing keyconsists of: I2LEOSP256(ak) I2LEOSP256(nk) I2LEOSP256(rivk) •32bytes (little-endian) specifyingak. •32bytes (little-endian) specifyingnk. •32bytes (little-endian) specifyingrivk. When decoding this representation, the keyMUSTbe considered invalid if ak, nk, or rivk are not canonically encoded elements of their respective fields, or if ak is not a valid affine 𝑥-coordinate of aPallas curvepoint in P*, or if either the external or internalincoming viewing keysderived as specified in §4.2.3 ‘Orchard Key Components’ on p. 40 are0or⊥. There is noBech32[m]encoding defined for an individual Orchardfull viewing key; instead use aunified full viewing keyas defined in [ZIP-316]. 5.6.4.5OrchardSpending Keys #orchardspendingkeyencoding An Orchardspending keyconsists ofsk B[ℓsk] (see §4.2.3 ‘Orchard Key Components’ on p.40). 122 Theraw encodingof an Orchardspending keyconsists of: LEBS2OSP256(sk) •32bytes specifyingsk. Orchardspending keysare encoded usingBech32m(notBech32). Forspending keysonMainnet, theHuman-Readable Partis“ secret-orchard-sk-main”. Forspending keyson Testnet, theHuman-Readable Partis“ secret-orchard-sk-test”. 5.7BCTV14zk-SNARK Parameters #bctvparameters The SHA-256 hashes of theproving keyandverifying keyfor the SproutJoinSplit circuit, encoded inlibsnarkformat, are: 8bc20a7f013b2b58970cddd2e7ea028975c88ae7ceb9259a5344a16bc2c0eef7 sprout-proving.key 4bd498dae0aacfd8e98dc306338d017d9c08dd0918ead18172bd0aec2fc5df82 sprout-verifying.key These parameters were obtained by amulti-party computationdescribed in [BGG-mpc] and [BGG2017]. They are used only before Sapling activation. Due to the security vulnerability described in §5.4.10.1 ‘BCTV14’ on p. 113, it is not recommended to use these parameters in new protocols, and it is recommended to stop using them in protocols other thanZcashwhere they are currently used. 5.8Groth16zk-SNARK Parameters #grothparameters bellman [Bowe-bellman] encodes theproving keyandverifying keyfor azk-SNARK circuitin a single parameters file. The BLAKE2b-512 hashes of this file for the SaplingSpend circuitandOutput circuit, and for the implementation of the SproutJoinSplit circuitused after Saplingactivation, are respectively: 8270785a1a0d0bc77196f000ee6d221c9c9894f55307bd9357c3f0105d31ca63 991ab91324160d8f53e2bbd3c2633a6eb8bdf5205d822e7f3f73edac51b2b70c sapling-spend.params 657e3d38dbb5cb5e7dd2970e8b03d69b4787dd907285b5a7f0790dcc8072f60b f593b32cc2d1c030e00ff5ae64bf84c5c3beb84ddc841d48264b4a171744d028 sapling-output.params e9b238411bd6c0ec4791e9d04245ec350c9c5744f5610dfcce4365d5ca49dfef d5054e371842b3f88fa1b9d7e8e075249b3ebabd167fa8b0f3161292d36c180a sprout-groth16.params These parameters were obtained by amulti-party computationdescribed in [BGM2017]. 5.9 Randomness Beacon #beacon LetURS:=“ 096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0”. This value is used in the definition of GroupHashJ(𝑟)* in §5.4.9.5 ‘Group Hash into Jubjub’ on p. 107, and in the multi-party computationto obtain the Saplingparameters given in §5.8 ‘Groth16 zk-SNARK Parameters’ on p. 123. It is derived as described in [Bowe2018]: • Take the hash of theBitcoinblockat height 514200 inRPC byte order, i.e. thebig-endian 32-byte representation of 0x00000000000000000034b33e842ac1c50456abe5fa92b60f6b3dfc5d247f7b58. •ApplySHA-2562 42 times. •Convert to aUS-ASCIIlowercase hexadecimal string. Note:URSis a64-byteUS-ASCIIstring, i.e. the first byte is 0x30, not 0x09. 123 6 Network Upgrades #networkupgrades Zcashlaunched with a protocol revision that we call Sprout. A first upgrade, calledOverwinter, activated onMainneton 26 June, 2018 atblock height 347500[Swihart2018] . Its specifications are described in this document, [ZIP-201], [ZIP-202], [ZIP-203], and [ZIP-143]. A second upgrade, called Sapling, activated onMainneton 28 October, 2018 atblock height 419200[Hamdon2018] . Its specifications are described in this document, [ZIP-205], and [ZIP-243]. A third upgrade, calledBlossom, activated onMainneton 11 December, 2019 atblock height 653600[Zcash-Blossom] . Its specifications are described in this document, [ZIP-206], and [ZIP-208]. A fourth upgrade, calledHeartwood, activated onMainneton 16 July, 2020 atblock height 903000[Zcash-Heartwd] . Its specifications are described in this document, [ZIP-250], [ZIP-213], and [ZIP-221]. A fifth upgrade, calledCanopy, activated onMainneton 18 November, 2020 atblock height 1046400 (coinciding with the firstblock subsidy halving) [Zcash-Canopy]. Its specifications are described in this document, [ZIP-251], [ZIP-207], [ZIP-211], [ZIP-212], [ZIP-214], and [ZIP-215]. Additional information and rationale is given in [ZIP-1014]. A sixth upgrade, called NU5, activated onMainneton 31 May, 2022 atblock height 1687104[Zcash-Nu5] . Its specifi- cations are described in this document, [ZIP-252], [ZIP-216], [ZIP-221], [ZIP-224], [ZIP-225], [ZIP-239], [ZIP-244], and [ZIP-316], with updates to [ZIP-32], [ZIP-203], [ZIP-209], [ZIP-212], [ZIP-213], and [ZIP-221]. Additional information and rationale is given in [Zcash-Orchard] and [Zcash-halo2]. A seventh upgrade, called NU6, activated onMainneton 23 November, 2024 atblock height 2726400 (coinciding with the secondblock subsidy halving) [Zcash-Nu6]. Its specifications are described in this document, [ZIP-253], [ZIP-236], and [ZIP-2001], with updates to [ZIP-207] and [ZIP-214]. Additional information and rationale is given in [ZIP-1015]. An eighth upgrade, called NU6.1, activated onMainneton 24 November, 2025 atblock height 3146400[Zcash-Nu6.1] . Its specifications are described in this document, [ZIP-255], and [ZIP-271], with updates to [ZIP-214]. Additional information and rationale is given in [ZIP-1016]. A ninth upgrade, called NU6.2, activated onMainneton 3 June, 2026 atblock height 3364600[Zcash-Nu6.2] [GHSA-zcashd]. It was necessary in order to re-enable the Orchard pool, after it had been temporarily disabled in order to mitigate a soundness vulnerability [GHSA-circuit] [ZIP-257]. Its specifications are described in this document and [ZIP-257]. This section summarizes the strategy for upgrading from the Sprout epoch to subsequent epochs of the protocol (Overwinter, Sapling,Blossom,Heartwood,Canopy, NU5, NU6, NU6.1, NU6.2, and NU6.3), and for future upgrades. Thenetwork upgrademechanism is described in [ZIP-200]. Eachnetwork upgradeis introduced as a “bilateral consensus rule change”. In this kind of upgrade, •there is anactivation block heightat which theconsensus rule changetakes effect; • blocksandtransactionsthat are valid according to the post-upgrade rules are not valid before the upgrade block height; • blocksandtransactionsthat are valid according to the pre-upgrade rules are no longer valid at or after the activation block height. Full support for eachnetwork upgradeis indicated by a minimum version of thepeer-to-peer protocol. At the plannedactivation block height, nodes that support a given upgrade will disconnect from (and will not reconnect to) nodes with a protocol version lower than this minimum. See [ZIP-201] for how this applies to theOverwinter upgrade, for example. This ensures that upgrade-supporting nodes transition cleanly from the old protocol to the new protocol. Nodes that do not support the upgrade will find themselves on a network that uses the old protocol and is fully partitioned from the upgrade-supporting network. This allows us to specify arbitrary protocol changes that take effect at a givenblock height. 124 Note, however, that ablock chain reorganizationacross the upgradeactivation block heightis possible. In the case of such a reorganization,blocksat a height before theactivation block heightwill still be created and validated according to the pre-upgrade rules, and upgrade-supporting nodesMUSTallow for this. 7 Consensus Changes from Bitcoin #consensusfrombitcoin 7.1 Transaction Encoding and Consensus #txnencoding TheZcashtransactionformat up to and includingtransaction version 4 is as follows (this should be read in the context of consensus rules later in the section): Version* Bytes Name Data Type Description 1..4 4 header uint32 Contains: · fOverwintered flag (bit31) · version (bits30..0) –transaction version. 3..4 4 nVersionGroupId uint32 Version group ID (nonzero). 1..4 Varies tx_in_count compactSize Number oftransparent inputs. 1..4 Varies tx_in tx_in Transparentinputs, encoded as inBitcoin. 1..4 Varies tx_out_count compactSize Number oftransparent outputs. 1..4 Varies tx_out tx_out Transparentoutputs, encoded as inBitcoin. 1..4 4 lock_time uint32 Unix-epoch UTC time orblock height,
프로젝트로 돌아가기