bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 19쪽 중 7쪽
ks with the original message). MLSAG signatures allow us to do all of this while also
obscuring the actual spent output amongst other outputs from the blockchain, so observers can’t
be sure which one is being spent.
48
CHAPTER 6. MONERO RING CONFIDENTIAL TRANSACTIONS (RINGCT) 49
6.1 Transaction types
Monero src/crypto-
note core/
cryptonote
tx utils.cpp
construct
tx with
tx key()
is a cryptocurrency under steady development. Transaction structures, protocols, and
cryptographic schemes are always prone to evolving as new innovations, objectives, or threats are
found.
In this report we have focused our attention on Ring Confidential Transactions, a.k.a. RingCT, as
they are implemented in the current version of Monero. RingCT is mandatory for all new Monero
transactions, so we will not describe any deprecated transaction schemes, even if they are still
partially supported. 1 The transaction type we have discussed so far, and which will be further
elaborated in this chapter, is RCTTypeBulletproof2.2
We present a conceptual summary of transactions in Section 6.3.
6.2 Ring Confidential Transactions of type RCTTypeBulletproof2
Currently (protocol v12) all new transactions must use this transaction type, in which each input
is signed separately. An actual example of an RCTTypeBulletproof2 transaction, with all its
components, can be inspected in Appendix A.
6.2.1 Amount commitments and transaction fees
Assume a transaction sender has previously received various outputs with amounts a1,...,a m
addressed to one-time addresses Koπ,1,...,K oπ,m and with amount commitments Caπ,1,...,C aπ,m.
This sender knows the private keys koπ,1,...,k oπ,m corresponding to the one-time addresses (Section
4.2). The sender also knows the blinding factors xj used in commitments Caπ,j (Section 5.3).
Typically transaction outputs are lower in total than transaction inputs, in order to provide a fee
that will incentivize miners to include the transaction in the blockchain.3 Transaction fee amounts
f are stored in clear text in the transaction data transmitted to the network. Miners can create
an additional output for themselves with the fee (see Section 7.3.6).
1 RingCT was first implemented in January 2017 (v4 of the protocol). It was made mandatory for all new
transactions in September 2017 (v6 of the protocol) [16]. RingCT is version 2 of Monero’s transaction protocol.
2 Within the RingCT era there are three deprecated transaction types: RCTTypeFull, RCTTypeSimple, and
RCTTypeBulletproof. The former two coexisted in the first iteration of RingCT and are explored in the first
edition of this report [33], then with the advent of Bulletproofs (protocol v8) RCTTypeFull was deprecated, and
RCTTypeSimple was upgraded to RCTTypeBulletproof. RCTTypeBulletproof2 arrived due to a minor improvement
in encrypting output commitments’ masks and amounts (v10).
3 In Monero there is a minimum base fee that scales with transaction weight. It is semi-mandatory because while
you can create new blocks containing tiny-fee transactions, most Monero nodes won’t relay such transactions to
other nodes. The result is few if any miners will try to include them in blocks. Transaction authors can provide
miner fees above the minimum if they want. We go into more detail on this in Section 7.3.4.
CHAPTER 6. MONERO RING CONFIDENTIAL TRANSACTIONS (RINGCT) 50
A transaction consists of inputsa1,...,a m and outputsb0,...,b p−1 such that
m∑
j=1
aj−
p−1∑
t=0
bt−f = 0.4
The sender calculates pseudo output commitments for the input amounts, C′aπ,1,...,C ′aπ,m, and
creates commitments for intended output amounts b0,...,b p−1. Let these new commitments be
Cb0,...,C bp−1.
He knows the private keys z1,...,z m to the commitments to zero (Caπ,1−C′aπ,1),..., (Caπ,m−C′aπ,m).
For verifiers to confirm transaction amounts sum to zero, the fee amount must be converted into a
commitment. The solution is to calculate the commitment of the fee f without the masking effect
of any blinding factor. That is, C(f) =fH .
Now src/ringct/
rctSigs.cpp
verRct-
Semantics-
Simple()
we can prove input amounts equal output amounts:
(
∑
j
C′aj − ∑
t
Cbt )−fH = 0
6.2.2 Signature
The sender selects m sets of size v, of additional unrelated one-time addresses and their commit-
ments from the blockchain, corresponding to apparently unspent outputs. 5,6 To sign input j, she
stirs a set of size v into a ring with her own jth unspent one-time address (placed at unique index
π), along with false commitments to zero, as follows: 7
Rj ={{Ko1,j, (C1,j−C′aπ,j)},
...
{Koπ,j, (Caπ,j−C′aπ,j)},
...
{Kov+1,j, (Cv+1,j−C′aπ,j)}}
4 Outputs
src/crypto-
note core/
cryptonote
tx utils.cpp
construct
tx with
tx key()
are randomly shuffled by the core implementation before getting assigned an index, so observers can’t
build heuristics around their order. Inputs are sorted by key image within transaction data.
5 In Monero it is standard for the sets src/wallet/
wallet2.cpp
get outs()
of ‘additional unrelated addresses’ to be selected from a gamma
gamma picker
::pick()
distribution
across the range of historical outputs (RingCT outputs only, a triangle distribution is used for pre-RingCT outputs).
This method uses a binning procedure to smooth out differences in block densities. First calculate the average time
between transaction outputs over up to a year ago of RingCT outputs (avg time = [#outputs/#blocks]*blocktime).
Select an output via the gamma distribution, then look inside its block and grab a random output to be a member
of the set. [93]
6 As of protocol v12, all transaction inputs must be at least 10 blocks old ( CRYPTONOTE DEFAULT TX
SPENDABLE AGE). Prior to v12 the core implementation used 10 blocks by default, but it was not required so an
alternate wallet could make different choices, and some apparently did [82].
7 In Monero each of a transaction’s rings must have the same size, and the protocol controls how many ring
members there can be per output-to-be-spent. It has changed with different protocol versions: v2 March 2016 ≥ 3,
v6 Sept. 2017≥ 5, v7 April 2018≥ 7, v8 Oct. 2018 11-only. Since src/crypto-
note core/
cryptonote
core.cpp
check
tx inputs
ring members
diff()
v6 each individual ring can not contain duplicate
members, though there may be duplicates between rings to allow multiple inputs when there are insufficient total
outputs in the transaction history (i.e. to assemble rings without cross-over) [135].
CHAPTER 6. MONERO RING CONFIDENTIAL TRANSACTIONS (RINGCT) 51
Alice src/ringct/
rctSigs.cpp
proveRct-
MGSimple()
uses an MLSAG signature (Section 3.5) to sign this ring, where she knows the private keys
koπ,j for Koπ,j, and zj for the commitment to zero ( Caπ,j - C′aπ,j). Since no key image is needed for
the commitments to zero, there is consequently no corresponding key image component in the
signature’s construction.8
Each input in a transaction is signed individually using rings like Rj as defined above, thereby
obscuring the real outputs being spent, ( Koπ,1,...,K oπ,m), amongst other unspent outputs. 9 Since
part of each ring includes a commitment to zero, the pseudo output commitment used must contain
an amount equal to the real input being spent. This ties input amounts to the proof that amounts
balance, without compromising which ring member is the real input.
The message m signed by each input is essentially a hash of all transaction data except for the
MLSAG signatures. 10 This ensures transactions are tamper-proof from the perspective of both
transaction authors and verifiers. Only one message is produced, and each input MLSAG signs it.
One-time private key ko is the essence of Monero’s transaction model. Signing m with ko proves
you are the owner of the amount committed to in Ca. Verifiers can be confident that transaction
authors are spending their own funds, without even knowing which funds are being spent, how
much is being spent, or what other funds they might own!
6.2.3 Avoiding double-spending
An src/crypto-
note core/
block-
chain.cpp
have tx
keyimges
as spent()
MLSAG signature (Section 3.5) contains images ˜Kj of private keys kπ,j. An important prop-
erty for any cryptographic signature scheme is that it should be unforgeable with non-negligible
probability. Therefore, to all practical effects, we can assume a signature’s key images must have
been deterministically produced from legitimate private keys.
The network only needs to verify that key images included with MLSAG signatures (corresponding
to inputs and calculated as ˜Koj =koπ,jHp(Koπ,j)) have not appeared before in other transactions. 11
If they have, then we can be sure we are witnessing an attempt to re-spend an output (Caπ,j,Koπ,j).
8 Building and verifying the signature excludes the term ri,2Hp(Ci,j−C′aπ,j) +ci ˜Kzj .
9 The advantage of signing inputs individually is that the set of real inputs and commitments to zero need not
be placed at the same index π, as they would be in the aggregated case. This means even if one input’s origin
becomes identifiable, the other inputs’ origins would not. The old transaction type RCTTypeFull used aggregated
ring signatures, combining all rings into one, and as we understand it was deprecated for that reason.
10 The src/ringct/
rctSigs.cpp
get pre
mlsag hash()
actual message is m =H(H(tx prefix),H(ss),H(range proofs)) where:
tx prefix ={transaction era version (i.e. RingCT = 2), inputs {ring member key offsets, key images}, outputs
{one-time addresses}, extra{transaction public key, payment ID or encoded payment ID, misc.}}
ss ={transaction type ( RCTTypeBulletproof2 = ‘4’), transaction fee, pseudo output commitments for inputs,
ecdhInfo (encrypted amounts), output commitments}.
See Appendix A regarding this terminology.
11 Verifiers must also check the key image is a member of the generator’s subgroup (recall Section 3.4).
CHAPTER 6. MONERO RING CONFIDENTIAL TRANSACTIONS (RINGCT) 52
6.2.4 Space requirements
MLSAG signature (inputs)
From Section 3.5 we recall that an MLSAG signature in this context would be expressed as
σj(m) = (c1,r 1,1,r 1,2,...,r v+1,1,rv+1,2) with ˜Koj
As a legacy of CryptoNote, the values ˜Koj are not referred to as part of the signature, but rather as
images of the private keyskoπ,j. These key images are normally stored separately in the transaction
structure, as they are used to detect double-spending attacks.
With this in mind and assuming point compression (Section 2.4.2), since each ring Rj contains
(v + 1)· 2 keys, an input signature σj will require (2(v + 1) + 1)· 32 bytes. On top of this, the key
image ˜Koπ,j and the pseudo output commitment C′aπ,j leave a total of (2(v + 1) + 3)· 32 bytes per
input.
To this value we would need additional space to store the ring member offsets in the blockchain (see
Appendix A). These offsets are used by verifiers to find each MLSAG signature’s ring members’
output keys and commitments in the blockchain, and are stored as variable length integers, hence
we can not exactly quantify the space needed. 12,13,14
Verifying
src/ringct/
rctSigs.cpp
verRctMG-
Simple()
verRct-
Semantics-
Simple()
all of an RCTTypeBulletproof2 transaction’s MLSAGs includes the computation of
(Ci,j−C′aπ,j) and ( ∑jC′aj ?= ∑tCbt +fH ), and verifying key images are in G’s subgroup with
l ˜K ?= 0.
Range proofs (outputs)
An src/ringct/
bullet-
proofs.cpp
bullet-
proof
VERIFY()
aggregate Bulletproof range proof will require (2 ·⌈ log2(64·p)⌉ + 9)· 32 total bytes.
12 See [66] or [24] for an explanation of Monero’s varint data type src/common/
varint.h
. It is an integer type that uses up to 9 bytes,
and stores up to 63 bits of information.
13 Imagine src/crypto-
note basic/
cryptonote
format
utils.cpp
absolute out-
put offsets
to relative()
the blockchain contains a long list of transaction outputs. We report the indices of outputs we want to
use in rings. Now, bigger indexes require more storage space. We just need the ‘absolute’ position of one index from
each ring, and the ‘relative’ positions of the other ring members’ indices. For example, with real indices{7,11,15,20}
we just need to report {7,4,4,5}. Verifiers can compute the last index with (7+4+4+5 = 20). Ring members are
organized in ascending order of blockchain index within rings.
14 A transaction with 10 inputs using rings with 11 total members will need ((11 · 2 + 3)· 32)· 10 = 8000 bytes for
its inputs, with around 110 to 330 bytes for the offsets (there are 110 ring members).
CHAPTER 6. MONERO RING CONFIDENTIAL TRANSACTIONS (RINGCT) 53
6.3 Concept summary: Monero transactions
To summarize this chapter, and the previous two chapters, we present the main content of a
transaction, organized for conceptual clarity. A real example can be found in Appendix A.
• Type: ‘0’ is RCTTypeNull (for miners), ‘4’ is RCTTypeBulletproof2
• Inputs: for each input j∈{ 1,...,m} spent by the transaction author
– Ring member offsets : a list of ‘offsets’ indicating where a verifier can find input j’s
ring members i∈{ 1,...,v + 1} in the blockchain (includes the real input)
– MLSAG Signature : σj terms c1, and ri,1 & ri,2 for i∈{ 1,...,v + 1}
– Key image : the key image ˜Ko,aj for input j
– Pseudo output commitment : C′aj for input j
• Outputs: for each output t∈{ 0,...,p − 1} to address or subaddress (Kvt,Kst )
– One-time address : Ko,bt for output t
– Output commitment : Cbt for output t
– Encoded amount : so output owners can compute bt for output t
∗ Amount: bt⊕8Hn(“amount”,Hn(rKvB,t ))
– Range proof : an aggregate Bulletproof for all output amounts bt
∗ Proof: ΠBP = (A,S,T 1,T 2,τx,µ, L, R,a,b,t )
• Transaction fee: communicated in clear text multiplied by 1012 (i.e. atomic units, see Section
7.3.1), so a fee of 1.0 would be recorded as 1000000000000
• Extra: includes the transaction public key rG, or, if at least one output is directed to a
subaddress,rtKs,it for each subaddress’d output t andrtG for each normal address’d output
t, and maybe an encoded payment ID (should be at most one per transaction) 15
Our final one-input/one-output example transaction sounds like this: “My transaction uses trans-
action public key rG. I will spend one of the outputs in set X (note that it has a hidden amount
AX, committed to inCX). The output being spent is owned by me (I made a MSLAG signature on
the one-time addresses in X), and hasn’t been spent before (its key image ˜K has not yet appeared
in the blockchain). I will give it a pseudo output commitment C′X. I will make one output Y ,
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. My
transaction includes a transaction fee f. Please note that C′X− (CY +Cf) = 0, and that I have
signed the commitment to zero C′X−CX =zG which means the input amount equals the output
amount (AX =A′X =AY +f). My MLSAG signed all transaction data, so observers can be sure
it hasn’t been tampered with.”
15 No information stored in the ‘extra’ field is verified, though it is signed by input MLSAGs, so no tampering is
possible (except with negligible probability). The field has no limit on how much data it can store, so long as the
maximum transaction weight is respected. See [81] for more details.
CHAPTER 6. MONERO RING CONFIDENTIAL TRANSACTIONS (RINGCT) 54
6.3.1 Storage requirements
For RCTTypeBulletproof2 we need (2(v + 1) + 2)·m· 32 bytes of storage, and the aggregate
Bulletproof range proof needs (2 ·⌈ log2(64·p)⌉ + 9)· 32 bytes of storage. 16
Miscellaneous requirements:
• Input key images: m∗ 32 bytes
• One-time output addresses: p∗ 32 bytes
• Output commitments: p∗ 32 bytes
• Encoded output amounts: p∗ 8 bytes
• Transaction public key: 32 bytes normally, p∗ 32 bytes if sending to at least one subaddress.
• Payment ID: 8 bytes for an integrated address. There should be no more than one per tx.
• Transaction fee: stored as a variable length integer, so ≤ 9 bytes
• Input offsets: stored as variable length integers, so ≤ 9 bytes per offset, for m∗ (v + 1) ring
members
• Unlock time: stored as a variable length integer, so ≤ 9 bytes17
• ‘Extra’ tags: each piece of data in the ‘extra’ field (e.g. a transaction public key) begins
with a 1 byte ‘tag’, and some pieces also have a 1+ byte ‘length’; see Appendix A for more
details
16 The amount of transaction content is limited by a maximum so-called ‘transaction weight’. src/crypto-
note core/
tx pool.cpp
get trans-
action weight
limit()
Before Bulletproofs
were added in protocol v8 (and indeed currently when transactions have only two outputs) the transaction weight and
size in bytes were equivalent. The maximum weight is (0.5*300kB - CRYPTONOTE COINBASE BLOB RESERVED SIZE),
where the blob reserve (600 bytes) is intended to leave room for the miner transaction within blocks. Before v8 the
0.5x multiplier was not included, and the 300kB term was smaller in earlier protocol versions (20kB v1, 60kB v2,
300kB v5). We elaborate on these topics in Section 7.3.2.
17 Any transaction’s author can lock its outputs src/crypto-
note core/
block-
chain.cpp
is tx
spendtime
unlocked()
, rendering them unspendable until a specified block height where
it may be spent (or until a UNIX timestamp, at which time its outputs may be included in a block’s transaction’s
ring members). He only has the option to lock all outputs to the same block height. It is not clear if this offers any
meaningful utility to transaction authors (perhaps smart contracts). Miner transactions have a mandatory 60-block
lock time. As of protocol v12 normal outputs can’t be spent until after the default spendable age (10 blocks) which
is functionally equivalent to a mandatory minimum 10-block lock time. If a transaction is published in the 10 th
block with an unlock time of 25, it may be spent in the 25 th block or later. Unlock time is probably the least used
of all transaction features for normal transactions.
CHAPTER 7
The Monero Blockchain
The Internet Age has brought a new dimension to the human experience. We can correspond
with people on every corner of the planet, and an unimaginable wealth of information is at our
fingertips. Exchanging goods and services is fundamental to a peaceful and prosperous society
[96], and in the digital realm we can offer our productivity to the whole world.
Media of exchange (moneys) are essential, giving us a point of reference to an immense diversity of
economic goods that would otherwise be impossible to evaluate, and enabling mutually beneficial
interactions between people with nothing in common [96]. Throughout history there have been
many kinds of money, from seashells to paper to gold. Those were exchanged by hand, and now
money can be exchanged electronically.
In the current, by far most pervasive, model, electronic transactions are handled by third-party
financial institutions. These institutions are given custody of money and trusted to transfer it
upon request. Such institutions must mediate disputes, their payments are reversible, and they
can be censored or controlled by powerful organizations. [97]
To alleviate these drawbacks decentralized digital currencies have been engineered. 1
7.1 Digital currency
Designing a digital currency is non-trivial. There are three types: personal, centralized, or dis-
tributed. Keep in mind that a digital currency is just a collection of messages, and the ‘amounts’
recorded in those messages are interpreted as monetary quantities.
1 This chapter includes more implementation details than previous chapters, as a blockchain’s nature depends
heavily on its specific structure.
55
CHAPTER 7. THE MONERO BLOCKCHAIN 56
In the email model anyone can make coins (e.g. a message saying ‘I own 5 coins’), and anyone
can send their coins over and over to whoever has an email address. It does not have a limited
supply, nor does it prevent spending the same coins over and over (double spending).
In the video game model, where the entire currency is stored/recorded on one central database,
users rely on the custodian to be honest. The currency’s supply is un프로젝트로 돌아가기