arnaucube
arnaucube/ethdos-foldPublic Self-hosted repository
ethdos-fold/index.html
index.htmlRaw
  1<!doctype html>
  2<html lang="en-US" class="h-100">
  3  <head>
  4    <meta charset="utf-8" />
  5    <meta name="viewport" content="width=device-width, initial-scale=1">
  6    <title>ETHdos fold</title>
  7
  8    <!-- Bootstrap CSS -->
  9    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
 10
 11    <style>
 12      body {
 13        background-color: #1a1a1a;
 14        color: #d4d4d4;
 15      }
 16
 17      .btn-primary {
 18        background-color: #6f42c1;
 19        border-color: #6f42c1;
 20      }
 21      .btn-primary:hover, .btn-primary:focus {
 22        background-color: #5a32a3;
 23        border-color: #5a32a3;
 24      }
 25      .btn-primary:active {
 26        background-color: #4a2785 !important;
 27        border-color: #4a2785 !important;
 28      }
 29
 30      #console-out {
 31        font-family: monospace;
 32        font-size:75%;
 33        padding: 10px;
 34        background-color: #2d2d2d;
 35        color: #d4d4d4;
 36        border-radius: 5px;
 37        overflow: scroll;
 38        height: 70vh;
 39      }
 40      #console-out p { margin:0px;}
 41      #console-out .log { color: #d4d4d4; }
 42      #console-out .warn { color: #ffa500; }
 43      #console-out .error { color: #ff6b6b; }
 44      #console-out .info { color: #4fc3f7; }
 45
 46      textarea {
 47        background-color: #2d2d2d;
 48        color: #d4d4d4;
 49        border: 1px solid #444;
 50        margin-top:5px;
 51      }
 52
 53      .box {
 54        padding-top: 10px;
 55        border: 1px solid #2d2d2d;
 56        border-radius: 5px;
 57      }
 58      a {
 59        color: #6f42c1;
 60      }
 61    </style>
 62  </head>
 63  <body class="container">
 64      <a target="_blank" href="https://github.com/arnaucube/ethdos-fold" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#fff; color:#151513; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
 65
 66      <div class="container py-5">
 67        <div class="row">
 68          <div class="col-md-1">
 69          </div>
 70          <div class="col-md-6 box">
 71            <h2 class="text-center mb-4">ETHdos fold</h2>
 72            <p>Follows the ideas of ETHdos (<a target="_blank" href="https://ethdos.xyz/blog">https://ethdos.xyz/blog</a>), but using Folding Schemes.</p>
 73            <p style="font-size:90%;">It uses <a target="_blank" href="https://github.com/privacy-scaling-explorations/sonobe">Sonobe</a> under the hood, compiled to WASM.</a>
 74          <p style="font-style:italic;font-size:80%;">
 75          Current version does not parallelize in wasm. Same execution can be run natively (no wasm), instructions <a target="_blank" href="https://github.com/arnaucube/ethdos-fold">in the repo</a>.<br>
 76            In the same laptop, natively takes ~290ms per step, in-browser takes ~1700ms per step.
 77          </p>
 78
 79              <button id="btn_gen_params" class="btn btn-primary">1. gen_params</button>
 80
 81            <div class="mb-3">
 82              <!-- <label for="params" class="form-label">params:</label> -->
 83              <textarea id="params" class="form-control" rows="3">params</textarea>
 84            </div>
 85
 86            <div class="mb-3">
 87              <button id="btn_gen_sigs" class="btn btn-primary">2. gen_sigs</button><br>
 88              <!-- <label for="sigs" class="form-label">sigs and pks:</label> -->
 89              <textarea id="sigs" class="form-control" rows="3">sigs and pks</textarea>
 90            </div>
 91
 92            <div class="mb-3">
 93              <button id="btn_fold_sigs" class="btn btn-primary">3. fold_sigs</button><br>
 94              <!-- <label for="ivc_proof" class="form-label">ivc proof:</label> -->
 95              <textarea id="ivc_proof" class="form-control" rows="3">ivc proof</textarea>
 96            </div>
 97              <button id="btn_verify_proof" class="btn btn-primary">4. verify_proof</button>
 98
 99          </div>
100          <div class="col-md-4">
101            logs:
102            <span id="spinner"></span>
103            <p style="font-style:italic;">(Open the browser console to see the execution logs)</p>
104            <div id="console-out" class="mt-4">
105              (logs will appear after the execution of each button ends)
106            </div>
107          </div>
108        </div>
109      </div>
110
111    <!-- Bootstrap JS -->
112    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
113
114    <script type="module">
115      import init, { gen_params, gen_sigs, fold_sigs, verify_proof } from "./pkg/ethdos_fold.js";
116
117      const n_sigs = 5;
118
119      await init();
120      console.log("ready");
121
122      document.getElementById('btn_gen_params').addEventListener('click', () => {
123        spinner_on();
124        setTimeout(() => {
125          let params = gen_params();
126          document.getElementById("params").innerHTML = JSON.stringify(params);
127          console.info("folding scheme params generated");
128          spinner_off();
129        }, 500);
130      });
131      document.getElementById('btn_gen_sigs').addEventListener('click', () => {
132        spinner_on();
133        let sigs = gen_sigs(n_sigs);
134        setTimeout(() => {
135          document.getElementById("sigs").innerHTML = JSON.stringify(sigs);
136          spinner_off();
137          console.info(`${n_sigs} signatures generated`);
138        }, 500);
139      });
140      document.getElementById('btn_fold_sigs').addEventListener('click', () => {
141        spinner_on();
142        setTimeout(() => {
143          let params = JSON.parse(document.getElementById("params").innerHTML);
144          let sigs = JSON.parse(document.getElementById("sigs").innerHTML);
145          let ivc_proof = fold_sigs(params, sigs);
146          document.getElementById("ivc_proof").innerHTML = JSON.stringify(ivc_proof);
147          console.info(`ivc_proof generated, proving distance of ${n_sigs} degrees (${n_sigs} recursive proofs) from the initial public key`);
148          spinner_off();
149        }, 500);
150      });
151      document.getElementById('btn_verify_proof').addEventListener('click', () => {
152        spinner_on();
153        setTimeout(() => {
154          let params = JSON.parse(document.getElementById("params").innerHTML);
155          let ivc_proof = JSON.parse(document.getElementById("ivc_proof").innerHTML);
156          let v = verify_proof(params[0], ivc_proof);
157          console.info("verification result:");
158          console.info(v);
159          spinner_off();
160        }, 500);
161      });
162
163
164    var oldLog = console.log;
165    var oldWarn = console.warn;
166    var oldError = console.error;
167    var oldInfo = console.info;
168    var outputDiv = document.getElementById('console-out');
169
170    function appendToDOM(message, type) {
171        var p = document.createElement('p');
172        p.textContent = "> " + message;
173        p.className = type;
174        outputDiv.appendChild(p);
175        outputDiv.scrollTop = outputDiv.scrollHeight;
176    }
177    console.log = function(message) {
178        oldLog.apply(console, arguments);
179        appendToDOM(message, 'log');
180    };
181    console.warn = function(message) {
182        oldWarn.apply(console, arguments);
183        appendToDOM(message, 'warn');
184    };
185    console.error = function(message) {
186        oldError.apply(console, arguments);
187        appendToDOM(message, 'error');
188    };
189    console.info = function(message) {
190        oldInfo.apply(console, arguments);
191        appendToDOM(message, 'info');
192    };
193
194    function spinner_on() {
195        document.getElementById("spinner").className="spinner-border";
196    }
197    function spinner_off() {
198        document.getElementById("spinner").className="spinner-border d-none";
199    }
200    </script>
201  </body>
202</html>