forked from repository23/hackathon2024warsaw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
122 lines (105 loc) · 4.23 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>zkVerifyJS Proof Checker</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
background-color: #f4f4f9;
}
h1, h2 {
color: #333;
}
form {
margin-bottom: 20px;
}
input {
padding: 10px;
margin: 10px 0;
width: 100%;
box-sizing: border-box;
}
button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
.result {
margin-top: 20px;
padding: 20px;
background-color: #e7f3fe;
border: 1px solid #2196F3;
color: #333;
}
</style>
</head>
<body>
<h1>zkVerifyJS Proof Checker</h1>
<h2>Enter Proof Data</h2>
<form id="proofForm">
<label for="proof">Proof:</label>
<input type="text" id="proof" name="proof" placeholder="Enter proof here" required>
<label for="publicSignals">Public Signals:</label>
<input type="text" id="publicSignals" name="publicSignals" placeholder="Enter public signals here" required>
<label for="vk">Verification Key (vk):</label>
<input type="text" id="vk" name="vk" placeholder="Enter verification key here" required>
<button type="button" id="checkProofBtn">Check the Proof</button>
</form>
<div class="result">
<h2>Proof Check Result:</h2>
<div id="result">Awaiting input...</div>
</div>
<script type="module">
import { zkVerifySession, ZkVerifyEvents, VerifyTransactionInfo } from 'zkverifyjs';
document.getElementById('checkProofBtn').addEventListener('click', async function () {
// Get the values from the form inputs
const proof = document.getElementById('proof').value;
const publicSignals = document.getElementById('publicSignals').value;
const vk = document.getElementById('vk').value;
try {
// Start a new zkVerifySession on the testnet
const session = await zkVerifySession.start()
.Testnet()
.withAccount('your-seed-phrase'); // Replace 'your-seed-phrase' with the actual value
// Execute the verification transaction
const { events, transactionResult } = await session.verify().risc0()
.waitForPublishedAttestation()
.execute(proof, publicSignals, vk);
// Listen for the 'includedInBlock' event
events.on(ZkVerifyEvents.IncludedInBlock, (eventData) => {
console.log('Transaction included in block:', eventData);
});
// Listen for the 'finalized' event
events.on(ZkVerifyEvents.Finalized, (eventData) => {
console.log('Transaction finalized:', eventData);
});
// Listen for errors
events.on('error', (error) => {
console.error('An error occurred during the transaction:', error);
document.getElementById('result').innerText = 'Error occurred while checking the proof.';
});
// Await the final transaction result
const transactionInfo = await transactionResult;
// Display the result based on the final transaction status
document.getElementById('result').innerText = 'Transaction completed successfully: ' + JSON.stringify(transactionInfo);
} catch (error) {
console.error('Error checking the proof:', error);
document.getElementById('result').innerText = 'Error occurred while checking the proof.';
} finally {
// Close the session when done
if (session) {
await session.close();
}
}
});
</script>
</body>
</html>