This is Part 6 in the technical article series about Bitcoin covenants by Cointelegraph Research. To read the previous article, click here.
Changing Bitcoin’s consensus rules is not merely a technical process. It requires that the network’s node operators, miners, developers and economic actors coordinate around a change. This coordination is difficult to achieve, which is why Bitcoin’s base layer has gradually ossified.
Researchers have spent the last several years investigating whether covenant behavior could be enforced without touching consensus rules. In May 2024, Jeremy Rubin, the original author of the OP_CTV proposal (BIP-119), offered an answer in a paper titled FE’d Up Covenants. His design proposed using functional encryption (FE) to move the covenant out of Bitcoin Script and into the signing key.
In ordinary public-key cryptography, a private key can sign any message. In hypothetical FE-based covenants, signing would be restricted to a predefined set of valid transactions. Bitcoin nodes would verify the signature with OP_CHECKSIG exactly as they do today, obviating the need for a soft fork.
Functional encryption: keys that only sign what the rules allow
Functional encryption (FE) generalizes public-key encryption. In ordinary cryptographic schemes, a private key can be used to fully decrypt a ciphertext and arrive at the plaintext. In FE, a master secret is instead used to issue subsidiary functional keys, each of which reveals only one chosen function of the plaintext. The holder of the functional key for a function f and the ciphertext of a secret x can compute f(x) but never gets to reveal x as a plaintext message.
In the academic literature, FE was first formalized by Dan Boneh, Amit Sahai and Brent Waters in 2011. Constructions for arbitrary functions followed from 2013, with polynomial runtime but overheads far beyond the resources of current computing technology. Furthermore, their security rested on new, untested building blocks called multilinear maps. Only in 2021 did researchers develop constructions from well-founded cryptographic assumptions, which could in principle open the door to practical implementations of FE.
The f in an FE scheme can be any feasibly computable function. However, in Bitcoin covenant constructions, f is a signing function. Its output is a Bitcoin signature for a transaction tx. Because this signature depends on both a private key and the transaction that is being signed, it takes at least two inputs, which is why Rubin’s design uses multi-input FE. For a covenant that only permits a single spending transaction, akin to OP_CTV, two inputs suffice. General, expressive constructions take more arguments, as in Rubin’s f(k, tx, program, proof).
Crucially, f does not sign directly with the private key k that is supplied in an encrypted form. Instead, the function derives a new key pair by tweaking k with a hash of the covenant’s spending policy. Signatures produced by f are valid for the tweaked public key, not for the base public key P itself.
Setting up FE-based covenants
To enable FE-based covenants from these primitives, a setup authority is required. It generates a Bitcoin key pair (the private key k and the public key P) as well as an FE key pair (the master secret msk and the FE public key mpk). It publishes P, mpk, k encrypted to mpk, and the functional key for f, which it derives from msk. The setup authority then needs to be trusted to destroy k and msk. Otherwise, it could sign spends that violate the covenant. With this setup completed, an indefinite number of new covenants may be created.
Every covenant has its own dedicated key pair, obtained by tweaking (k, P) with the spending policy. The private key of this tweaked key pair exists only inside f and is never revealed. The public key can be derived from P by anyone who knows the hash of the desired spending policy. This way, covenant receiving addresses can be generated. In practice, the receiving address would commit to a 2-of-2 script that requires a signature from a key the user controls alongside the FE signature. This is to keep unauthorized parties from triggering a transaction permitted by the covenant.

To create an FE signature for a covenant spend, the signer takes a tx that conforms to the spending policy and encrypts it to mpk. Using the encrypted tx, together with the encrypted k and the functional key published by the authority, they can then evaluate f. The function f signs tx with k tweaked by the hash of the spending policy. A transaction that breaks the spending policy of the address that holds the coins could at best be signed for some other, differently tweaked public key that does not control the funds.The function f can also be designed to block such a signature outright.

The general version of FE-based covenants with f(k, tx, program, proof) is strictly more expressive than OP_CTV. The general function proposed by Rubin takes a program that checks a condition on the…
cointelegraph.com
