Zcash 백서

Zcash

원문

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

the non-Zcash-specific parts of thetransaction. InZcash, allSIGHASH typesare extended to cover theZcash-specific fields nJoinSplit, vJoinSplit, and if present joinSplitPubKey. These fields are described in §7.1 ‘Transaction Encoding and Consensus’ on p. 125. The hash does not cover the field joinSplitSig. AfterOverwinteractivation, allSIGHASH typesare also extended to cover transactionfields introduced in that upgrade, and similarly after Saplingactivation and after NU5activation. The originalSIGHASH algorithmdefined byBitcoinsuffered from some deficiencies as described in [ZIP-143]; in Zcashthese were addressed by changing this algorithm as part of theOverwinterupgrade. Orchardand the NU5 network upgradeintroducetransaction version5. If Orchard-pool Action transfersare present, version 5MUSTbe used. Transaction version5 also provide nonmalleabletransactionidentifiers, andMAYbe used for that reason whether or notAction transfersare present. Consensus rules: • [ NU5 onward] AnySIGHASH typeencoding used in a version 5transactionMUSTbe the canonical encoding of one of the definedSIGHASH types, i.e. one of 0x01, 0x02, 0x03, 0x81, 0x82, or 0x83. (In previoustransaction versions, undefined bits of aSIGHASH typeencoding were ignored.) • [Pre-Overwinter] TheSIGHASH algorithmused prior toOverwinteractivation, i.e. for version 1 and 2 transactions, will be defined in [ZIP-76] (to be written). • [Overwinteronly, pre- Sapling] TheSIGHASH algorithmused afterOverwinteractivation and before Sapling activation, i.e. for version 3transactions, is defined in [ZIP-143]. •[ Saplingonward] TheSIGHASH algorithmused for version 4transactionsis defined in [ZIP-243]. •[ NU5onward] TheSIGHASH algorithmused for version 5transactionsis defined in [ZIP-244]. • [Overwinteronly, pre- Sapling] AlltransactionsMUSTuse theOverwinterconsensus branch ID 0x5BA81B19 as defined in [ZIP-201]. • [ Sapling only, pre-Blossom] AlltransactionsMUSTuse the Sapling consensus branch ID 0x76B809BB as defined in [ZIP-205]. • [Blossomonly, pre-Heartwood] AlltransactionsMUSTuse theBlossomconsensus branch ID 0x2BB40E60 as defined in [ZIP-206]. 53 • [Heartwoodonly, pre-Canopy] AlltransactionsMUSTuse theHeartwoodconsensus branch ID 0xF5B9230B as defined in [ZIP-250]. • [Canopyonly, pre- NU5] AlltransactionsMUSTuse theCanopyconsensus branch ID 0xE9FF75A6 as defined in [ZIP-251]. • [ NU5 only, pre- NU6] AlltransactionsMUSTuse the NU5 consensus branch ID 0xF919A198 as defined in [ZIP-252]. • [ NU6 only, pre- NU6.1] AlltransactionsMUSTuse the NU6 consensus branch ID 0xC8E71055 as defined in [ZIP-253]. • [ NU6.1 only, pre- NU6.2] AlltransactionsMUSTuse the NU6.1 consensus branch ID 0x4DEC4DF0 as defined in [ZIP-255]. • [ NU6.2 only] AlltransactionsMUSTuse the NU6.2 consensus branch ID 0x5437F330 as defined in [ZIP-257]. 4.11 Non-malleability (Sprout) #sproutnonmalleability Let dataToBeSigned be the hash of thetransaction, not associated with an input, using the SIGHASH_ALL SIGHASH type. In order to ensure that aJoinSplit descriptionis cryptographically bound to thetransparentinputs and outputs corresponding to vnewpub and voldpub, and to the otherJoinSplit descriptionsin the sametransaction, an ephemeral JoinSplitSig key pair is generated for eachtransaction, and the dataToBeSigned is signed with the privatesigning key of this key pair. The corresponding publicvalidating keyis included in thetransactionencoding as joinSplitPubKey. JoinSplitSigis instantiated in §5.4.6 ‘Ed25519’ on p.93. If nJoinSplit is zero, the joinSplitPubKey and joinSplitSig fields are omitted. Otherwise, atransactionhas a correctJoinSplit signatureif and only ifJoinSplitSig.Validate joinSplitPubKey(dataToBeSigned,joinSplitSig) = 1. Leth Sig be computed as specified in §4.3 ‘JoinSplit Descriptions’ on p.41. LetPRF pk be as defined in §4.1.2 ‘Pseudo Random Functions’ on p.26. For each𝑖∈{1..N old}, the creator of aJoinSplit descriptioncalculatesh 𝑖 =PRF pkaoldsk,𝑖(𝑖,h Sig). The correctness of h1..Nold is enforced by theJoinSplit statementgiven in §4.18.1 ‘JoinSplit Statement (Sprout)’ on p. 63. This ensures that a holder of all of theaoldsk,1..Nold for everyJoinSplit descriptionin thetransactionhas authorized the use of the privatesigning keycorresponding to joinSplitPubKey to sign thistransaction. 4.12 Balance (Sprout) #joinsplitbalance InBitcoin, all inputs to and outputs from atransactionare transparent. The total value oftransparent outputsmust not exceed the total value oftransparent inputs. The net value oftransparent inputsminustransparent outputsis transferred to the miner of theblockcontaining thetransaction; it is added to theminer subsidyin thecoinbase transactionof theblock. Zcash Sproutextends this by addingJoinSplit transfers. EachJoinSplit transfercan be seen, from the perspective of thetransparent transaction value pool, as an input and an output simultaneously. voldpub takes value from thetransparent transaction value pooland vnewpub adds value to thetransparent transaction value pool. As a result,v oldpub is treated like an output value, whereasv newpub is treated like an input value. Unlike originalZerocash [BCGGMTV2014],Zcashdoes not have a distinction between Mint and Pour operations. The addition ofv oldpub to aJoinSplit descriptionsubsumes the functionality of both Mint and Pour. Also, a difference in the number of real inputnotesdoes not by itself cause twoJoinSplit descriptionsto be distinguishable. 54 As stated in §4.3 ‘JoinSplit Descriptions’ on p. 41, either voldpub or vnewpub MUSTbe zero. No generality is lost because, if atransactionin which both voldpub and vnewpub were nonzero were allowed, it could be replaced by an equivalent one in which min(voldpub,v newpub ) is subtracted from both of these values. This restriction helps to avoid unnecessary distinctions betweentransactionsaccording to client implementation. 4.13 Balance and Binding Signature (Sapling) #saplingbalance SaplingaddsSpend transfersandOutput transfersto the transparent andJoinSplit transferspresent in Sprout. The net value ofSpend transfersminusOutput transfersin atransactionis called theSapling-pool balancing value, measured inzatoshias a signed integerv SaplingPoolBalance. vSaplingPoolBalance is encoded in atransactionas the field valueBalanceSapling. For a v4transaction, vSaplingPoolBalance is always explicitly encoded. For v5, vSaplingPoolBalance is implicitly zero if thetransactionhas noSpend descriptionsor Output descriptions. Transaction fields are described in §7.1 ‘Transaction Encoding and Consensus’ on p.125. A positiveSapling-pool balancing value takes net value from theSapling chain value pooland adds it to thetransparent transaction value pool. A negativeSapling-pool balancing value does the reverse. As a result, positivevSaplingPoolBalance is treated like an input to thetransparent transaction value pool, whereas negative vSaplingPoolBalance is treated like an output from that pool. Consistency of vSaplingPoolBalance with thevalue commitmentsinSpend descriptionsandOutput descriptionsis enforced by theSapling binding signature. This signature has a dual rôle in the Saplingprotocol: • To prove that the total value spent bySpend transfers, minus that produced byOutput transfers, is consistent with thev SaplingPoolBalance field of thetransaction; • To prove that the signer knew the randomness used for the Spend and Outputvalue commitments, in order to preventOutput descriptionsfrom being replayed by an adversary in a differenttransaction. (ASpend descriptionalready cannot be replayed due to itsspend authorization signature.) Instead of generating a key pair at random, we generate it as a function of thevalue commitmentsin theSpend descriptionsandOutput descriptionsof thetransaction, and theSapling-pool balancing value. LetJ (𝑟),J (𝑟)*, and𝑟 J be as defined in §5.4.9.3 ‘Jubjub’ on p.105. §5.4.8.3 ‘Homomorphic Pedersen commitments (Sapling and Orchard)’ on p.99 instantiates: ValueCommitSapling ValueCommitSapling.Trapdoor× {︀− 𝑟J−12 .. 𝑟J−12 }︀→ValueCommit Sapling.Output; 𝒱Sapling J(𝑟)*, the value base inValueCommit Sapling; ℛSapling J(𝑟)*, the randomness base inValueCommit Sapling. BindingSigSapling, , and are instantiated in §5.4.7.2 ‘Binding Signature (Sapling and Orchard)’ on p.98. §4.1.7.2 ‘Signature with Signing Key to Validating Key Monomorphism’ on p. 32 specifies these operations and the derived notation , N 𝑖=1 , , and N 𝑖=1 , which in this section are to be interpreted as operating on the prime-order subgroupof points on theJubjub curveand on its scalar field. Suppose that thetransactionhas: •𝑛Spend descriptionswithvalue commitmentscv old1..𝑛, committing to valuesv old1..𝑛 with randomnessrcv old1..𝑛; •𝑚 Output descriptionswithvalue commitments cvnew1..𝑚, committing to values vnew1..𝑚 with randomness rcvnew1..𝑚; •Sapling-pool balancing valuev SaplingPoolBalance. In a correctly constructedtransaction, vSaplingPoolBalance = ∑︀𝑛𝑖=1vold𝑖 − ∑︀𝑚𝑗=1vnew𝑗 , but validators cannot check this directly because the values are hidden by the commitments. 55 Instead, validators calculate thetransaction binding validating keyas: bvkSapling := (︃ 𝑛 𝑖=1 cvold𝑖 )︃ (︃ 𝑚 𝑗=1 cvnew𝑗 )︃ ValueCommitSapling0 (︀vSaplingPoolBalance)︀. (This key is not encoded explicitly in thetransactionand must be recalculated.) The signer knowsrcv old1..𝑛 andrcv new1..𝑚, and so can calculate the correspondingsigning keyas: bskSapling := (︃ 𝑛 𝑖=1 rcvold𝑖 )︃ (︃ 𝑚 𝑗=1 rcvnew𝑗 )︃ . In order to check for implementation faults, the signerSHOULDalso check that bvkSapling =BindingSig Sapling.DerivePublic(bskSapling). AtransactioncontainingAction descriptionsis necessarily a version 4 or version 5transaction. Let SigHash be theSIGHASH transaction hashfor the appropriatetransaction version, not associated with an input, using the SIGHASH type SIGHASH_ALL. This is defined in [ZIP-243] for a version 4transaction, or in [ZIP-244] for a version 5 transaction. A validator checks balance by validating thatBindingSig Sapling.ValidatebvkSapling(SigHash, bindingSigSapling) = 1. We now explain why this works. ASapling binding signatureproves knowledge of thediscrete logarithm bskSapling of bvkSapling with respect toℛSapling. That is, bvkSapling =[bsk Sapling]ℛ Sapling. So the value 0 and randomness bskSapling is an opening of thePedersen commitment bvkSapling =ValueCommit SaplingbskSapling(0). By thebindingproperty of thePedersen commitment, it is infeasible to find another opening of this commitment to a different value. Similarly, thebindingproperty of thevalue commitmentsin theSpend descriptionsandOutput descriptions ensures that an adversary cannot find an opening to more than one value for any of those commitments, i.e. we may assume that vold1..𝑛 are determined by cvold1..𝑛, and that vnew1..𝑚 are determined by cvnew1..𝑚. We may also assume, from Knowledge Soundness of Groth16, that the Spend proofs could not have been generated without knowing rcvold1..𝑛 (mod𝑟 J), and the Output proofs could not have been generated without knowingrcv new1..𝑚 (mod𝑟 J). Using the fact that ValueCommitSaplingrcv (v) =[v]𝒱 Sapling [rcv]ℛ Sapling, the expression for bvkSapling above is equivalent to: bvkSapling = [︃(︃ 𝑛 𝑖=1 vold𝑖 )︃ (︃ 𝑚 𝑗=1 vnew𝑗 )︃ vSaplingPoolBalance ]︃ 𝒱Sapling [︃(︃ 𝑛 𝑖=1 rcvold𝑖 )︃ (︃ 𝑚 𝑗=1 rcvnew𝑗 )︃]︃ ℛSapling =ValueCommit SaplingbskSapling (︃ 𝑛∑︁ 𝑖=1 vold𝑖 − 𝑚∑︁ 𝑗=1 vnew𝑗 −v SaplingPoolBalance )︃ . Letv* = 𝑛∑︁ 𝑖=1 vold𝑖 − 𝑚∑︁ 𝑗=1 vnew𝑗 −v SaplingPoolBalance. Suppose that v* =v bad̸= 0 (mod𝑟 J). Then bvkSapling =ValueCommit SaplingbskSapling(vbad). If the adversary were able to find thediscrete logarithmof this bvkSapling with respect toℛSapling, say bsk′ (as needed to create a validSapling binding signature), then (vbad,bsk Sapling) and (0,bsk′) would be distinct openings of bvkSapling to different values, breaking thebindingproperty of thevalue commitment scheme. 56 The preceding argument shows only that v* = 0 (mod𝑟 J); in order to show that v* = 0, we will also demonstrate that it does not overflow {︀ − 𝑟J−12 .. 𝑟J−12 }︀. The Spend statements ( §4.18.2 ‘Spend Statement (Sapling)’ on p. 64) prove that all of vold1..𝑛 are in{0..2 ℓvalue−1}. Sim- ilarly the Output statements ( §4.18.3 ‘Output Statement (Sapling)’ on p. 65) prove all of vnew1..𝑚 are in{0..2 ℓvalue−1}. vSaplingPoolBalance is encoded in thetransactionas a signed two’s complement64-bit integer in the range{−263 ..2 63−1} . ℓvalue is defined as 64, so v* is in the range{−𝑚·(2 64−1)−2 63 + 1.. 𝑛·(264−1) + 2 63}. The maximumtransaction size is 2 MB, and the minimum contributions of aSpend descriptionand anOutput descriptiontotransactionsize are (in a v5transaction) 352 bytes and 948 bytes respectively, limiting 𝑛 to at most floor (︀ 2000000 352 )︀ = 5681 and 𝑚 to at mostfloor (︀ 2000000 948 )︀ = 2109. This ensures thatv*∈{−38913406623490299131842..104805176454780817500623}, a subrange of {︀− 𝑟J−12 .. 𝑟J−12 }︀. Thus checking theSapling binding signatureensures that theSpend transfersandOutput transfersin thetransaction balance, without their individual values being revealed. In addition this proves that the signer, knowing the -sum of the Sapling-pool value commitmentrandomnesses, authorized atransactionwith the givenSIGHASH transaction hashby signingSigHash. Note:The spenderMAYreveal any strict subset of the Sapling-pool value commitmentrandomnesses to other parties that are cooperating to create thetransaction. If all of thevalue commitmentrandomnesses are revealed, that could allow replaying theOutput descriptionsof thetransaction. Non-normative note:The technique of checking signatures using avalidating keyderived from a sum ofPedersen commitmentsis also used in the Mimblewimble protocol [Jedusor2016]. Theprivate key bskSapling acts as a “synthetic blinding factor”, in the sense that it is synthesized from the other blinding factors (trapdoors) rcvold1..𝑛 and rcvnew1..𝑚; this technique is also used inBulletproofs[Dalek-notes]. 4.14 Balance and Binding Signature (Orchard) #orchardbalance OrchardintroducesAction transfers, each of which can optionally perform a spend, and optionally perform an output. As for Sapling, the net value ofOrchard pool spends minus outputs in atransactionis called theOrchard-pool balancing value, measured inzatoshias a signed integerv OrchardPoolBalance. vOrchardPool is encoded in atransactionas the field valueBalanceOrchard. If atransactionhas noAction descriptions, vOrchardPool is implicitly zero. Transaction fields are described in §7.1 on p.125. A positive Orchard- or Ironwood-pool balancing value takes net value from the Orchard chain value pooland adds it to thetransparent transaction value pool. A negative Orchard- or Ironwood-pool balancing value does the reverse. As a result, positive vOrchardPoolBalance is treated like an input to thetransparent transaction value pool, whereas negativev OrchardPoolBalance is treated like an output from that pool. Consistency of vOrchardPoolBalance with thevalue commitmentsinAction descriptionsis enforced by theOrchard binding signature. The rôle of this signature in the Orchardprotocol is to prove that the net value spent (i.e. the total value spent minus the total value produced) byAction transfersis consistent with the vOrchardPoolBalance field of the transaction. Non-normative note:The other rôle ofSapling binding signatures, to prove that the signer knew the randomness used for commitments in order to prevent them from being replayed, is less important in the Orchard shielded protocolbecause allAction descriptionshave aspend authorization signature. Still, anOrchard binding signature does prove that the signer knew this commitment randomness; this provides defence in depth and reduces the differences of the Orchard shielded protocolfrom the Sapling shielded protocol, which may simplify security analysis. 57 Instead of generating a key pair at random, we generate it as a function of thevalue commitmentsin theAction descriptionsof thetransaction, and theOrchard- or Ironwood-pool balancing value. LetP,P *, and𝑟 P be as defined in §5.4.9.6 ‘Pallas and Vesta’ on p.108. §5.4.8.3 ‘Homomorphic Pedersen commitments (Sapling and Orchard)’ on p.99 instantiates: ValueCommitOrchard ValueCommitOrchard.Trapdoor× {︀− 𝑟P−12 .. 𝑟P−12 }︀→ValueCommit Orchard.Output; 𝒱Orchard P*, the value base inValueCommit Orchard; ℛOrchard P*, the randomness base inValueCommit Orchard. BindingSigOrchard, , and are instantiated in §5.4.7.2 ‘Binding Signature (Sapling and Orchard)’ on p.98. §4.1.7.2 ‘Signature with Signing Key to Validating Key Monomorphism’ on p. 32 specifies these operations and the derived notation , N 𝑖=1 , , and N 𝑖=1 , which in this section are to be interpreted as operating on thePallas curveand its scalar field. Suppose that thetransactionhas: •𝑛 Action descriptionsfor pool withvalue commitments cvnet1..𝑛, committing to values vnet1..𝑛 with randomness rcvnet1..𝑛; •Orchard- or Ironwood-pool balancing valuev OrchardPoolBalance. In a correctly constructedtransaction, vOrchardPoolBalance = ∑︀𝑛𝑖=1vnet𝑖 , but validators cannot check this directly because the values are hidden by the commitments. Instead, validators calculate thetransaction binding validating keyas: bvkOrchard := (︃ 𝑛 𝑖=1 cvnet𝑖 )︃ ValueCommitOrchard0 (︀vOrchardPoolBalance)︀. (This key is not encoded explicitly in thetransactionand must be recalculated.) The signer knowsrcv net1..𝑛, and so can calculate the correspondingsigning keyas: bskOrchard := 𝑛 𝑖=1 rcvnet𝑖 . In order to check for implementation faults, the signerSHOULDalso check that bvkOrchard =BindingSig Orchard.DerivePublic(bskOrchard). AtransactioncontainingAction descriptionsis necessarily a version 5transaction. Let SigHash be theSIGHASH transaction hashfor a version 5transaction, not associated with an input, using theSIGHASH type SIGHASH_ALL. This is defined in [ZIP-244]. A validator checks balance by validating thatBindingSig Orchard.ValidatebvkOrchard(SigHash, bindingSigOrchard) = 1. The security argument is very similar to that forSapling binding signatures, but for completeness we spell it out, since there are minor differences due to the net value commitments, and a different bound on the net value sumv*. AnOrchard binding signatureproves knowledge of thediscrete logarithm bskOrchard of bvkOrchard with respect to ℛOrchard. That is, bvkOrchard =[bsk Orchard]ℛ Orchard. So the value 0 and randomness bskOrchard is an opening of the Pedersen commitment bvkOrchard =ValueCommit OrchardbskOrchard(0). By thebindingproperty of thePedersen commitment,it is infeasible to find another opening of this commitment to a different value. Similarly, thebindingproperty of thevalue commitmentsin theAction descriptionsensures that an adversary cannot find an opening to more than one value for any of those commitments, i.e. we may assume thatvnet1..𝑛 are determined by cvnet1..𝑛. We may also assume, from Knowledge Soundness of Halo 2, that the Action proofs could not have been generated without knowingrcv net1..𝑛 (mod𝑟 P). 58 Using the fact ValueCommitOrchardrcv (v) =[v]𝒱 Orchard [rcv]ℛ Orchard, the expression for bvkOrchard above is equivalent to: bvkOrchard = [︃(︃ 𝑛 𝑖=1 vnet𝑖 )︃ vOrchardPoolBalance ]︃ 𝒱Orchard [︃ 𝑛 𝑖=1 rcvnet𝑖 ]︃ ℛOrchard =ValueCommit OrchardbskOrchard (︃ 𝑛∑︁ 𝑖=1 vnet𝑖 −v OrchardPoolBalance )︃ . Letv* = 𝑛∑︁ 𝑖=1 vnet𝑖 −v OrchardPoolBalance. Suppose that v* =v bad̸= 0 (mod𝑟 P). Then bvkOrchard =ValueCommit OrchardbskOrchard(vbad). If the adversary were able to find thediscrete logarithmof this bvkOrchard with respect toℛOrchard, say bsk′ (as needed to create a validOrchard binding signature), then (vbad,bsk Orchard) and (0,bsk′) would be distinct openings of bvkOrchard to different values, breaking thebindingproperty of thevalue commitment scheme. The preceding argument shows only that v* = 0 (mod𝑟 P); in order to show that v* = 0, we will also demonstrate that it does not overflow {︀ − 𝑟P−12 .. 𝑟P−12 }︀. The Action statements ( §4.18.4 ‘Action Statement (Orchard)’ on p. 66) prove that all v
프로젝트로 돌아가기