Post
Topic
Board Development & Technical Discussion
Topic OP
[Tutorial] How to use OP_CHECKSIG + Taproot to spend 1-of-n puzzles
by
cmpeq
on 11/02/2024, 17:51:24 UTC
I noticed that recently there have been some questions about properly constructing signatures for OP_CHECKSIG in P2TR, so decided to make a video for the curious.

This technique can be useful for creating puzzle/other challenges (pay to ZKP =D) that cannot be frontran by folks monitoring the mempool (one unique challenge per public key/tapscript path).




Scripts from the video

Setup
Code:
docker pull qedprotocol/bitide:latest
docker run -p 1337:1337 -it --rm qedprotocol/bitide:latest


user_1_lock.basm
Code:
/*
note that the dummy signature "?2742ce32de496f3d51ddd8b57cee513e982ef66adb51324343a9ec2516281093"
can be used to test OP_CHECKSIG in the editor, but must be removed in the tapscript runner witness input before unlocking the UTXO
*/

<"?2742ce32de496f3d51ddd8b57cee513e982ef66adb51324343a9ec2516281093">
<"some other secret value">

END_EXAMPLE_WITNESS

OP_HASH160
<0xda70d9c91368cc32d8bdaf0dd82f53c07272fd17>
OP_EQUALVERIFY

<0x2742ce32de496f3d51ddd8b57cee513e982ef66adb51324343a9ec2516281093> // public key 1
OP_CHECKSIG


user_2_lock.basm
Code:
// to make a dummy signature for any public key just push a string to the stack containing a question mark followed by the hex encoded public key (x only/last 32 bytes)
<"?bee908511ef6d1c5d99ca33ea0db1fbbf313a5c3c08471702595eae888ff012b">
<"super secret value">
END_EXAMPLE_WITNESS
OP_HASH160

<0x32cac4959b6bc4aad4bc65fc7b4eab19506359b2>
OP_EQUALVERIFY

<0xbee908511ef6d1c5d99ca33ea0db1fbbf313a5c3c08471702595eae888ff012b> // public key 2
OP_CHECKSIG


Would love any feedback on other tutorials anyone may want to see or how things could be made easier to bring in newer bitcoin devs (maybe a button to generate/download a standalone js project that automates the tx with bitcoinjs?).