bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 19쪽 중 6쪽
code
path transfer selected rct() → construct tx and get tx key() → construct tx with tx key() →
generate output ephemeral keys() and classify addresses()) surrounding change outputs where the transac-
tion author knows the recipient’s view key (since it’s himself; also the case for dummy change outputs, which are
created when a 0-amount output is necessary, since authors generate those addresses). Whenever there are at least
two non-change outputs, and at least one of their recipients is a subaddress, proceed in the normal way explained
above (a current bug in the core implementation adds an extra transaction public key to transaction data even
beyond the additional keys, which is not used for anything). If either just the change output is to a subaddress, or
CHAPTER 4. MONERO ADDRESSES 41
4.4 Integrated addresses
To differentiate between the outputs they receive, a recipient can request senders include apayment
ID in transaction data. 17 For example, if Alice wants to buy an apple from Bob on a Tuesday,
Bob could write a receipt describing the purchase and ask Alice to include the receipt’s ID number
when she sends him the money. This way Bob can associate the money he receives with the apple
he sold.
At one point senders could communicate payment IDs in clear text, but manually including the
IDs in transactions is inconvenient, and cleartext is a privacy hazard for recipients, who might
inadvertently expose their activities.18 In src/crypto-
note basic/
cryptonote
basic
impl.cpp
get
account
integrated
address as
str()
Monero, recipients can integrate payment IDs into their
addresses, and provide those integrated addresses, containing (Kv, Ks, payment ID), to senders.
Payment IDs can technically be integrated into any kind of address, including normal addresses,
subaddresses, and multisignature addresses. 19
Senders addressing outputs to integrated addresses can encode payment IDs using the shared
secretrKvt and an XOR operation (recall Section 2.5), which recipients can then decode with the
appropriate transaction public key and another XOR operation [9]. Encoding payment IDs in
this way also allows senders to prove they made particular transaction outputs (e.g. for audits,
refunds, etc.).20
Encoding
The src/device/
device de-
fault.cpp
encrypt
payment
id()
sender encodes the payment ID for inclusion in transaction data 21
kmask =Hn(rKvt, pid tag)
kpayment ID =kmask→ reduced to bit length of payment ID
encoded payment ID = XOR(kpayment ID, payment ID)
there is just one non-change output and it’s to a subaddress, then only one transaction public key is created. In the
former case, the transaction public key is rG and the change’s one-time key is (subaddress index 1, using c subscript
to denote the change’s keys) Ko =Hn(kvcrG,t )G +Ks,1c using the normal view key and subaddress’s spend key. In
the latter case the transaction public key rKv,1 is based off the subaddress’s view key, and the change’s one time
key is Ko =Hn(kvc∗rKv,1,t )G +Ksc . These details help mingle a portion of subaddress transactions amongst the
more common normal address transactions, and 2-output transactions which compose around 95% of transaction
volume as of this writing.
17 Currently, Monero implementations only support one payment ID per transaction regardless of how many
outputs it has.
18 These long-form (256 bit) cleartext payment IDs were deprecated in v0.15 of the core software implementation
(coincident with protocol v12 in November 2019). While other wallets may still support them and allow their
inclusion in transaction data, the core wallet will ignore them.
19 Within the authors’ knowledge, integrated addresses have only ever been implemented for normal addresses.
20 Since an observer can recognize the difference between transactions with and without payment IDs, using
them is thought to make the Monero transaction history less uniform. Because of this, since protocol v10 the core
implementation adds a dummy src/crypto-
note core/
cryptonote
tx utils.cpp
construct
tx with
tx key()
encrypted payment ID to all 2-output transactions. Decoding one will reveal all 0s
(this is not required by the protocol, just best practice).
21 In Monero payment IDs for integrated addresses are conventionally 64 bits long.
CHAPTER 4. MONERO ADDRESSES 42
We include pid tag to ensurekmask is different from the componentHn(rKvt,t ) in one-time output
addresses.22
Decoding
Whichever src/device/
device.hpp
decrypt
payment
id()
recipient the payment ID was created for can find it using his view key and the trans-
action public key rG:23
kmask =Hn(kvtrG, pid tag)
kpayment ID =kmask→ reduced to bit length of payment ID
payment ID = XOR(kpayment ID, encoded payment ID)
Similarly, senders can decode payment IDs they had previously encoded by recalculating the shared
secret.
4.5 Multisignature addresses
Sometimes it is useful to share ownership of funds between different people/addresses. We dedicate
Chapter 9 to elaborating this topic.
22 In Monero, pid tag = ENCRYPTED PAYMENT ID TAIL = 141. In, for example, multi-input transactions we compute
Hn(rKvt,t ) (mod l) to ensure we are using a scalar less than the EC subgroup order, but since l is 253 bits and
payment IDs are only 64 bits, taking the modulus for encoding payment IDs would be meaningless, so we don’t.
23 Transaction data does not indicate which output a payment ID ‘belongs’ to. Recipients have to identify their
own payment IDs.
CHAPTER 5
Monero Amount Hiding
In most cryptocurrencies like Bitcoin, transaction output notes, which give spending rights to
‘amounts’ of money, communicate those amounts in clear text. This allows observers to easily
verify the amount spent equals the amount sent.
In Monero we usecommitments to hide output amounts from everyone except senders and receivers,
while still giving observers confidence that a transaction sends no more or less than what is spent.
As we will see, amount commitments must also have corresponding ‘range proofs’ which prove the
hidden amount is within a legitimate range.
5.1 Commitments
Generally speaking, a cryptographic commitment scheme is a way of committing to a value without
revealing the value itself. After committing to something, you are stuck with it.
For example, in a coin-flipping game Alice could privately commit to one outcome (i.e. ‘call it’)
by hashing her committed value with secret data and publishing the hash. After Bob flips the
coin, Alice declares which value she committed to and proves it by revealing the secret data. Bob
could then verify her claim.
In other words, assume that Alice has a secret string blah and the value she wants to commit to
is heads. She hashes h =H(blah,heads ) and gives h to Bob. Bob flips a coin, then Alice tells
Bob the secret string blah and that she committed to heads. Bob calculates h′ =H(blah,heads ).
If h′ =h, then he knows Alice called heads before the coin flip.
43
CHAPTER 5. MONERO AMOUNT HIDING 44
Alice uses the so-called ‘salt’, blah, so Bob can’t just guessH(heads) andH(tails) before his coin
flip, and figure out she committed to heads.1
5.2 Pedersen commitments
A Pedersen commitment [113] is a commitment that has the property of being additively ho-
momorphic. If C(a) and C(b) denote the commitments for values a and b respectively, then
C(a +b) =C(a) +C(b).2 This property will be useful when committing transaction amounts, as
one can prove, for instance, that inputs equal outputs, without revealing the amounts at hand.
Fortunately, Pedersen commitments are easy to implement with elliptic curve cryptography, as
the following holds trivially
aG +bG = (a +b)G
Clearly, by defining a commitment as simply C(a) = aG, we could easily create cheat tables of
commitments to help us recognize common values of a.
To attain information-theoretic privacy, one needs to add a secret blinding factor and another
generator H, such that it is unknown for which value of γ the following holds: H = γG. The
hardness of the discrete logarithm problem ensures calculating γ from H is infeasible.3
We can then define the commitment to a value a as C(x,a ) = xG +aH, where x is the blinding
factor (a.k.a. ‘mask’) that prevents observers from guessing a.
CommitmentC(x,a ) is information-theoretically private because there are many possible combi-
nations of x and a that would output the same C.4 If x is truly random, an attacker would have
literally no way to figure out a [88, 122].
5.3 Amount commitments
In Monero, output amounts are stored in transactions as Pedersen commitments. We define a
commitment to an output’s amount b as:
1 If the committed value is very difficult to guess and check, e.g. if it’s an apparently random elliptic curve point,
then salting the commitment isn’t necessary.
2 Additively homomorphic in this context means addition is preserved when you transform scalars into EC points
by applying, for scalar x, x→xG.
3 In the case of Monero src/ringct/
rctTypes.h
, H = 8∗to point(Hn(G)). This differs from the Hp hash function in that it directly
interprets the output of Hn(G) as a compressed point coordinate instead of deriving a curve point mathematically
(see [107]). The historical reasons for this discrepancy tests/unit
tests/
ringct.cpp
TEST(ringct,
HPow2)
are unknown to us, and indeed this is the only place where
Hp is not used (Bulletproofs also use Hp). Note how there is a ∗8 operation, to ensure the resultant point is in our
l subgroup (Hp also does that).
4 Basically, there are many x′ and a′ such that x′ +a′γ =x +aγ. A committer knows one combination, but an
attacker has no way to know which one. This property is also known as ‘perfect hiding’ [138]. Furthermore, even the
committer can’t find another combination without solving the DLP for γ, a property called ‘computational binding’
[138].
CHAPTER 5. MONERO AMOUNT HIDING 45
C(y,b ) =yG +bH src/ringct/
rctOps.cpp
addKeys2()Recipients should be able to know how much money is in each output they own, as well asreconstruct the amount commitments, so they can be used as the inputs to new transactions.
This means the blinding factor y and amount b must be communicated to the receiver.
The solution adopted is a Diffie-Hellman shared secret rKvB using the ‘transaction public key’
(recall Section 4.2.1). For any given transaction in the blockchain, each of its outputst∈{ 0,...,p−
1} has a mask yt that senders and receivers can privately compute, and an amount stored in the
transaction’s data. While yt is an elliptic curve scalar and occupies 32 bytes, b will be restricted
to 8 bytes by the range proof so only an 8 byte value needs to be stored. 5,6
src/ringct/
rctOps.cpp
ecdh-
Encode()
yt =Hn(“commitment mask”,Hn(rKvB,t ))
amountt =bt⊕8Hn(“amount”,Hn(rKvB,t ))
Here,⊕8 means to perform an XOR operation (Section 2.5) between the first 8 bytes of each
operand (bt which is already 8 bytes, and Hn(...) which is 32 bytes). Recipients can perform the
same XOR operation on amountt to reveal bt.
The receiver Bob will be able to calculate the blinding factor yt and the amount bt using the
transaction public key rG and his view key kvB. He can also check that the commitment C(yt,bt)
provided in the transaction data, henceforth denoted Cbt , corresponds to the amount at hand.
More generally, any third party with access to Bob’s view key could decrypt his output amounts,
and also make sure they agree with their associated commitments.
5.4 RingCT introduction
A transaction will contain references to other transactions’ outputs (telling observers which old
outputs are to be spent), and its own outputs. The content of an output includes a one-time
address (assigning ownership of the output) and an output commitment hiding the amount (also
the encoded output amount from Section 5.3).
While a transaction’s verifiers don’t know how much money is contained in each input and output,
they still need to be sure the sum of input amounts equals the sum of output amounts. Monero
uses a technique called RingCT [108], first implemented in January 2017 (v4 of the protocol), to
accomplish this.
5 As src/crypto-
note core/
cryptonote
tx utils.cpp
construct
tx with
tx key() calls
generate
output
ephemeral
keys()
with the one-time address Ko from Section 4.2, the output index t is appended to the shared secret before
hashing. This ensures outputs directed to the same address do not have similar masks and amounts, except with
negligible probability. Also like before, the term rKvB is multiplied by 8, so it’s really 8 rKvB.
6 This solution (implemented in v10 of the protocol) replaced a previous method that used more data, thereby
causing the transaction type to change from v3 ( RCTTypeBulletproof) to v4 ( RCTTypeBulletproof2). The first
edition of this report discussed the previous method [33].
CHAPTER 5. MONERO AMOUNT HIDING 46
If we have a transaction withm inputs containing amountsa1,...,a m, andp outputs with amounts
b0,...,b p−1, then an observer would justifiably expect that: 7
∑
j
aj−
∑
t
bt = 0
Since commitments are additive and we don’t know γ, we could easily prove our inputs equal
outputs to observers by making the sum of commitments to input and output amounts equal zero
(i.e. by setting the sum of output blinding factors equal to the sum of old input blinding factors): 8
∑
j
Cj,in−
∑
t
Ct,out = 0
To avoid sender identifiability we use a slightly different approach. The amounts being spent
correspond to the outputs of previous transactions, which had commitments
Caj =xjG +ajH
The sender can create new commitments to the same amounts but using different blinding factors;
that is,
C′aj =x′jG +ajH
Clearly, she would know the private key of the difference between the two commitments:
Caj−C′aj = (xj−x′j)G
Hence, she would be able to use this value as a commitment to zero, since she can make a signature
with the private key (xj−x′j) =zj and prove there is no H component to the sum (assuming γ is
unknown). In other words prove that Caj−C′aj =zjG + 0H, which we will actually do in Chapter
6 when we discuss the structure of RingCT transactions.
Let us call C′aj a pseudo output commitment . Pseudo output commitments are included in trans-
action data, and there is one for each input.
Before committing a transaction to the blockchain, the network will want to verify that its amounts
balance. Blinding factors for pseudo and output commitments are selected such that
∑
j
x′j− ∑
t
yt = 0
This src/ringct/
rctSigs.cpp
verRct-
Semantics-
Simple()
allows us to prove input amounts equal output amounts:
(
∑
j
C′aj − ∑
t
Cbt ) = 0
Fortunately, choosing such blinding factors is easy. In the current version of Monero, all blinding
7 If the intended total output amount doesn’t precisely equal any combination of owned outputs, then transaction
authors can add a ‘change’ output sending extra money back to themselves. By analogy to cash, with a 20$ bill and
15$ expense you will receive 5$ back from the cashier.
8 Recall from Section 2.3.1 we can subtract a point by inverting its coordinates then adding it. If P = (x,y ),
−P = (−x,y ). Recall also that negations of field elements are calculated (mod q), so (–x (mod q)).
CHAPTER 5. MONERO AMOUNT HIDING 47
factors are random except for the mth pseudo out commitment, where x′m is simply genRct-
Simple()
x′m = ∑
t
yt−
m−1∑
j=1
x′j
5.5 Range proofs
One problem with additive commitments is that, if we have commitmentsC(a1),C(a2),C(b1), and
C(b2) and we intend to use them to prove that (a1 +a2)− (b1 +b2) = 0, then those commitments
would still apply if one value in the equation were ‘negative’.
For instance, we could have a1 = 6, a2 = 5, b1 = 21, and b2 =−10.
(6 + 5)− (21 +−10) = 0
where
21G +−10G = 21G + (l− 10)G = (l + 11)G = 11G
Since−10 =l− 10, we have effectively created l more Moneroj (over 7.2x10 74!) than we put in.
The solution addressing this issue in Monero is to prove each output amount is in a certain range
(from 0 to 2 64− 1) using the Bulletproofs proving scheme first described by Benedikt B¨ unzet al.
in [43] (and also explained in [138, 50]). 9 Given the involved and intricate nature of Bulletproofs,
it is not elucidated in this document. Moreover we feel the cited materials adequately present its
concepts.10
The Bulletproof proving algorithm src/ringct/
rctSigs.cpp
proveRange-
Bullet-
proof()
takes as input output amounts bt and commitment masks yt,
and outputs allCbt and ann-tuple aggregate proof ΠBP = (A,S,T 1,T 2,τx,µ, L, R,a,b,t )11,12. That
single proof is used to prove all output amounts are in range at the same time, as aggregating
them greatly reduces space requirements (although it does increase the time to verify). 13 The
verification algorithm takes as input all Cbt , and ΠBP , and outputs true if all committed amounts
are in the range 0 to 2 64− 1.
The n-tuple ΠBP occupies (2·⌈ log2(64·p)⌉ + 9)· 32 bytes of storage.
9 It’s conceivable that with several outputs in a legitimate range, the sum of their amounts could roll over and
cause a similar problem. However, when the maximum output is much smaller than l it takes a huge number of
outputs for that to happen. For example, if the range is 0-5, and l = 99, then to counterfeit money using an input
of 2, we would need 5 + 5 +.... + 5 + 1 = 101≡ 2 (mod 99), for 21 total outputs. In Monero l is about 2ˆ189 times
bigger than the available range, which means a ridiculous 2ˆ189 outputs to counterfeit money.
10 Prior to protocol v8 range proofs were accomplished with Borromean ring signatures, which were explained in
the first edition of Zero to Monero [33].
11 Vectors L and R contain⌈log2(64·p)⌉ elements each. ⌈⌉ means the log function is rounded up. Due to their
construction, some Bulletproofs use ‘dummy outputs’ as padding to ensure p plus the number of dummy outputs is
a power of 2. Those dummy outputs can be generated during verification, and are not stored with the proof data.
12 The variables in a Bulletproof are unrelated to other variables in this document. Symbol overlap is merely
coincidental. Note that group elements A,S,T 1,T 2, L, and R are multiplied by 1/8 before being stored, then
multiplied by 8 during verification. This ensures they are all members of the l sub-group (recall Section 2.3.1).
13 It turns out multiple separate Bulletproofs can be ‘batched’ rct/ringct/
bulletproofs.cc
bulletproof
VERIFY()
together, which means they are verified simulta-
neously. Doing so improves how long it takes to verify them, and currently in Monero Bulletproofs are batched on
a per-block basis, although there is no theoretical limit to how many can be batched together. Each transaction is
only allowed to have one Bulletproof.
CHAPTER 6
Monero Ring Confidential Transactions (RingCT)
Throughout Chapters 4 and 5 we built up several aspects of Monero transactions. At this point a
simple one-input, one-output transaction from some unknown author to some unknown recipient
sounds like:
“My transaction uses transaction public key rG. I will spend old output X (note that it has a
hidden amount AX, committed to in CX). I will give it a pseudo output commitment C′X. I will
make one outputY , which may be spent by the one-time address KoY . It has a hidden amount AY
committed to in CY , encrypted for the recipient, and proven in range with a Bulletproofs-style
range proof. Please note that C′X−CY = 0.”
Some questions remain. Did the author actually own X? Does the pseudo output commitment
C′X actually correspond to CX, such that AX = A′X = AY ? Has someone tampered with the
transaction, and perhaps directed the output at a recipient unintended by the original author?
As mentioned in Section 4.2, we can prove ownership of an output by signing a message with its
one-time address (whoever has the address’s key owns the output). We can also prove it has the
same amount as a pseudo output commitment by proving knowledge of the commitment to zero’s
private key (CX−C′X =zXG). Moreover, if that message is all the transaction data (except the
signature itself), then verifiers can be assured everything is as the author intended (the signature
only wor프로젝트로 돌아가기