-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathverifiers.ts
More file actions
71 lines (60 loc) · 1.94 KB
/
verifiers.ts
File metadata and controls
71 lines (60 loc) · 1.94 KB
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
import { AttestationResponse } from "./types.ts";
/**
* Verify Intel DCAP attestation (TDX/SGX)
* Proxies to Phala Cloud API
*/
export async function verifyIntelDcap(hex: string): Promise<AttestationResponse> {
const normalizedHex = hex.startsWith("0x") ? hex : `0x${hex}`;
const response = await fetch(
"https://cloud-api.phala.network/proofofcloud/attestations/verify",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ hex: normalizedHex }),
}
);
if (!response.ok) {
throw new Error(`Phala API error: ${response.status} ${response.statusText}`);
}
return (await response.json()) as AttestationResponse;
}
/**
* Verify AMD SEV-SNP attestation
* Proxies to Nillion Verifier API
*/
export async function verifyAmdSev(hex: string): Promise<AttestationResponse> {
// Nillion endpoint expects raw hex without 0x prefix
const reportHex = hex.startsWith("0x") ? hex.slice(2) : hex;
const response = await fetch("https://nilcc-verifier.nillion.network/v1/attestations/verify-amd", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ report: reportHex }),
});
if (!response.ok) {
throw new Error(
`Nillion API error: ${response.status} ${response.statusText}`
);
}
const data = (await response.json()) as { chip_id?: string };
const result: AttestationResponse = {
success: true,
proof_of_cloud: true,
quote: {
header: {
tee_type: "TEE_AMD_SEV_SNP",
},
},
...(data.chip_id ? { chip_id: data.chip_id } : {}),
};
return result;
}
/**
* Verify AWS Nitro Enclave attestation
* TODO: Implement AWS Nitro verification
* See: https://docs.aws.amazon.com/enclaves/latest/user/verify-root.html
*/
export async function verifyAwsNitro(hex: string): Promise<AttestationResponse> {
throw new Error(
"AWS Nitro verification not implemented. Contributors welcome!"
);
}