Skip to content

RCP-250113A: Unify single-use seals #16

@dr-orlovsky

Description

@dr-orlovsky
author: @dr-orlovsky
layers: consensus
targets: v0.12
breaking: consensus

Background

RGB since v0.7 (introduction of taproot-based commitment scheme called tapret, released in June 2022) allows two commitment schemes. The reason was the following:

  1. tapret commitments save on transaction cost and privacy;
  2. but OP_RETURN based commitments opret are needed for Lightning and hardware wallets.

The immediate issue appeared: if we have two commitment schemes, nothing prevents from creating two distinct single-use seals under each of commitment schemes using the same UTXO. And with that a wallet gets blocked and have no choice other than to burn some assets (all assets under one of commitment schemes). Thus, we had to allow two, not one commitment and anchor per bitcoin witness transaction, so transaction may have both tapret and opret commitments present.

In autumn 2023 in Viareggio we also have found a vulnerability of simultaneous use of tapret and opret in v0.10. So, before Viareggio 2023, in v0.9 and v0.10 we thought “well, we just need to prohibit a wallet to create different seal types”. But it was naive. The real problem is that an adversary can do an inflation attack, by creating two commitments in one transaction and never exposing them both: the first in taproot and the other in an op-Return output following taproot (since he can claim the first taproot do not have tapret, while it actually has).

So the moment you have two commitment schemes you must assume they are both present in the same transaction. I spent three months fighting it, got v0.11 with HUGE complexity of dealing with different double commitment cases [1], - and we spent whole 2024 testing and debugging it.

In Lugano last Autumn we decided to make contracts monotonic on commitments, so we can be sure there are no inflation bugs possible. In v0.12 I have implemented it, and everything was fine (and much simpler) in the consensus layer (so each contract is either opret or tapret), but it has stroke back in wallet: tapret wallets need to work with both opret and tapret contracts, and other types of wallets - just with opret. Right now in v0.12 contracts commit to the seal type via generic constant parameter - which is a safety measure. It is impossible to put contracts of different seal types into the same wallet, preventing from completing tests and releasing v0.12.

Motivation

  1. Have a single RGB-related deterministic bitcoin commitment (and anchor) per witness transaction, and not two
  2. Simplify the audit and formal analysis by getting rid of multiple commitment schemes and supporting just one (per blockchain)
  3. Reduce codebase
  4. Reduce attack surface

Proposal

Unification means that from now on in v0.12 there will be not two commitment schemes (seal closiing methods), but a single one. Thus, neither contracts nor seal definitions commit to a closing method, and receiver doesn't need to provide one via invoice. Witness transaction will always have just a single anchor and commitment - and not two as before. This is a great simplification, since reduces attack surface by a lot, and simplifies a lot of code, business logic and workflows.

The single unified commitment scheme can be described as "look for the first explicit commitment in OP_RETURN output or assume tapret commitment in the first taproot output".

The algorithm details are the following:

  1. iterate over tx outputs
  2. if an output is OP_RETURN, check opret commitment to all the seals (remember seals definitions are commitment-agnostic). Stop
  3. if an output is taproot, assume tapret commitment, and require proof. Stop
  4. if neither, process to the next output

Rationale

Unification of commitments results in:

  • removal of a concept of a seal closing method/commitment scheme (since just one exists);
  • removal of contract commitments to the seal closing method;
  • removal of method field in seal definition (anyway already happened in v0.2);
  • removal of method from invoices;
  • differentiation of contracts into two unrelated sets (opret and tapret), which would be never able to interact (basically two independent "RGB protocols");
  • differentiation between tapret and opret wallets, providing a single RGB wallet API;
  • all contracts will have access to Lightning network (before it was not possible for tapret contracts);
  • all contracts will have access a simplified use of hardware wallets via bitcoin apps (before it was not possible for tapret contracts).

FAQ

  • No, this doesn't introduce requirement for a specific ordering of outputsl; this requirement was as well present before for opret and tapret schemes;
  • No, this doesn't mean a client software needs to change; since it is related to a new v0.12 version, which is a consensus breaking and requires changes to software integration anyway.

Implementation

Tracking issue for the implementation in v0.12 is RGB-WG/rgb#275

Appendix

[1] The complexities of two commitment schemes

image

[2] Ideas tried alognside the idea of unification

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-pushbackConsensus-breaking changeS-implementedepicEpic task covering multiple steps of implementation

    Type

    No type

    Projects

    Status

    In review

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions