forked from Path-Check/paper-cred-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.v3.html
308 lines (269 loc) · 15.5 KB
/
index.v3.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!doctype html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.v2.css">
<link rel="stylesheet" href="css/topnav.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="https://www.pathcheck.org/hubfs/Favicon.png">
<title>Vaccine Distribution Certificates Generator</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DTDMHW3NV6"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-DTDMHW3NV6');
</script>
</head>
<body>
<div class="topnav">
<div class="topnavContainer">
<a href="index.html">Signers</a>
<a href="verify.html"><span class="xs-hidden">Universal </span>Verifier</a>
<a class="xs-hidden" href="debug.html">QR Debugger</a>
<a class="xs-hidden" href="https://github.com/Path-Check/paper-cred-demo">Source Code</a>
<a href="https://github.com/Path-Check/paper-cred"><span class="xs-hidden"> QR </span>Specs</a>
<a href="http://vaccine-docs.pathcheck.org"><span class="xs-hidden">Vaccine </span>Docs</a>
<a class="xs-hidden" href="http://pathcheck.org">About PathCheck</a>
</div>
</div>
<div class="center">
<h1>Vax Journey (El. Curve)</h1>
<div class="full-div">
<div class="quarter">
<h4>Coupon</h4>
<table>
<tr><td>ID</td><td><input id="qr-coupon-id" type="text" placeholder="2"/></td></tr>
<tr><td>Coupons</td><td><input id="qr-coupon-coupons" type="text" placeholder="5000"/></td></tr>
<tr><td>Phase</td><td><input id="qr-coupon-phase" type="text" placeholder="1A, 2A, ..."/></td></tr>
<tr><td>City</td><td><input id="qr-coupon-city" type="text" placeholder="Somerville, Cambridge, ..."/></td></tr>
<tr><td>Age</td><td><input id="qr-coupon-age" type="text" placeholder="Under 65, Over 65, ...>"/></td></tr>
<tr><td>Conditions</td><td><input id="qr-coupon-conditions" type="text" placeholder="Diabetes, ...."/></td></tr>
<tr><td>Job</td><td><input id="qr-coupon-job" type="text" placeholder="Teacher, Healthworker, ..."/></td></tr>
</table>
</div>
<div class="quarter">
<h4>PassKey</h4>
<table>
<tr><td>Name</td><td><input id="qr-passkey-name" type="text" placeholder="Patient Name"/></td></tr>
<tr><td>Phone</td><td><input id="qr-passkey-phone" type="text" placeholder="617 .."/></td></tr>
<tr><td>Birthdate</td><td><input id="qr-passkey-dob" type="text" placeholder="YYYY-MM-DD"/></td></tr>
<tr><td>Salt</td><td><input id="qr-passkey-salt" type="text" placeholder="2342342"/></td></tr>
</table>
</div>
<div class="quarter">
<h4>Badge</h4>
<table>
<tr><td>Date</td><td><input id="qr-badge-date" type="text" placeholder=""/></td></tr>
<tr><td>Manuf</td><td><input id="qr-badge-manuf" type="text" placeholder="Pfizer, Moderna, etc"/></td></tr>
<tr><td>Product</td><td><input id="qr-badge-product" type="text" placeholder="COVID-19"/></td></tr>
<tr><td>Lot#</td><td><input id="qr-badge-lot" type="text" placeholder="012L20A, ..."/></td></tr>
<tr><td>Route</td><td><input id="qr-badge-route" type="text" placeholder="Intramuscular, Intranasal, Subcut, Oral, ..."/></td></tr>
<tr><td>Site</td><td><input id="qr-badge-site" type="text" placeholder="Right Arm, Left Arm, ..."/></td></tr>
<tr><td>Dosage</td><td><input id="qr-badge-dose" type="text" placeholder="1.0ml, 0.5ml, ..."/></td></tr>
<tr><td>Doses</td><td><input id="qr-badge-required_doses" type="text" placeholder="1, 2, 3, ..."/></td></tr>
<tr><td>Next Dose</td><td><input id="qr-badge-next_dose_in_days" type="text" placeholder="21, 28, ..."/></td></tr>
<tr><td>Vaccinator</td><td><input id="qr-badge-vacinator" type="text" placeholder="Pharmacy Name, City, ..."/></td></tr>
<tr><td>PassKey</td><td><input id="qr-badge-vaccinee" type="text" placeholder="User Hash" readonly/></td></tr>
</table>
</div>
<div class="quarter">
<h4>Status</h4>
<table>
<tr><td>Doses</td><td><input id="qr-status-vaccinated" type="text" placeholder="0,1,2"/></td></tr>
<tr><td>PassKey</td><td><input id="qr-status-vaccinee" type="text" placeholder="User Hash" readonly/></td></tr>
</table>
</div>
<div class="quarter">
<h4>Credentials</h4>
<label for="privkey">Private Key</label><br/>
<textarea id="privkey" rows="10" cols="30">-----BEGIN EC PARAMETERS-----
BgUrgQQACg==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIPWKbSezZMY1gCpvN42yaVv76Lo47FvSsVZpQl0a5lWRoAcGBSuBBAAK
oUQDQgAE6DeIun4EgMBLUmbtjQw7DilMJ82YIvOR2jz/IK0R/F7/zXY1z+gqvFXf
DcJqR5clbAYlO9lHmvb4lsPLZHjugQ==
-----END EC PRIVATE KEY-----</textarea>
<br><br>
<label for="pubkey">Link to Public Key</label><br/>
<textarea id="qr-link" rows="3" cols="30">github.pathcheck.org/keys/ecdsa_pub_key</textarea>
<br><br>
<label for="privkey">QR Code Format</label><br/>
<pre><span class='protocol'>Protocol</span>:<span class='crypto-algo'>HashAlgo</span>\<span class='signature'>Signature</span>@<span class='pub-key'>PubKey</span>?<span class='message'>Message</span></pre>
</div>
</div>
<br>
<div class="four-quarter">
<button class="qr-btn" onclick="generateQRCodes()">Create Certificates</button>
</div>
<div class="full-div">
<div class="quarter">
<h4>Coupon</h4>
<canvas id="qr-coupon-code"></canvas><br/>
<pre id="qr-coupon-result"></pre>
<p id="qr-coupon-verified"></p>
</div>
<div class="quarter">
<h4>Passkey</h4>
<canvas id="qr-passkey-code"></canvas><br/>
<pre id="qr-passkey-result"></pre>
<p id="qr-passkey-verified"></p>
</div>
<div class="quarter">
<h4>Badge</h4>
<canvas id="qr-badge-code"></canvas><br/>
<pre id="qr-badge-result"></pre>
<p id="qr-badge-verified"></p>
</div>
<div class="quarter">
<h4>Status</h4>
<canvas id="qr-status-code"></canvas><br/>
<pre id="qr-status-result"></pre>
<p id="qr-status-verified"></p>
</div>
<div class="quarter">
</div>
</div>
</div>
<script src="js/qrious.min.js"></script>
<script src="js/elliptic.min.js"></script>
<script src="js/sha256.js"></script>
<script src="js/asn1.min.js"></script>
<script>
var EC = elliptic.ec;
var ANS1 = asn1;
var ECPublicKey = ANS1.define("PublicKey", function() {
this.seq().obj(
this.key("algorithm").seq().obj(
this.key("id").objid(),
this.key("curve").objid()
),
this.key("pub").bitstr()
);
});
var ECPrivateKey = ANS1.define("ECPrivateKey", function() {
this.seq().obj(
this.key('version').int().def(1),
this.key('privateKey').octstr(),
this.key('parameters').explicit(0).objid().optional(),
this.key('publicKey').explicit(1).bitstr().optional()
);
});
function e(elem) { return document.getElementById(elem); }
function addIfExists(prefix, elemId) {
let value = encodeURIComponent(e(elemId).value);
return value ? prefix+value : "";
}
function verify(pubkey, message, signature, feedback_elem_id) {
// Download pubkey to verify
var client = new XMLHttpRequest();
client.open('GET', "https://" + pubkey);
client.addEventListener("load",
function() {
// Verify with the public key...
var ec = new EC('secp256k1');
var ec_pubk = ECPublicKey.decode(this.response, 'pem', {label: 'PUBLIC KEY'});
var key = ec.keyFromPublic(ec_pubk.pub.data, 'der');
var verified = key.verify(message, signature);
e(feedback_elem_id).innerHTML = "Verified: " + verified;
}
);
client.send();
}
function signAndDisplayQR(elemPref, protocol, crypto, prikey, pubkey, message) {
var ec = new EC(crypto);
var ec_pk = ECPrivateKey.decode(prikey, 'pem', {label: 'EC PRIVATE KEY'});
var key = ec.keyFromPrivate(ec_pk.privateKey, 'der');
var signature = key.sign(message).toDER('hex');
var uri = protocol+":"+crypto+"\\"+signature+"@"+pubkey+"?"+message;
var qr = new QRious({ element: e(elemPref+'-code') });
qr.set({
foreground: '#3654DD',
size: e(elemPref+'-code').scrollWidth,
level: 'M',
value: uri
});
e(elemPref+"-result").innerHTML= "<span class='protocol'>"+protocol+"</span>:" +
"<span class='crypto-algo'>"+crypto+"</span>\\" +
"<span class='signature'>" + signature + "</span>" + "@" +
"<span class='pub-key'>" + pubkey + "</span>" + "?" +
"<span class='message'>" + message + "</span>";
e(elemPref+"-verified").innerHTML = "Verified: false";
verify(pubkey, message, signature, elemPref + "-verified");
}
function generateQRCodes() {
gtag('event', 'generateQR');
var pubkey = e("qr-link").value.trim().replace("http://","");
var prikey = e('privkey').value;
var messageCoupon = "type=coupon";
messageCoupon += addIfExists("&id=", "qr-coupon-id");
messageCoupon += addIfExists("&coupons=", "qr-coupon-coupons");
messageCoupon += addIfExists("&phase=", "qr-coupon-phase");
messageCoupon += addIfExists("&city=", "qr-coupon-city");
messageCoupon += addIfExists("&age=", "qr-coupon-age");
messageCoupon += addIfExists("&conditions=", "qr-coupon-conditions");
messageCoupon += addIfExists("&job=", "qr-coupon-job");
signAndDisplayQR("qr-coupon", "healthpass", 'secp256k1', prikey, pubkey, messageCoupon);
// PassKey
var messagePassKey = "type=passkey";
messagePassKey += addIfExists("&name=", "qr-passkey-name");
messagePassKey += addIfExists("&phone=", "qr-passkey-phone");
messagePassKey += addIfExists("&dob=", "qr-passkey-dob");
messagePassKey += addIfExists("&salt=", "qr-passkey-salt");
signAndDisplayQR("qr-passkey", "healthpass", 'secp256k1', prikey, pubkey, messagePassKey);
var hashPassKey = CryptoJS.SHA256(messagePassKey);
e("qr-status-vaccinee").value = hashPassKey;
e("qr-badge-vaccinee").value = hashPassKey;
// Badge
var messageBadge = "type=badge";
messageBadge += "&date="+e("qr-badge-date").value;
messageBadge += addIfExists("&vaccinee=", "qr-badge-vaccinee");
messageBadge += addIfExists("&vaccinator=", "qr-badge-vacinator");
messageBadge += addIfExists("&manuf=", "qr-badge-manuf");
messageBadge += addIfExists("&name=", "qr-badge-product");
messageBadge += addIfExists("&lot=", "qr-badge-lot");
messageBadge += addIfExists("&route=", "qr-badge-route");
messageBadge += addIfExists("&site=", "qr-badge-site");
messageBadge += addIfExists("&dose=", "qr-badge-dose");
messageBadge += addIfExists("&required_doses=", "qr-badge-required_doses");
messageBadge += addIfExists("&next_dose_in_days=", "qr-badge-next_dose_in_days");
signAndDisplayQR("qr-badge", "healthpass", 'secp256k1', prikey, pubkey, messageBadge);
// Status
var messageStatus = "type=status";
messageStatus += addIfExists("&vaccinated=", "qr-status-vaccinated");
messageStatus += addIfExists("&vaccinee=", "qr-status-vaccinee");
signAndDisplayQR("qr-status", "healthpass", 'secp256k1', prikey, pubkey, messageStatus);
}
</script>
<script>
// Defaults
e("qr-badge-date").value = new Date().toJSON().slice(0, 16);
// Salt
e("qr-passkey-salt").value = Math.random().toString(36).substring(3);
function loadDemo() {
e("qr-coupon-id").value = "US MA 0001";
e("qr-coupon-coupons").value = 5000;
e("qr-coupon-phase").value = "1A";
e("qr-coupon-city").value = "Somerville";
e("qr-coupon-age").value = "<65";
e("qr-coupon-conditions").value = "Chronic";
e("qr-coupon-job").value = "HealthWorkers, Teachers";
e("qr-passkey-name").value = "John Doe";
e("qr-passkey-phone").value = "+1 617 333 2345";
e("qr-passkey-dob").value = "1950-04-22";
e("qr-badge-vacinator").value = "CVS Minute Clinic";
e("qr-badge-manuf").value = "Moderna";
e("qr-badge-product").value = "COVID-19";
e("qr-badge-lot").value = "012L20A";
e("qr-badge-route").value = "IM";
e("qr-badge-site").value = "RA";
e("qr-badge-dose").value = ".5ml";
e("qr-badge-required_doses").value = "2";
e("qr-badge-next_dose_in_days").value = "28";
e("qr-status-vaccinated").value = "1";
}
loadDemo();
</script>
</body>
</html>