-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying to gh-pages from @ d0c8a01 🚀
- Loading branch information
Showing
4 changed files
with
87 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
function verify() { | ||
let repo = document.getElementById("repo").value; | ||
let hostname = document.getElementById("domain").value; | ||
|
||
document.getElementById("logs").innerHTML = ""; | ||
|
||
function addLog(...messages) { | ||
const date = new Date(); | ||
const timestamp = `${date.getFullYear()}/${String(date.getMonth() + 1).padStart(2, '0')}/${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`; | ||
console.log(`${timestamp}`, ...messages, '\n'); | ||
} | ||
|
||
const go = new Go(); | ||
WebAssembly.instantiateStreaming(fetch("tinfoil-verifier.wasm"), go.importObject).then((result) => { | ||
go.run(result.instance); | ||
|
||
let enclavePromise = verifyEnclave(hostname).then(result => { | ||
addLog("Enclave attested certificate fingerprint:", result.certificate); | ||
return result.measurement; | ||
}).catch(error => { | ||
addLog("Error verifying enclave:", error); | ||
}); | ||
|
||
addLog(`Fetching latest release for ${repo}`); | ||
let sigstorePromise = fetch("https://api.github.com/repos/" + repo + "/releases/latest") | ||
.then(response => response.json()) | ||
.then(data => { | ||
let latestTag = data.tag_name; | ||
|
||
const regex = /EIF hash: ([a-f0-9]{64})/i; | ||
const match = data.body.match(regex); | ||
if (match) { | ||
let digest = match[1]; | ||
addLog(`Found latest release ${latestTag}`); | ||
return digest; | ||
} else { | ||
addLog("Failed to find EIF hash"); | ||
} | ||
}) | ||
.then(digest => { | ||
return verifyCode(repo, digest) | ||
}) | ||
.catch(error => { | ||
addLog("Failed to fetch latest release: " + error); | ||
throw error; | ||
}) | ||
|
||
Promise.all([sigstorePromise, enclavePromise]) | ||
.then(([sigstoreMeasurement, enclaveMeasurement]) => { | ||
addLog("Source:", sigstoreMeasurement); | ||
addLog("Enclave:", enclaveMeasurement); | ||
if (sigstoreMeasurement === enclaveMeasurement) { | ||
addLog("Verification successful! ✅"); | ||
} else { | ||
throw new Error("Verification failed: measurements do not match"); | ||
} | ||
}) | ||
.catch(error => { | ||
addLog("Verification failed: " + error); | ||
}); | ||
}); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", function () { | ||
let url = new URL(window.location.href); | ||
let urlRepo = url.searchParams.get("repo"); | ||
let urlDomain = url.searchParams.get("domain"); | ||
|
||
if (urlRepo) { | ||
document.getElementById("repo").value = urlRepo; | ||
} | ||
if (urlDomain) { | ||
document.getElementById("domain").value = urlDomain; | ||
} | ||
|
||
let logsElement = document.getElementById("logs"); | ||
|
||
console.stdlog = console.log.bind(console); | ||
console.log = function () { | ||
console.stdlog.apply(console, arguments); | ||
logsElement.innerHTML = logsElement.innerHTML + Array.from(arguments).join(" ") + "<br>"; | ||
} | ||
|
||
verify(); | ||
}); |
Binary file not shown.
This file was deleted.
Oops, something went wrong.