However, a lockbox on one chain is a WT on the otherchain. We can create a free lockbox on Ess, then use that lockbox asa WT on Tee, inflating TeeCoin.
However, this parameter is used to determine if it is a WT. Sidechainconsensus should require that freely-created lockboxes set thisparameter to 0, so that a side block that creates free lockboxes wherethis parameter is non-zero is an invalid side block. Then a sidechainwill only treat a lockbox on another chain as a WT if the wtFlagparameter is nonzero. This way, freely-created lockboxes are notvalid WT. Valid WT must lock actual, already unlocked coins, notcreate new locked coins.
Good morning,Chris mentioned the use of OP_WITHDRAWPROOFVERIFY. I've come to realizethat this is actually superior to use OP_WITHDRAWPROOFVERIFY with asidechain-headers-on-mainchain approach.Briefly, a payment to OP_WITHDRAWPROOFVERIFY is an instruction to transfervalue from the mainchain to a sidechain. Thus, a payment toOP_WITHDRAWPROOFVERIFY includes the sidechain to pay to, and a commitmentto a sidechain address (or whatever is the equivalent to a sidechainaddress).Various OP_WITHDRAWPROOFVERIFY explanations exist. Most of them includeOP_REORGPROOFVERIFY. With sidechain-headers-on-mainchain, however, there is no need for reorg proofs. This is because, the mainchain can see, in realtime, which branch of the sidechain is getting extended. Thus if someoneattempts to defraud a sidechain by forking the sidechain to an invalidstate, sidechainers can immediately detect this on the mainchain andimmediately act to prevent the invalid fork from being advanced. Afterall, a reorg proof is really just an SPV proof that is longer than someprevious SPV proof, that shows that the previous SPV proof is incorrect,by showing that the block at the specified height of the WT is not presenton a longer SPV proof.Since sidechain-headers-on-mainchain implies merge mining of sidechains,with no option to have independent proof-of-work of sidechains, thesidechain's entire history is recorded on the mainchain, visible to allmainchain nodes.--An advantage of sidechain-headers-on-mainchain is a side-to-side peg withoutpassing through the mainchain.That is, a 2-way peg between any two chains, whether side or main.Sidechains supporting side-to-side transfer would require supportingOP_WITHDRAWPROOFVERIFY, but not any of the other parts of sidechains.We must consider a WT format (withdrawal transaction) that is compatiblewith an OP_WITHDRAWPROOFVERIFY Bitcoin transaction.***That is, a lockbox UTXO on one chain is a WT on another chain.***Sidechains need not follow the mainchain format for its normaltransactions, only for WT transactions that move coins across chains.For this, mainchain should also have its own "sidechain ID". Perhaps asidechain ID of 0 would be appropriate for mainchain, as its status asmainchain.Suppose we have two sidechains, Ess and Tee, both of which supportside-to-side pegs.An Ess fullnode is a Bitcoin fullnode, but an Ess fullnode is notnecessarily a Tee fullnode, and vice versa.A lockbox redemption in sidechain-headers-on-mainchain is simply a spend ofa lockbox, pointing to the sidechain header containing WT, the merkle treepath to the WT transaction from the h* commitment of the header, the outputwhich locks, and so on as per usual OP_WITHDRAWPROOFVERIFY.Then a sidechain can create tokens from nothing, that are locked in aOP_WITHDRAWPROOFVERIFY lockbox; this is the only way to create sidecoin.When transferring into a sidechain from mainchain, or anywhere, thesidechain either creates tokens locked into OP_WITHDRAWPROOFVERIFY, orlooks for an existing UTXO with OP_WITHDRAWPROOFVERIFY from the sourcechain and spends them (the latter is preferred as it is fewertransactions and less space on the sideblock, reducing sidechain fees).OP_WITHDRAWPROOFVERIFY on a sidechain would query the mainchain fullnodes.Whatever rules allow lockbox unlocking on mainchain, will also be the samerules that allow lockbox unlocking on sidechains.A mainchain RPC can even be made to simplify sidechain verification ofside-to-side pegs, and to ensure that sidechains follow the same consensusrules for OP_WITHDRAWPROOFVERIFY.So if we want transfer TeeCoin to EssCoin, we spend into aOP_WITHDRAWPROOFVERIFY lockbox on Teechain pointing to Esschain (i.e. aTee->Ess lockbox). This lockbox is itself a WT from the point of view ofEsschain. On Esschain, we look for an existing Ess->Tee lockbox, orcreate a Ess->Tee lockbox of our own for a EssCoin fee. Then we create aspend of the Ess->Tee lockbox on Esschain, wait until spending ispossible, and then post that transaction on Esschain.Again, with sidechain-headers-on-mainchain, reorg proofs are unnecessary, since any invalid chain should be quickly buried by a valid chain,unless the economic majority decides that a sidechain is not worthprotecting.--All is not well, however. Remember, on a sidechain, we can create newsidecoin for free, provided they are in a lockbox. Unlocking thatlockbox would require a valid WT on the chain that the lockbox isdedicated to. However, a lockbox on one chain is a WT on the otherchain. We can create a free lockbox on Ess, then use that lockbox asa WT on Tee, inflating TeeCoin.Instead, we add an additional parameter, wtFlag, toOP_WITHDRAWPROOFVERIFY.This parameter is ignored by OP_WITHDRAWPROOFVERIFY opcode.However, this parameter is used to determine if it is a WT. Sidechainconsensus should require that freely-created lockboxes set thisparameter to 0, so that a side block that creates free lockboxes wherethis parameter is non-zero is an invalid side block. Then a sidechainwill only treat a lockbox on another chain as a WT if the wtFlagparameter is nonzero. This way, freely-created lockboxes are notvalid WT. Valid WT must lock actual, already unlocked coins, notcreate new locked coins.On Bitcoin, of course, this parameter must always be nonzero, sincefreely-created lockboxes are not allowed on mainchain, as assetissuance on mainchain is already fixed.--Let us now flesh out how WT and lockboxes look like. As we mentioned, alockbox on one chain is a WT on the destination chain. Or to be moreprecise, what a destination chain sees as a WT, is a lockbox on the sourcechain.Thus, a lockbox is a Bitcoin-formatted transaction output paying to thescriptPubKey:<sidechain address commitment> <sidechain ID> OP_WITHDRAWPROOFVERIFY(assuming a softfork, additional OP_DROP operations may occur afterOP_WITHDRAWPROOFVERIFY)Suppose the above lockbox is paid to in the Bitcoin mainchain, with thesidechain ID being the ID of Esschain. This is itself a WT transactionfrom the point of view of Esschain, on the principle that a lockbox onone chain is a WT on another chain.Assuming Esschain is a brand-new sidechain, it has no EssCoins yet. Thesidechain allows the arbitrary creation of sidecoin provided the newsidecoins are in a lockbox whose sidechain address commitment is 0. Soin Esschain, we create the same coins on a UTXO paying to thescriptPubKey:0 0 OP_WITHDRAWPROOFVERIFYThe first 0 is the sidechain address commitment, which is 0 since thisoutput was not created by transferring to a sidechain; wereuse the sidechain address commitment as the wtFlag. Thesecond 0 is the mainchain's ID. The above is a lockbox from the point ofview of Esschain. It is not a WT on mainchain, however, because thesidechain address commitment is 0, which we use also as the wtFlagparameter.Now, how does a main-to-side peg work? After creating the above output onEsschain, we now spend the output with the below scriptSig:<mainchain output ID> <mainchain WT transaction> <merkle path to WT transaction> <mainchain block hash>On Esschain, OP_WITHDRAWPROOFVERIFY then verifies that the mainchain blockhash is a valid past block of the mainchain, then locates the mainchainheader. It then checks the merkle tree path to the mainchain WTtransaction,confirming that the mainchain contains that transaction, and confirms thattheindicated output is in fact, a payment to an OP_WITHDRAWPROOFVERIFY, whichpushes the Esschain ID, and with a nonzero sidechain address commitment.(Esschain also needs to ensure that a single WT is not used to unlockmultiple lockboxes on Esschain; the easiest way is to add it to a set,but this set cannot be pruned; other ways of ensuring only a WT is onlyused to unlock once might be designed)On Esschain, the sidechain does one final check: the transaction that spendsan OP_WITHDRAWPROOFVERIFY must have an output that pays to the sidechainaddress committed to, and that output's value must be the same as the valuelocked in the mainchain.(for now, I think all lockboxes must have the same fixed amount, forsimplicity)Now suppose we want to convert back our EssCoin to Bitcoin. We create alockbox on Esschain, paying to the below:<bitcoin P2SH address> 0 OP_WITHDRAWPROOFVERIFYThe bitcoin P2SH address is mainchain address commitment; for simplicitywe just use P2SH on mainchain as it can encode any address. The 0 is themainchain ID. The above Esschain lockbox is itself a WT from Esschain tomainchain.Then, we look for an unspent lockbox on Esschain whose sidechain ID is theEsschain ID. Note that we can select any lockbox with the correctsidechain ID, regardless of the sidechain address commitment it may have.Locating an appropriate mainchain lockbox for Esschain coins, we thenprovide the below scriptSig, paying out to the bitcoin P2SH address weselected:<esschain output ID> <esschain WT tx> <merkle path to WT tx> <esschain block header hash>On mainchain, we check that the indicated sidechain block header hash is ablock header on the longest chain of Esschain. We check it has sufficientdepth. Then we check if the merkle path to the WT tx is correct and goesto esschain WT tx. Finally, we check the indicated output ID, and check thatit is indeed an Esschain lockbox dedicated to mainchain. Finally, we checkthat the transaction has an output that spends the lockbox amount to thespecified bitcoin P2SH address.(similarly mainchain nees to ensure that the Esschain WT is only usedonce)The key insight here is that side-to-side pegs are just like side-to-mainpegs. Suppose instead we want to transfer our coins from Esscoin toTeecoin. We would instead pay to the following lockbox on Esschain:<teecoin address commitment> <teechain ID> OP_WITHDRAWPROOFVERIFYThen a Teechain transaction spending some Tee->Ess lockbox (or a freshlockbox if there are no Tee->Ess lockboxes on Teechain) is created.We proceed as if it were a side-to-main peg, except it is a peg toTeechain, either creating or unlocking TeeCoins. Indeed, mainchainfullnodes may even provide an RPC for checking OP_WITHDRAWPROOFVERIFY,so as to reduce risk that a sidechain breaks consensus due to buggycode.--All is still not well with side-to-side pegs, however.Suppose the economic majority decides that Esschain must die. Perhaps ithas some irrecoverable security bug, perhaps it adds features that allowEsschain fullnodes to kill baby seals, perhaps a successful theft ofEsschain lockboxes was performed and Esscoins are now functionallyworthless. Killing a sidechain is done by bribing miners to put invalidvalues into h*, and thus stealing Bitcoin->Ess lockboxes.If Esschain dies, however, and the economic majority is not prepared to keepEsschain dead, it is possible to unlock Tee->Ess lockboxes on Teechain.Unlocking existing Tee->Ess lockboxes on Teechain is safe, since theyrepresent coins that were locked into Bitcoin->Tee lockboxes. However,it is still possible to create "free" Tee->Ess lockboxes on Teechain, thenprovide an invalid Tee->Ess WT lockbox on the now-moribund Esschain tounlock the free Tee->Ess lockbox on Teechain, inflating TeeCoin value.Thus in the presence of side-to-side pegs, the death of even one sidechainrepresents the death of every other sidechain!Thus, to properly kill Esschain, the economic majority should spam theEsschain headers slot with a fixed value, say 0, forever. This makes itvery difficult to create a Tee->Ess WT lockbox on Esschain, as you wouldnow be able to reverse a one-way hash function.Alternatively, Teechain can softfork so that Tee->Ess lockboxes are nolonger creatable or spendable. However, the death of Esschain requiresthat all other sidechains, including Youchain, Veechain, Dubyachain, andso on, to softfork similarly.Perhaps both can be done: first the economic majority wanting to killEsschain starts spamming it with invalid spends of Bitcoin->Ess lockboxes,then when all Bitcoin->Ess lockboxes have been stolen, spam it with 0suntil all other sidechains have banned free Ess lockboxes on their chains.Then, the economic majority can leave Esschain dead, and a later softforkof mainchain prevents Esschain from being extended and allows mainchainfullnodes to prune Esschain headers.--Thieves will still have the same difficulty stealing from sidechains, butnow their payoff is increased. If a thief wants to steal Esschainlockboxes, then it is possible to pack an invalid Esschain block full ofinvalid WT to other chains. Even chains that don't have lockboxes toEsschain can create lockboxes to Esschain for free. Thus, instead ofstealing only one lockbox at a time on mainchain, the thief can steal onelockbox on mainchain, and on every sidechain that supports side-to-sidepegs, at a time. The risk/reward ratio may shift drastically in that case.However, this does mean that users of one chain must pay attention toattacks on other chains, not just the chain they use. If Teechain has noside-to-side pegs, then Teechain users will not care if Esschain is underattack. But if side-to-side pegs are allowed on Teechain, then Teechainusers must also care about Esschain's health, as well as the health ofevery other sidechain in existence. Mainchain is protected since freelockboxes are not creatable on mainchain. Each sidechain is not; thusthe user of any sidechain must also stand by users of every othersidechain, or else they all fall apart. Of course, this could moresimply lead to "I will not use Teechain even if it would be useful to me,because if I use Teechain, I have to care about Esschain and Youchain andwhatever."--Side-to-side pegs are useful to allow better liquidity and providearbitrage quickly between sidechains, without having to pass throughmainchain. Otherwise, Esscoin may be valued slightly lower than Bitcoin,then Teecoin valued slightly higher than Bitcoin, creating a largerdifference between Esscoin and Teecoin values than what a fullside-to-side peg could support. 2-way pegs from mainchainto sidechain stabilize sidecoin with respect to maincoin. Side-to-sidepegs stabilize all sidecoins to all other sidecoins.Side-to-side pegs are enabled implicitly by sidechain-headers-on-mainchain, as all sidechain fullnodes must necessarily be mainchain fullnodes, andany mainchain fullnode can judge the validity of any WT from any sidechainwithout a miner voting period.Side-to-side pegs are a generalization of main-to-side and side-to-mainpegs. A sidechain can simply implement OP_WITHDRAWPROOFVERIFY and allowfree lockboxes, and that is sufficient for the sidechain to supportimports of bitcoin from mainchain and from any other sidechain.Side-to-side pegs seem to imply that all pegs must have the same bitcoinvalue transferred. What that value must be, is something that may bedebated endlessly.A side-to-side peg is a cut-through of a side-to-main peg fromone sidechain into a main-to-side peg into another sidechain. If awithdrawal from side-to-main peg would be accepted by mainchain, thenanother sidechain could, in principle, accept a proof that wouldauthorize a side-to-main peg directly as a side-to-side peg.Side-to-side pegs make attacks on sidechains more lucrative, as itbecomes possible to print sidecoins by successfully attacking adifferent sidechain.Drivechain cannot implement side-to-side pegs, as WT validity isvoted on by mainchain miners, and asking mainchain miners aboutside-to-side pegs requires mainchain miners to be aware of bothsidechains. Sidechain-headers-on-mainchain publishes SPV proofscontinuously to the mainchain, and since any sidechain fullnode isalso a mainchain fullnode (since sidechains are mergemined), thenevery sidechain fullnode is automatically capable of accessingand verifying SPV proofs for every other sidechain.However, the pegging here seems less flexible than the peggingsupported by drivechain. Drivechain lets pegs be any size, withminer voting being the basis of knowing how much money is ownedby whom.Regards,ZmnSCPxj