Look Up Records
In this guide, we will read a full record with an encrypted lookup.Why Use Lookups?
The normal read endpoints return records over HTTPS. A lookup returns the full record encrypted to a key your device chooses for that one request. Nothing between Hyperion and your device can read it.
| Lookup | Route | Scope |
|---|---|---|
| Monitorable lookup | POST /v1/monitorable-lookup/:monitorableId | monitorable:read |
| Incident lookup | POST /v1/monitorables/:monitorableId/incident-lookup/:incidentId | monitorable-incident:read |
| Incident action lookup | POST /v1/monitorables/:monitorableId/incidents/:incidentId/action-lookup/:actionId | monitorable-incident:read |
| Event lookup | POST /v1/monitorables/:monitorableId/event-lookup/:eventId | event:read |
All four take the same request and return the same envelope.
Getting Started
Before looking up records, you need:
- An application with
key:readand the scope for the lookup you want. - The helpers and encryption key from the Encrypt Monitorable Data guide.
Step 1: Choose a Response Key
Generate a random 32-byte response key for each lookup. Hyperion encrypts the record to it, so keep it until you read the response.
import { webcrypto } from "node:crypto";
const responseKey = webcrypto.getRandomValues(new Uint8Array(32));
Step 2: Encrypt the Lookup Request
The encrypted payload is a JSON object with the response key. Use lp(monitorableId) as both the HPKE info and aad. If the monitorable has a signing key, the info starts with the key's hash and the request must be signed:
const requestTimestamp = canonicalTimestamp();
const info = signingKey
? concat(lp(sha256(signingKey.publicKeySpki)), lp(monitorableId))
: lp(monitorableId);
const encryptedPayload = await sealHpke(
encryptionKey,
jsonBytes({ responseKey: toBase64(responseKey) }),
info,
lp(monitorableId),
);
const lookupRequest = {
encryptionKeyId: encryptionKey.id,
requestTimestamp,
encryptedPayload: toBase64(encryptedPayload),
...(signingKey && {
signature: toBase64(
await signingKey.sign(
sha256(
concat(
lp(monitorableId),
lp(requestTimestamp),
lp(sha256(encryptedPayload)),
),
),
),
),
}),
};
The monitorableId is always the monitorable the record belongs to, including for incident, action, and event lookups.
Lookups also accept RSA-OAEP encryption keys. Encrypt the same JSON payload
with RSA-OAEP, using SHA-256 for RSA-OAEP-256 or SHA-512 for
RSA-OAEP-512. RSA has no info or aad,
so sign RSA lookups to bind them to the monitorable.
Step 3: Send the Lookup
Send the request to the lookup route:
The response contains only the encrypted record:
{
"encryptedPayload": "Vt9k2Zm9vYmFy..."
}
Step 4: Decrypt the Response
The response is AES-256-GCM under your response key: a 12-byte IV, then the ciphertext, then the 16-byte tag. The aad is lp(monitorableId) ‖ lp(requestTimestamp), using the requestTimestamp you sent:
const sealed = fromBase64(response.encryptedPayload);
const key = await webcrypto.subtle.importKey(
"raw",
responseKey,
{ name: "AES-GCM" },
false,
["decrypt"],
);
const plaintext = await webcrypto.subtle.decrypt(
{
name: "AES-GCM",
iv: sealed.subarray(0, 12),
additionalData: concat(lp(monitorableId), lp(requestTimestamp)),
},
key,
sealed.subarray(12),
);
const record = JSON.parse(new TextDecoder().decode(plaintext));
WebCrypto expects the tag at the end of the ciphertext, which is how Hyperion sends it.
Try It: Look Up a Record
Use the builder below to run a lookup from your browser. Choose the record, enter its IDs, and select Encrypt lookup. The builder generates a new response key for each lookup and keeps it in the page.
Send the cURL command, then paste the response into Decrypt the response to read the record. Lookups accept HPKE and RSA-OAEP encryption keys. If the monitorable has a signing key, select the same signing profile and key you registered it with.
Encrypted lookup builder
Encrypt a lookup request and decrypt the record Hyperion returns.
Encryption key
Paste the id, algorithm, and publicKey from GET /v1/encryption-keys/current, or generate a demo key. Hyperion can't decrypt requests built with a demo key.
Monitorable signing key
Generated in this browser tab and kept only until you reload. Other builders on these pages sign with the same key.
Record
{"responseKey": "A new key is generated when you encrypt"}
Conclusion
You've read a full record with an encrypted lookup. Each lookup uses its own response key, so a captured response can't be read later.
Best Practices
- Use a new response key for every lookup: Never reuse one
- Discard the response key after decrypting: It's only needed for one response
- Prefer HPKE keys: An HPKE lookup is bound to the monitorable even without a signature
- Sign lookups for signed monitorables: A monitorable with a signing key rejects unsigned lookups with 401
Learn More
Related Guides
- Encrypt Monitorable Data - Register and update monitorables with encrypted requests
- Sign Requests - Add a monitorable signing key and sign requests
Related Concepts
- Encrypted Requests - Every envelope, binding, and signed commitment
- Encryption Keys - Create, rotate, and fetch encryption keys
API Reference
- Monitorable Lookup - Look up a monitorable
- Incident Lookup - Look up a monitorable incident
- Incident Action Lookup - Look up a monitorable incident action
- Event Lookup - Look up an event