bitcoincashorg / spec

Technical specifications
112 stars 64 forks source link

The script Opcode candidates for the next HF #40

Closed DesWurstes closed 6 years ago

DesWurstes commented 6 years ago

I've compiled all the Opcodes that Bitcoin Cash should have, to make it easier to decide.

Satoshi's removed script commands: OP_CAT, OP_SUBSTR, OP_LEFT, OP_RIGHT

OP_INVERT, OP_AND, OP_OR, OP_XOR

OP_2MUL, OP_2DIV, OP_MUL, OP_DIV, OP_MOD

OP_LSHIFT, OP_RSHIFT

(For reference purposes, those are already implemented here: https://github.com/ElementsProject/elements/blob/alpha/src/script/interpreter.cpp)

Now here are the innovative ones

OP_DATASIGVERIFY:

This script basically does what OP_CHECKSIGVERIFY does, but it does it for data on the stack rather than for the transaction. Specifically, it pops the top 3 items off the stack, the pubkeyhash, the signature, and some data and verifies that the signature is valid for the provided data and that the signature’s public key hashes to pubkeyhash. If this is invalid the transaction validation fails. If it validates the data is pushed back onto the stack for use by the rest of the script.

Description: https://medium.com/@g.andrew.stone/bitcoin-scripting-applications-decision-based-spending-8e7b93d7bdb9

OP_MERKLEBRANCHVERIFY: The combination of BIP 116 and BIP 117 yields MAST script, which would make Bitcoin's script 2.0

Implementations: https://github.com/maaku/bitcoin/tree/merkle-branch-verify https://github.com/maaku/bitcoin/tree/tail-call-semantics

OP_GROUP (too early for the may hardfork?): Simple tokens: https://bitco.in/forum/threads/buip077-enable-representative-tokens-via-op_group-on-bitcoin-cash.7501/

Have I missed something?

shadders commented 6 years ago

With respect to OP_DATASIGVERIFY: Although it mirrors the language in the medium article, the use of the term pubkeyhash is somewhat confusing. In order to verify a signature you need the signature (r,s), the original message and the public key. The pubkeyhash isn't useful here as you can't reverse it to determine the pubkey. Standard p2pkh requires the public key to be on the stack before calling OP_CHECKSIG. Verifying it matches the pubkeyhash is part of the standard p2pkh script but it is a separate operation to the signature verification.