Zcash 백서

Zcash

원문

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

each coordinate of (𝑥𝑆, 𝑦𝑅) =[1 +𝑠 0 + 2·𝑠 1]𝑃 as a linear combination of𝑠 0,𝑠 1, and𝑠 î : let𝑥 𝑆 =𝑥 1 + (𝑥2−𝑥 1)·𝑠 0 + (𝑥3−𝑥 1)·𝑠 1 + (𝑥4 +𝑥 1−𝑥 2−𝑥 3)·𝑠 î let𝑦 𝑅 =𝑦 1 + (𝑦2−𝑦 1)·𝑠 0 + (𝑦3−𝑦 1)·𝑠 1 + (𝑦4 +𝑦 1−𝑦 2−𝑦 3)·𝑠 î We implement the conditional negation as (︀ 2·𝑦 𝑅 )︀ (︀ 𝑠2 )︀ = (︀ 𝑦𝑅−𝑦 𝑆 )︀ . After substitution of𝑦 𝑅 this becomes: (︀ 2·(𝑦 1 + (𝑦2−𝑦 1)·𝑠 0 + (𝑦3−𝑦 1)·𝑠 1 + (𝑦4 +𝑦 1−𝑦 2−𝑦 3)·𝑠 î ) )︀ (︀ 𝑠2 )︀ =(︀ 𝑦1 + (𝑦2−𝑦 1)·𝑠 0 + (𝑦3−𝑦 1)·𝑠 1 + (𝑦4 +𝑦 1−𝑦 2−𝑦 3)·𝑠 î −𝑦 𝑆 )︀ 218 Then we substitute 𝑥𝑆 into the Montgomery addition constraints from §A.3.3.4 ‘Affine-Montgomery arithmetic’ on p.213, as follows: (︀ 𝑥1 + (𝑥2−𝑥 1)·𝑠 0 + (𝑥3−𝑥 1)·𝑠 1 + (𝑥4 +𝑥 1−𝑥 2−𝑥 3)·𝑠 î −𝑥 𝐴 )︀ (︀ 𝜆 )︀ = (︀ 𝑦𝑆−𝑦 𝐴 )︀ (︀ 𝐵M·𝜆 )︀ (︀ 𝜆 )︀ = (︀ 𝐴M +𝑥 𝐴 +𝑥 1 + (𝑥2−𝑥 1)·𝑠 0 + (𝑥3−𝑥 1)·𝑠 1 + (𝑥4 +𝑥 1−𝑥 2−𝑥 3)·𝑠 î +𝑥 𝐶 )︀ (︀ 𝑥𝐴−𝑥 𝐶 )︀ (︀ 𝜆 )︀ = (︀ 𝑦𝐶 +𝑦 𝐴 )︀ (In the sapling-crypto implementation, linear combinations are first-class values, so these substitutions do not need to be done “by hand” .) For the first addition in each segment, both sides are looked up and substituted into the Montgomery addition, so the first lookup takes only2constraints. When these hashes are used in the circuit, the first 6 bits of the input are fixed. For example, in the Merkle tree hashes they represent the layer number. This would allow a precomputation for the first two windows, but that optimization is not done in Sapling. The cost of a Pedersen hash over ℓ bits (where ℓ includes the fixed bits) is as follows. The number of chunks is 𝑐=ceiling (︁ ℓ 3 )︁ and the number of segments is𝑛=ceiling (︁ ℓ 3·63 )︁ . The cost is then: •2·𝑐constraints for the lookups; •3·(𝑐−𝑛)constraints for incomplete additions on theMontgomery curve; •2·𝑛constraints for Montgomery-to-ctEdwardsconversions; •6·(𝑛−1)constraints forctEdwardsadditions; for a total of5·𝑐+ 5·𝑛−6constraints. This does not include the cost of boolean-constraining inputs. In particular, •for the Merkle tree hashesℓ= 516, so𝑐= 172,𝑛= 3, and the cost is869constraints; • when a Pedersen hash is used to implement part of a Pedersen commitment forNoteCommitSapling ( §5.4.8.2 ‘Windowed Pedersen commitments’ on p. 99), ℓ= 6 +ℓ value + 2·ℓJ = 582, 𝑐= 194 , and 𝑛= 4 , so the cost of the hash alone is984constraints. A.3.3.10 Mixing Pedersen hash #cctmixinghash A mixingPedersen hashis used to compute ρ from cm and pos in §4.16 ‘Computingρvalues and Nullifiers’ on p.60. It takes as input aPedersen commitment𝑃, and hashes it with another input𝑥. Let𝒥 Sapling be as defined in §5.4.1.8 ‘Mixing Pedersen Hash Function’ on p.84. We defineMixingPedersenHash {0.. 𝑟J−1}×J→Jby: MixingPedersenHash(𝑃, 𝑥) :=𝑃+[𝑥]𝒥 Sapling. This costs 92 constraints for a scalar multiplication ( §A.3.3.7 ‘Fixed-base Affine-ctEdwards scalar multiplication’ on p. 215), and 6 constraints for actEdwardsaddition ( §A.3.3.5 ‘Affine-ctEdwards arithmetic’ on p. 214), for a total of98constraints. 219 A.3.4 Merkle path check #cctmerklepath Checking each layer of a Merkle authentication path, as described in §4.9 ‘Merkle Path Validity’ on p. 52, requires to: •boolean-constrain the path bit specifying whether the previous node is a left or right child; •conditionally swap the previous-layer and sibling hashes (asF 𝑟 elements) depending on the path bit; •unpack the left and right hash inputs to two sequences of255bits; •compute the Merkle hash for this node. The unpacking need not be canonical in the sense discussed in §A.3.2.1 ‘[Un]packing modulo𝑟 S’ on p. 209; that is, it is not necessary to ensure that the left or right inputs to the hash represent integers in the range{0.. 𝑟S−1} . Since the root of the Merkle tree is calculated outside the circuit using the canonical representations, and since the Pedersen hashesarecollision-resistanton arbitrarybit-sequenceinputs, an attempt by an adversarial prover to use anon-canonicalinput would result in the wrong root being calculated, and the overall path check would fail. For each layer, the cost is1 + 2·255 boolean constraints, 2 constraints for the conditional swap (implemented as two selection constraints), and 869 constraints for the Merkle hash ( §A.3.3.9 ‘Pedersen hash’ on p. 217), for a total of 1380constraints. Non-normative note:The conditional swap (𝑎0, 𝑎1)↦→(𝑐 0, 𝑐1) could be implemented in only one constraint by substituting𝑐 1 =𝑎 0 +𝑎 1−𝑐 0 into the uses of𝑐 1. The Saplingcircuit does not use this optimization. A.3.5 Windowed Pedersen Commitment #cctwindowedcommit We constructwindowed Pedersen commitmentsby reusing the Pedersen hash implementation described in §A.3.3.9 ‘Pedersen hash’ on p.217, and adding a randomized point: WindowedPedersenCommit𝑟(𝑠) =PedersenHashToPoint(“ Zcash_PH”, 𝑠) +[𝑟]FindGroupHashJ(𝑟)*(“Zcash_PH”,“ r”) This can be implemented in: •5·𝑐+ 5·𝑛−6 constraints for the Pedersen hash applied to ℓ= 6 +length(𝑠) bits, where 𝑐=ceiling (︁ ℓ 3 )︁ and 𝑛=ceiling (︁ ℓ 3·63 )︁ ; •750constraints for the fixed-base scalar multiplication; •6constraints for the finalctEdwardsaddition. When WindowedPedersenCommit is used to instantiate NoteCommitSapling, the cost of the Pedersen hash is 984 con- straints as calculated in §A.3.3.9 ‘Pedersen hash’ on p. 217, and so the total cost in that case is 1740 constraints. This does not include the cost of boolean-constraining the input𝑠or the randomness𝑟. A.3.6 Homomorphic Pedersen Commitment #ccthomomorphiccommit Thewindowed Pedersen commitmentsdefined in the preceding section are highly efficient, but they do not support the homomorphic property we need when instantiatingValueCommit. In order to support this property, we also definehomomorphic Pedersen commitmentsas follows: HomomorphicPedersenCommitSaplingrcv (𝐷,v) =[v]FindGroupHash J(𝑟)*(𝐷,“ v”) +[rcv]FindGroupHash J(𝑟)*(𝐷,“ r”) 220 In the case that we need for ValueCommit, v has 64 bits17. This value is given as a bit representation, which does not need to be constrained equal to an integer. ValueCommitcan be implemented in: •750constraints for the252-bit fixed-base multiplication byrcv; •191constraints for the64-bit fixed-base multiplication byv; •6constraints for thectEdwardsaddition for a total cost of 947 constraints. This does not include the cost to boolean-constrain the input v or randomness rcv. A.3.7 BLAKE2s hashes #cctblake2s BLAKE2sis defined in [ANWW2013]. Its main subcomponent is a “𝐺function” , defined as follows: 𝐺 {0..9}×{0..2 32−1}[4]→{0..2 32−1}[4] 𝐺(𝑎, 𝑏, 𝑐, 𝑑, 𝑥, 𝑦) = (𝑎′′, 𝑏′′, 𝑐′′, 𝑑′′)where 𝑎′ = (𝑎+𝑏+𝑥) mod 2 32 𝑑′ = (𝑑⊕𝑎 ′)≫16 𝑐′ = (𝑐+𝑑 ′) mod 232 𝑏′ = (𝑏⊕𝑐 ′)≫12 𝑎′′ = (𝑎′ +𝑏′ +𝑦) mod 2 32 𝑑′′ = (𝑑′⊕𝑎′′)≫8 𝑐′′ = (𝑐′ +𝑑′′) mod 232 𝑏′′ = (𝑏′⊕𝑐′′)≫7 The following table is used to determine which message words the𝑥and𝑦arguments to𝐺are selected from: 𝜎0 = [ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ] 𝜎1 = [ 14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3 ] 𝜎2 = [ 11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4 ] 𝜎3 = [ 7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8 ] 𝜎4 = [ 9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13 ] 𝜎5 = [ 2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9 ] 𝜎6 = [ 12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11 ] 𝜎7 = [ 13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10 ] 𝜎8 = [ 6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5 ] 𝜎9 = [ 10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0 ] The Initialization Vector is defined as: IV {0..2 32−1}[8] := [ 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 ] 17It would be sufficient to use51bits, which accomodates the range{0..MAX_MONEY}, but the Saplingcircuit uses64. 221 The full hash function applied to an 8-byte personalization string and a single 64-byte block, in sequential mode with32-byte output, can be expressed as follows. DefineBLAKE2s-256 (𝑝 BY Y[8])×(𝑥 BY Y[64])→B Y Y[32] as: letPB BY Y[32] = [32,0,1,1]||[ 0x00]20||𝑝 let[𝑡 0, 𝑡1, 𝑓0, 𝑓1 ] {0..2 32−1}[4] = [ 0,0,0, 0xFFFFFFFF,0 ] letℎ {0..2 32−1}[8] = [ [LEOS2IP32(PB4·𝑖 ..4·𝑖+ 3)⊕IV 𝑖 for𝑖from0up to7 ] ] let𝑚 {0..2 32−1}[16] = [ [LEOS2IP32(𝑥4·𝑖 ..4·𝑖+ 3)for𝑖from0up to15 ] ] let mutable𝑣 {0..2 32−1}[16]←ℎ||[IV 0,IV 1,IV 2,IV 3, 𝑡0⊕IV 4, 𝑡1⊕IV 5, 𝑓0⊕IV 6, 𝑓1⊕IV 7 ] for𝑟from0up to9: set(𝑣 0, 𝑣4, 𝑣8, 𝑣12)←𝐺(𝑣 0, 𝑣4, 𝑣8, 𝑣12, 𝑚𝜎𝑟,0, 𝑚𝜎𝑟,1 ) set(𝑣 1, 𝑣5, 𝑣9, 𝑣13)←𝐺(𝑣 1, 𝑣5, 𝑣9, 𝑣13, 𝑚𝜎𝑟,2, 𝑚𝜎𝑟,3 ) set(𝑣 2, 𝑣6, 𝑣10, 𝑣14)←𝐺(𝑣 2, 𝑣6, 𝑣10, 𝑣14, 𝑚𝜎𝑟,4, 𝑚𝜎𝑟,5 ) set(𝑣 3, 𝑣7, 𝑣11, 𝑣15)←𝐺(𝑣 3, 𝑣7, 𝑣11, 𝑣15, 𝑚𝜎𝑟,6, 𝑚𝜎𝑟,7 ) set(𝑣 0, 𝑣5, 𝑣10, 𝑣15)←𝐺(𝑣 0, 𝑣5, 𝑣10, 𝑣15, 𝑚𝜎𝑟,8, 𝑚𝜎𝑟,9 ) set(𝑣 1, 𝑣6, 𝑣11, 𝑣12)←𝐺(𝑣 1, 𝑣6, 𝑣11, 𝑣12, 𝑚𝜎𝑟,10, 𝑚𝜎𝑟,11) set(𝑣 2, 𝑣7, 𝑣8, 𝑣13)←𝐺(𝑣 2, 𝑣7, 𝑣8, 𝑣13, 𝑚𝜎𝑟,12, 𝑚𝜎𝑟,13) set(𝑣 3, 𝑣4, 𝑣9, 𝑣14)←𝐺(𝑣 3, 𝑣4, 𝑣9, 𝑣14, 𝑚𝜎𝑟,14, 𝑚𝜎𝑟,15) returnLEBS2OSP 256(concatB([ [I2LEBSP32(ℎ𝑖⊕𝑣 𝑖⊕𝑣 𝑖+8)for𝑖from0up to7 ] ]) ) In practice the message and output will be expressed asbit sequences. In the Saplingcircuit, the personalization string will be constant for each use. Each 32-bit exclusive-or is implemented in 32 constraints, one for each bit position 𝑎⊕𝑏=𝑐 as in §A.3.1.5 ‘Exclusive-or constraints’ on p.209. Additions not involving a message word, i.e. (𝑎+𝑏) mod 2 32 =𝑐 , are implemented using 33 constraints and a 33-bit equality check: constrain33boolean variables𝑐 0..32 , and then check ∑︀𝑖=31 𝑖=0 (𝑎𝑖 +𝑏 𝑖)·2 𝑖 = ∑︀𝑖=32𝑖=0 𝑐𝑖·2 𝑖. Additions involving a message word, i.e.(𝑎+𝑏+𝑚) mod 2 32 =𝑐 , are implemented using 34 constraints and a 34-bit equality check: constrain34boolean variables𝑐 0..33 , and then check ∑︀𝑖=31 𝑖=0 (𝑎𝑖 +𝑏 𝑖 +𝑚 𝑖)·2 𝑖 = ∑︀𝑖=33𝑖=0 𝑐𝑖·2 𝑖. For each addition, only𝑐 0..31 are used subsequently. The equality checks are batched; as many sets of 33 or 34 boolean variables as will fit in a F𝑟S field element are equated together using one constraint. This allows7such checks per constraint. Each𝐺evaluation requires262constraints: •4·32 = 128constraints for⊕operations; •2·33 = 66constraints for32-bit additions not involving message words (excluding equality checks); •2·34 = 68constraints for32-bit additions involving message words (excluding equality checks). 222 The overall cost is21006constraints: •10·8·262−4·2·32 = 20704 constraints for 80𝐺 evaluations, excluding equality checks (the deduction of 4·2·32 is because 𝑣 is constant at the start of the first round, so in the first four calls to 𝐺, the parameters 𝑏 and𝑑are constant, eliminating the constraints for the first two XORs in those four calls to𝐺); •ceiling (︁10·8·4 7 )︁ = 46constraints for equality checks; •8·32 = 256 constraints for final 𝑣𝑖⊕𝑣 𝑖+8 operations (the ℎ𝑖 words are constants so no additional constraints are required to exclusive-or with them). This cost includes boolean-constraining the hash output bits (done implicitly by the final⊕ operations), but not the message bits. Non-normative notes: • The equality checks could be eliminated entirely by substituting each check into a boolean constraint for 𝑐0, for instance, but this optimization is not done in Sapling. • It should be clear that BLAKE2s is very expensive in the circuit compared to elliptic curve operations. This is primarily because it is inefficient to use F𝑟S elements to represent single bits. However Pedersen hashes do not have the necessary cryptographic properties for the two cases where theSpend circuituses BLAKE2s. While it might be possible to use variants of functions with low circuit cost such as MiMC [AGRRT2017], it was felt that they had not yet received sufficient cryptanalytic attention to confidently use them for Sapling. 223 A.4 TheSaplingSpend circuit #cctsaplingspend The SaplingSpendstatementis defined in §4.18.2 ‘Spend Statement (Sapling)’ on p.64. The primary input is (︀ rtSaplingPool B[ℓSaplingMerkle ], cvold ValueCommitSapling.Output, nfold BY Y[ℓPRFnfSapling/8], rk SpendAuthSigSapling.Public)︀, which is encoded as8F 𝑟S elements (starting with the fixed element1required byGroth16): [︀ 1, 𝑢(rk), v(rk), 𝑢(cvold), v(cvold),LEBS2IP ℓSaplingMerkle (︀rtSaplingPool)︀,LEBS2IP 254(︀nf⋆old0..253 )︀,LEBS2IP 2(︀nf⋆old254..255 )︀]︀ wherenf ⋆ old =LEOS2BSP ℓPRFnfSapling (︀ nfold)︀. The auxiliary input is (︀ path B[ℓSaplingMerkle ][MerkleDepthSapling], pos {0..2 MerkleDepthSapling−1}, gd J, pkd J, vold {0..2 ℓvalue−1}, rcvold {0..2 ℓSaplingscalar−1}, cmold J, rcmold {0..2 ℓSaplingscalar−1}, 𝛼 {0..2 ℓSaplingscalar−1}, ak SpendAuthSigSapling.Public, nsk {0..2 ℓSaplingscalar−1})︀. ValueCommitSapling.Output and SpendAuthSigSapling.Public are of type J, so we have cvold, cmold, rk, gd, pkd, and ak that representJubjub curvepoints. However, •cv old will be constrained to an output ofValueCommit Sapling; •cm old will be constrained to an output ofNoteCommit Sapling; •rkwill be constrained to[𝛼]𝒢 Sapling +ak; •pk d will be constrained to[ivk]g d socv old,cm old,rk, andpk d do not need to be explicitly checked to be on the curve. In addition, nk⋆ and ρ⋆ used inNullifier integrityare compressed representations ofJubjub curvepoints. {TODO: explain why these are implemented as §A.3.3.2 ‘ctEdwards [de]compression and validation’ on p.212 even though the statement spec doesn’t explicitly say to do validation.} Therefore we have gd, ak, nk, and ρ that need to be constrained to validJubjub curvepoints as described in §A.3.3.2 ‘ctEdwards [de]compression and validation’ on p.212. 224 In order to aid in comparing the implementation with the specification, we present the checks needed in the order in which they are implemented in the sapling-crypto code: Check Implements Cost Reference ak is on the curve {TODO: FIXME also decompressed below} ak SpendAuthSigSapling.Public 4 §A.3.3.1 on p.212 akis notsmall-order Small order checks 16 §A.3.3.6 on p.215 𝛼⋆ B[ℓSaplingscalar ] 𝛼 {0..2 ℓSaplingscalar−1} 252 §A.3.1.1 on p.208 𝛼′ =[𝛼⋆]𝒢 Sapling Spend authority 750 §A.3.3.7 on p.215 rk=𝛼 ′ +ak 6 §A.3.3.5 on p.214 inputize rk{TODO: not ccteddecom- pressvalidate => wrong count} rk SpendAuthSigSapling.Public 392? §A.3.3.2 on p.212 nsk⋆ B[ℓSaplingscalar ] nsk {0..2 ℓSaplingscalar−1} 252 §A.3.1.1 on p.208 nk=[nsk⋆]ℋ Sapling Nullifier integrity 750 §A.3.3.7 on p.215 ak⋆=repr J(ak J) Diversified address integrity 392 §A.3.3.2 on p.212 nk⋆=repr J(nk){TODO: spec doesn’t say to validatenksince it’s calculated} Nullifier integrity 392 §A.3.3.2 on p.212 ivk⋆=I2LEBSP 251 (︀ CRHivk(ak,nk) )︀† Diversified address integrity 21006 §A.3.7 on p.221 gd is on the curve gd J 4 §A.3.3.1 on p.212 gd is notsmall-order Small order checks 16 §A.3.3.6 on p.215 pkd =[ivk⋆]g d Diversified address integrity 3252 §A.3.3.8 on p.216 v⋆ old B[64] vold {0..2 64−1} 64 §A.3.1.1 on p.208 rcv⋆ B[ℓSaplingscalar ] rcv {0..2 ℓSaplingscalar−1} 252 §A.3.1.1 on p.208 cv=ValueCommit rcv( vold) Value commitment integrity 947 §A.3.6 on p.220 inputizecv ? rcm⋆ B[ℓSaplingscalar ] rcm {0..2 ℓSaplingscalar−1} 252 §A.3.1.1 on p.208 cm=NoteCommit Saplingrcm (gd,pk d,v old) Note commitment integrity 1740 §A.3.5 on p.220 cm𝑢 =Extract J(𝑟)(cm) Merkle path validity 0 rt′ is the root of a Merkle tree with leafcm 𝑢, and authentication path (path,pos⋆) 32·1380 §A.3.4 on p.220 pos⋆=I2LEBSP MerkleDepthSapling(pos) 1 §A.3.2.1 on p.209 ifv old̸= 0thenrt ′ =rt SaplingPool 1 §A.3.1.2 on p.208 inputizert SaplingPool ? ρ=MixingPedersenHash(cm old,pos) Nullifier integrity 98 §A.3.3.10 on p.219 ρ⋆=repr J(ρ){TODO: spec doesn’t say to validateρsince it’s calculated} 392 §A.3.3.2 on p.212 nfold =PRF nfSaplingnk⋆ (ρ⋆) 21006 §A.3.7 on p.221 packnf old0..253 andnf old254..255 into two F𝑟S inputs input encoding 2 §A.3.2.1 on p.209 225 † This is implemented by taking the output of BLAKE2s-256 as abit sequenceand dropping the most significant 5bits, not by converting to an integer and back to abit sequenceas literally specified. Note:The implementation represents 𝛼⋆, nsk⋆, ivk⋆, rcm⋆, rcv⋆, and v⋆ old asbit sequencesrather than integers. It representsnfas abit sequencerather than abyte sequence. A.5 TheSaplingOutput circuit #cctsaplingoutput The SaplingOutputstatementis defined in §4.18.3 ‘Output Statement (Sapling)’ on p.65. The primary input is (︀ cvnew ValueCommitSapling.Output, cm𝑢 B[ℓSaplingMerkle ], epk J )︀ , which is encoded as6F 𝑟S elements (starting with the fixed element1required byGroth16):[︀ 1, 𝑢(cvnew), v(cvnew), 𝑢(epk), v(epk),LEBS2IP ℓSaplingMerkle (cm𝑢) ]︀ The auxiliary input is (gd J, pk⋆d B[ℓJ], vnew {0..2 ℓvalue−1}, rcvnew {0..2 ℓSaplingscalar−1}, rcmnew {0..2 ℓSaplingscalar−1}, esk {0..2 ℓSaplingscalar−1}) ValueCommitSapling.Outputis of typeJ, so we havecv new,epk, andg d that representJubjub curvepoints. However, •cv new will be constrained to an output ofValueCommit Sapling; •epkwill be constrained to[esk]g d socv new andepkdo not need to be explicitly checked to be on the curve. Therefore we have only gd that needs to be constrained to a validJubjub curvepoint as described in §A.3.3.2 ‘ctEdwards [de]compression and validation’ on p.212. Note:pk⋆ d is not checked to be a valid compressed representation of aJubjub curvepoint. 226 In order to aid in comparing the implementation with the specification, we present the checks needed in the order in which they are implemented in the sapling-crypto code: Check Implements Cost Reference v⋆ old B[64] vold {0..2 64−1} 64 §A.3.1.1 on p.208 rcv⋆ B[ℓSaplingscalar ] rcv {0..2 ℓSaplingscalar−1} 252 §A.3.1.1 on p.208 cv=ValueCommit Saplingrcv (vold) Value commitment integrity 947 §A.3.6 on p.220 inputizecv ? g⋆d =repr J(gd J) Note commitment integrity 392 §A.3.3.2 on p.212 gd is notsmall-order Small order checks 16 §A.3.3.6 on p.215 esk⋆ B[ℓSaplingscalar ] esk {0..2 ℓSaplingscalar−1} 252 §A.3.1.1 on p.208 epk=[esk⋆]g d Ephemeral public key integrity 3252 §A.3.3.8 on p.216 inputizeepk ? pk⋆d B[ℓJ] pk⋆d B[ℓJ] 256 §A.3.1.1 on p.208 rcm⋆ B[ℓSaplingscalar ] rcm {0..2 ℓSaplingscalar−1} 252 §A.3.1.1 on p.208 cm=NoteCommit Saplingrcm (gd,pk d,v old) Note commitment integrity 1740 §A.3.5 on p.220 pack inputs ? Note:The implementation representsesk⋆,pk⋆ d,rcm⋆,rcv⋆, andv ⋆ old asbit sequencesrather than integers. B Batching Optimizations #batching B.1RedDSAbatch validation #reddsabatchvalidate The reference validation algorithm for RedDSA signatures is defined in §5.4.7 ‘RedDSA,RedJubjub, andRedPallas’ on p.95. Let the RedDSA parameters G (defining a subgroup G(𝑟) of order 𝑟G, a cofactor ℎG, a group operation +, an additive identity𝒪G, a bit-length ℓG, a representation function reprG, and an abstraction function abstG);𝒫G G; ℓH N; H BY Y[N]→B Y Y[ℓH/8]; and the derived hash functionH ⊛ BY Y[N]→F 𝑟G be as defined in that section. ImplementationsMAYalternatively use the optimized procedure described in this section to perform faster validation of a batch of signatures, i.e. to determine whether all signatures in a batch are valid. Its input is a sequence of𝑁signature batch entries, each of which is a (validating key, message, signature) triple. Let LEOS2BSP, LEOS2IP, and LEBS2OSP be as defined in §5.1 ‘Integers, Bit Sequences, and Endianness’ on p. 76. DefineRedDSA.BatchEntry:=RedDSA.Public×RedDSA.Message×RedDSA.Signature. 227 DefineRedDSA.BatchValidate (entry0.. 𝑁−1 RedDSA.BatchEntry[𝑁])→Bas: For each𝑗∈{0.. 𝑁−1}: Let(vk 𝑗, 𝑀𝑗, 𝜎𝑗) =entry 𝑗. Let𝑅 𝑗 be the firstceiling (︀ ℓG /8 )︀ bytes of𝜎 𝑗, and let𝑆 𝑗 be the remainingceiling(bitlength(𝑟 G)/8)bytes. Let𝑅 𝑗 =abst G (︀ LEOS2BSPℓG (𝑅𝑗) )︀ , and let𝑆 𝑗 =LEOS2IP 8·length(𝑆𝑗)(𝑆𝑗). Letvk 𝑗 =LEBS2OSP ℓG (︀ reprG(vk𝑗) )︀ . Let𝑐 𝑗 =H ⊛(𝑅𝑗||vk 𝑗||𝑀 𝑗). Choose random𝑧 𝑗 F*𝑟G←R{1..2 128−1}. Return1if •for all𝑗∈{0.. 𝑁−1},𝑅 𝑗̸=⊥and𝑆 𝑗 < 𝑟G; and •[ℎ G] (︁ − [︁∑︀𝑁−1 𝑗=0 (𝑧𝑗·𝑆 𝑗) (mod𝑟 G) ]︁ 𝒫G + ∑︀𝑁−1 𝑗=0 [𝑧𝑗]𝑅 𝑗 + ∑︀𝑁−1 𝑗=0 [𝑧𝑗·𝑐 𝑗 (mod𝑟 G)]vk 𝑗 )︁ =𝒪 G, otherwise0. The𝑧 𝑗 valuesMUSTbe chosen independently of thesignature batch entries. Non-normative note:It is also acceptable to sample each 𝑧𝑗 from{0..2 128−1} , since the probability of obtaining zero for any𝑧 𝑗 is negligible. The performance benefit of this approach arises partly from replacing the per-signature scalar multiplication of the base𝒫G with one such multiplication per batch, and partly from using an efficient algorithm for multiscalar multiplication such as Pippinger’s method [Bernstein2001] or the Bos–Coster method [deRooij1995], as explained in [BDLSY2012, section 5]. Note:Spend authorization signatures ( §5.4.7.1 ‘Spend Authorization Si
프로젝트로 돌아가기