Created
February 21, 2022 06:51
-
-
Save A60AB5450353F40E/aa990c4c0012b24a8b04723bbbb3d00e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://bitauth.com/schemas/authentication-template-v0.schema.json", | |
"description": "The user pays 10,000 satoshis to get a token. They can transfer that token to use 2-of-3, then back to single sig, then deposit the token and get back their 10,000 satoshis from the parent covenant.", | |
"name": "Jason's Challenge", | |
"entities": {}, | |
"scripts": { | |
"depository_corporation": { | |
"name": "DEPOSITORY CORPORATION", | |
"script": "// # Unlocking Script\n// Token burn output index\n<0x01>\n// Part 3. of groupID preimage (genesis input parameters)\n<0x0000000001008d110100000000000000>\n// Part 1. of groupID preimage (hash of genesis input's prevout ref.)\n<0xe69b80d54c704b204143089c4e00ee86fa5a4f897878fe1ce0e6661fbc4e7067>\n// Genesis input's prevout owner (PKH)\n<0x0233bc976da9a9e30ff18b35195693b938e06eaf>\n// Genesis input's prevout satoshi amount\n<0xa086010000000000>\n// Redeem Script Raw\n<0x01177E02A9147E0376A9147B7E0388ADAB7E4c5676A9140233BC976DA9A9E30FF18B35195693B938E06EAF88ADABC0D276008791697601447F517F7551887576AA766B011F7F0111887501487F0801000000000000008875C0CE008876CC08102700000000000088CD177EC0C77E3088C351A26300C0876400D200886868C352A26351C0876451D200886868C353A26352C0876452D200886868C353A169517EA97E01877EAA7E7C7EAA7C76CD016A8876D108010000000000000088D088C351A26300C0876400C7C0C78791696868C352A26351C0876451C7C0C78791696868C353A26352C0876452C7C0C78791696868C353A16951>\n\n// # Locking Script\nOP_HASH160\n<0xd2c802d0d3a2c0061ff11afbdd0a67a5d728d68a>\nOP_EQUAL\n\n// # Simulate Redeem Script Execution\nOP_VERIFY\n\n// # Redeem Script\n// ## Reconstruct burned token's groupID preimage by filling in\n// the expected genesis script template.\n// Locking script length\n<0x17>\nOP_CAT\n// P2SH header\n<OP_HASH160 0x14>\nOP_CAT\n // Genesis output's P2SH reconstruction\n <OP_DUP OP_HASH160 0x14>\n // First owner's PKH must be provided by future spenders\n OP_ROT OP_CAT\n <OP_EQUALVERIFY OP_CHECKSIGVERIFY OP_CODESEPARATOR> OP_CAT\n // Genesis input's proof of genesis part 1\n <0xC0D276008791697601447F517F7551887576AA766B011F7F0111887501487F0801000000000000008875C0CE008876CC08102700000000000088CD17>\n OP_CAT\n // Insert P2SH address of this covenant\n op_inputindex_0 op_utxobytecode_dc OP_CAT\n // Genesis input's proof of genesis part 2\n <0x88C351A26300C0876400D200886868C352A26351C0876451D200886868C353A26352C0876452D200886868C353A16951>\n OP_CAT \n OP_HASH160\nOP_CAT\n// P2SH footer\n<OP_EQUAL> OP_CAT\n// Compute part 2. of groupID preimage (hash of genesis input's prevout)\nOP_HASH256\n// Append it to part 1., provided by the spender\nOP_CAT\n// Append part 3., provided by the spender\nOP_SWAP\nOP_CAT\n// Compute the expected groupID\nOP_HASH256\n// ## Verify that it's burned at the token burn index\nOP_SWAP\nOP_DUP op_outputbytecode_opreturn <OP_RETURN> OP_EQUALVERIFY\nOP_DUP op_outputgroupamount_1 <0x0100000000000000> OP_EQUALVERIFY\nop_outputgroupid_nft OP_EQUALVERIFY\n\n// Allow only 1 depository corporation input in the transaction,\n// otherwise a single NFT could unlock multiple UTXOs while it has\n// a right to exactly 1.\nop_txinputcount_2 <1> OP_GREATERTHANOREQUAL OP_IF\n OP_0 op_inputindex_0 OP_EQUAL OP_NOTIF\n OP_0 op_utxobytecode_dc op_inputindex_0 op_utxobytecode_dc OP_EQUAL OP_NOT OP_VERIFY\n OP_ENDIF\nOP_ENDIF\nop_txinputcount_2 <2> OP_GREATERTHANOREQUAL OP_IF\n OP_1 op_inputindex_0 OP_EQUAL OP_NOTIF\n OP_1 op_utxobytecode_0 op_inputindex_0 op_utxobytecode_dc OP_EQUAL OP_NOT OP_VERIFY\n OP_ENDIF\nOP_ENDIF\nop_txinputcount_2 <3> OP_GREATERTHANOREQUAL OP_IF\n OP_2 op_inputindex_0 OP_EQUAL OP_NOTIF\n OP_2 op_utxobytecode_0 op_inputindex_0 op_utxobytecode_dc OP_EQUAL OP_NOT OP_VERIFY\n OP_ENDIF\nOP_ENDIF\nop_txinputcount_2 <3> OP_LESSTHANOREQUAL OP_VERIFY\nOP_1\n\n" | |
}, | |
"nft_proof_of_deposit": { | |
"name": "NFT (PROOF OF DEPOSIT)", | |
"script": "// # Unlocking Script\n// Corporation covenant output index\n<0x0100>\n// This prevout's signature\n<0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041>\n// This prevout's owner (PK)\n<0x0346864c7bbd25b86932742e6681990f67d180d104f66ba2cdb9dd56c194a32cc6>\n// Redeem Script Raw\n<0x76A9140233BC976DA9A9E30FF18B35195693B938E06EAF88ADABC0D276008791697601447F517F7551887576AA766B011F7F0111887501487F0801000000000000008875C0CE008876CC08102700000000000088CD17a914d2c802d0d3a2c0061ff11afbdd0a67a5d728d68a8788C351A26300C0876400D200886868C352A26351C0876451D200886868C353A26352C0876452D200886868C353A16951>\n\n// # Locking Script\nOP_HASH160\n<0x730646f5ec71b49808decce63e15c59fa4bf67fb>\nOP_EQUAL\n\n// # Simulate Redeem Script Execution\nOP_VERIFY\n\n// # Redeem Script\n\n// ## UTXO Owner\nOP_DUP OP_HASH160 <0x0233bc976da9a9e30ff18b35195693b938e06eaf>\nOP_EQUALVERIFY\nop_checksigverify_1\nOP_CODESEPARATOR\n\n// ## Proof of Genesis\n// In addition to signature verification, this UTXO must be spent as\n// a group genesis input\nop_inputindex_0 op_inputgroupgenesis_nft OP_DUP\nOP_0 OP_EQUAL OP_NOT OP_VERIFY\n\n// ## Additional Genesis Conditions\n// Because this UTXO will be part of the new group's genesis preimage,\n// by here requiring some condition to be satisfied, the groupID can\n// later be upacked to prove that it was satisfied.\n\n// Verify genesis version\nOP_DUP <68> OP_SPLIT <1> OP_SPLIT OP_DROP <0x01> OP_EQUALVERIFY OP_DROP\n// Generate groupID from introspected preimage\nOP_DUP OP_HASH256 OP_DUP OP_TOALTSTACK\n// Verify that the new group is a native token group\n<31> OP_SPLIT <0x11> OP_EQUALVERIFY OP_DROP\n// Verify that the genesis input is an NFT\n<72> OP_SPLIT <0x0100000000000000> OP_EQUALVERIFY OP_DROP\n// Disallow genesis input's prevout from being grouped\nop_inputindex_0 op_utxogroupid_0 OP_0 OP_EQUALVERIFY\n// Verify the deposit into the deposatory corporation covenant\nOP_DUP\nop_outputvalue_10k <0x1027000000000000> OP_EQUALVERIFY\nop_outputbytecode_dc <OP_HASH160 0x14 0xd2c802d0d3a2c0061ff11afbdd0a67a5d728d68a OP_EQUAL>\nop_equalverify_1\n\n// Allow only 1 genesis input in the transaction, otherwise multiple\n// NFTs like this could be created and later compete to redeem the\n// covenant payment as their own but the covenant would have balance\n// for only 1 redemption.\nop_txinputcount_2 <1> OP_GREATERTHANOREQUAL OP_IF\n OP_0 op_inputindex_0 OP_EQUAL OP_NOTIF\n OP_0 op_inputgroupgenesis_nft OP_0 OP_EQUALVERIFY\n OP_ENDIF\nOP_ENDIF\nop_txinputcount_2 <2> OP_GREATERTHANOREQUAL OP_IF\n OP_1 op_inputindex_0 OP_EQUAL OP_NOTIF\n OP_1 op_inputgroupgenesis_0 OP_0 OP_EQUALVERIFY\n OP_ENDIF\nOP_ENDIF\nop_txinputcount_2 <3> OP_GREATERTHANOREQUAL OP_IF\n OP_2 op_inputindex_0 OP_EQUAL OP_NOTIF\n OP_2 op_inputgroupgenesis_0 OP_0 OP_EQUALVERIFY\n OP_ENDIF\nOP_ENDIF\nop_txinputcount_2 <3> OP_LESSTHANOREQUAL OP_VERIFY\nOP_1" | |
}, | |
"helper_group_genesis_generator": { | |
"name": "HELPER: GROUP GENESIS GENERATOR", | |
"script": "// # Poor man's group genesis generator\n// Set prevout and genesis parameters, and then manually roll the nonce\n// until the groupGenType matches.\n\n// Part 1. - genesis input's prevout reference\n // Prevout hash\n <0x699099d656be426a9618d732fd21e626667361d463ba9cae07d9517fc1768582>\n // Prevout index\n <0x00000000> OP_CAT\n OP_HASH256\n// Part 2. - genesis input's prevout\n // Prevout satoshi amount\n <0xa086010000000000> \n // Prevout locking script length\n <0x17> OP_CAT // Pure\n // <0x40> OP_CAT // Grouped\n // Prevout group annotation\n // PFX_GROUP\n // <0xEE> OP_CAT\n // groupID\n // <0x0e83da9144f9d9c45d1b442684c57b7c516ab18fb112da3c31bf8b807ed13c92> OP_CAT\n // groupAmount\n // <0x0123456789ABCDEF> OP_CAT\n // Locking script\n <0xa914730646f5ec71b49808decce63e15c59fa4bf67fb87> OP_CAT\n OP_HASH256\n// Part 3. - genesis input parameters\n // Genesis input index\n <0x00000000>\n // groupGenVersion\n <0x01> OP_CAT\n // groupGenNonce, roll this until line 38 verifies\n <0x008d> OP_CAT\n // groupGenType\n <0x11> OP_DUP OP_TOALTSTACK OP_CAT \n // groupGenAmount\n <0x0100000000000000> OP_CAT\n// Generate groupID preimage\nOP_CAT OP_CAT\n// Generate groupID\nOP_DUP OP_HASH256\n// Verify groupType\n<31> OP_SPLIT OP_FROMALTSTACK OP_EQUALVERIFY\nOP_DROP\n\n// groupID preimage left on the stack" | |
}, | |
"op_inputindex_0": { | |
"name": "OP_INPUTINDEX_0", | |
"script": "OP_0" | |
}, | |
"op_utxobytecode_dc": { | |
"name": "OP_UTXOBYTECODE_DC", | |
"script": "OP_DROP <0xa914d2c802d0d3a2c0061ff11afbdd0a67a5d728d68a87>\n" | |
}, | |
"op_outputbytecode_opreturn": { | |
"name": "OP_OUTPUTBYTECODE_OPRETURN", | |
"script": "OP_DROP\n<OP_RETURN>" | |
}, | |
"op_outputgroupamount_1": { | |
"name": "OP_OUTPUTGROUPAMOUNT_1", | |
"script": "OP_DROP\n<0x0100000000000000>" | |
}, | |
"op_outputgroupid_nft": { | |
"name": "OP_OUTPUTGROUPID_NFT", | |
"script": "OP_DROP\n<0xd5de6dc2a737d8a25ccb5fa23040f84e55f8164139752c5ff15ffcc0c3fa7a11>" | |
}, | |
"op_equalverify_1": { | |
"name": "OP_EQUALVERIFY_1", | |
"script": "OP_2DROP" | |
}, | |
"op_checksigverify_1": { | |
"name": "OP_CHECKSIGVERIFY_1", | |
"script": "OP_2DROP" | |
}, | |
"op_outputvalue_10k": { | |
"name": "OP_OUTPUTVALUE_10k", | |
"script": "OP_DROP\n<0x1027000000000000>" | |
}, | |
"op_inputgroupgenesis_0": { | |
"name": "OP_INPUTGROUPGENESIS_0", | |
"script": "OP_DROP\nOP_0\n" | |
}, | |
"op_inputgroupgenesis_nft": { | |
"name": "OP_INPUTGROUPGENESIS_NFT", | |
"script": "OP_DROP\n<0xe69b80d54c704b204143089c4e00ee86fa5a4f897878fe1ce0e6661fbc4e7067fa151b786164c897ef7f011bdd38fa80fda43022e7c715902c88e6e660c893ba0000000001008d110100000000000000>\n" | |
}, | |
"op_utxogroupid_0": { | |
"name": "OP_UTXOGROUPID_0", | |
"script": "OP_DROP\nOP_0\n" | |
}, | |
"op_outputbytecode_dc": { | |
"name": "OP_OUTPUTBYTECODE_DC", | |
"script": "OP_DROP <0xa914d2c802d0d3a2c0061ff11afbdd0a67a5d728d68a87>" | |
}, | |
"op_txinputcount_1": { | |
"name": "OP_TXINPUTCOUNT_1", | |
"script": "OP_1" | |
}, | |
"op_txinputcount_2": { | |
"name": "OP_TXINPUTCOUNT_2", | |
"script": "OP_2" | |
}, | |
"op_txinputcount_3": { | |
"name": "OP_TXINPUTCOUNT_3", | |
"script": "OP_3" | |
}, | |
"op_utxobytecode_0": { | |
"name": "OP_UTXOBYTECODE_0", | |
"script": "OP_DROP\nOP_0" | |
} | |
}, | |
"supported": [ | |
"BCH_2020_05" | |
], | |
"version": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment