Skip to content

Specify opcodes for MATT #25

@bigspider

Description

@bigspider

Edit: Obsolete, see below for the latest attempt.


Hello, I hope it's fine if I slightly abuse this space to get feedback on my specific proposal - please let me know if this is not appreciated and I'll find a different venue.

I'm trying to formalize the exact opcodes for MATT for the purpose of implementing them for bitcoin-inquisition.

One thing that was left unspecified in the initial sketch (h/t @darosior for pointing that out) is that a way is needed to make "arguments" passed to the covenant non-malleable, if they are passed via the witness.
Building on top of Antoine Riard's PR on the annex format, I think using the annex for this purpose is the best course of action.

I would love if someone more experienced with bitcoin-core would like to help with putting together a good PR.
MATT needs your help! :)

This is what I'm planning right now for an (almost) complete set of opcodes - please let me know if you have any comments or suggestions.

MATT tentative specs

Covenant opcodes: verify or commit to data in the taproot internal key of an input/output

  • OP_CHECKINPUTCOVENANTVERIFY: let x, d be the two top elements of the stack; fail if any of x and d is not exactly 32 bytes; otherwise, check that the x is a valid x-only pubkey, and the internal pubkey P of the current input is indeed obtained by tweaking lift_x(x) with d.
  • OP_CHECKOUTPUTCOVENANTVERIFY: given a number out_i and three 32-byte hash elements x, d and taptree on top of the stack, verifies that the out_i-th output is a P2TR output with the taproot internal key computed as above, and tweaked with taptree. Fail if if any of x, d or taptree is not exactly 32 bytes.

Data manipulation:

  • OP_CAT: pop the top two stack elements, push their concatenation; fail if the concatenation is longer than a predefined limit (256 bytes?).

Additional introspection (compulsory):

Additional introspection (optional): one can probably do some interesting things without, but these would allow concepts like "pay to a contract" or "withdraw from a contract", where the contract is a covenant-encumbered UTXO.

  • OP_INSPECTNUMINPUTS and OP_INSPECTNUMOUTPUTS: push to the stack the number of inputs/outputs.
  • OP_INSPECTINPUTVALUE and OP_INSPECTOUTPUTVALUE: given an index i popped from the top of the stack, push to the stack the amount in sats of a certain input/output.

Still unresolved: as pointed out by Anthony Towns, amounts do not fit in 32-bytes; therefore, some way of enabling 64-bit maths would be desirable. It's a technicality, so it might safely be left for later.

Comments

  • OP_CHECKINPUTCOVENANTVERIFY and OP_CHECKOUTPUTCOVENANTVERIFY could be replaced with more general opcodes to inspect input/output scriptPubKey, and do some elliptic curve maths. Those are already available in Liquid, see here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions