<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Patricio Gallardo on Medium]]></title>
        <description><![CDATA[Stories by Patricio Gallardo on Medium]]></description>
        <link>https://medium.com/@patogallaiov?source=rss-13fd6773af32------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ec5-0CoqJ_A6VSg-1MCdgQ.jpeg</url>
            <title>Stories by Patricio Gallardo on Medium</title>
            <link>https://medium.com/@patogallaiov?source=rss-13fd6773af32------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:42:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@patogallaiov/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[RSK’s Peg-out efficiency improvement — Segwit (part 3/3)]]></title>
            <link>https://medium.com/rootstock-tech-blog/rsks-peg-out-efficiency-improvement-segwit-part-3-3-df9986e9e14d?source=rss-13fd6773af32------2</link>
            <guid isPermaLink="false">https://medium.com/p/df9986e9e14d</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[bridge]]></category>
            <category><![CDATA[rsksmart]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Patricio Gallardo]]></dc:creator>
            <pubDate>Wed, 19 Oct 2022 11:42:37 GMT</pubDate>
            <atom:updated>2024-04-18T15:33:22.677Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rootstock (RSK)’s Peg-out efficiency improvement — Segwit (part 3/3)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CkrUArjuZNgoxOXxnL9JEQ.jpeg" /></figure><p>Co-authors: <a href="https://medium.com/u/a4d9b433d49a">Ramsès Fernàndez-València</a> and <a href="https://medium.com/u/848f289098c6">Nicolás Vescovo</a></p><p>In the previous posts (<a href="https://medium.com/iovlabs-innovation-stories/rsks-peg-out-efficiency-improvement-segwit-part-1-3-28968bfa649b">part 1</a> &amp; <a href="https://medium.com/iovlabs-innovation-stories/rsks-peg-out-efficiency-improvement-segwit-part-2-3-d36f68723a5">part 2</a>) on our RSK’s Peg-out efficiency improvement series, I described the main actors of the architecture, the limitations of the current design and a brief introduction to Segwit versions. I also went more in-depth and described the different proposals studied with their corresponding implementation: Segwit v0 and Segwit v1/Taproot (FROST, ICE-FROST and MuSig2).</p><p>In this last post, I will end up with a comparison of the proposals and a conclusion.</p><h3>Comparison</h3><h4>Summary</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*EjCBiTR7urC4xMYkuLur6g.png" /></figure><h3>PowHSM Complexity</h3><p>When we refer to the <em>complexity</em> we are talking about code and data structure.</p><h4>Segwit v0</h4><p>The complexity here involves only code, as the only change involves the fields that now compose the digest of the signature, and where (in the transaction) to put the resulting signature. We consider that comparing the rest of the protocols is a low-effort change, not to underestimate the complexity but to expose it compared to the rest.</p><h4>Segwit v1</h4><p>In both cases, it is easy to see that FROST would be much more complex than MuSig2. In the case of Musig2, it is a “medium” complexity. We can highlight:</p><ul><li>that the Bitcoin transaction parsing by the powHSM changes (we have to account for witness parsing, which is currently not supported).</li><li>that the message to sign computation by the powHSM changes</li><li>that the powHSM does not have to validate the chosen script path and therefore there’s no Merkle proof parsing involved</li><li>that, as opposed to FROST, there is no additional “step” with added complexity in the signing operation</li></ul><p>But in the case of FROST, we have much more complex logic to implement:</p><ul><li>Setup process generating a shared secret depending on the “m” of the threshold.</li><li>Random generation for each UTXO to sign.</li><li>Random association for different rounds between the random and a UTXO id. (additional data structure).</li><li>Signing process custom using random generated and pk.</li></ul><h3>Fees cost</h3><p>We will consider “fee reduction” only in terms of signature and redeem script, which is the variable data necessary to redeem an output. For calculating the total fee reduction we would have to analyze different scenarios combining a quantity of inputs and outputs, and all the data regarding the transaction (not in the scope of this document).</p><p>It became clear that the main fee reduction comes with the upgrade to Segwit v0 (~70% fee reduction) and that Segwit v1 takes advantage of it and makes it even more efficient (~90% fee reduction).</p><p>Focusing on Segwit v1, we can say that although both schemas would have better fees than the current one, we could prove that FROST has a constant low fee which is several times (15x approx.) lower than what it is now. While the MuSig2 depends on the size of the threshold (m and n), the reduction percentage is not as significant as FROST.</p><h4>Notes</h4><ol><li>We calculated the bytes as an approximation. There are more components of the transaction not relevant to this study.</li><li>An ECDSA signature is usually about 72 bytes in size for a single signature in a transaction. Schnorr signatures clock in at a maximum of 64 bytes per signature.</li></ol><h4>Example of fee calculation for a threshold 7 of 13:</h4><p>Current (<strong>P2SH</strong>) fee calculation</p><ul><li>Script: “M &lt;pk1&gt; &lt;pk2&gt; … &lt;pkN&gt; N OP_CHECKMULTISIG”</li><li>Script vb (M of N) : 1 + 33 * N + 2 = X</li><li>Script vb (7 of 13): 1 + 33 * 13 + 2 = 432</li><li>Signatures vb (M of N) : (72+1) * M = X</li><li>Signatures vb (7 of 13) : (72+1) * 7 = 511</li><li>Total = 432 + 511 = <strong>943 vbytes</strong></li></ul><p>Segwit Compatible (<strong>P2SH-P2WSH</strong>) fee calculation</p><ul><li>Script: “0 &lt;ActualRedeemScriptHash&gt;”</li><li>ActualRedeemScript: “M &lt;pk1&gt; &lt;pk2&gt; … &lt;pkN&gt; N OP_CHECKMULTISIG”</li><li>Script WU (sha256=32b / not in witness -&gt; *4) : (32 + 1 ) * 4 = 132 WU</li><li>ActualRedeemScript WU (M of N) : 1 + 33 * N + 2 = X WU</li><li>ActualRedeemScript WU (7 of 13): 1 + 33 * 13 + 2 = 432 WU</li><li>Signatures WU (M of N) : (72+1) * M = X WU</li><li>Signatures WU (7 of 13) : (72+1) * 7 = 511 WU</li><li>Total = 132 + 432 + 511 = 1075 WU / 4 = <strong>268.75 vbytes</strong></li></ul><p>Segwit Native (<strong>P2WSH</strong>) fee calculation</p><ul><li>Script: “&lt;pk1&gt; OP_CHECKSIG &lt;pk2&gt; OP_CHECKSIGADD … &lt;pkN&gt; OP_CHECKSIGADD M OP_EQUAL”</li><li>Script WU (M of N) : (33+1) * N + 2 = X WU</li><li>Script WU (7 of 13): 34 * 13 + 2 = 444 WU</li><li>Signatures WU (M of N) : (72+1) * M = X WU</li><li>Signatures WU (7 of 13) : (72+1) * 7 = 511 WU</li><li>Total = 444 + 511 = 955 WU / 4 = <strong>238.75 vbytes</strong></li></ul><p>FROST (<strong>P2TR — key path</strong>) fee calculation</p><ul><li>Signatures WU (1 signature only): 64 WU</li><li>Total = 64 WU / 4 = <strong>16 vbytes</strong></li><li>Musig2 (<strong>P2TR — script path — MAST</strong>) fee calculation</li><li>Script: “&lt;pk&gt; OP_CHECKSIG”</li><li>Script WU: 34 WU</li><li>Inner key of root key: 32 WU</li><li>Hashing partner in tree: 32 WU * Log_2 (Cmn )</li><li>Hashing partner in tree (7 of 13): 32 WU * 11 = 352 WU</li><li>Signatures WU (1 signature only): 64 WU</li><li>Total = 34 WU + 32 WU + 352 WU + 64 WU = 482 / 4 = <strong>120 vbytes</strong></li></ul><p>We are not going to show the demonstration, but in an example of a threshold of<strong> 17 of 34 </strong>(this is the maximum we can represent due to a limitation of MAST being 32 the maximum height of the tree), the difference between the options becomes notable in favor of FROST which is constant. But we have an acceptable difference in favor of Segwit (both scenarios).</p><ul><li>Current (P2SH): <strong>2396 vbytes</strong></li><li>Segwit Compatible: <strong>620.25 vbytes</strong></li><li>Segwit Native: <strong>599.25 vbytes</strong></li><li>FROST: <strong>16 vbytes</strong></li><li>Musig2: <strong>288.5 vbytes</strong></li></ul><h3>Real world example</h3><h4>Peg-out transaction:</h4><p><a href="https://www.blockchain.com/btc/tx/cdbae904e8465fe42cadf61e584a948a40a8a1852f0a444c9d8c4c3aa0fa65d6">https://www.blockchain.com/btc/tx/cdbae904e8465fe42cadf61e584a948a40a8a1852f0a444c9d8c4c3aa0fa65d6</a></p><ul><li>Fee: 0.00016305 BTC</li><li>Fee ~$: 6</li></ul><h4>Fee reduction:</h4><p>P2WSH (Segwit v0):</p><ul><li>Fee: 0.000048915 BTC</li><li>Fee ~$: 1,85</li></ul><p>Musig2:</p><ul><li>Fee: 0.00003261 BTC</li><li>Fee ~$: 1,20</li></ul><p>FROST:</p><ul><li>Fee: 0.0000179355 BTC</li><li>Fee ~$: 0,70</li></ul><h3>Verification complexity</h3><p>Here we want to compare how hard it is to verify that, for security reasons, the possible ways to spend the UTXO are completely transparent and there is no hidden condition that someone could exploit.</p><p>In the case of FROST, the shared keys should be easily computable, checking that the aggregation of the same corresponds to a valid threshold of m of n. Which should require a short computation time and effort.</p><p>But in the case of Musig, it depends on the size of the threshold. If it increments in size, the combination of possible scripts becomes higher, and we would need much computation time and effort. For instance, if we take a threshold of 17 of 34, we have approximately 2.333 Millions possible scripts. To validate the tree, we should rebuild it by combining all possible groups of 17, hashing all intermediate keys (another 2.333 Million hashes) to reach the Merkle root, and reconstructing the main Taproot key. It is possible but confusing and adds complexity to its use and trust.</p><h3>Robustness</h3><p>Let’s define robustness as the ability of the schema to resume in case of failure or malicious actors without needing the whole process to restart from the beginning.</p><p>We could say that FROST and MuSig2 have the worst robustness because they need to restart the process. But, in the case of FROST, it has its variant ICE-FROST, which improves some scenarios, making it a more robust solution. Neither of them reaches the current working solution, which has better robustness, not being possible to abort the process if one of the actors acts maliciously.</p><p>It is good to mention that we didn’t explore the possibility of improving Musig2 robustness. Still, we believe that it should be possible to get a better result by analyzing different scenarios with the Federation team, once they understand the implementation aspects of this schema.</p><h3>Implementation time</h3><p>This is only an estimated subjective opinion since we still don’t have any valid PoC of these schemas. But, supported by the analysis, we could say that Segwit could be the easiest solution to implement in the short term, followed by FROST in the medium/large term, due to complexity and the need to develop new features involving more than 1 team (Federation, Core and HSM).</p><p>Short-term would be estimated in a couple of months, while long-term we would require an estimate of 1 year development time.</p><h3>Threshold N Limit</h3><p>Segwit has a limitation of a threshold of “m of 67” due to the limit on the script size (3600 bytes) and the 201 script ops limit, where we publish all the public keys of the pegnatories.</p><p>MuSig2 has a limit of a threshold of 17 of 34 (this is the maximum we can represent due to a limitation of MAST being 32 the maximum height of the tree), whereas FROST has no limit in terms of how many participants can generate an aggregate signature. But we believe that FROST has a limit in terms of the complexity of communication of signatures and Bridge coordination between them. So this “unlimited” feature related to FROST is just theoretical.</p><p>Furthermore, in practice, we have another constraint, which is memory consumption. The Bridge runs into a node of limited memory. In the case of FROST that constraint doesn’t matter at all since we only need to recover some signatures and do some small computations. But in the case of Musig2, we need to compute the tree, which can have millions of elements and hashes in memory.</p><p>An estimative table has been made with the following formula:</p><ul><li>Being X = # of elements</li><li>Size of script (leaf) = 34 bytes</li><li>Size of the hash (intermediate leaf) = 32 bytes</li><li>Total size of the tree (in megabytes) = (X * 34 + X * 32 * 2) / 1.000.000</li></ul><p>The next table is estimated in MegaBytes (MB), combining thresholds of M of N:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*PHV4dKPHDtGkTxQyC76SDw.png" /></figure><p>For the purpose of this analysis, we suggest taking ~500MB as a limit of what a node can use to represent this tree. So the maximum possible N is <strong>25</strong>.</p><h3>Conclusion</h3><p>After the analysis, we can take some takeaways.</p><ul><li>Comparing all the proposals with the current method (P2SH), we can see that Segwit improves several aspects, especially those related to fees and, in particular, when it comes to the threshold limit, which allows Segwit to provide more flexibility. Even with just Segwit v0, the improvement is considerable.</li><li>When comparing Segwit v1 proposals (FROST, ICE-FROST and MuSig2), we can observe that FROST is the most efficient scheme. It has a fixed fee cost, a no-limited threshold and an improvement in a fee reduction of around 98%. However, the scheme is hard to implement and requires a big effort. We could consider this schema for the long term in the future.</li></ul><p>To put it all together, although Segwit v0 does not provide the best overall performance compared to the other mechanisms, it emerges as the most robust option with promising results in terms of efficiency and greatly improves the economic aspects of P2SH.</p><p>As a first step considering the benefits, we are going to propose an upgrade to Segwit v0 (<a href="https://ips.rsk.co/IPs/RSKIP305.html">RSKIP-305</a>) in the short term and the plan for a long-term FROST (TBD) scheme implementation, which will lead to outstanding performance and more security for the RSK PowPeg.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df9986e9e14d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rootstock-tech-blog/rsks-peg-out-efficiency-improvement-segwit-part-3-3-df9986e9e14d">RSK’s Peg-out efficiency improvement — Segwit (part 3/3)</a> was originally published in <a href="https://medium.com/rootstock-tech-blog">RootstockLabs: Research &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RSK’s Peg-out efficiency improvement — Segwit (part 2/3)]]></title>
            <link>https://medium.com/rootstock-tech-blog/rsks-peg-out-efficiency-improvement-segwit-part-2-3-d36f68723a5?source=rss-13fd6773af32------2</link>
            <guid isPermaLink="false">https://medium.com/p/d36f68723a5</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[bridge]]></category>
            <category><![CDATA[rsksmart]]></category>
            <dc:creator><![CDATA[Patricio Gallardo]]></dc:creator>
            <pubDate>Tue, 18 Oct 2022 17:02:11 GMT</pubDate>
            <atom:updated>2024-04-18T15:33:27.984Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rootstock (RSK)’s Peg-out efficiency improvement — Segwit (part 2/3)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cSliNt10ioeq0jnxXXLIqQ.jpeg" /></figure><p>Co-authors: <a href="https://medium.com/u/a4d9b433d49a">Ramsès Fernàndez-València</a> and <a href="https://medium.com/u/848f289098c6">Nicolás Vescovo</a></p><p>In the <a href="https://medium.com/iovlabs-innovation-stories/rsks-peg-out-efficiency-improvement-segwit-part-1-3-28968bfa649b">previous post</a> on our RSK’s Peg-out efficiency improvement series, I described the main actors of the architecture, the limitations of the current design and a brief introduction to Segwit versions.</p><p>In this post, I go even more in-depth and describe the proposals studied: Segwit v0 and Segwit v1/Taproot (FROST, ICE-FROST and MuSig2). And I also explain the modifications required to implement each scheme.</p><p><a href="https://medium.com/iovlabs-innovation-stories/rsks-peg-out-efficiency-improvement-segwit-part-3-3-df9986e9e14d">In the next and last post</a>, I will wrap up with the most interesting part: a comparison of the proposals and a conclusion.</p><h3>Studied Proposals</h3><h4>Segwit v0</h4><p>This proposal only requires minor changes to the current RSK Peg implementation. That is why we will not do any specific analysis in this section as it won’t require any significant change in the signature scheme. It is still a regular “m of n” multi-signature scheme in which a group of m participants signs the transaction, and the data published on-chain is n public keys and m signatures.</p><p>The implementation of this proposal involves moving the redeem script and the signatures to the <em>witness data</em> section, which drastically reduces the fee cost of the transaction.</p><p>The main advantages and drawbacks of this mechanism will be discussed in detail when compared with the rest of the proposals.</p><h4>MuSig2 (Segwit v1)</h4><p>Musig2 is a multi-signature protocol for Schnorr signatures. The proposal MuSig2 cannot be considered a naive multi-signature scheme as it shares some similarities with aggregate signature proposals. Although MuSig2 is not a threshold, thanks to Taproot MAST (Merkelized Alternative Script Tree) feature, it could be adapted to be one</p><p>Amongst the highlights of the scheme, one finds:</p><ul><li>It’s secure under parallel signing sessions.</li><li>The possibility of key aggregation.</li><li>It outputs ordinary Schnorr signatures.</li><li>Reduces the communication rounds to two, in contrast to the earlier proposal MuSig, which requires three rounds.</li><li>Has signer complexity similar to ordinary Schnorr signatures.</li></ul><p>In MuSig2 each participant has a pair of keys, one private and one public key. They are generated by taking <em>x</em> ∈ ℤ at random and computing X =<em> gx</em> for <em>g</em> a generator of a cyclic group <em>G</em>.</p><p>The scheme uses two signing rounds to produce <em>m </em>intermediate signatures for the <em>m</em> users, and a final combination of these signatures creates a single final signature. This signature is verified with a public key generated by the combination of the public keys of the users.</p><p>When this scheme is used to authenticate a blockchain transaction, the only data published on-chain is one public key and one signature, which is indistinguishable from a usual Schnorr signature, therefore the costs are much lower than a multi-signature and equal to those generated by a threshold mechanism. Furthermore, the key generation in MuSig2 is simpler than the key generation in threshold schemes.</p><p>Like I mentioned at the beginning, although MuSig2 is not a threshold, thanks to Taproot MAST (Merkelized Alternative Script Tree) feature, it could be adapted to be one. So instead of one public key generated by the combination of the public keys of the users, we could build a Merkle tree of keys with the combination of the signers grouped by <em>m</em> .</p><p>The idea of including a Merkle tree with the groups of admissible signers can be used with MuSig2, BLS, or any other multi-signature scheme. This feature is included in Taproot under the hood of Merkelized abstract syntax trees (MAST), which are a method of using Merkle trees to store the various user-selected conditions that must be fulfilled for the encumbered bitcoins to be spent.</p><p>When we compare MuSig2 threshold variant with other threshold signature schemes, we can identify a negative aspect against it which requires exactly the chosen <em>m</em> signers to participate (<em>m </em>= <em>n</em>) and makes MuSig2 a rigid solution. If one of the signers fails to sign, then another group of <em>m</em> signers must be chosen and start the process all over again.</p><h4>FROST (Segwit v1)</h4><p>The threshold proposal FROST uses a semi-trusted signature aggregator (SA) whose role allows signers to reduce the network overhead. The aggregator is used for coordination and it doesn’t have access to privileged information. The SA role can be played either by a participant in the protocol or by an external 3rd party. The SA is trusted to identify misbehaving participants and is also responsible for publishing the group’s signature at the end of the protocol. In case of a misbehaving SA, the protocol remains secure against adaptive CCA. A malicious SA has the power to perform DDoS attacks, or falsely report malicious participants, but cannot learn the private key or cause improper messages to be signed.</p><p>Key generation in FROST is done in 2 rounds and relies on Pedersen’s distributed key generation algorithm, whereas the singing algorithm builds upon additive secret sharing.</p><p>Furthermore, signing operations make use of binding techniques to avoid forgery attacks. The signing process consists of two phases: a pre-processing stage and a single-round signing phase, but one may combine them to get a single-round signing phase.</p><p>In the FROST scheme the only thing a malicious actor or signer could achieve is the invalidation of the complete process by sending an invalid signature in the last step. It cannot cheat other participants nor the SA.</p><h4>ICE–FROST (Segwit v1)</h4><p>To improve the robustness of FROST, an Identifiable Cheating Entity (ICE) mechanism is introduced that allows the identification and exclusion of malicious participants in FROST.</p><p>The ICE mechanism uses symmetric encryption algorithms at the cost of more interaction between users. In the proposal, the shares are encrypted using a shared secret key derived from Diffie-Hellman key exchange between sender and receiver.</p><p>In the ICE mechanism, each participant issues a complaint against a malicious action instead of aborting the protocol. The complaint must be validated by honest users.</p><p>In practice, the sender establishes a secure channel by encrypting shares and broadcasting the encrypted values. One way to prove that the sender of a share has cheated is for the receiver to reveal the received encrypted value to every participant by revealing the decryption key. This approach requires the decryption key to satisfy the properties below:</p><ol><li>The decryption key associated with the communication of each pair of users should be unique.</li><li>The decryption key should be verifiable by other participants.</li></ol><h3>Remarks on the Proposals</h3><p>Depending on the scheme chosen, the situation changes:</p><ul><li>Choosing <strong>FROST</strong> avoids the requirement of using a Merkle tree containing the information of admissible signing groups since it is based on secret sharing: all the possible signers (<em>n</em>) can participate in the secret-sharing phase, and then the system requires enough pegnatories (<em>m</em>) to perform the signature.</li><li>It is well known that <strong>FROST</strong> is vulnerable to malicious participants (that would force abortions in the process) but detecting them can be done at the early stages of the protocol: in the key generation stage, the end of the first round requires a sequential checking that would report an error and the author of that error. Similarly, in the signing process, the third step of the algorithm requires a similar sequential checking. In the worst case, when the signature aggregator comes into the game, it will perform one further check, at the end of the signing process.</li><li>The possible main drawback of <strong>FROST</strong> is the key generation phase, which relies on secret sharing. This stage may present difficulties at the implementation level, although the underlying idea is not hard. In particular, the interaction of several participants may be hard to manage.</li><li>Choosing <strong>MuSig2</strong> will require using a MAST, containing the admissible signing groups. Computational complexity implications of turning MuSig2 into a threshold mechanism follow:</li></ul><p>Let <em>n</em> be the number of participants and <em>m</em> the threshold.</p><ul><li>The <strong>number of elements</strong> contained in the above Merkle tree is:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/22/1*YaJ2iPSSBmn3onq8TAITig.png" /></figure><ul><li>The <strong>space complexity</strong> of this tree is exponential on the threshold:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/63/1*UkoLTpX45wUgtDJnDPdsHg.png" /></figure><ul><li>Searching, traversing, inserting or deleting an element in a Merkle tree has <strong>time complexity</strong>:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*TIqDNEJBU4cWthOv8znS3Q.png" /></figure><h3>Implementing FROST, ICE-FROST and MuSig2 schemes</h3><h3>FROST</h3><h4>Implementation</h4><p>The critical part of implementing this scheme in RSK is concerning the PowHSM, which is why we will need to focus on it.</p><p>The FROST first round of signing is about generating what we call the random <em>R key par</em>. For that to happen, each of the pegnatories has to generate one random key pair (r, R) for each of the UTXOs in the transaction (because what they sign is each of the UTXOs). RSK’s new version (<a href="https://github.com/rsksmart/rskj/releases/tag/HOP-4.0.0">HOP 4.0.0</a>) includes “peg-out batching” (<a href="https://ips.rsk.co/IPs/RSKIP271.html">RSKIP-271</a>) which helps reduce some of this effort by grouping multiple peg-out requests into a single transaction.</p><p>The random R is shared between the rest of the pegnatories by publishing it to the Bridge. Once all the required actors publish their proper R to the bridge, the <em>signing process</em> or the <em>second round</em> begins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*SJCY3e4q03vBEaXi" /><figcaption><em>Figure. Representation of 1st round.</em></figcaption></figure><p>In the second round, every pegnatory will receive the addition of all R’s, named “R+”. Its PowHSM will take this R+ related to the specific UTXO, recover the (r, R) generated in the previous step, and sign the UTXO. Finally, the pegnatory will be in charge of publishing that signature to the Bridge, which will ultimately build the final signature after validating them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/0*FK15dck9kzkJ_ei4" /><figcaption>Figure. <em>Representation of 2nd round.</em></figcaption></figure><h4>Failure Flow</h4><p>During this process, it could happen that one of the actors (pegnatories/PowHSM) doesn’t generate proper output. As a consequence, the whole process is interrupted. The malicious actor could be easily identified and probably banned (i.e.: 1000 blocks penalty, where it cannot process any transaction).</p><h4>Setup</h4><p>The initial setup of this schema is interactive, which means that the participants have to exchange data through the Bridge. It is important to remark that this should be on chain interaction, since the pegnatories are not connected between each other, and the only way to interact is through the Bridge.</p><p>The participants generate a shared secret whose input is the number “m” of the threshold (m of n). Once all the participants have shared their secrets, the Bridge can generate the final PK, which will be part of the bitcoin script (from which the taproot address of the threshold is derived).</p><h4>Feasibility</h4><p>We concluded that while it is feasible to implement the whole scheme, there are a few concerns to be cleared if we desire to implement a POC:</p><ul><li>The random number has to be a <em>secure</em> random number (not possible to generate the same twice)</li><li>Once we know what data structure PowHSM needs to validate, we have to check the feasibility of implementing new types of parsers.</li></ul><h3>ICE — FROST</h3><p>This schema variation improves the robustness of the previously explained schema. In terms of implementation, it is slightly different but not significantly different. It means that if we can prove that it is feasible (by some PoC) to implement the previous schema, it is most probable that this other schema is also doable.</p><p>One of the variations resides after the first round. There is an extra step that checks the validity of R+. If a participant did not generate a valid R, that part of the process is automatically cancelled and restarted from scratch.</p><p>The second and primary difference is during the second round. If a participant tries to cheat or generates a corrupted signature, the whole process doesn’t necessarily have to restart entirely but just from the second round.</p><p>That makes the entire process more robust without critical changes needed. It adds some new checks in the Bridge and a way to restart the second round within the Bridge, which we consider feasible and not so complex to implement.</p><h3>MuSig2</h3><h4>Implementation</h4><p>Musig2 schema is much easier to implement than FROST but less effective and less performant than the latter.</p><p>For PowHSM it becomes much more straightforward. It doesn’t need any random generation or extra data structure to relate key pairs with UTXOs. It only receives the UTXOs and the revealing path (from the MAST path correlated to the group that is going to sign) and returns the UTXO signed. Which makes it simpler and has fewer steps.</p><p>The complexity resides in the Merkle Tree with the combination of all possible threshold groups from all the pegnatories. That logic has to be implemented in the Bridge contract along with the group selection once the pegnatories express they want to sign.</p><p>Because of having to reveal the path to the group and the signature to spend each UTXO, the revealing data becomes heavier than FROST.</p><p>Using the same structure of rounds as we explain FROST, we can say that the first round of Musig2 is only for showing purpose from the pegnatories to be selected as one of the signers by the Bridge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/0*lYFDzcGq-oU2rpgq" /><figcaption><em>Figure. Representation of 1st round.</em></figcaption></figure><p>Once the group is selected (the Bridge could build it pseudo-randomly based on the PoW of the previous block), each of the pegnatories chosen takes the transaction and the path to the selected group inside the Merkle Tree of possible groups and passes it to their PowHSM. Each pegnatory’s PowHSM signs all the UTXOs and returns each signature to the pegnatory to be published again to the Bridge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/0*JKr8XIMPpUbaqjCr" /><figcaption><em>Figure. Representation of 2nd round.</em></figcaption></figure><p>Finally, the Bridge builds the final transaction with each pegnatories’ signatures and leaves it ready to be published into the Bitcoin network.</p><h4>Failure Flow</h4><p>During this process, it could happen that one of the actors (pegnatories/PowHSM) doesn’t generate a valid output and, as a result, the Bridge could decide to abort the whole process.</p><p>Also, The malicious actor could be easily identified and probably banned (i.e.: 1000 blocks penalty, where it cannot process any transaction).</p><p>The need for a restart is due to how Taproot script path signing is defined. The signature commits to the script selected and the MAST proof. It means that the signature only works for the selected group. If we need to change the group, we must generate a new signature again.</p><p>As an alternative, a way of improving the process could be to anticipate a possible failure and select a backup group. Although it could reduce the risk, it would still make the process more complex and less performant in terms of computation, communication and size of the messages. And there is a big chance that the malicious actor is part of both groups.</p><h4>Setup</h4><p>The initial setup for building the Merkle tree does not need to be interactive. Each participant publishes their PK. Then the Bridge builds the tree and derives the taproot PK and pay-to-taproot address.</p><p>Building the tree means combining each of the participants in all possible ways of the threshold:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/32/1*DWgYxMB1s8HeLgcx47q1Iw.png" /></figure><p>and the same quantity of combinations will be the intermediate hashes to reach the Merkle root.</p><p>Number of elements of the tree (M of N):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*QtI1cYrPeNlaxkXRR3l_eg.png" /></figure><p>Height of the tree (M of N):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*bhK5abEtop8jS44ETH6o8A.png" /></figure><h4>Feasibility</h4><p>After a deep analysis, we concluded that it is feasible to implement the whole scheme.</p><h3>Final remarks</h3><p>In this post, we have analysed and described the possible implementations of the different Segwit mechanisms to improve the RSK Peg-out.</p><p><a href="https://medium.com/iovlabs-innovation-stories/rsks-peg-out-efficiency-improvement-segwit-part-3-3-df9986e9e14d">In the next and last post</a>, I will end up with a comparison of the proposals and a conclusion.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d36f68723a5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rootstock-tech-blog/rsks-peg-out-efficiency-improvement-segwit-part-2-3-d36f68723a5">RSK’s Peg-out efficiency improvement — Segwit (part 2/3)</a> was originally published in <a href="https://medium.com/rootstock-tech-blog">RootstockLabs: Research &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RSK’s Peg-out efficiency improvement — Segwit (part 1/3)]]></title>
            <link>https://medium.com/rootstock-tech-blog/rsks-peg-out-efficiency-improvement-segwit-part-1-3-28968bfa649b?source=rss-13fd6773af32------2</link>
            <guid isPermaLink="false">https://medium.com/p/28968bfa649b</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[bridge]]></category>
            <category><![CDATA[rsksmart]]></category>
            <dc:creator><![CDATA[Patricio Gallardo]]></dc:creator>
            <pubDate>Mon, 17 Oct 2022 11:47:21 GMT</pubDate>
            <atom:updated>2024-04-18T15:33:32.530Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rootstock (RSK)’s Peg-out efficiency improvement — Segwit (part 1/3)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AtTSkANZnlZiRfONrKm7jg.jpeg" /></figure><p>Co-authors: <a href="https://medium.com/u/a4d9b433d49a">Ramsès Fernàndez-València</a> and <a href="https://medium.com/u/848f289098c6">Nicolás Vescovo</a></p><p>This analysis presents a proposal for the reduction of the peg-out cost and it would also allow increasing the number of pegnatories without increasing the peg-out cost based on the use of <em>Segwit</em> in RSK’s PEG, including a modified digital signature scheme. It also analyzes the feasibility and the effort needed to implement either a <em>threshold</em> or a <em>multi-signature</em> scheme.</p><p>In this post, I describe the main actors of the architecture, namely: the bridge, the pegnatories, and the HSM. I also introduce the limitations of the current design, in terms of cost and scalability, and provide a brief introduction to Segwit versions.</p><p><a href="https://medium.com/iovlabs-innovation-stories/rsks-peg-out-efficiency-improvement-segwit-part-2-3-d36f68723a5">In the next post</a>, I will describe the proposals studied: Segwit v0 and Segwit v1/Taproot (FROST, ICE-FROST and MuSig2). And I will also explain the modifications required by each scheme to be implemented successfully.</p><p>Finally,<a href="https://medium.com/iovlabs-innovation-stories/rsks-peg-out-efficiency-improvement-segwit-part-3-3-df9986e9e14d"> in the last post</a>, I will end up with a comparison of the proposals and a conclusion.</p><p>No more waiting, let’s start introducing the actors of the current RSK architecture.</p><h3>Actors</h3><h4>Bridge and 2 Way Peg</h4><p>A bridge is a mechanism to transfer value across blockchains by locking assets on one side and unlocking (equivalent value) on the other. In RSK, this is implemented by the Bridge Contract.</p><p>The Bridge Contract is an unstoppable pre-compiled smart contract living in the RSK blockchain. The role of the Bridge Contract is to maintain an up-to-date view of the Bitcoin blockchain, verify peg-in requests and command peg-outs. To accomplish this functionality, the Bridge contract manages a Bitcoin wallet in SPV (<a href="https://en.bitcoinwiki.org/wiki/Simplified_Payment_Verification">Simple Payment Verification</a>) mode. In this mode, transactions are confirmed by block headers and block headers are minimally validated, but the validation includes the expected proof of work.</p><p>Technically, the RSK Powpeg is a hybrid peg. Performing a peg-in is as easy as sending the bitcoins to the Powpeg address and informing the Bridge Contract about the Bitcoin transaction. The Powpeg functionaries provide a “watchtower” service on behalf of users and inform the Bridge of any peg-in as well. Users can also inform the Bridge about peg-in transactions and Bitcoin block headers. To prevent intended or unintended invalid forks, the Bridge is designed to wait for 100 confirmations (on Bitcoin network) before confirming a peg-in transaction.</p><p>To perform peg-outs is not as simple as a peg-in. The Bridge accepts peg-out requests from RSK accounts, and after 4000 RSK block confirmations (approximately 200 Bitcoin blocks), the Bridge builds a Bitcoin peg-out transaction, and the pegnatories transmit the transaction to the PowHSM to sign this transaction. The Bridge selects the transaction inputs (or UTXOs) to include in the peg-out transactions, preventing selective censorship of UTXOs of any kind.</p><h4>Pegnatories</h4><p>A pegnatory is an autonomous functionary that protects the multi-signature of the Powpeg. The primary role of a pegnatory is to keep their PowHSM hardware and Powpeg node connected and alive at all times; pegnatories are involved in the signing of transactions indirectly as well as being data relays. To be clear, pegnatories do not participate in the production of blocks on the RSK blockchain. Pegnatories are incentivized to participate by receiving a small portion of RSK transaction fees that are automatically channeled to them. At present, RSK uses a 7/13 multisig. Thus, at any point, there are 13 Pegnatories each running a distinct Powpeg node with its unique PowHSM.</p><h4>PowHSM</h4><p>The PowHSM is specialized hardware connected to a special type of RSK full node (the “Powpeg Node”). A PowHSM is an external tamper-proof device that creates and protects one of the private keys required for the Bitcoin multi-signature protocol, only signing transactions proven valid by enough cumulative work. The Powpeg node is designed to have maximal connectivity and to communicate information about the RSK blockchain avoiding becoming isolated. The RSK Powpeg protects private keys stored in these special-purpose PowHSMs based on tamper-proof secure elements. Each PowHSM runs an RSK node in SPV mode, so signatures can only be commanded by a chain containing enough cumulative proof of work.</p><h4>Users</h4><p>The users of the bridge are merchants and exchanges or any individual user transferring value between the Bitcoin and RSK networks. Users interact with the RSK 2-way peg by sending and receiving peg-in and peg-out transactions to the Bridge smart contract through the Bitcoin and RSK networks.</p><h3>The Limitations of the current RSK peg</h3><p>The RSK peg uses multi-signatures to implement a threshold scheme that protects the locked bitcoins. Multi-signatures are simple and relatively efficient for small groups, but they become expensive as the number of signers increases. Each input signed in a peg-out transaction must transmit m-out-of-n signatures, and each signature consumes 65 bytes, and n public keys, consuming 33 or 65 bytes each, depending on if they are compressed or not. <em>Threshold signatures</em>, on the contrary, consume only 65 bytes for all signers, no matter their number.</p><p>ECDSA threshold signatures were possible even before the activation of Taproot in Bitcoin. However, this upgrade has enabled more signature schemes that are simpler, more secure and more efficient.</p><h3>Segwit v0 / v1</h3><h4>Segwit v0 (Native)</h4><p>Segwit stands for “segregated witness”, and it is an upgrade to the Bitcoin consensus rules and network protocol proposed and implemented as a BIP — 91 (<a href="https://github.com/bitcoin/bips/blob/master/bip-0091.mediawiki">https://github.com/bitcoin/bips/blob/master/bip-0091.mediawiki</a>) soft-fork that was activated on Bitcoin’s main-net in 2017.</p><p>Before segwit’s introduction, every input in a transaction was followed by the witness data that unlocked it. The witness data was embedded in the transaction as part of each input. It is called segregated witness because it implies separating the signature or the unlocking script of a specific output. The witness data is moved outside the transaction.</p><p>In Segwit v0, the Block Size concept is replaced by Block Weight. Block Size is measured in Bytes and Block Weight is measured in Weight Units (WU). The maximum weight of a 1 MB block is 4000 WU. In calculating the weight of a transaction, a non-witness 1 byte weighs 4 WU and a witness byte weighs 1 WU.</p><p>Segwit Native addresses are also named “<strong>P2WSH</strong>”, which stands for Pay-To-Witness-Script-Hash.</p><h4>Segwit v0 (Compatible)</h4><p>This design allows older wallets and other software to send bitcoin to SegWit addresses even if they themselves do not support SegWit. The receiver of a SegWit compatible transaction can spend the bitcoin as a SegWit input, and thus save on fees.</p><p>Therefore, a P2WSH can be embedded in a P2SH address and is noted as <strong>P2SH-P2WSH</strong>. The sender’s wallet sees this as a P2SH address and can make payments to it without any knowledge of segwit. The receiver’s wallet can then spend this payment with a segwit transaction, taking full advantage of segwit and reducing transaction fees.</p><h4>Segwit v1</h4><p>Segwit v1 (aka <strong>Taproot</strong>) is an upgrade of the previously mentioned Segwit v0. It allows payments to Schnorr public keys that may optionally commit to a script that can be revealed at spend time.<br>Coins protected by taproot may be spent either by satisfying one of the committed scripts or by simply providing a signature that verifies against the public key (allowing the script to be kept private). Taproot is intended for use with Schnorr signatures that simplify multiparty construction (e.g. using Frost) and with MAST (e.g. using MuSig2) to allow committing to more than one script, any one of which may be used at spend time.</p><p>This soft fork was composed of three main BIPs:</p><ul><li>BIP-340: <a href="https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki">https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki</a></li><li>BIP-341: <a href="https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki">https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki</a></li><li>BIP-342: <a href="https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki">https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki</a></li></ul><p>Segwit v1 addresses are also named “<strong>P2TR</strong>”, which stands for Pay-To-Taproot.</p><h3>Final remarks</h3><p>In this post, I have introduced the current actors and limitations of the RSK PEG mechanism, as well as a brief introduction to Segwit. In the <a href="https://medium.com/iovlabs-innovation-stories/rsks-peg-out-efficiency-improvement-segwit-part-3-3-df9986e9e14d">next</a> <a href="https://medium.com/iovlabs-innovation-stories/rsks-peg-out-efficiency-improvement-segwit-part-3-3-df9986e9e14d">ones</a>, I will dive deeper into different proposals related to Segwit, that could make this mechanism more efficient.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28968bfa649b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rootstock-tech-blog/rsks-peg-out-efficiency-improvement-segwit-part-1-3-28968bfa649b">RSK’s Peg-out efficiency improvement — Segwit (part 1/3)</a> was originally published in <a href="https://medium.com/rootstock-tech-blog">RootstockLabs: Research &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>