mirror of
https://github.com/arnaucube/miksi-app.git
synced 2026-02-06 19:26:49 +01:00
Add deposit zkProof generation
This commit is contained in:
BIN
circuits-files/deposit-proving_key.bin
Normal file
BIN
circuits-files/deposit-proving_key.bin
Normal file
Binary file not shown.
BIN
circuits-files/deposit.wasm
Normal file
BIN
circuits-files/deposit.wasm
Normal file
Binary file not shown.
BIN
circuits-files/withdraw-proving_key.bin
Normal file
BIN
circuits-files/withdraw-proving_key.bin
Normal file
Binary file not shown.
BIN
circuits-files/withdraw.wasm
Normal file
BIN
circuits-files/withdraw.wasm
Normal file
Binary file not shown.
@@ -73,24 +73,6 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc66ff', end
|
|||||||
-webkit-touch-callout: none; /* Disable Android and iOS callouts*/
|
-webkit-touch-callout: none; /* Disable Android and iOS callouts*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#qrcode > img {
|
|
||||||
border: 8px solid #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-btn-wrapper {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-btn-wrapper input[type=file] {
|
|
||||||
font-size: 100px;
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.balanceBox {
|
.balanceBox {
|
||||||
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#cc66ff+0,FF00B9+98 */
|
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#cc66ff+0,FF00B9+98 */
|
||||||
background: #cc66ff; /* Old browsers */
|
background: #cc66ff; /* Old browsers */
|
||||||
@@ -106,6 +88,14 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc66ff', end
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
/* box-shadow: 0px 0px 30px grey; */
|
/* box-shadow: 0px 0px 30px grey; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.balanceBox > h3 {
|
.balanceBox > h3 {
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.alertBox {
|
||||||
|
border: 1px #FF00B9 solid;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 20px;
|
||||||
|
color: #FF00B9;
|
||||||
|
}
|
||||||
|
|||||||
14
index.html
14
index.html
@@ -53,7 +53,10 @@
|
|||||||
<i>From Esperanto, <b>miksi</b> (miks·i): to mingle, to blend, to mix, to shuffle</i>
|
<i>From Esperanto, <b>miksi</b> (miks·i): to mingle, to blend, to mix, to shuffle</i>
|
||||||
<br>
|
<br>
|
||||||
Ethereum trustless <b>zk-mixer</b>.
|
Ethereum trustless <b>zk-mixer</b>.
|
||||||
<br><br><br>
|
<br><br>
|
||||||
|
<div class="alertBox"><b>WARNING</b>: experimental code, use only in Göerli testnet, and without real value.</div>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<!-- deposit -->
|
<!-- deposit -->
|
||||||
<div class="tab-pane fade show active" id="deposit" role="tabpanel" aria-labelledby="deposit-tab">
|
<div class="tab-pane fade show active" id="deposit" role="tabpanel" aria-labelledby="deposit-tab">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -62,7 +65,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit.
|
Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit.
|
||||||
<br><br>
|
<br><br>
|
||||||
<button onclick="todo()" class="btn color_primary float-right">Deposit 1 ETH</button>
|
<button onclick="deposit('deposit')" class="btn color_primary float-right">Deposit 1 ETH</button>
|
||||||
<br><br><br>
|
<br><br><br>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
@@ -166,6 +169,13 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.min.js"></script> -->
|
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.min.js"></script> -->
|
||||||
|
|
||||||
|
<script src="lib/wasmsnark_bn128.js"></script>
|
||||||
|
<script src="lib/snarkjs.js"></script>
|
||||||
|
<!-- <script src="node_modules/web3/dist/web3.min.js"></script> -->
|
||||||
|
<script src="lib/miksi-browser.js"></script>
|
||||||
|
|
||||||
|
<script src="index.js"></script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
49
index.js
Normal file
49
index.js
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
var circuit = {};
|
||||||
|
var provingKey = {};
|
||||||
|
var witnessCalc = {};
|
||||||
|
|
||||||
|
function loadCircuit(circuitname) {
|
||||||
|
fetch("circuits-files/"+circuitname+"-proving_key.bin").then( (response) => {
|
||||||
|
return response.arrayBuffer();
|
||||||
|
}).then( (b) => {
|
||||||
|
provingKey[circuitname] = b;
|
||||||
|
console.log("proving_key loaded for", circuitname);
|
||||||
|
});
|
||||||
|
|
||||||
|
fetch("circuits-files/"+circuitname+".wasm").then( (response) => {
|
||||||
|
return response.arrayBuffer();
|
||||||
|
}).then( (b) => {
|
||||||
|
witnessCalc[circuitname] = b;
|
||||||
|
console.log("w", b);
|
||||||
|
console.log("witnessCalc loaded for", circuitname);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deposit(circuitname) {
|
||||||
|
console.log("circuit:", circuitname);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
const secret = "1234567890";
|
||||||
|
const nullifier = "567891234";
|
||||||
|
const commitments = [];
|
||||||
|
|
||||||
|
// witness
|
||||||
|
console.log(witnessCalc[circuitname]);
|
||||||
|
const witness = await miksi.calcWitness(witnessCalc[circuitname], secret, nullifier, commitments);
|
||||||
|
console.log("w", witness);
|
||||||
|
|
||||||
|
// proof
|
||||||
|
const start = new Date().getTime();
|
||||||
|
console.log(provingKey[circuitname]);
|
||||||
|
const proof = await window.groth16GenProof(witness.buffer, provingKey[circuitname]);
|
||||||
|
const end = new Date().getTime();
|
||||||
|
const time = end - start;
|
||||||
|
console.log("circuit " + circuitname + " took " + time + "ms to compute");
|
||||||
|
console.log(proof);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadCircuit("deposit");
|
||||||
|
loadCircuit("withdraw");
|
||||||
|
|
||||||
|
|
||||||
|
// var web3 = new Web3(Web3.givenProvider || "ws://localhost:8545");
|
||||||
76368
lib/miksi-browser.js
Normal file
76368
lib/miksi-browser.js
Normal file
File diff suppressed because one or more lines are too long
13317
lib/snarkjs.js
Normal file
13317
lib/snarkjs.js
Normal file
File diff suppressed because it is too large
Load Diff
5839
lib/wasmsnark_bn128.js
Normal file
5839
lib/wasmsnark_bn128.js
Normal file
File diff suppressed because one or more lines are too long
3974
package-lock.json
generated
3974
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"build": "browserify node_modules/snarkjs/index.js -o lib/snarkjs.js --standalone snarkjs --ignore-missing",
|
||||||
"predeploy": "npm install",
|
"predeploy": "npm install",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
@@ -12,6 +13,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.18.0",
|
"axios": "^0.18.0",
|
||||||
"bootstrap": "^4.2.1",
|
"bootstrap": "^4.2.1",
|
||||||
"toastr": "^2.1.4"
|
"toastr": "^2.1.4",
|
||||||
|
"wasmsnark": "0.0.10",
|
||||||
|
"snarkjs": "^0.1.31",
|
||||||
|
"web3": "^1.0.0-beta.30"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"browserify": "^16.5.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user