{"type":"rich","version":"1.0","author_name":"npub1vtwuk4rjyj6zrq3tv2z9lvdm6a7g8zujf0gz9q2vljlztdaqw36sjjsjpg","author_url":"https://nostr.ae/npub1vtwuk4rjyj6zrq3tv2z9lvdm6a7g8zujf0gz9q2vljlztdaqw36sjjsjpg","provider_name":"njump","provider_url":"https://nostr.ae","html":"📅 Original date posted:2019-08-07\n📝 Original message:Hi,\n\nI have a proposal for implementing bitcoin vaults in a way that does not\nrequire any soft-forks or other software upgrades, although it could benefit\nfrom SIGHASH_NOINPUT which I'll describe later.\n\nI call them pre-signed vaults.\n\nVault definition\n================\n\nHere, a vault is defined as a transaction setup scheme that binds both the user\nand the attacker to always using a public observation and delay period before a\nweakly-secured hot key is allowed to arbitrarily spend coins. This is the same\ndefinition previously used[1]. During the delay period, there is an opportunity\nto initiate recovery/clawback which can either trigger deeper cold storage\nparameters or at least reset the delay period to start over again for the same\nkeys.\n\nOne of the important components of this is the delete-the-key pre-signed\ntransaction concept, where only a single transaction is (pre)signed before\ndeleting the key. This is basically an emulation of a covenant and enforces a\ncertain outcome.\n\nBackground and motivation\n=========================\n\nI was looking at Eyal and Sirer's 2016 vaults paper [1], and I saw this\nheadscratcher:\n\n\u003e Vault transactions use a delay mechanism. We note that vault transactions\n\u003e cannot be implemented with existing timing mechanisms such as\n\u003e CHECKLOCKTIMEVERIFY opcode or transaction locktime.\n\nThis was probably written before the introduction of OP_CHECKSEQUENCEVERIFY.\nStill, a viable construction would have more steps than just using OP_CSV. They\nwere probably not thinking about what those steps might be, because in the\ncontext of the paper they were proposing a bitcoin vault implemented using\nrecursive consensus-enforced covenants via a new opcode, which obviously cannot\nbe deployed without an upgrade fork. Covenants have been discussed for years,\nbut require new opcodes or other consensus-enforcement changes.\n\nRelative locktimes are useful here because there is no knowledge as to when the\ntransactions might be broadcasted in the future. The delays need to be relative\nto after the transaction is included in the blockchain, not to setup\ninitialization time.\n\nAlso, from [2]:\n\n\u003e We show that a [vault transaction] mechanism is currently not possible in all\n\u003e cryptocurrencies [...] Bitcoin's scripting language requires support for\n\u003e covenants.\n\nI haven't seen any previous proposal for how to implement recursive bitcoin\nvaults without a fork and without a covenant. After asking around, I am pretty\nsure this is somewhat novel. The closest I guess is [3].\n\nVaults are particularly interesting as a bitcoin cold storage security\nmechanism because they enable a publicly observable delay period during which\ntime a user could be alerted by a watchtower that a thief might be in the\nprocess of stealing their coins, and then the user may take some actions to\nplace the coins back into the vault before the relative timelock expires. There\nseems to be no way to get this notification or observation period without a\nvault construction. It might have been assumed it required a covenant.\n\nHaving a vault construction might go a long way to discourage would-be\nattackers, on principle that the attacker might be incapable of recovering\ntheir cost-of-attack because the recovery mechanism can lock up the coins\nindefinitely. Griefing or denial-of-service would still be possible, of course,\nbut with multisig there might be some ways to put a halt to that as well. I am\nworking under the assumption that the attacker knows that the user is a vault\nuser.\n\nVaults\n======\n\nThe idea is to have a sequence of pre-generated pre-signed transactions that\nare generated in a certain way. The basic components are a vaulting transaction\nthat locks coins into a vault, a delayed-spend transaction which is the only\nway to spend from a vault, and a re-vaulting transaction which can\nrecover/clawback coins from the delayed-spend transaction. The security of this\nscheme is enforced by pre-signing transactions and deleting private keys, or\nwith the help of SIGHASH_NOINPUT then there's another scheme where private keys\nare provably never known. This enforces that there's only a specific set of\npossible outcomes at every step of the vault.\n\nSome examples of what the set of broadcasted transactions might look like in\nregular usage:\n\n    coins -\u003e VT -\u003e DST -\u003e exit via hot wallet key\n    coins -\u003e VT -\u003e DST -\u003e RVT\n    coins -\u003e VT -\u003e DST -\u003e RVT -\u003e DST -\u003e ...\n    coins -\u003e VT -\u003e ... -\u003e RVT998 -\u003e nuclear abort\n\nwhere:\n    VT = vault transaction\n    DST = delayed-spend transaction\n    RVT = re-vaulting transaction\n\nThe delayed-spending transaction would have a single output with a script like:\n(\n    30 days AND hot wallet key\n OR 10 days AND re-vaulting public key\n OR 1 day AND 4-of-7 multisig\n OR 0 days and super-secure nuclear abort ragequit key\n)\n\nAnother diagram:\n\n    VT_100 -\u003e DST -\u003e (optionally) RVT -\u003e coins are now in VT_99\n    VT_99 -\u003e DST -\u003e (optionally) RVT -\u003e coins are now in VT_98\n    ...\n    VT_1 -\u003e burn-all-coins nuclear abort ragequit (final)\n\nDefinitions\n===========\n\nTransactions and components:\n\n* Commitment/funding vault setup transaction. Signed after setting up the\ntransaction tree, and it is broadcasted whenever funds are to be placed into\nthe vault.\n\n* Delayed-spend transaction. Signed during the vault transaction tree setup,\nand it is broadcasted when the user wants to withdraw coins from cold storage\nor otherwise manipulate the coins. The output script template used by the\ndelayed-spend transaction was defined earlier.\n\n* Hot wallet key: Somewhat insecure key. This can also be multisig using\nmultiple hot keys.\n\n* Re-vaulting key: It is important to note that the private key either never\nexisted (SIGHASH_NOINPUT + P2WPK for the re-vaulting transaction) or the\nprivate key was deleted after pre-signing the re-vaulting transaction.\n\n* 4-of-7 multisig: This is a group of differently-motivated individuals who are\nresponsible for signing transactions. This multisig group is not necessry to\ndescribe the technique, I just think it's a useful feature for a vault to\ninclude.\n\n* Nuclear abort key: Also unnecessary. This is a key for which only a single\nsigned transaction will ever exist, and that single transaction will spend to a\nproof-of-burn key like 0x00. This key must be extremely secure, and if there\nis any doubt about the ability to keep such a key secured, then it is better to\nnot include this in the protocol. Alternatively, maybe include it as an option\n50 layers down in the revaulting sequence.\n\n* Nuclear-abort pre-signed transaction. This is signed during transaction tree\nsetup, before constructing the delayed-spend transaction. It is broadcasted\nonly if the user wants to provably relinquish coins forever without giving the\nattacker any coins.\n\n* Re-vaulting transaction. This is where the magic happens. The re-vaulting\ntransaction is signed during transaction tree setup, before constructing the\ndelayed-spend transaction for the parent vault. The re-vaulting transaction is\nbroadcasted when someone wants to prevent a coin withdrawal during the public\nobservation delay period. The re-vaulting transaction spends the delayed-spend\ntransaction outputs. It has a single output with a script created by running\nthe entire vault setup function again. Hence, when the re-vaulting transaction\nis confirmed, all of the coins go back into a new identically-configured vault\ninstead of being relinquished through the delayed-spend transaction timeout for\nhot wallet key signing.\n\n* Special case: final transaction. This is the very first pre-signed\ntransaction during setup, and the transaction spends the coins using any\nprovable burn technique. This is broadcasted only at the end of the game, as an\nultimate abort and forfeiture of coins without giving in to an adversary. It's\nsimilar to the nuclear-abort ragequit transaction but it sits at the same place\nthat a delayed-spend transaction would, at the very end of the rainbow or\nyellow brick road.\n\nExample log during vault setup\n==============================\n\nWhen running the recursive vault setup function, the created artifacts (in\norder) will look like:\n\n1) choose one of:\n   (first iteration) pre-signed burn-all-coins nuclear abort ragequit (final)\n   (all others) a new vault setup transaction spendable only by its\n                delayed-spend transaction\n\n2) pre-signed re-vaulting transaction sending to vault setup or final\ntransaction, with a unique private key\n\n3) pre-signed delayed-spend transaction, with a unique private key\n\n4) vault transaction spendable only by the delayed-spend public key\n\nPseudocode\n==========\n\nIn pseudocode (where PTX is a pre-signed transaction function with\nprivate key deletion):\n\n    VT(counter, *args, **kwargs) =\n        if counter == 0:\n            DST = PTX(\"burn-all-coins\")\n        else:\n            next_vault = VT(counter-1, *args, **kwargs)\n            revaulting = PTX(\"only spendable by next_vault public key\")\n            DST = PTX(\"DST policy including revaulting and other conditions\")\n        vault = PTX(\"spendable only by this DST\")\n        return vault\n\nPre-signed transactions\n=======================\n\nWhat has been known for a while is that a covenant can be somewhat emulated\nusing a pre-signed transaction where the user then deletes the private key,\nenforcing that the user's chosen policy must be enforced since there is only\none existing option and there will only ever be one option.\n\nSuch a scheme has been previously described for simple one-time and chained\nvaults [3]. I have learned that the author has an implementation that is in\npreparation, for a non-recursive version.\n\nNote that a series of pre-signed transactions can be considered to be an\nemulation of a covenant. Imagine a linear chain of pre-signed transactions\nwhere each hop has a relative locktime before being able to broadcast the next\ntransaction. To recover the coins at the end of the rainbow, one would need to\nbroadcast each sequential transaction in order and wait for the relative\ntimelocks to expire each time. Here, covenants provide something like an undo\nfor bitcoin, but only between pre-determined addresses and scripts.\n\nFees for pre-signed transactions\n================================\n\nThere's a few different techniques to talk about:\n\n1) SIGHASH_SINGLE|SIGHASH_ANYONECANPAY to let someone add inputs and outputs.\nThis can get pretty complex though.\n\n2) Add a zero-value OP_TRUE output and let anyone spend the zero-value output\nand attach a child-pays-for-parent (CPFP) transaction to pay for everything.\n\n3) Pre-sign a variety of different possible fee rates. Unfortunately this\ninvolves an explosive blow-up in the amount of transaction data to generate. It\nmight actually be a reasonable blow-up amount, only resulting in a few hundred\nmegabytes of additional data. But given the other options, this is unnecessary.\n\nDelete the key (for pre-signed transactions)\n============================================\n\nThe delete-the-key trick is simple. The idea is to pre-sign at least one\ntransaction and then delete the private key, thus locking in that course of\naction.\n\nUnfortunately, delete-the-key doesn't really work for multisig scenarios\nbecause nobody would trust that anyone else in the scheme has actually deleted\nthe secret. If they haven't deleted the secret, then they have full unilateral\ncontrol to sign anything in that branch of the transaction tree. The only time\nthat delete-the-key might be appropriate would be where the user who deletes\nthe key and controls the key during the setup process is also the sole\nbeneficiary of the entire setup with the multisig participants.\n\nAlternative fee rates are easier to deal with using delete-the-key, compared to\na technique where the private key never existed which can only be used to sign\none fee rate per public key, requiring an entirely new vault subtree for each\nalternative fee rate. With delete-the-key, the alternative fee rates are signed\nwith the private key before the private key is deleted.\n\nMultisig gated by ECDSA pubkey recovery for provably-unknown keys\n=================================================================\n\nA group can participate in a multisig scheme with provably-unknown ECDSA keys.\nInstead of deleting the key, the idea is to agree on a blockheight and then\nselect the blockhash (or some function of the chosen blockhash like\nH(H(H(blockhash)))) as the signature. Next, the group agrees on a transaction\nand they recover the public key from the signature using ECDSA pubkey recovery.\nA pre-signed transaction is created, which will trigger the start of the public\nobservation period described earlier and also start the clock for the bip112\nrelative timelock on its output. In the output script, an OR branch\nis added that enables the use of a re-vaulting key which could also be its own\nseparate multisig construction.\n\nThis is incompatible with P2WPKH because the P2WPKH spending scriptSig needs to\nhave the pubkey (to check the hash of the pubkey against the pubkeyhash in the\nscriptPubKey), which in turn makes it incompatible with ECDSA pubkey recovery\nwhich requires a hash of the message. However, with P2WPK and SIGHASH_NOINPUT\ninstead of P2WPKH it could conceivably work. SIGHASH_NOINPUT is required because\notherwise the input includes a txid which references the public key. With P2WPK,\nthe scriptSig only needs a signature and not a public key. Note that what would\nbe required is a version of SIGHASH_NOINPUT that does not commit to the public\nkey, and I think a few of the NOINPUT proposals are committing to the public\nkey.\n\nAlternatively, there may be some constructions using the 2-party ECDSA\ntechniques or m-n party ECDSA techniques.\n\nDeploying exceedingly large scripts\n===================================\n\nA brief interlude to share a somewhat obvious construction. I haven't seen this\nwritten down yet.\n\nSuppose there is a bitcoin script that someone is interested in using, but it\nfar exceeds the size limits and sigop limits. To fix this, they would split up\nthe script into usable chunks, and then use the delete-the-key mechanism (or\nthe other one) to create an OR branch that is signable by a single key for\nwhich only a single signature is known. That new pre-signed transaction would\nspend to a script that has the output with the remainder of the script of\ninterest. Re-vaulting or clawback clauses can be added to that output as well,\nbut spending back to the original root script will only work by generating new\nscripts and keys (since the final hash isn't known until the whole tree is\nconstructed, it's a dependency loop).\n\nRecursively-enforced multi-party multisig bitcoin vaults\n========================================================\n\nIdeally, to enforce a covenant with impossible fairy dust magic, we would ask\nfor a bitcoin transaction that could be self-referential because the\nonly-one-signature-ever trick requires that the signed message be known before\nproducing the signature, and the signature has to be known before the public\nkey can be known, and the public key would have to be included in the\nself-referential message/transaction hash value. So, that's a dependency loop\nand it doesn't work. It would be interesting to explore a variation of this\nidea with masking, such that a value X can be replaced by a hash over the whole\nscript with the X value, even though the real script will have the hash.\nSomeone else can figure that one out for me :-).\n\nInstead of the self-referential values attempting to reference the same\nscript that is in the process of being constructed, an alternative is to use\nthe same script template but populate it with different parameters. The script\ntemplate gets reused over and over again, all the way down the tree, until the\nfinal transaction which could be \u003e100 years into the future once done adding up\nall the relative locktimes. In fact, to create and populate this terrifying\nrecursive script tree, the final transaction needs to be created first, and\nthen it is given as input to the script template function and that output is\nthen given to the script template function itself-- and so on. At each stage,\nthere are additional pre-signed transactions and values to remember.\n\nThis can be written as:\n\n    final_transaction = TX(spend to 0x0000 to burn the coins)\n    initial_transaction = F(F(...F(final_transaction))\n\n    (This is missing parameters to indicate to the function what the spending\n    keys requirements are to be.)\n\nSee earlier explanation for more details.\n\nEach call to the template populating function produces values that each must be\npreserved for a very long time. It is less safe to store all of the pre-signed\ntransactions together at the same time, but more convenient. With less\nredundancy, there is an increased chance of losing data over time, which could\nrender the coins completely frozen. This doesn't particularly worry me because\nforgetting a key has that property already, and this could be likened to\nhundreds of megabytes of extra key data or something. Unlike the much smaller\ncovenant-based (opcode-based covenant) vault construction, the multiple layers\nhere can be separately stored and protected, which might be able to protect\nagainst an adversary that has stolen some of the re-vaulting keys but not all\nof them.\n\nOptimizations can be made to store parameters for generating the remainder of\nthe tree, such as using deterministic key derivation, such that megabytes of\ndata wouldn't need to be long-term stored. Only the initial parameters would\nneed to be stored.\n\nFinancial privacy for custody\n=============================\n\nOne of the concerns raised in [2] is that if all coins at an exchange are\nstored together in the same vault, then attackers would be able to learn about\naccess control policies by observing scripts and keys. Some privacy can be\nrecovered by using segregated vaults, at the cost of additional setup\ncomplexity and keeping more data in long-term storage.\n\nHowever, note that I think vaults are also useful for personal cold storage\nsolutions.\n\nFail-deadly mechanism\n=====================\n\nAn early nuclear abort option can be added to these scripts. This idea was\nexplored in [2]. This would be a very cold very secret key that would abort the\nre-vaulting procedure and send all coins to a (provably) nonsense key. This\nallows a vault user to destroy the coins instead of continuously monitoring the\nbitcoin blockchain for the rest of his life. The attacker can't recover their\ncost of attack if they never get the coins, and this eliminates an entire class\nof potential attackers who are directly interested only in financial gain. The\ndisadvantage is that if the attacker finds the secret key for the fail-deadly\nmechanism and uses it, then all of the coins are gone forever.\n\nMultisig variations\n===================\n\nThe re-vaulting key could be the same key at each layer, or only sometimes the\nsame key, or always a unique key stored separately in another secure location.\n\nAdditionally, these re-vaulting keys could be subjected to multisig schemes, as\nwell as Shamir secret sharing schemes or other secret sharing schemes.\n\nThe idea of adding the 4-of-7 multisig component is to avoid griefing\nsituations, at the cost of the additional security requirements for the 4-of-7\nmultisig group.\n\nKey rotation for vaults\n=======================\n\nKeeping the same hot wallet key for 100 years is not advisable. Rotate the keys\nby setting up a new vault construction and initiating a withdrawal transaction\nfrom the old vault to the new vault.\n\nSingle-use seals\n================\n\nThis proposal may have inadvertedly demonstrated a practical way to implement\nPeter Todd's single-use seals concept [4]. I am hesitant to say so, though,\nbecause I think he would ask for a more sophisticated way to verify seal\nclosure.\n\nPaid defection\n==============\n\nIt might be advisable to add small rewards for evidence of defection amongst\nmultiparty multisig setups. Besides amounts spendable by individual keys from a\nmultisig setup, it may be possible to use a zero-knowledge contingent payment\nfor a zero-knowledge statement like: I have a signature s over some message m\nwhich validates for pubkey pk where pk is a member of the multisig group. Then\nthe zkcp transaction would pay for knowledge of defectors. The zkcp procedure\nwould require interaction with the defector, while the direct pubkey method\nwould not. This is similar to companies paying employees to quit when they\nvalue the payment over the value of continued employment.\n\nHandling change\n===============\n\nIt is important to note that this vault setup is one-time and once-only. There\nmust only ever be one deposit into one vault. Also, spending some coins would\nrequire sending the change amount back into a new vault.  Alternatively,\nupfront work can be done to set a regular withdrawal stipend or assumption\nabout how many coins are left, such that the transaction tree can be\npre-generated for those possibilities, hence cutting down on future vault\nreinitializations. It would also be possible to commit upfront to only ever\nworking in some minimum increment number of bitcoin or something.\n\nIt is very important to only fund the vault once, and only with the amount that\nwas configured when setting up the vault.\n\nReferences\n==========\n\n[1] https://fc16.ifca.ai/bitcoin/papers/MES16.pdf\n\n[2] http://www0.cs.ucl.ac.uk/staff/P.McCorry/preventing-cryptocurrency-exchange.pdf\n\n[3] http://web.archive.org/web/20180503151920/https://blog.sldx.com/re-imagining-cold-storage-with-timelocks-1f293bfe421f?gi=da99a4a00f67\n\n[4] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-December/015350.html\nor https://diyhpl.us/wiki/transcripts/building-on-bitcoin/2018/single-use-seals/\nor https://petertodd.org/2016/closed-seal-sets-and-truth-lists-for-privacy\n\nAcknowledgements\n================\n\n* Jeremy Rubin for pointing out something embarrassingly broken in an earlier\ndraft.\n\n* Bob McElrath for telling me to use SIGHASH_NOINPUT which I proceeded to\npromptly forget about.\n\n* Andrew Poelstra for the OP_TRUE trick.\n\n* Joe Rayhawk for paid defection.\n\n* Tadge Dryja for pointing out a few differences between SIGHASH_NOINPUT\nproposals.\n\n\n\nThank you,\n\n- Bryan\nhttp://heybryan.org/"}
