<!doctype html>
|
|
<head>
|
|
<link rel="stylesheet" href="css/style.v2.css">
|
|
<link rel="shortcut icon" href="https://www.pathcheck.org/hubfs/Favicon.png">
|
|
<title>Vial Signed Certificate Proposal</title>
|
|
</head>
|
|
<body>
|
|
<div class="center">
|
|
<div class="full-div">
|
|
<h3>Vial Signed Certificate Proposal (<a href="https://github.com/Path-Check/paper-cred/">Spec</a>, <a href="https://vaccine-docs.pathcheck.org/">Main Page</a>, <a href="https://github.com/Path-Check/paper-cred-demo/">Source Code</a>)</h3>
|
|
|
|
<div class="third">
|
|
<h4>Vial Information</h4>
|
|
<table>
|
|
<tr><td>Manuf</td><td><input id="qr-manuf" type="text" placeholder="Pfizer, Moderna, ..."/></td></tr>
|
|
<tr><td>Product</td><td><input id="qr-product" type="text" placeholder="COVID-19"/></td></tr>
|
|
<tr><td>Lot#</td><td><input id="qr-lot" type="text" placeholder="012L20A, ..."/></td></tr>
|
|
<tr><td>NDC</td><td><input id="qr-ndc" type="text" placeholder="59267-1000-1, ..."/></td></tr>
|
|
<tr><td>Expiration</td><td><input id="qr-exp" type="text" placeholder="YYYYMMDD"/></td></tr>
|
|
<tr><td>Beyond Use</td><td><input id="qr-bud" type="text" placeholder="YYYYMMDD"/></td></tr>
|
|
</table>
|
|
</div>
|
|
<div class="third">
|
|
<h4>Optional Information</h4>
|
|
<table>
|
|
<tr><td>Route</td><td><input id="qr-route" type="text" placeholder="C38238, C38276, ..."/></td></tr>
|
|
<tr><td>Dosage (ul)</td><td><input id="qr-dose" type="text" placeholder="1000, 500, ..."/></td></tr>
|
|
<tr><td>Doses (#)</td><td><input id="qr-doses" type="text" placeholder="10, ..."/></td></tr>
|
|
<tr><td>Serial #</td><td><input id="qr-serial" type="text" placeholder="Pfizer, Moderna, ..."/></td></tr>
|
|
</table>
|
|
</div>
|
|
<div class="third">
|
|
<h4>Design Restrictions</h4>
|
|
<ul>
|
|
<li>Must be printable to 8x8mm curved area</li>
|
|
<li>Must be readable by a regular phone</li>
|
|
</ul>
|
|
|
|
<h4>Benefits</h4>
|
|
<ul>
|
|
<li>Streamline text input</li>
|
|
<li>Trace Vial to shot</li>
|
|
<li>Easy to track counterfeiters</li>
|
|
</ul>
|
|
<a href="https://lh3.googleusercontent.com/9HKRm5Sgt8Hc-eOiQDvGpc4fcEfd2y9oaJN0Fk-JUFD5qaeD2ib2EVvg25_mifdb0jAqfX-eeZAyCx4NBY-epQzvN9btBxhEJ0uOLNAnHOgXMm-YQWn2zwnZZB9ht6xg6Q2S2vjv-wk=w2400?source=screenshot.guru"> <img src="https://lh3.googleusercontent.com/9HKRm5Sgt8Hc-eOiQDvGpc4fcEfd2y9oaJN0Fk-JUFD5qaeD2ib2EVvg25_mifdb0jAqfX-eeZAyCx4NBY-epQzvN9btBxhEJ0uOLNAnHOgXMm-YQWn2zwnZZB9ht6xg6Q2S2vjv-wk=w200-h200-p-k" /> </a>
|
|
</div>
|
|
|
|
<div class="quarter">
|
|
<h4>Credentials</h4>
|
|
<label for="privkey">Private Key <small>(openssl ecparam -name secp256k1 -genkey -out private.key)</small></label><br/>
|
|
<textarea id="privkey" rows="10" style="width: 100%;">-----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">Public Key <small>(openssl ec -in private.key -pubout -out public.key)</small></label><br/>
|
|
<label for="qr-link">KeyID: </label><input id="qr-link" type="text" value="1A9.PCF"></input>
|
|
</div>
|
|
</div>
|
|
<div class="full-div">
|
|
<br>
|
|
<div style="margin: 0 auto; height:50px;">
|
|
<div class="center-in-div">
|
|
<button class="qr-btn" onclick="generateQRCodes()">Create Certificates</button>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
</div>
|
|
<div class="full-div">
|
|
<div class="two-quarter">
|
|
<h4>QR Format</h4>
|
|
<canvas id="qr-vial-code"></canvas><br/>
|
|
<pre id="qr-vial-result"></pre>
|
|
<pre id="qr-vial-verified"></pre>
|
|
<pre id="qr-vial-bytes"></pre>
|
|
</div>
|
|
<div class="two-quarter">
|
|
<h4>PDF 417 Format</h4>
|
|
<canvas id="pdf-vial-code"></canvas><br/>
|
|
</div>
|
|
<div class="quarter">
|
|
<label for="verify">Verify a QR Code</label>
|
|
<div id="reader" style="margin-top: 10px;margin-bottom: 10px;"></div>
|
|
<label for="verify">Or Paste the Code here:</label>
|
|
<textarea id="qr-verify" rows="10" cols="33" placeholder="cred:type:version:signature:pubkey:payload"></textarea>
|
|
<br><br>
|
|
<button class="qr-btn" onclick="verifyQRCode()">Verify</button>
|
|
<br><br>
|
|
<pre>cred:<span class='protocol'>type:version</span>:<span class='signature'>Signature</span>:<span class='pub-key'>PubKey</span>:<span class='message'>Payload</span></pre>
|
|
<pre id="qr-verify-result"></pre>
|
|
<pre id="qr-verify-verified"></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="js/qrcode.min.js"></script>
|
|
|
|
<script src="js/elliptic.min.js"></script>
|
|
<script src="js/sha256.js"></script>
|
|
<script src="js/asn1.min.js"></script>
|
|
<script src="js/base32.min.js"></script>
|
|
<script src="js/html5-qrcode.min.js"></script>
|
|
|
|
<script src="js/libbcmath.js" type="text/javascript"></script>
|
|
<script src="js/bcmath.js" type="text/javascript"></script>
|
|
<script src="js/pdf417.js" type="text/javascript"></script>
|
|
|
|
<script src="js/pcf.js"></script>
|
|
|
|
<script>
|
|
function e(elem) { return document.getElementById(elem); }
|
|
|
|
function getValueArray(elemArray) {
|
|
const fields = elemArray.map(function(elemId) {
|
|
return e(elemId).value;
|
|
})
|
|
return fields;
|
|
}
|
|
|
|
function clearQR(elemPrefix) {
|
|
e(elemPrefix+'-code').getContext('2d').clearRect(0, 0, e(elemPrefix+'-code').width, e(elemPrefix+'-code').height);
|
|
e(elemPrefix+'-result').innerHTML = "";
|
|
e(elemPrefix+'-verified').innerHTML = "";
|
|
e(elemPrefix+'-bytes').innerHTML = "";
|
|
}
|
|
|
|
async function clear() {
|
|
clearQR('qr-vial');
|
|
}
|
|
|
|
function signAndDisplayQR(elemPref, _type, _version, priKeyPEM, pubKeyId, payloadValueArray) {
|
|
const uri = PCF.sign(_type, _version, priKeyPEM, pubKeyId, payloadValueArray);
|
|
const [schema, type, version, signature, pubKeyLink, payload] = PCF.parseURI(uri);
|
|
|
|
const params = { margin:0, width:520, errorCorrectionLevel: 'L', color: {dark: '#3654DD' }};
|
|
|
|
// Builds QR Element
|
|
QRCode.toCanvas(e(elemPref+'-code'), uri, params)
|
|
|
|
PDF417.draw(uri, e("pdf-vial-code"), 3, 2, 2);
|
|
|
|
// Updates screen elements.
|
|
e(elemPref+"-result").innerHTML= schema+":<span class='protocol'>"+type+":"+version+"</span>:" +
|
|
"<span class='signature'>" + signature + "</span>" + ":" +
|
|
"<span class='pub-key'>" + pubKeyLink + "</span>" + ":" +
|
|
"<span class='message'>" + payload + "</span><br>";
|
|
e(elemPref+"-verified").innerHTML = "Signature: Not Verified. ";
|
|
|
|
let qr = QRCode.create(uri, params);
|
|
|
|
let qrQ = QRCode.create(uri, { margin:0, width:275, errorCorrectionLevel: 'Q', color: {dark: '#3654DD' }});
|
|
let qrH = QRCode.create(uri, { margin:0, width:275, errorCorrectionLevel: 'H', color: {dark: '#3654DD' }});
|
|
let qrM = QRCode.create(uri, { margin:0, width:275, errorCorrectionLevel: 'M', color: {dark: '#3654DD' }});
|
|
let qrL = QRCode.create(uri, { margin:0, width:275, errorCorrectionLevel: 'L', color: {dark: '#3654DD' }});
|
|
|
|
e(elemPref+"-bytes").innerHTML = "URI in A/N (5.5bit/char): "+ Math.round(uri.length * 5.5/8) + " bytes<br>";
|
|
|
|
e(elemPref+"-bytes").innerHTML += "<br>QR Size Analysis: ";
|
|
e(elemPref+"-bytes").innerHTML += "<br>- ECC L 7% " + describe(qrL);
|
|
e(elemPref+"-bytes").innerHTML += "<br>- ECC M 15% " + describe(qrM);
|
|
e(elemPref+"-bytes").innerHTML += "<br>- ECC Q 25% " + describe(qrQ);
|
|
e(elemPref+"-bytes").innerHTML += "<br>- ECC H 30% " + describe(qrH);
|
|
|
|
e(elemPref+"-bytes").innerHTML += "<br><br>QR built with " + qr.segments.length + " segments";
|
|
for (i=0; i<qr.segments.length; i++) {
|
|
e(elemPref+"-bytes").innerHTML += "<br>- " + i + ": " + qr.segments[i].mode.id + " " + qr.segments[i].data;
|
|
}
|
|
|
|
e(elemPref + "-verified").innerHTML = PCF.debugDownloadVerify(pubKeyLink, payload, signature);
|
|
}
|
|
|
|
function describe(qr) {
|
|
return qr.modules.size + "x" + qr.modules.size + " bits " + Math.round((qr.modules.size*qr.modules.size)/8) + " bytes ";
|
|
}
|
|
|
|
function generateQRCodes() {
|
|
clear();
|
|
|
|
// Where to Download the public key
|
|
const pubKeyLink = e("qr-link").value.trim().replace("http://","");
|
|
|
|
// PEM code of the private key
|
|
const priKeyPEM = e('privkey').value;
|
|
|
|
const valueArray = [
|
|
"qr-manuf",
|
|
"qr-product",
|
|
"qr-lot",
|
|
"qr-ndc",
|
|
"qr-exp",
|
|
"qr-bud",
|
|
"qr-route",
|
|
"qr-dose",
|
|
"qr-doses",
|
|
"qr-serial",
|
|
];
|
|
|
|
signAndDisplayQR("qr-vial", "vial", "1", priKeyPEM, pubKeyLink, getValueArray(valueArray));
|
|
}
|
|
|
|
function verifyQRCode() {
|
|
e("qr-verify-result").innerHTML = PCF.debugParseURI(e("qr-verify").value);
|
|
e('qr-verify-verified').innerHTML = PCF.debugVerify(e("qr-verify").value);
|
|
}
|
|
|
|
function onScanSuccess(qrMessage) {
|
|
e("qr-verify").value = qrMessage;
|
|
verifyQRCode();
|
|
}
|
|
|
|
function onScanFailure(error) {
|
|
// handle scan failure, usually better to ignore and keep scanning
|
|
console.warn(`QR error = ${error}`);
|
|
}
|
|
</script>
|
|
|
|
<script>
|
|
function loadDemo() {
|
|
e("qr-manuf").value = "Moderna";
|
|
e("qr-product").value = "COVID-19";
|
|
e("qr-lot").value = "012L20A";
|
|
e("qr-ndc").value = "80777-273-10";
|
|
e("qr-exp").value = "20210501";
|
|
e("qr-bud").value = "20210208";
|
|
e("qr-route").value = "C28161";
|
|
e("qr-dose").value = "500";
|
|
e("qr-doses").value = "10";
|
|
e("qr-serial").value = "701861";
|
|
}
|
|
|
|
loadDemo();
|
|
|
|
|
|
let html5QrcodeScanner = new Html5QrcodeScanner("reader", { fps: 10, qrbox: 150 }, /* verbose= */ true);
|
|
html5QrcodeScanner.render(onScanSuccess, onScanFailure);
|
|
</script>
|
|
|
|
<script>
|
|
async function preloadKey() {
|
|
PCF.getKeyId(e("qr-link").value);
|
|
}
|
|
window.onload = function() {
|
|
preloadKey();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|
|
|