Bitcoin Covenants: CHECKTEMPLATEVERIFY (BIP 119)

This is the first article of a series that immerses itself in individual alliance proposals that have reached a high school point that deserves a thorough break.

CheckTemplavely (CTV), presented by Jeremy Rubin with Bip 119, is the most mature and completely enriched alliance proposal, not only by the proposals that we will cover, but from all the proposals of alliance in their entirety. As I said in the introduction article to this series, there are many concerns in the ecosystem as regards alliances that are too flexible that allow things that end up having very harmful consequences for Bitcoin.

CTV has been designed specifically to limit its abilities strictly to avoid one of these concerns. First understand how CTV works, we must understand the individual parts of a bitcoin transaction.

https://www.researchgate.net/figure/a-sample-bitcoin-transotion_fig1_340234444

This is a very high level vision of a bitcoin transaction. It has inputs or coins that are not spent (UTXOS) and output, the new coins that are not expenses that the transaction will create when confirmed in a block. There are many more pieces that we will cross, but this is the highest level vision of the structure of a transaction.

Each transaction also has a number of version number for the entire transaction, indicating the applicability of new versions of rules or functionality. There is also the marker and flag, which are set on specific values ​​to indicate that the transaction uses segwit. After this is the counting of the inputs, the input number in the transaction. So real inputs come.

Each input contains a TXID of the transaction that has created the coin that is not spent spending, a vout that marks what the output in that transaction is spent, the size of scriptsig and scriptsig, which is the unlock script that demonstrates the spent input is authorized by its closing closure rules, and finally a sequence number that is used to ensure that the input has been following the rules of the Timasus that is The input existed for a number of blocks or for the period of time from its creation.

Output count is the next piece of data, the output number in the transaction. After this, the actual outputs arrive, which contain a quantity of satoshis assigned to this output, the size of scriptpubkey and the actual scriptputubkey, which is the locking script for such output. Finally, the Nlocktime field applies a Timelock value in the TimesTamp or in the height of the block that applies to the entire transaction.

Each Segwit transaction also contains a section of witnesses, in which each input has a corresponding witness containing a counting of elements of the stack, how many things will be inserted in the script stack, a field of size for each element and the element of effective data to go to the stack.

How CTV works

CTV is an operating code that allows the most elementary form of introspection and forward data that perform all the alliance proposals. It allows a script to take a 32 predefined 32 byte hash and compare it with a hash of most of the fields of the spending transaction. If the hash derived from the actual spending transaction does not correspond to the default Hash, the transaction is not valid.

The fields in which it is committed are:

  • nversion
  • nlocktime
  • Input count
  • A hash of all seques fields
  • Counting of exits
  • A hash of all outings
  • Input index (the entry place has in the transaction, 1st input, 2nd, etc.)

These are all the fields engaged by the Hash CTV, in their entirety and without any ability to choose. This is the degree of introspection that CTV enables: “The hash of these fields in the spending transaction corresponds to the insu hash in the locking screenplay for the spent”, that’s all. The hash essentially engages to the entire transaction except the actual inputs. There is a reason why the hash does not include inputs. To block an output on a 32 byte hash with CTV, you need to know the hash of the transaction you are ensuring is the only way to be spent. The input blocked with CTV spent must include this hash to be verified against CTV. This requires having the hash of that transaction Before The complete transaction is created. This is not possible.

You can also nest CTV scripts, i.e. having an initial COMT CTV script in a transaction with output that also include CTV scripts. This is what allows CTV to “carry on” the data. Everything that carries out in practice is that any data is contained in the transactions chain. You can theoretically do it at an infinite depth, but you are limited in practice to a finished depth because the nesting must be generated back from the end. This is because every level, or “hop”, must have the hash of the transaction that moves to the next one, otherwise it is not possible to create the locking script first. If you don’t already know the next transaction, you cannot generate the previous one.

What is useful to CTV

CTV allows you to limit an output so that it can be spent, according to the rules of consent, with an exact default transaction. Some of you could ask you what the big problem is, we can already pre-mean transactions. If the level of introspection is so limited that it can only make something that we can already do only pre-firm, what is the added value?

First of all, pre-operated transactions always leave the possibility that the key holders sign new transactions and spend these coins in a different way. You have to trust that the owner will not do it or eliminate the necessary key with which to sign (on which you must also trust them). CTV completely removes this trust. Once the spending transaction has been defined and the output blocked at that hash CTV is created, there is no possibility of being spent in another way, applied by consent.

Currently the only way to get around that confidence is to be involved in pre-function transactions alone using Multisig. So you can be completely sure that if you do not choose to sign one alone, it is not possible to create any valid transaction that spends a coin in a different way. The problem is that more people are involved, the more it becomes coordinating all difficult and unreliable to pre-file a transaction at the same time. Past small size becomes a totally little practical problem to solve reliably.

CTV gives people to know a series of transactions is busy without everyone having to be online at the same time to sign them. The coordination process is significantly simplified by allowing everyone to obtain the information necessary for anyone else every time they can, and once that person has everyone’s information can create the CTV transactions chain without the involvement of anyone else and everyone can verify and be sure that the correct result is the only possible.

This is incredibly precious alone, but CTV can also allow even more precious things in combination with other operational codes, which we will see in the next article.

Closing thoughts

The CTV is a strictly limited alliance that allows a degree of introspection and transport of forward data which is so limited that it does not exceed the actual function of everything that can be done with pre-operated transactions. The proposal for value is not to allow new functionality in its own right, but drastically improving the efficiency, scalability and security guarantees of what can be built currently using pre-operated transactions. This alone is a huge advantage for almost all protocols currently distributed using pre-operated transactions.

Here are some of the projects that demonstrate how completely enriched and explored this particular alliance is compared with others:

  • An example of stutxo basic payments pool.
  • An implementation of CTV Vault by James O’Beirne, who continued to propose Op_vault (which still uses CTV).
  • A proof of the pre-firmed transaction implementation from the second by Steven Roose to use CTV instead.
  • The Sapi language of Jeremy Rubin himself, a higher level language for the construction of contracts with CTV (also supports the use of pre-operated transactions).
  • Timeout Trees, a proposal for a very simple CoinPool design by John Law.
  • Numerous other possible protocols, such as optimized discreet registration contracts (DLC), non -interactive lightning channels that one part could open without the other, and even decentralized ways for miners to meet together.

CTV is an incredibly mature proposal at this point, with an addition of addition of high value and no risk of allowing anything to guide the concerns about the alliances. This should not only be considered very seriously, but in my opinion it should have been activated years ago.

Leave a Comment