bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 35쪽 중 17쪽
097b425ed097b425ed0ac03e8e134eb3e493e53ab371c71c4f,
0x0c02c5bcca0e6b7f0790bfb3506defb65941a3a4a97aa1b35a28279b1d1b42ae,
0x17033d3c60c68173573b3d7f7d681310d976bbfabbc5661d4d90ab820b12320a,
0x40000000000000000000000000000000224698fc094cf91b992d30ecfffffde5
].
11 For a brief introduction to isogenies between elliptic curves, see [Cook2019]. For deeper mathematical background, see the notes for
lectures 4, 5, and 6 at [Sutherland2021].
110
Let𝒞 V F𝑞V[13] := [
0x38e38e38e38e38e38e38e38e38e38e390205dd51cfa0961a43cd42c800000001,
0x1d935247b4473d17acecf10f5f7c09a2216b8861ec72bd5d8b95c6aaf703bcc5,
0x18760c7f7a9ad20ded7ee4a9cdf78f8fd59d03d23b39cb11aeac67bbeb586a3d,
0x31c71c71c71c71c71c71c71c71c71c71e1c521a795ac8356fb539a6f0000002b,
0x0a2de485568125d51454798a5b5c56b2a3ad678129b604d3b7284f7eaf21a2e9,
0x14735171ee5427780c621de8b91c242a30cd6d53df49d235f169c187d2533465,
0x12f684bda12f684bda12f684bda12f685601f4709a8adcb36bef1642aaaaaaab,
0x2ec9a923da239e8bd6767887afbe04d121d910aefb03b31d8bee58e5fb81de63,
0x19b0d87e16e2578866d1466e9de10e6497a3ca5c24e9ea634986913ab4443034,
0x1ed097b425ed097b425ed097b425ed098bc32d36fb21a6a38f64842c55555533,
0x2f44d6c801c1b8bf9e7eb64f890a820c06a767bfc35b5bac58dfecce86b2745e,
0x3d59f455cafc7668252659ba2b546c7e926847fb9ddd76a1d43d449776f99d2f,
0x40000000000000000000000000000000224698fc0994a8dd8c46eb20fffffde5
].
Letiso_map G iso-G→Gbe the isogeny map given by:
iso_mapG (︀𝒪iso-G)︀ =𝒪 G
iso_mapG (︀(𝑥, 𝑦))︀ = (︂𝒞G1 ·𝑥 3 +𝒞 G2 ·𝑥 2 +𝒞 G3 ·𝑥+𝒞 G4
𝑥2 +𝒞 G5 ·𝑥+𝒞 G6 ,
(︀
𝒞G7 ·𝑥 3 +𝒞 G8 ·𝑥 2 +𝒞 G9 ·𝑥+𝒞 G10)︀·𝑦
𝑥3 +𝒞 G11·𝑥 2 +𝒞 G12·𝑥+𝒞 G13
)︂
.
LetBLAKE2b-512 BY Y[16]×B Y Y[N]→B Y Y[ℓ/8] be as defined in §5.4.1.2 ‘BLAKE2 Hash Functions’ on p.79.
Define the notation ?√∙ as in §2 ‘Notation’ on p.11.
LetBEOS2IPbe as defined in §5.1 ‘Integers, Bit Sequences, and Endianness’ on p.76.
Definehash_to_field
F𝑞G[2]
XMD:BLAKE2b(msg BY Y[N],DST BY Y[{0..255}] )→F 𝑞G[2] as follows:
letDST′ =DST||[length(DST) ]
letmsg′ = [0x00]128||msg||[ 0,128 ]||[ 0 ]||DST ′
let𝑏 0 =BLAKE2b-512
(︀
[0x00]16,msg′)︀
let𝑏 1 =BLAKE2b-512
(︀
[0x00]16, 𝑏0||[ 1 ]||DST′)︀
let𝑏 2 =BLAKE2b-512
(︀
[0x00]16,(𝑏 0⊕𝑏 1)||[ 2 ]||DST ′)︀
return[BEOS2IP 512(𝑏1) (mod𝑞 G),BEOS2IP 512(𝑏2) (mod𝑞 G) ].
Non-normative notes:
• This algorithm is intended to correspond to hash_to_field(msg,2) defined in [ID-hashtocurve, section 5.3],
using as its expand_message parameter the function XMD:BLAKE2b corresponding to expand_message_xmd
defined in [ID-hashtocurve, section 5.4.1], and with domain separation tag DST. In expand_message_xmd, H is
instantiated as BLAKE2b-512 with b_in_bytes= 64 and r_in_bytes= 128 , and we specialize to len_in_bytes= 128
since that is the only case we need. In the event of any discrepancy or change to the Internet Draft, the
definition here takes precedence.
• The “security level” 𝑘 in the Internet Draft is taken to be 256. Although this is greater than the conjectured
126-bit security of thePallas curveagainst generic (e.g. Pollard rho) attacks [Hopwood2020], this design choice
is consistent with other instances of extracting a uniformly distributed field element from a hash output in
the Orchardprotocol, such as ToScalarOrchard and ToBaseOrchard defined in §4.2.3 ‘Orchard Key Components’ on
p.40, andH ⊛ defined in §5.4.7 ‘RedDSA,RedJubjub, andRedPallas’ on p.95.
• Unlike other uses of BLAKE2b inZcash, zero bytes are used for the BLAKE2b personalization, in order to
follow the Internet Draft which encodesDSTin the hash inputs instead.
• The conversion from bytes to field elements usesbig-endianorder, again in order to follow the Internet Draft .
111
• A minor optimization is to cache the state of the BLAKE2b-512 instance used to compute 𝑏0 after processing
[0x00]128, since this state does not depend on the message.
Let𝜆 G be any fixed nonsquare inF𝑞G. Definesqrt_ratio F𝑞G(num,div) F𝑞G×F*𝑞G→F 𝑞G×Bas follows:
sqrt_ratioF𝑞G(num,div) =
{︃ (︀ ?√︀num/div ,1 )︀,ifnum/divis square inF 𝑞G(︀ ?√︀𝜆G·num/div ,0 )︀,otherwise.
Non-normative notes:
•An arbitrary square root may be chosen in either case of the definition. The result is never⊥.
• The choice of the nonsquare 𝜆G is also arbitrary and will not affect the output of map_to_curve_simple_swuiso-G
defined below.
•The computation ofsqrt_ratio F𝑞G can be optimized as described in [Zcash-halo2, section 3.2.1 Fields].
Define𝑍 iso-G :=−13 (mod𝑞 G). (This value is suitable for bothiso-Pallasandiso-Vesta.)
Precompute𝜃 iso-G := ?√︀𝑍iso-G/𝜆G , which is not⊥. 12
By definition we have that 𝐸G is theshort Weierstrass curvewith equation 𝑦2 =𝑥 3 +𝑏 G, and 𝐸iso-G is theshort
Weierstrass curvewith equation𝑦 2 =𝑥 3 +𝑎 iso-G·𝑥+𝑏 iso-G.
Definemap_to_curve_simple_swu iso-G(𝑢 F𝑞G)→iso-Gas follows:
letZuu=𝑍 iso-G·𝑢 2
letta=Zuu 2 +Zuu
letx1 num =𝑏 iso-G·(ta+ 1)
letx div =𝑎 iso-G·
(︀
(ta= 0) ? 𝑍iso-G :−ta
)︀
computex 2div andx 3div
letU= (x1 2num +𝑎 iso-G·x 2div)·x1 num +𝑏 iso-G·x 3div
letx2 num =Zuu·x1 num
let(y1,is_gx1_square) =sqrt_ratio F𝑞G(U,x 3div)
lety2=𝜃 iso-G·Zuu·𝑢·y1
letx num =is_gx1_square ? x1num :x2 num
lety′ =is_gx1_square ? y1:y2
lety= (𝑢mod 2 =𝑦mod 2) ? y′ :−y′
return the𝐸 iso-G point withaffine-short-Weierstrasscoordinates(x num/xdiv,y).
Let GroupHashG .Input:=B Y Y[N]×B Y Y[N]. The first input element acts as a domain separator to distinguish uses of the
group hashfor different purposes; the second input element is the message.
Thishash-to-curvealgorithm does not have a URS, i.e.GroupHash G .URSType:= ().
12Both𝑍 iso-G and𝜆 G are nonsquare, and so their ratio is square inF𝑞G . An arbitrary square root may be chosen.
112
The hashGroupHash G(𝐷 BY Y[N], 𝑀 BY Y[N]) Gis calculated as follows:
letDST=𝐷||“ -”||curveName G||“ _XMD:BLAKE2b_SSWU_RO_”
fail iflength(DST)>255
let[𝑢 0, 𝑢1 ] =hash_to_field
F𝑞G[2]
XMD:BLAKE2b(𝑀,DST)
let𝑄 𝑖 =map_to_curve_simple_swu iso-G(𝑢𝑖)for𝑖∈{0,1}
returniso_map G(𝑄0 +𝑄 1).
Non-normative notes:
• The length of 𝐷 is in practice limited to 233−length(curveName G) bytes due to the restriction of DST to at
most255bytes. This limit is not exceeded by any use ofGroupHash P orGroupHash V in this specification.
•GroupHash P and GroupHashV are intended to be instantiations of hash_to_curve using “Simplified SWU for
𝐴𝐵= 0 ” described in[ID-hashtocurve, section 6.6.3]. In the event of any discrepancy or change to the Internet
Draft, the definition here takes precedence.
• It is not necessary to use the clear_cofactor function specified in the Internet Draft, because Pallas and Vesta
(and thereforeiso-Pallasandiso-Vesta) areprime-order curves.
• The above description incorporates optimizations from [WB2019] that avoid inversions and unnecessary
square tests in the computation of map_to_curve_simple_swuiso-G. In order to fully avoid inversions, the output
of map_to_curve_simple_swuiso-G can be expressed in Jacobian coordinates, as can the input and output of
iso_mapG. It is outside the scope of this document to describe Jacobian coordinates, but for example, the𝐸iso-G
point withaffine-short-Weierstrasscoordinates
(︀
xnum/xdiv,y
)︀
, has Jacobian coordinates
(︀
xnum·xdiv :y·x 3div :x div)︀.
Note:The uses of GroupHashP for DiversifyHashOrchard, and of bothGroupHashP and GroupHashV to generate indepen-
dent bases, need arandom oracle. The hash_to_curve algorithm in[ID-hashtocurve] is designed to be indifferentiable
from arandom oracle(in the framework of [MRH2003]), given that XMD:BLAKE2b satisfies the requirements of
[ID-hashtocurve, section 5.5.4]. The security of the Brier et al. construction on which this algorithm is based is
analysed in [FFSTV2013] and [KT2015], with a verified proof in [BGHOZ2013].
5.4.10 Zero-Knowledge Proving Systems #concretezk
5.4.10.1BCTV14 #bctv
Before Sapling activation,Zcashuseszk-SNARKsgenerated by a fork oflibsnark [Zcash-libsnark] with the BCTV14
proving systemdescribed in [BCTV2014a], which is a modification of the systems in [PHGR2013] and [BCGTV2013].
A BCTV14 proof comprises (𝜋𝐴 G(𝑟)*1 , 𝜋′𝐴 G(𝑟)*1 , 𝜋𝐵 G(𝑟)*2 , 𝜋′𝐵 G(𝑟)*1 , 𝜋𝐶 G(𝑟)*1 , 𝜋′𝐶 G(𝑟)*1 , 𝜋𝐾 G(𝑟)*1 , 𝜋𝐻 G(𝑟)*1 ).
It is computed as described in [BCTV2014a, Appendix B], using the pairing parameters specified in §5.4.9.1 ‘BN-254’
on p.102.
Note:Many details of theproving systemare beyond the scope of this protocol document. For example, the
quadratic constraint programverifying theJoinSplit statement, or its translation to aQuadratic Arithmetic Program
[BCTV2014a, section 2.3], are not specified in this document. In 2015, Bryan Parno found a bug in this transla-
tion, which is corrected by thelibsnarkimplementation 13 [WCBTV2015] [Parno2015] [BCTV2014a, Remark 2.5]. In
practice it will be necessary to use the specific proving and verifying keys that were generated for theZcash
productionblock chain, given in §5.7 ‘BCTV14 zk-SNARK Parameters’ on p. 123, together with aproving system
implementation that is interoperable with theZcashfork oflibsnark, to ensure compatibility.
13Confusingly, the bug found by Bryan Parno was fixed inlibsnarkin 2015, but that fix was incompletely described in the May 2015 update
[BCTV2014a-old, Theorem 2.4]. It is described completely in [BCTV2014a, Theorem 2.4] and in [Gabizon2019].
113
Vulnerability disclosure: BCTV14 is subject to a security vulnerability, separate from[Parno2015], that could allow
violation of Knowledge Soundness (and Soundness) [CVE-2019-7167] [SWB2019] [Gabizon2019]. The consequence
forZcashis that balance violation could have occurred before activation of the Sapling network upgrade, although
there is no evidence of this having happened. Use of the vulnerability to produce false proofs is believed to have
been fully mitigated by activation of Sapling. The use of BCTV14 inZcashis now limited to verifying proofs that
were made prior to the Saplingnetwork upgrade.
Due to this issue, new forks ofZcash MUST NOTuse BCTV14, and any other users of theZcashprotocolSHOULD
discontinue use ofBCTV14as soon as possible.
The vulnerability does not affect the Zero Knowledge property of the scheme (as described in any version of
[BCTV2014a] or as implemented in any version oflibsnarkthat has been used inZcash), even under subversion of
the parameter generation [BGG2017, Theorem 4.10].
[ Sapling onward] An implementation ofZcashthat checkpoints on ablockafter Sapling MAYchoose to skip
verification of BCTV14 proofs. Note that in §3.3 ‘The Block Chain’ on p. 19, there is a requirement that afull
validatorthat potentially risksMainnetfunds or displaysMainnet transactioninformation to a userMUSTdo so
only for ablock chainthat includes theactivation blockof the most recentsettled network upgrade, with its known
block hashas specified in §3.12 ‘Mainnet and Testnet’ on p. 24. Since the most recentsettled network upgradeis
after the Saplingnetwork upgrade, this mitigates the potential risks due to skippingBCTV14proof verification.
Encoding ofBCTV14Proofs #bctvencoding
ABCTV14proof is encoded by concatenating the encodings of its elements; for theBN-254pairing this is:
264-bit𝜋 𝐴 264-bit𝜋′𝐴 520-bit𝜋 𝐵 264-bit𝜋′𝐵 264-bit𝜋 𝐶 264-bit𝜋′𝐶 264-bit𝜋 𝐾 264-bit𝜋 𝐻
The resulting proof size is296bytes.
In addition to the steps to verify a proof given in[BCTV2014a, Appendix B], the verifierMUSTcheck, for the encoding
of each element, that:
•the lead byte is of the required form;
•the remaining bytes encode abig-endianrepresentation of an integer in{0.. 𝑞 S−1}or (for𝜋 𝐵){0.. 𝑞S2−1};
• the encoding represents a point in G(𝑟)*1 or (for 𝜋𝐵) G(𝑟)*2 , including checking that it is of order 𝑟G in the latter
case.
5.4.10.2Groth16 #groth
After Sapling activation,Zcashuseszk-SNARKswith the Groth16 proving systemdescribed in [BGM2017], which is
a modification of the system in [Groth2016]. An independent security proof of this system and its setup is given in
[Maller2018].
Groth16 zk-SNARK proofsare used intransaction version4 and later ( §7.1 ‘Transaction Encoding and Consensus’
on p. 125), both in SproutJoinSplit descriptionsand in SaplingSpend descriptionsandOutput descriptions. They
are generated by thebellmanlibrary [Bowe-bellman].
A Groth16 proof comprises (𝜋𝐴 S(𝑟)*1 , 𝜋𝐵 S(𝑟)*2 , 𝜋𝐶 S(𝑟)*1 ). It is computed as described in [Groth2016, section 3.2],
using the pairing parameters specified in §5.4.9.2 ‘BLS12-381’ on p. 104. The proof elements are in a different order
to the presentation in [Groth2016].
Note:Thequadratic constraint programsverifying theSpend statementandOutput statementare described
in Appendix §A ‘Circuit Design’ on p. 207. However, many other details of theproving systemare beyond the
scope of this protocol document. For example, certain details of the translations of theSpend statementand
Output statementtoQuadratic Arithmetic Programsare not specified in this document. In practice it will be
necessary to use the specific proving and verifying keys generated for theZcashproductionblock chain(see §5.8
‘Groth16 zk-SNARK Parameters’ on p. 123), and aproving systemimplementation that is interoperable with the
bellmanlibrary used byZcash, to ensure compatibility.
114
Encoding ofGroth16Proofs #grothencoding
AGroth16proof is encoded by concatenating the encodings of its elements; for theBLS12-381pairing this is:
384-bit𝜋 𝐴 768-bit𝜋 𝐵 384-bit𝜋 𝐶
The resulting proof size is192bytes.
In addition to the steps to verify a proof given in [Groth2016], the verifierMUSTcheck, for the encoding of each
element, that:
•the leading bitfield is of the required form;
• the remaining bits encode abig-endianrepresentation of an integer in {0.. 𝑞S−1} or (in the case of 𝜋𝐵) two
integers in that range;
• the encoding represents a point in S(𝑟)*1 or (in the case of 𝜋𝐵) S(𝑟)*2 , including checking that it is of order 𝑟S in
each case.
5.4.10.3Halo 2 #halo2
For Orchard-pool Action descriptionsin version 5transactions,Zcashuseszk-SNARKswith the Halo 2 proving
systemdescribed in [Zcash-halo2].
Encoding ofHalo 2Proofs #halo2encoding
Halo 2proofs are defined asbyte sequences, and so the encoding is the proof itself.
5.5 Encodings of Note Plaintexts and Memo Fields #noteptencoding
As explained in §3.2.1 ‘Note Plaintexts and Memo Fields’ on p. 16, transmittednotesare stored on theblock chain
in encrypted form. The components and usage ofnote plaintexts, and which keys they are encrypted to, are defined
in that section.
The encoding of a Sproutnote plaintextconsists of:
8-bitleadByte 64-bitv 256-bitρ 256-bitrcm memo(512bytes)
•A byte, 0x00, indicating this version of the encoding of a Sproutnote plaintext.
•8bytes specifyingv.
•32bytes specifyingρ.
•32bytes specifyingrcm.
•512bytes specifyingmemo.
115
The encoding of a Saplingor Orchardnote plaintextconsists of:
8-bitleadByte 88-bitd 64-bitv 256-bitrseed memo(512bytes)
• A byte, 0x01 or 0x02 as specified in §3.2.1 ‘Note Plaintexts and Memo Fields’ on p. 16, indicating this version
of the encoding of a Saplingor Orchardnote plaintext.
•11bytes specifyingd.
•8bytes specifyingv.
•32bytes specifyingrseed.
•512bytes specifyingmemo.
5.6 Encodings of Addresses and Keys #addressandkeyencoding
This section describes howZcashencodesshielded payment addresses,incoming viewing keys, andspending keys.
Addresses and keys can be encoded as abyte sequence; this is called theraw encoding. For Sproutshielded payment
addresses, thisbyte sequencecan then be further encoded usingBase58Check. TheBase58Checklayer is the same
as for upstreamBitcoinaddresses [Bitcoin-Base58].
For Sapling-specific key and address formats,Bech32[ZIP-173] is used instead ofBase58Check.
Non-normative note:ZIP 173 is similar toBitcoin’s BIP 173, except for dropping the limit of 90 characters on an
encodedBech32string (which does not hold for Saplingviewing keys, for example), and requirements specific to
Bitcoin’s Segwit addresses.
Orchardintroduces a new address format called aunified payment address. This can encode an Orchardaddress, but
also a Saplingaddress, atransparent address, and potentially future address formats, all in the sameunified payment
address. It isRECOMMENDEDto useunified payment addressesfor all new applications, unless compatibility with
software that only accepts previous address formats is required.
Unified payment addressesand Orchardspending keysare encoded withBech32m [BIP-350] rather thanBech32.
Payment addressesMAYbe encoded as QR codes; in this case, theRECOMMENDEDformat for a Saplingpayment
addressis theBech32form converted to uppercase, using the Alphanumeric mode [ISO2015, sections 7.3.4 and 7.4.4].
Similarly, theRECOMMENDEDformat for a unifiedpayment addressis theBech32mform converted to uppercase,
using the Alphanumeric mode.
5.6.1 Transparent Encodings #transparentencodings
5.6.1.1 Transparent Addresses #transparentaddrencoding
Transparent addressesare eitherP2SH(Pay to Script Hash) addresses [BIP-13] orP2PKH(Pay to Public Key Hash)
addresses [Bitcoin-P2PKH].
Theraw encodingof aP2SH addressconsists of:
8-bit 0x1C 8-bit 0xBD 160-bit script hash
• Two bytes [0x1C, 0xBD], indicating this version of theraw encodingof aP2SH addressonMainnet. (Addresses
onTestnetuse[ 0x1C, 0xBA]instead.)
•20bytes specifying a script hash [Bitcoin-P2SH].
116
Theraw encodingof aP2PKH addressconsists of:
8-bit 0x1C 8-bit 0xB8 160-bitvalidating keyhash
• Two bytes[0x1C, 0xB8], indicating this version of theraw encodingof aP2PKH addressonMainnet. (Addresses
onTestnetuse[ 0x1D, 0x25]instead.)
•20 bytes specifying avalidating keyhash, which is a RIPEMD-160 hash [RIPEMD160] of a SHA-256 hash
[NIST2015] of a compressedECDSAkey encoding.
Notes:
• InBitcoina single byte is used for the version field identifying the address type. InZcashtwo bytes are used.
For addresses onMainnet, this and the encoded length cause the first two characters of theBase58Check
encoding to be fixed as“ t3”forP2SH addresses, and as“ t1”forP2PKH addresses. (This does not imply that a
transparentZcashaddress can be parsed identically to aBitcoinaddress just by removing the“ t”.)
•Zcashdoes not yet support Hierarchical Deterministic Wallet addresses [BIP-32].
5.6.1.2 Transparent Private Keys #transparentkeyencoding
These are encoded in the same way as inBitcoin[Bitcoin-Base58], for bothMainnetandTestnet.
5.6.2SproutEncodings #sproutencodings
5.6.2.1SproutPayment Addresses #sproutpaymentaddrencoding
LetKA Sprout be as defined in §5.4.5.1 ‘Sprout Key Agreement’ on p.91.
A Sproutshielded payment addressconsists ofa pk B[ℓSproutPRF ] andpk enc KASprout.Public.
apk is a SHA256Compress output. pkenc is a KASprout.Public key, for use with the encryption scheme defined in §4.19
‘In-band secret distribution (Sprout)’ on p. 68. These components are derived from aspending keyas described in
§4.2.1 ‘Sprout Key Components’ on p.38.
Theraw encodingof a Sproutshielded payment addressconsists of:
8-bit 0x16 8-bit 0x9A 256-bita pk 256-bitpk enc
• Two bytes [0x16, 0x9A], indicating this version of theraw encodingof a Sproutshielded payment addresson
Mainnet. (Addresses onTestnetuse[ 0x16, 0xB6]instead.)
•32bytes specifyinga pk.
•32bytes specifyingpk enc, using the normal encoding of aCurve25519public key[Bernstein2006].
Note:For addresses onMainnet, the lead bytes and encoded length cause the first two characters of the
Base58Checkencoding to be fixed as“ zc”. ForTestnet, the first two characters are fixed as“ zt”.
117
5.6.2.2SproutIncoming Viewing Keys #sproutinviewingkeyencoding
LetKA Sprout be as defined in §5.4.5.1 ‘Sprout Key Agreement’ on p.91.
A Sproutincoming viewing keyconsists ofa pk B[ℓSproutPRF ] andsk enc KASprout.Private.
apk is a SHA256Compress output. skenc is a KASprout.Private key, for use with the encryption scheme defined in §4.19
‘In-band secret distribution (Sprout)’ on p. 68. These components are derived from aspending keyas described in
§4.2.1 ‘Sprout Key Components’ on p.38.
Theraw encodingof a Sproutincoming viewing keyconsists of:
8-bit 0xA8 8-bit 0xAB 8-bit 0xD3 256-bita pk 256-bitsk enc
• Three bytes [0xA8, 0xAB, 0xD3], indicating this version of theraw encodingof aZcashincoming viewing key
onMainnet. (Addresses onTestnetuse[ 0xA8, 0xAC, 0x0C]instead.)
•32bytes specifyinga pk.
•32bytes specifyingsk enc, using the normal encodin프로젝트로 돌아가기