-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create minimal web attestation explaination library with the wasm-pac…
…k CLI. (We'll later use wasm-pack for a web client). Due to persistent issues with wasm-pack and bazel, we're just using the cargo version for now. Bug: 354737767 Change-Id: I562cbc3360d1c6b14a368c3505671c1c532f8ed5
- Loading branch information
Showing
9 changed files
with
107 additions
and
103 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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,20 @@ | ||
[package] | ||
name = "oak_attestation_explain_wasm" | ||
version = "0.1.0" | ||
authors = ["Juliette Pretot <[email protected]>"] | ||
edition = "2018" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[features] | ||
default = ["js"] | ||
js = ["getrandom/js"] | ||
|
||
[dependencies] | ||
wasm-bindgen = "*" | ||
getrandom = "*" | ||
oak_attestation_explain = { workspace = true } | ||
oak_proto_rust = { workspace = true } | ||
prost = { workspace = true, default-features = false } | ||
oak_attestation_verification = { workspace = true } |
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 |
---|---|---|
@@ -1,20 +1,39 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>WASM Test</title> | ||
<title>Oak Attestation Explanation</title> | ||
<meta charset="UTF-8" /> | ||
<script type="module"> | ||
// For now we're just hardcoding the evidence. | ||
const ENCODED_EVIDENCE = | ||
'Co0KCAESoAkCAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAAAABTRAQAAAAAAAAAAAAAAAAAAAI/GdBW4EgHxifLRnL5Xqmb3KCkWtbnmzKg6uGiPRJnTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABsCQ5FlP1A7hhskNQ/etjZBIOLqpZDpL4dnU/w/dZwpiVl4kF2YACOBYzC8gKerIoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJOH58KqtA5m+Yoa65PFh51fAe9E57qR3Qs9LeRbfH+v//////////////////////////////////////////8DAAAAAAAU0QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAELh+SZgzCv32Zak216+r+gzYerG+W2zUKcMfgcRX61gqF9a6YuPuH7HbOKj+BrXDfiuu94cPCF5eJegS2FiNe8DAAAAAAAU0RA3AQAQNwEAAwAAAAAAFNEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACyRezDOZVCOuEtZ7eE7nzrH14TlglDRsp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yMWJmYTE3NjgwNTU2ZDExMgJ4KDc3NjY3MWVkMDUyNWQ2ZGViMDQyNGYwNjY4Yzc4OTkwYzliYmU5MmM6AEdEV1hmpwECAlR3ZnHtBSXW3rBCTwZox4mQybvpLAMmBIECIAEhWCBhf/ZC0txzHodUydtnhEbQtgiUPowmjUBNzbfsk6rqZiJYIFPkHIY/dtu7nh9sw25yuPDl5MJg8ihMcXoXT5hI+TLHOgBHRFhCIAA6AEdEW6I6AEdEZqE6AEdEa1ggfUaCqaD5et4PrZpH8kfhy27TJugLoF6jn8hLL+a8rPs6AEdEaaE6AEdEa0BYQMw83xBhzxnkCvILq9UkvjNF2CRh0b4xZI1/t/bVzihuSdCfBllSwbG/koyeUNqxb+roLfyj++z+Hasz2XbLP/U='; | ||
|
||
import init, { explain } from './oak_attestation_explain_wasm.js'; | ||
|
||
// Function to decode Base64 to bytes | ||
function decodeBase64(base64) { | ||
const binaryString = atob(base64); | ||
const bytes = new Uint8Array(binaryString.length); | ||
for (let i = 0; i < binaryString.length; i++) { | ||
bytes[i] = binaryString.charCodeAt(i); | ||
} | ||
return bytes; | ||
} | ||
|
||
// Function to explain attestation | ||
async function explainAttestation(attestationBytes) { | ||
await init(); | ||
const explanation = explain(decodeBase64(attestationBytes)); | ||
document.getElementById('explanation').textContent = explanation; | ||
} | ||
|
||
window.onload = () => { | ||
explainAttestation(ENCODED_EVIDENCE); | ||
}; | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
const importObj = {}; | ||
(async () => { | ||
const response = await fetch('./oak_attestation_explain_wasm.wasm'); | ||
const { instance } = await WebAssembly.instantiateStreaming( | ||
response, | ||
importObj, | ||
); | ||
console.log(instance.exports.nth_prime(10)); | ||
})(); | ||
</script> | ||
<pre id="explanation">verifying attestation evidence...</pre> | ||
</body> | ||
</html> |
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,19 @@ | ||
#!/bin/bash | ||
|
||
# Exit immediately if a command exits with a non-zero status | ||
set -e | ||
|
||
readonly WORKSPACE_ROOT=$(bazel info workspace) | ||
readonly OUTPUT_DIR=oak_attestation_explain_wasm/pkg | ||
|
||
# Navigating to the Bazel workspace root | ||
cd "$WORKSPACE_ROOT" | ||
|
||
echo "INFO: Building the project using wasm-pack" | ||
just oak_attestation_explain_wasm | ||
|
||
echo "INFO: Copying index.html to the output directory: ${OUTPUT_DIR}" | ||
cp oak_attestation_explain_wasm/index.html "${OUTPUT_DIR}" | ||
|
||
echo "INFO: Starting a HTTP server in the output directory: ${OUTPUT_DIR}" | ||
python3 -m http.server --directory "${OUTPUT_DIR}" 0 |
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