Skip to content

Commit

Permalink
Patch import/index and import/standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
r-n-o committed May 9, 2024
1 parent a42ce6f commit 7de782f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
11 changes: 10 additions & 1 deletion import/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,16 @@
if (!TKHQ.verifyEnclaveSignature) {
throw new Error("method not loaded");
}
verified = await TKHQ.verifyEnclaveSignature(bundleObj.enclaveQuorumPublic, bundleObj.dataSignature, bundleObj.data);

// Temporary solution to get the bytes signed by the enclave
var signedData = /"data":({[^}]+)/.exec(bundle);
if (signedData === null || signedData.length !== 2) {
throw new Error(`unable to find signed data in bundle: ${bundle}`);
}
const signedDataBytes = new TextEncoder().encode(signedData[1] + "}");
const signedDataHexString = TKHQ.uint8arrayToHexString(signedDataBytes);

verified = await TKHQ.verifyEnclaveSignature(bundleObj.enclaveQuorumPublic, bundleObj.dataSignature, signedDataHexString);
if (!verified) {
throw new Error(`failed to verify enclave signature: ${bundle}`);
}
Expand Down
12 changes: 11 additions & 1 deletion import/standalone.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,17 @@ <h2>Message log</h2>
if (!TKHQ.verifyEnclaveSignature) {
throw new Error("method not loaded");
}
verified = await TKHQ.verifyEnclaveSignature(bundleObj.enclaveQuorumPublic, bundleObj.dataSignature, bundleObj.data);

// Temporary solution to get the bytes signed by the enclave
var signedData = /"data":({[^}]+)/.exec(bundle);
if (signedData === null || signedData.length !== 2) {
throw new Error(`unable to find signed data in bundle: ${bundle}`);
}
const signedDataBytes = new TextEncoder().encode(signedData[1] + "}");
const signedDataHexString = TKHQ.uint8arrayToHexString(signedDataBytes);

verified = await TKHQ.verifyEnclaveSignature(bundleObj.enclaveQuorumPublic, bundleObj.dataSignature, signedDataHexString);

if (!verified) {
throw new Error(`failed to verify enclave signature: ${bundle}`);
}
Expand Down

0 comments on commit 7de782f

Please sign in to comment.