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    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  9
 10    <style>
 11      body {
 12        background-color: #1a1a1a;
 13        color: #d4d4d4;
 14      }
 15
 16      .btn-primary {
 17        background-color: #6f42c1;
 18        border-color: #6f42c1;
 19      }
 20      .btn-primary:hover, .btn-primary:focus {
 21        background-color: #5a32a3;
 22        border-color: #5a32a3;
 23      }
 24      .btn-primary:active {
 25        background-color: #4a2785 !important;
 26        border-color: #4a2785 !important;
 27      }
 28
 29      #console-out {
 30        font-family: monospace;
 31        font-size:75%;
 32        padding: 10px;
 33        background-color: #2d2d2d;
 34        color: #d4d4d4;
 35        border-radius: 5px;
 36        overflow: scroll;
 37        height: 70vh;
 38      }
 39      #console-out p { margin:0px;}
 40      #console-out .log { color: #d4d4d4; }
 41      #console-out .warn { color: #ffa500; }
 42      #console-out .error { color: #ff6b6b; }
 43      #console-out .info { color: #4fc3f7; }
 44
 45      textarea {
 46        background-color: #2d2d2d;
 47        color: #d4d4d4;
 48        border: 1px solid #444;
 49        margin-top:5px;
 50      }
 51
 52      .box {
 53        padding-top: 10px;
 54        border: 1px solid #2d2d2d;
 55        border-radius: 5px;
 56      }
 57      a {
 58        color: #6f42c1;
 59      }
 60    </style>
 61  </head>
 62  <body class="container">
 63      <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>
 64
 65      <div class="container py-5">
 66        <div class="row">
 67          <div class="col-md-1">
 68          </div>
 69          <div class="col-md-6 box">
 70            <h2 class="text-center mb-4">ETHdos fold</h2>
 71            <p style="font-style:italic;font-size:80%;" class="text-center">(simple browser demo)</p>
 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 ethdos-fold repo</a>.<br>
 76          </p>
 77
 78              <button id="btn_gen_params" class="btn btn-primary">1. gen_params</button>
 79
 80            <div class="mb-3">
 81              <textarea id="params" class="form-control" rows="3">params</textarea>
 82            </div>
 83
 84            <div class="mb-3">
 85              <button id="btn_gen_sigs" class="btn btn-primary">2. gen_sigs</button><br>
 86              <textarea id="sigs" class="form-control" rows="3">sigs and pks</textarea>
 87            </div>
 88
 89            <div class="mb-3">
 90              <button id="btn_fold_sigs" class="btn btn-primary">3. fold_sigs</button><br>
 91              <textarea id="ivc_proof" class="form-control" rows="3">ivc proof</textarea>
 92            </div>
 93              <button id="btn_verify_proof" class="btn btn-primary">4. verify_proof</button>
 94
 95          </div>
 96          <div class="col-md-4">
 97            logs:
 98            <span id="spinner"></span>
 99            <p style="font-style:italic;">(Open the browser console to see the execution logs)</p>
100            <div id="console-out" class="mt-4">
101              (logs will appear after the execution of each button ends)
102            </div>
103          </div>
104        </div>
105      </div>
106
107    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
108
109    <script type="module">
110      import init, { gen_params, gen_sigs, fold_sigs, verify_proof } from "./pkg/ethdos_fold.js";
111
112      const n_sigs = 5;
113
114      await init();
115      console.log("ready");
116
117      document.getElementById('btn_gen_params').addEventListener('click', () => {
118        spinner_on();
119        setTimeout(() => {
120          let params = gen_params();
121          document.getElementById("params").innerHTML = JSON.stringify(params);
122          console.info("folding scheme params generated");
123          spinner_off();
124        }, 500);
125      });
126      document.getElementById('btn_gen_sigs').addEventListener('click', () => {
127        spinner_on();
128        let sigs = gen_sigs(n_sigs);
129        setTimeout(() => {
130          document.getElementById("sigs").innerHTML = JSON.stringify(sigs);
131          spinner_off();
132          console.info(`${n_sigs} signatures generated`);
133        }, 500);
134      });
135      document.getElementById('btn_fold_sigs').addEventListener('click', () => {
136        spinner_on();
137        setTimeout(() => {
138          let params = JSON.parse(document.getElementById("params").innerHTML);
139          let sigs = JSON.parse(document.getElementById("sigs").innerHTML);
140          let ivc_proof = fold_sigs(params, sigs);
141          document.getElementById("ivc_proof").innerHTML = JSON.stringify(ivc_proof);
142          console.info(`ivc_proof generated, proving distance of ${n_sigs} degrees (${n_sigs} recursive proofs) from the initial public key`);
143          spinner_off();
144        }, 500);
145      });
146      document.getElementById('btn_verify_proof').addEventListener('click', () => {
147        spinner_on();
148        setTimeout(() => {
149          let params = JSON.parse(document.getElementById("params").innerHTML);
150          let ivc_proof = JSON.parse(document.getElementById("ivc_proof").innerHTML);
151          let v = verify_proof(params[0], ivc_proof);
152          console.info("verification result:");
153          console.info(v);
154          spinner_off();
155        }, 500);
156      });
157
158
159    var oldLog = console.log;
160    var oldWarn = console.warn;
161    var oldError = console.error;
162    var oldInfo = console.info;
163    var outputDiv = document.getElementById('console-out');
164
165    function appendToDOM(message, type) {
166        var p = document.createElement('p');
167        p.textContent = "> " + message;
168        p.className = type;
169        outputDiv.appendChild(p);
170        outputDiv.scrollTop = outputDiv.scrollHeight;
171    }
172    console.log = function(message) {
173        oldLog.apply(console, arguments);
174        appendToDOM(message, 'log');
175    };
176    console.warn = function(message) {
177        oldWarn.apply(console, arguments);
178        appendToDOM(message, 'warn');
179    };
180    console.error = function(message) {
181        oldError.apply(console, arguments);
182        appendToDOM(message, 'error');
183    };
184    console.info = function(message) {
185        oldInfo.apply(console, arguments);
186        appendToDOM(message, 'info');
187    };
188
189    function spinner_on() {
190        document.getElementById("spinner").className="spinner-border";
191    }
192    function spinner_off() {
193        document.getElementById("spinner").className="spinner-border d-none";
194    }
195    </script>
196  </body>
197</html>