text
stringlengths
0
1.08k
In the next paragraphs, we will focus on client-side validation combined with the above construction of a single-use seal, showing them step by step trough the usual cryptographic characters: Alice, who deals with a seal operation, and Bob as an observer.
1. First of all, Alice has a [UTXO](https://docs.rgb.info/annexes/glossary#utxo) **that is linked to some client-side validated data** known only by her.
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-b07b6a06618ac32fda4ff6b22a476935da9e4e99%2Ftxo2-1.png?alt=media" alt=""><figcaption><p><strong>A seal definition is applied to a specific Bitcoin UTXO.</strong></p></figcapti...
2. Alice informs Bob that the spending of these UTXO represents a sign that some seal was closed.
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-71ec62ac2447fcaa8a52d3cfe1a62d1247dea3ad%2Ftxo2-2.png?alt=media" alt=""><figcaption><p><strong>The UTXO is associated to some meaning agreed between Alice and Bob.</strong></...
3. Once Alice spends her UTXO, only Bob knows that this event has some additional meaning and consequences, even though everyone (i.e. the Bitcoin Blockchain audience) can see it.
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-5172325cede4eb8ece345c27b40f7810dc540864%2Ftxo2-3.png?alt=media" alt=""><figcaption><p><strong>The spending event of the UTXO triggers some meaningful consequences for the pa...
4. In fact, the UTXO spent by Alice through the [witness transaction](https://docs.rgb.info/annexes/glossary#witness-transaction) contains a commitment to a change in the client-side validated data. By passing the original data to Bob, she is able to prove him that it is properly referenced by the commitment that Alice...
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-71180ca0f842bc73bbc7399549ca1edaa5a16532%2Ftxo2-4.png?alt=media" alt=""><figcaption><p><strong>Alice can prove to Bob deterministically the uniqueness of the message committe...
The key point of using the single-use seal in combination with client-side validation is the uniqueness of the spending event and the data committed (i.e., the message) in it, which cannot be changed in the future. The whole operation can be summarized in the following terms.
<figure><img src="https://160813645-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaUAGORrT1fl6qzaZSTKt%2Fuploads%2Fgit-blob-dbf6ab85d6210c537191c0793d443d37f12a65ed%2Ftxo2-5.png?alt=media" alt=""><figcaption><p><strong>The UTXO being spent represents the seal closing. A precise kind of transaction...
The next important step is to illustrate precisely how the two commitment schemes adopted in RGB protocol, **Opret** and **Tapret**, work and which features they must meet, particularly concerning commitment determinism.
***
# Deterministic Bitcoin Commitments - DBC
For RGB commitment operations, the main requirement for a Bitcoin commitment scheme to be valid is that:
> The witness transaction must provably contain a single commitment.
With this requirement, it is not possible to construct an "alternative history" related to client-side data commitment in the same transaction. Thus, the message around which the single-use seal is closed is unique. To meet the above requirement, regardless of the number of outputs in a transaction, *one and only one o...
> The only valid output that can contain an RGB message commitment is the first DBC-compatible output, i.e. the first that has either:
>
> 1. an OP\_RETURN spending script; in this case it will encode its Opret commitment there
> 2. a taproot spending script; in this case it will encode its Tapret commitment in the corresponding taproot tree
It is worth observing that a transaction **only contains either a single** `Opret` **OR a single** `Tapret` commitment in the first applicable output. This approach guarantees uniqueness of the seal closing strategy without committing to it at seal creation, allowing to avoid the complexity of transfers involving multi...
***
# Opret
This represents the simplest and most straightforward scheme. The commitment is inserted into the first `OP_RETURN` output of the [witness transaction](https://docs.rgb.info/annexes/glossary#witness-transaction) in the following way:
```
34-byte_Opret_Commitment =
OP_RETURN OP_PUSHBYTE_32 <mpc::Commitment>
|_________| |______________| |_________________|
1-byte 1-byte 32 bytes
```
`mpc::Commitment` is the 32-byte Tagged hash resulting from the [MPC tree](https://docs.rgb.info/multi-protocol-commitments-mpc#mpc-tagged-hash) which is covered in detail [later](https://docs.rgb.info/commitment-layer/multi-protocol-commitments-mpc). Hence an opret commitment will have a total size of 34 bytes.
***
# Tapret
The `Tapret` scheme is a more complex form of deterministic commitment and represents an improvement in terms of chain footprint and privacy of contract operations. The main idea of this application is to hide the commitment within the `Script Path Spend` of a [taproot transaction](https://github.com/bitcoin/bips/blob/...
First, before describing how the commitment is actually embedded in a taproot transaction, we will show the exact **form of the commitment which must match exactly a 64-byte string size** constructed as follows:
```
64-byte_Tapret_Commitment =
OP_RESERVED ... ... .. OP_RESERVED OP_RETURN OP_PUSHBYTE_33 <mpc::Commitment> <Nonce>
|___________________________________| |_________| |______________| |_______________| |______|
OP_RESERVED x 29 times = 29 bytes 1 byte 1 byte 32 bytes 1 byte
|________________________________________________________________| |_________________________|
TAPRET_SCRIPT_COMMITMENT_PREFIX = 31 bytes MPC commitment + NONCE = 33 bytes
```
Thus the 64-byte `Tapret` commitment is an `Opret` commitment preceded by 29 bytes of the `OP_RESERVED` operator and to which is added a 1-byte `Nonce` whose usefulness will be addressed [later](#nonce-optimization).
In order to preserve highest degree of implementation flexibility, privacy and scalability, **the Tapret scheme is designed to integrate many different cases that occur according to the user's bitcoin spending needs**. Specifically we distinguish the following Tapret scenarios:
* **Single incorporation** of a Tapret commitment into a taproot transaction **without a pre-existing Script Path Spend structure**.
* **Integration** of a Tapret commitment into a taproot transaction **containing a pre-existing Script Path Spend structure**.
We will analyze each of these scenarios in depth in the next paragraphs.
## **Tapret Incorporation without pre-existing Script Path Spend**
In this first scenario, we start with a Taproot Output Key `Q` consisting only of an Internal Key `P` and **no Spending script path**:
```
+---+ +---+ +---+ +---+
| Q | = | P | + | m | * | G |
+---+ +---+ +-^-+ +---+
|
+-------------+
| tH_TWEAK(P) |
+-------------+
```