Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Putting mintscript on chain #1781

Open
iljakuklic opened this issue Jun 15, 2024 · 0 comments
Open

Putting mintscript on chain #1781

iljakuklic opened this issue Jun 15, 2024 · 0 comments
Labels

Comments

@iljakuklic
Copy link
Contributor

iljakuklic commented Jun 15, 2024

The mintscript module is currently only used internally for verifying transactions. It is, however, designed with the possibility of putting it on chain in mind. This allows users of the blockchain to place custom spending conditions on UTXOs.

Here is a rough and probably incomplete outline of steps needed to achieve it.

Make script encodable

Encoding has to be picked. Putting Encode and Decode derive traits on script types should work fine as a starting point. Since script is a recursive data structure, a maximum depth limit should be probably imposed. There seems to be some support for this in SCALE.

Script commitment

It is most likely not a good idea to place script spending conditions directly into outputs. Rather, only a hash-commitment for spending conditions should be in the output. The full script is revealed when spent by placing it into the witness part of the transaction.

The commitment hash contains parts of the script that specify spending conditions:

  • For signatures, it's pubkey/destination. Signature is omitted.
  • For hashlocks, it's the hash challenge, not preimage
  • Timelocks are committed completely.
  • For thresholds, the number of required conditions, the total number conditions (may need some extra thought) and the merkle root of the conditions is comitted.

When spending, the commitment calculated from revealed script must be checked against the one specified in the output.

Threshold

It makes sense to only reveal the threshold conditions the spender wishes to satisfy for threshold conditions. This could be done by reusing the merkle multiproofs currently being used for multisig.

The DissatisfiedScript type is currently a placeholder for conditions the spender does not wish to (or can't) satisfy. With the merkle construction, the dissatisfied conditions are represented simply by the pruned out branches of the merkle tree.

Achieving a degree of compatibility with Bitcoin

The constructs available in mintscript closely follow the ones included in Bitcoin miniscript. It should be possible, with some effort put into the appropriate tooling, to translate miniscript into mintscript which provides a pipeline for translating a well-behaved subset of bitcoin scripts to equivalent spending conditions on Mintlayer.

Remarks

These are just ideas / suggestions, this will sure be a subject of intense subsequent discussion. Just sketching out the initial proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant