2019-11-19 13:49:32 +03:00
# Introduction to Mimblewimble and Grin
2017-03-20 19:57:54 +03:00
2020-09-10 16:45:14 +03:00
*Read this in other languages: [简体中文 ](translations/intro_ZH-CN.md ), [Español ](translations/intro_ES.md ), [Nederlands ](translations/intro_NL.md ), [Русский ](translations/intro_RU.md ), [日本語 ](translations/intro_JP.md ), [Deutsch ](translations/intro_DE.md ), [Portuguese ](translations/intro_PT-BR.md ), [Korean ](translations/intro_KR.md ).*
2018-05-29 05:40:47 +03:00
2019-11-19 13:49:32 +03:00
Mimblewimble is a blockchain format and protocol that provides
2017-03-20 19:57:54 +03:00
extremely good scalability, privacy and fungibility by relying on strong
cryptographic primitives. It addresses gaps existing in almost all current
blockchain implementations.
2019-11-19 13:49:32 +03:00
Grin is an open source software project that implements a Mimblewimble
2017-03-20 19:57:54 +03:00
blockchain and fills the gaps required for a full blockchain and
cryptocurrency deployment.
The main goal and characteristics of the Grin project are:
2017-03-22 00:05:10 +03:00
* Privacy by default. This enables complete fungibility without precluding
2018-10-03 23:31:28 +03:00
the ability to selectively disclose information as needed.
2018-05-28 21:00:03 +03:00
* Scales mostly with the number of users and minimally with the number of
2019-01-05 03:57:51 +03:00
transactions (< 100 byte `kernel` ), resulting in a large space saving compared
2018-05-28 21:00:03 +03:00
to other blockchains.
2019-11-19 13:49:32 +03:00
* Strong and proven cryptography. Mimblewimble only relies on Elliptic Curve
2017-03-20 19:57:54 +03:00
Cryptography which has been tried and tested for decades.
* Design simplicity that makes it easy to audit and maintain over time.
2018-12-20 01:42:54 +03:00
* Community driven, encouraging mining decentralization.
2017-03-20 19:57:54 +03:00
2020-09-10 16:45:14 +03:00
A detailed post on the step-by-step of how Grin transactions work (with graphics) can be found [in this Medium post ](https://medium.com/@brandonarvanaghi/grin-transactions-explained-step-by-step-fdceb905a853 ).
2019-03-06 12:21:34 +03:00
2021-05-13 21:07:14 +03:00
## Tongue-Tying for Everyone
2017-03-20 19:57:54 +03:00
This document is targeted at readers with a good
understanding of blockchains and basic cryptography. With that in mind, we attempt
2019-11-19 13:49:32 +03:00
to explain the technical buildup of Mimblewimble and how it's applied in Grin. We hope
2017-11-01 01:50:36 +03:00
this document is understandable to most technically-minded readers. Our objective is
2017-03-20 19:57:54 +03:00
to encourage you to get interested in Grin and contribute in any way possible.
To achieve this objective, we will introduce the main concepts required for a good
2019-11-19 13:49:32 +03:00
understanding of Grin as a Mimblewimble implementation. We will start with a brief
2017-03-20 19:57:54 +03:00
description of some relevant properties of Elliptic Curve Cryptography (ECC) to lay the
foundation on which Grin is based and then describe all the key elements of a
2019-11-19 13:49:32 +03:00
Mimblewimble blockchain's transactions and blocks.
2017-03-20 19:57:54 +03:00
2018-10-03 23:31:28 +03:00
### Tiny Bits of Elliptic Curves
2017-03-20 19:57:54 +03:00
We start with a brief primer on Elliptic Curve Cryptography, reviewing just the
2019-11-19 13:49:32 +03:00
properties necessary to understand how Mimblewimble works and without
2017-03-20 19:57:54 +03:00
delving too much into the intricacies of ECC. For readers who would want to
2017-11-01 01:50:36 +03:00
dive deeper into those assumptions, there are other opportunities to
2017-03-20 19:57:54 +03:00
[learn more ](http://andrea.corbellini.name/2015/05/17/elliptic-curve-cryptography-a-gentle-introduction/ ).
2020-08-12 00:43:06 +03:00
An elliptic curve for the purpose of cryptography is simply a large set of points that
we will call _C_ . These points can be added and subtracted, and the result is a point on the curve _C_ . Furthermore, a point can be successively added to itself, which is represented as point multiplication by integers (also called scalars).
2019-05-15 00:05:54 +03:00
Given such a point _H_ , an integer _k_ and
2018-02-24 16:59:21 +03:00
using the scalar multiplication operation we can compute `k*H` , which is also a point on
curve _C_ . Given another integer _j_ we can also calculate `(k+j)*H` , which equals
`k*H + j*H` . The addition and scalar multiplication operations on an elliptic curve
2020-08-12 00:43:06 +03:00
maintain the distributive property of addition and multiplication:
2017-03-20 19:57:54 +03:00
(k+j)*H = k*H + j*H
2020-08-12 00:43:06 +03:00
In ECC, if we pick a (very large) number _k_ as a _private key_ , `k*H` is
considered the corresponding _public key_ . Even if one knows the
2017-03-20 19:57:54 +03:00
value of the public key `k*H` , deducing _k_ is close to impossible (or said
2017-03-22 00:05:10 +03:00
differently, while multiplication is trivial, "division" by curve points is
2017-11-01 01:50:36 +03:00
extremely difficult).
2017-03-20 19:57:54 +03:00
The previous formula `(k+j)*H = k*H + j*H` , with _k_ and _j_ both private
keys, demonstrates that a public key obtained from the addition of two private
keys (`(k+j)*H`) is identical to the addition of the public keys for each of those
two private keys (`k*H + j*H`). In the Bitcoin blockchain, Hierarchical
2019-11-19 13:49:32 +03:00
Deterministic wallets heavily rely on this principle. Mimblewimble and the Grin
2017-03-20 19:57:54 +03:00
implementation do as well.
2019-11-19 13:49:32 +03:00
### Transacting with Mimblewimble
2017-03-20 19:57:54 +03:00
2019-11-19 13:49:32 +03:00
The structure of transactions demonstrates a crucial tenet of Mimblewimble:
2017-03-20 19:57:54 +03:00
strong privacy and confidentiality guarantees.
2019-11-19 13:49:32 +03:00
The validation of Mimblewimble transactions relies on two basic properties:
2017-03-20 19:57:54 +03:00
2017-03-22 00:05:10 +03:00
* **Verification of zero sums.** The sum of outputs minus inputs always equals zero,
2018-10-03 23:31:28 +03:00
proving that the transaction did not create new funds, _without revealing the actual amounts_ .
2017-03-20 19:57:54 +03:00
* **Possession of private keys.** Like with most other cryptocurrencies, ownership of
2018-10-03 23:31:28 +03:00
transaction outputs is guaranteed by the possession of ECC private keys. However,
the proof that an entity owns those private keys is not achieved by directly signing
the transaction.
2017-03-20 19:57:54 +03:00
The next sections on balance, ownership, change and proofs details how those two
fundamental properties are achieved.
2018-10-03 23:31:28 +03:00
#### Balance
2017-03-20 19:57:54 +03:00
2017-11-08 00:49:03 +03:00
Building upon the properties of ECC we described above, one can obscure the values
2017-03-20 19:57:54 +03:00
in a transaction.
2020-09-10 16:45:14 +03:00
If _v_ is the value of a transaction input or output and _H_ a point on the elliptic curve _C_ , we can simply
2017-03-22 00:05:10 +03:00
embed `v*H` instead of _v_ in a transaction. This works because using the ECC
2017-03-20 19:57:54 +03:00
operations, we can still validate that the sum of the outputs of a transaction equals the
sum of inputs:
2017-03-22 00:05:10 +03:00
v1 + v2 = v3 => v1*H + v2*H = v3*H
2017-03-20 19:57:54 +03:00
Verifying this property on every transaction allows the protocol to verify that a
transaction doesn't create money out of thin air, without knowing what the actual
2020-08-12 00:43:06 +03:00
values are. Note that knowing *v1* (from a previous transaction for example) and the resulting `v1*H` reveals all outputs with
value *v1* across the blockchain. We introduce a second point _G_ on the same elliptic curve
2019-02-28 01:20:20 +03:00
(practically _G_ is just another generator point on the same curve group as _H_ ) and
2017-06-18 06:17:20 +03:00
a private key _r_ used as a *blinding factor* .
2017-03-20 19:57:54 +03:00
An input or output value in a transaction can then be expressed as:
2017-03-22 00:05:10 +03:00
r*G + v*H
2017-03-20 19:57:54 +03:00
Where:
2019-02-28 01:20:20 +03:00
* _r_ is a private key used as a blinding factor, _G_ is a point on the elliptic curve _C_ and
2020-08-12 00:43:06 +03:00
the point `r*G` is the public key for _r_ (using _G_ as generator point).
2019-02-28 01:20:20 +03:00
* _v_ is the value of an input or output and _H_ is another point on the elliptic curve _C_ ,
together producing another public key `v*H` (using _H_ as generator point).
2017-03-20 19:57:54 +03:00
2017-03-22 00:05:10 +03:00
Neither _v_ nor _r_ can be deduced, leveraging the fundamental properties of Elliptic
Curve Cryptography. `r*G + v*H` is called a _Pedersen Commitment_ .
2017-03-20 19:57:54 +03:00
2019-02-01 14:01:26 +03:00
As an example, let's assume we want to build a transaction with two inputs and one
2017-05-01 06:00:40 +03:00
output. We have (ignoring fees):
2017-03-20 19:57:54 +03:00
2020-02-04 23:50:06 +03:00
* *vi1* and *vi2* as input values.
* *vo3* as output value.
2017-03-20 19:57:54 +03:00
Such that:
vi1 + vi2 = vo3
Generating a private key as a blinding factor for each input value and replacing each value
with their respective Pedersen Commitments in the previous equation, we obtain:
2017-03-22 00:05:10 +03:00
(ri1*G + vi1*H) + (ri2*G + vi2*H) = (ro3*G + vo3*H)
2017-03-20 19:57:54 +03:00
Which as a consequence requires that:
2017-03-22 00:05:10 +03:00
ri1 + ri2 = ro3
2017-03-20 19:57:54 +03:00
2019-11-19 13:49:32 +03:00
This is the first pillar of Mimblewimble: the arithmetic required to validate a
2017-03-20 19:57:54 +03:00
transaction can be done without knowing any of the values.
As a final note, this idea is actually derived from Greg Maxwell's
2019-01-07 13:03:33 +03:00
[Confidential Transactions ](https://elementsproject.org/features/confidential-transactions/investigation ),
2020-09-10 16:45:14 +03:00
which is itself derived from an
[Adam Back proposal for homomorphic values ](https://bitcointalk.org/index.php?topic=305791.0 )
2019-02-28 01:20:20 +03:00
applied to Bitcoin.
2017-03-20 19:57:54 +03:00
2018-10-03 23:31:28 +03:00
#### Ownership
2017-03-20 19:57:54 +03:00
In the previous section we introduced a private key as a blinding factor to obscure the
2019-11-19 13:49:32 +03:00
transaction's values. The second insight of Mimblewimble is that this private
2017-03-20 19:57:54 +03:00
key can be leveraged to prove ownership of the value.
2018-09-06 10:09:15 +03:00
Alice sends you 3 coins and to obscure that amount, you chose 28 as your
2020-08-12 00:43:06 +03:00
blinding factor (note that in practice the blinding factor, being a private key, is an
2017-03-20 19:57:54 +03:00
extremely large number). Somewhere on the blockchain, the following output appears and
should only be spendable by you:
2018-08-29 14:54:33 +03:00
X = 28*G + 3*H
2017-03-20 19:57:54 +03:00
2020-08-12 00:43:06 +03:00
_X_, the addition result, is visible to everyone. The value 3 is only known to you and Alice,
2018-08-29 14:54:33 +03:00
and 28 is only known to you.
2017-03-20 19:57:54 +03:00
2018-08-29 14:54:33 +03:00
To transfer those 3 coins again, the protocol requires 28 to be known somehow.
2017-03-20 19:57:54 +03:00
To demonstrate how this works, let's say you want to transfer those 3 same coins to Carol.
2017-11-01 01:50:36 +03:00
You need to build a simple transaction such that:
2017-03-20 19:57:54 +03:00
Xi => Y
2019-02-28 01:20:20 +03:00
Where _Xi_ is an input that spends your _X_ output and _Y_ is Carol's output. There is no way to build
2018-08-29 14:54:33 +03:00
such a transaction and balance it without knowing your private key of 28. Indeed, if Carol
2017-03-20 19:57:54 +03:00
is to balance this transaction, she needs to know both the value sent and your private key
so that:
2018-08-29 14:54:33 +03:00
Y - Xi = (28*G + 3*H) - (28*G + 3*H) = 0*G + 0*H
2017-03-20 19:57:54 +03:00
By checking that everything has been zeroed out, we can again make sure that
no new money has been created.
2020-08-12 00:43:06 +03:00
Wait! Stop! Now you know the private keys in Carol's output (which, in this case, must
2017-03-20 19:57:54 +03:00
be the same as yours to balance out) and so you could
steal the money back from Carol!
2018-08-29 14:54:33 +03:00
To solve this, Carol uses a private key of her choosing.
She picks 113 say, and what ends up on the blockchain is:
2017-03-20 19:57:54 +03:00
2018-10-03 23:31:28 +03:00
Y - Xi = (113*G + 3*H) - (28*G + 3*H) = 85*G + 0*H
2017-03-20 19:57:54 +03:00
2020-08-12 00:43:06 +03:00
Now the transaction no longer sums to zero and we have an _excess value_ (85), which is the result of the summation (and correspondingly subtraction) of all blinding factors. Note that `85*G` is a valid public key for the generator point _G_ .
2017-03-20 19:57:54 +03:00
2020-08-12 00:43:06 +03:00
Therefore, the protocol needs to verify that the transacting parties collectively can produce the private key (85 in the above example) for the resulting point `Y - Xi` (this should be the corresponding public key, for generator point _G_ ; `85*G` in the above example).
A simple way of doing so is by using the public key `Y - Xi` (`85*G`) to verify a signature, that was signed using the excess value (85). This ensures that:
2019-02-28 01:20:20 +03:00
2020-08-12 00:43:06 +03:00
* The transacting parties collectively can produce the private key (the excess value) for the public key (`Y - Xi`).
* The sum of _values_ in the outputs minus the sum of _values_ in the inputs is zero (otherwise there would be no correspondence between private and public keys, which is exactly the reason for having a signature).
2017-03-20 19:57:54 +03:00
2018-08-29 14:54:33 +03:00
This signature, attached to every transaction, together with some additional data (like mining
fees), is called a _transaction kernel_ and is checked by all validators.
2017-03-20 19:57:54 +03:00
2018-10-03 23:31:28 +03:00
#### Some Finer Points
2017-03-20 19:57:54 +03:00
This section elaborates on the building of transactions by discussing how change is
introduced and the requirement for range proofs so all values are proven to be
2019-11-19 13:49:32 +03:00
non-negative. Neither of these are absolutely required to understand Mimblewimble and
2018-02-20 20:04:56 +03:00
Grin, so if you're in a hurry, feel free to jump straight to
2018-10-03 23:31:28 +03:00
[Putting It All Together ](#putting-it-all-together ).
2017-03-20 19:57:54 +03:00
2018-10-03 23:31:28 +03:00
##### Change
2017-03-20 19:57:54 +03:00
Let's say you only want to send 2 coins to Carol from the 3 you received from
2018-08-29 14:54:33 +03:00
Alice. To do this you would send the remaining 1 coin back to yourself as change.
You generate another private key (say 12) as a blinding factor to
protect your change output. Carol uses her own private key as before.
2017-03-20 19:57:54 +03:00
2018-08-29 14:54:33 +03:00
Change output: 12*G + 1*H
Carol's output: 113*G + 2*H
2017-03-20 19:57:54 +03:00
2018-08-29 14:54:33 +03:00
What ends up on the blockchain is something very similar to before.
And the signature is again built with the excess value, 97 in this example.
2017-03-20 19:57:54 +03:00
2018-08-29 14:54:33 +03:00
(12*G + 1*H) + (113*G + 2*H) - (28*G + 3*H) = 97*G + 0*H
2017-03-20 19:57:54 +03:00
2018-10-03 23:31:28 +03:00
##### Range Proofs
2017-03-20 19:57:54 +03:00
In all the above calculations, we rely on the transaction values to always be positive. The
introduction of negative amounts would be extremely problematic as one could
create new funds in every transaction.
For example, one could create a transaction with an input of 2 and outputs of 5
2020-02-04 23:50:06 +03:00
and -3 and still obtain a well-balanced transaction. This can't be easily detected because even if _x_ is
2019-02-28 01:20:20 +03:00
negative, the corresponding point `x*H` on the curve looks like any other.
2017-03-20 19:57:54 +03:00
2019-11-19 13:49:32 +03:00
To solve this problem, Mimblewimble leverages another cryptographic concept (also
2017-03-20 19:57:54 +03:00
coming from Confidential Transactions) called
range proofs: a proof that a number falls within a given range, without revealing
the number. We won't elaborate on the range proof, but you just need to know
2020-08-12 00:43:06 +03:00
that for any `r*G + v*H` we can build a proof that shows that _v_ is non-negative and does not overflow.
2017-03-20 19:57:54 +03:00
2020-02-04 23:50:06 +03:00
It's also important to note that range proofs for both the blinding factor and the values are needed. The reason for this
is that it prevents a censoring attack where a third party would be able to lock UTXOs without knowing their private keys
by creating a transaction such as the following:
2019-03-26 21:40:35 +03:00
2020-02-04 23:50:06 +03:00
Carol's UTXO: 113*G + 2*H
Attacker's output: (113 + 99)*G + 2*H
2019-03-26 21:40:35 +03:00
2020-02-04 23:50:06 +03:00
which can be signed by the attacker because Carol's blinding factor cancels out in the equation `Y - Xi` :
Y - Xi = ((113 + 99)*G + 2*H) - (113*G + 2*H) = 99*G
2020-09-10 16:45:14 +03:00
2020-02-04 23:50:06 +03:00
This output (`(113 + 99)*G + 2*H`) requires that both the numbers 113 and 99 are known in order to be spent; the attacker
would thus have successfully locked Carol's UTXO. The requirement for a range proof for the blinding factor prevents this
because the attacker doesn't know the number 113 and thus neither (113 + 99). A more detailed description of range proofs is further detailed in the [range proof paper ](https://eprint.iacr.org/2017/1066.pdf ).
2017-09-07 01:38:55 +03:00
2018-10-03 23:31:28 +03:00
#### Putting It All Together
2017-03-20 19:57:54 +03:00
2019-11-19 13:49:32 +03:00
A Mimblewimble transaction includes the following:
2017-03-20 19:57:54 +03:00
* A set of inputs, that reference and spend a set of previous outputs.
* A set of new outputs that include:
2020-09-10 16:45:14 +03:00
* A blinding factor *r* and a value *v* used for scalar multiplication for the curve
2020-08-12 00:43:06 +03:00
points G,H correspondingly, and subsequently summed to be `r*G + v*H` .
2020-02-04 23:50:06 +03:00
* A range proof that among other things shows that *v* is non-negative.
2020-08-12 00:43:06 +03:00
* A transaction fee in cleartext.
* A signature signed with the excess value (the sum of all
output values and the fee minus the input values) as the private key.
2017-03-20 19:57:54 +03:00
2018-10-03 23:31:28 +03:00
### Blocks and Chain State
2017-03-20 19:57:54 +03:00
2020-02-04 23:50:06 +03:00
We explained above how Mimblewimble transactions can provide
2017-03-20 19:57:54 +03:00
strong anonymity guarantees while maintaining the properties required for a valid
2017-11-01 01:50:36 +03:00
blockchain, i.e., a transaction does not create money and proof of ownership
2017-03-20 19:57:54 +03:00
is established through private keys.
2019-11-19 13:49:32 +03:00
The Mimblewimble block format builds on this by introducing one additional
concept: _cut-through_ . With this addition, a Mimblewimble chain gains:
2017-03-20 19:57:54 +03:00
* Extremely good scalability, as the great majority of transaction data can be
2017-11-01 01:50:36 +03:00
eliminated over time, without compromising security.
* Further anonymity by mixing and removing transaction data.
2017-03-20 19:57:54 +03:00
2018-10-03 23:31:28 +03:00
#### Transaction Aggregation
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
Recall that a transaction consists of the following:
2018-10-03 23:31:28 +03:00
2020-08-12 00:43:06 +03:00
* a set of inputs that reference and spend a set of previous outputs
2020-02-04 23:50:06 +03:00
* a set of new outputs
* a transaction kernel consisting of:
2020-08-12 00:43:06 +03:00
* kernel excess (the public key corresponding to the excess value)
* transaction signature signed by the excess value (and verifies with the kernel excess)
2018-06-25 23:14:48 +03:00
2021-05-13 21:07:14 +03:00
(The presentation above did not explicitly include the kernel excess in the transaction, because it can be computed from the inputs and outputs. This paragrpah shows the benefit in including it, for aggregation within block construction.)
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
We can say the following is true for any valid transaction (ignoring fees for simplicity):
2018-06-25 23:14:48 +03:00
2018-10-03 23:31:28 +03:00
sum(outputs) - sum(inputs) = kernel_excess
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
The same holds true for blocks themselves once we realize a block is simply a set of aggregated inputs, outputs and transaction kernels. We can sum the outputs, subtract the inputs from it and equating the resulting Pedersen commitment to the sum of the kernel excesses:
2018-06-25 23:14:48 +03:00
2018-10-03 23:31:28 +03:00
sum(outputs) - sum(inputs) = sum(kernel_excess)
2018-06-25 23:14:48 +03:00
2020-08-12 00:43:06 +03:00
Simplifying slightly (again ignoring transaction fees), we can say that Mimblewimble blocks can be treated exactly as Mimblewimble transactions.
2018-06-25 23:14:48 +03:00
2018-10-03 23:31:28 +03:00
##### Kernel Offsets
2018-06-25 23:14:48 +03:00
2020-08-12 00:43:06 +03:00
There is a subtle problem with Mimblewimble blocks and transactions as described above. It is possible (and in some cases trivial) to reconstruct the constituent transactions in a block. This is clearly bad for privacy. This is the "subset" problem: given a set of inputs, outputs and transaction kernels, a subset of these will recombine to reconstruct a valid transaction.
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
Consider the following two transactions:
2018-06-25 23:14:48 +03:00
2018-10-03 23:31:28 +03:00
(in1, in2) -> (out1), (kern1)
(in3) -> (out2), (kern2)
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
We can aggregate them into the following block (or aggregate transaction):
2018-06-25 23:14:48 +03:00
2018-10-03 23:31:28 +03:00
(in1, in2, in3) -> (out1, out2), (kern1, kern2)
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
It is trivially easy to try all possible permutations to recover one of the transactions (where it successfully sums to zero):
2018-06-25 23:14:48 +03:00
2018-10-03 23:31:28 +03:00
(in1, in2) -> (out1), (kern1)
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
We also know that everything remaining can be used to reconstruct the other valid transaction:
2018-06-25 23:14:48 +03:00
2018-10-03 23:31:28 +03:00
(in3) -> (out2), (kern2)
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
Remember that the kernel excess `r*G` simply is the public key of the excess value *r* . To mitigate this we redefine the kernel excess from `r*G` to `(r-kernel_offset)*G` and distribute the _kernel offset_ to be included with every transaction kernel. The kernel offset is thus a blinding factor that needs to be added to the excess value to ensure the commitments sum to zero:
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
sum(outputs) - sum(inputs) = r*G = (r-kernel_offset)*G + kernel_offset*G
2020-09-10 16:45:14 +03:00
2020-02-04 23:50:06 +03:00
or alternatively
2018-06-25 23:14:48 +03:00
2020-02-04 23:50:06 +03:00
sum(outputs) - sum(inputs) = kernel_excess + kernel_offset*G
2020-09-10 16:45:14 +03:00
2020-08-12 00:43:06 +03:00
For a commitment `r*G + 0*H` with the offset `a` , the transaction is signed with `(r-a)` and *a* is published so that `r*G` could be computed in order to verify the validity of the transaction: given the kernel excess (recall that it is given as part of the transaction kernel) `(r-a)*G` and the offset `a` , one computes `a*G` and obtains `(r-a)*G + a*G = r*G` .
During block construction all kernel offsets are summed to generate a _single_ aggregate kernel offset to cover the whole block. The kernel offset for any individual transaction is then unrecoverable and the subset problem is solved.
2018-06-25 23:14:48 +03:00
2018-10-03 23:31:28 +03:00
#### Cut-through
2017-03-20 19:57:54 +03:00
Blocks let miners assemble multiple transactions into a single set that's added
to the chain. In the following block representations, containing 3 transactions,
we only show inputs and
outputs of transactions. Inputs reference outputs they spend. An output included
in a previous block is marked with a lower-case x.
I1(x1) --- O1
|- O2
I2(x2) --- O3
I3(O2) -|
I4(O3) --- O4
|- O5
We notice the two following properties:
2020-02-04 23:50:06 +03:00
* Within this block, some outputs are directly spent by following inputs (*I3*
spends *O2* and *I4* spends *O3* ).
* The structure of each transaction does not actually matter. Since all transactions
2018-10-03 23:31:28 +03:00
individually sum to zero, the sum of all transaction inputs and outputs must be zero.
2017-03-20 19:57:54 +03:00
Similarly to a transaction, all that needs to be checked in a block is that ownership
2020-02-04 23:50:06 +03:00
has been proven (which comes from the _transaction kernels_ ) and that the whole block did
not create any coins (other than what's allowed as the mining reward).
2017-03-20 19:57:54 +03:00
Therefore, matching inputs and outputs can be eliminated, as their contribution to the overall
sum cancels out. Which leads to the following, much more compact block:
I1(x1) | O1
I2(x2) | O4
| O5
Note that all transaction structure has been eliminated and the order of inputs and
2020-02-04 23:50:06 +03:00
outputs does not matter anymore. However, the sum of all inputs and outputs is still guaranteed to be zero.
2017-03-20 19:57:54 +03:00
A block is simply built from:
* A block header.
* The list of inputs remaining after cut-through.
* The list of outputs remaining after cut-through.
2020-08-12 00:43:06 +03:00
* A single kernel offset (sum of all kernel offsets) to cover the full block.
2017-03-20 19:57:54 +03:00
* The transaction kernels containing, for each transaction:
2020-08-12 00:43:06 +03:00
* The public key `(r-a)*G` , which is the (modified) kernel excess.
* The signatures generated using the (modified) excess value `(r-a)` as the private (signing) key.
2017-03-20 19:57:54 +03:00
* The mining fee.
2020-09-10 16:45:14 +03:00
The block contents satisfy:
2020-08-12 00:43:06 +03:00
sum(outputs) - sum(inputs) = sum(kernel_excess) + kernel_offset*G
2019-11-19 13:49:32 +03:00
When structured this way, a Mimblewimble block offers extremely good privacy
2017-03-20 19:57:54 +03:00
guarantees:
2018-06-25 23:14:48 +03:00
* Intermediate (cut-through) transactions will be represented only by their transaction kernels.
2020-02-04 23:50:06 +03:00
* All outputs look the same: very large numbers that are impossible to
meaningfully differentiate from one another. If someone wants to exclude a specific output, they'd have
2018-10-03 23:31:28 +03:00
to exclude all.
2020-02-04 23:50:06 +03:00
* All transaction structure has been removed, making it impossible to tell which inputs and outputs match.
2017-03-20 19:57:54 +03:00
And yet, it all still validates!
2018-10-03 23:31:28 +03:00
#### Cut-through All The Way
2017-03-20 19:57:54 +03:00
2020-02-04 23:50:06 +03:00
Going back to the previous example block, outputs *x1* and *x2* , spent by *I1* and
*I2*, must have appeared previously in the blockchain. So after the addition of
this block, those outputs as well as *I1* and *I2* can also be removed from the
blockchain as they now are intermediate transactions.
2017-03-20 19:57:54 +03:00
2020-02-04 23:50:06 +03:00
We conclude that the chain state (excluding headers) at any point
2017-03-20 19:57:54 +03:00
in time can be summarized by just these pieces of information:
1. The total amount of coins created by mining in the chain.
2019-11-26 16:57:01 +03:00
1. The complete set of unspent outputs.
1. The transactions kernels for each transaction.
2017-03-20 19:57:54 +03:00
The first piece of information can be deduced just using the block
2020-09-10 16:45:14 +03:00
height.
2020-02-04 23:50:06 +03:00
Both the UTXOs and the
transaction kernels are extremely compact. This has two important consequences:
2017-03-20 19:57:54 +03:00
2020-09-10 16:45:14 +03:00
* The blockchain a node needs to maintain is very small (on the
2020-02-04 23:50:06 +03:00
order of a few gigabytes for a bitcoin-sized blockchain, and
2018-10-03 23:31:28 +03:00
potentially optimizable to a few hundreds of megabytes).
2020-02-04 23:50:06 +03:00
* When a new node joins the network the amount of
information that needs to be transferred is very small.
2017-03-20 19:57:54 +03:00
2020-02-04 23:50:06 +03:00
In addition, the UTXO set cannot be tampered with. Adding or removing even
one input or output would change the sum of the transactions to be something other than zero.
2017-03-20 19:57:54 +03:00
2018-10-03 23:31:28 +03:00
### Conclusion
2017-03-20 19:57:54 +03:00
2019-11-19 13:49:32 +03:00
In this document we covered the basic principles that underlie a Mimblewimble
2020-08-12 00:43:06 +03:00
blockchain. By using addition of elliptic curve points, we're
2017-03-20 19:57:54 +03:00
able to build transactions that are completely opaque but can still be properly
validated. And by generalizing those properties to blocks, we can eliminate a large
amount of blockchain data, allowing for great scaling and fast sync of new peers.