Skip to main content

Module enrollment

Module enrollment 

Source
Expand description

Register a device’s keys with PhyCloud (issues #397, #453), and bind them to the device’s TPM (issue #452).

PhyCloud only trusts ES256 event signatures from keys enrolled for the event’s source, and TPM quotes signed by the device’s registered attestation key. These helpers run once on the device, with an operator credential that has the devices:write scope; afterwards the device sends events with its normal events:write key. They mirror the Python SDK’s phytrace.enrollment.

use phytrace_sdk::core::enrollment::{enroll_device, register_attestation_key};

let device = enroll_device(
    "https://api.phycloud.phyware.io", "operator-key", signer.as_ref(),
    "turtlebot4-lite-01", Some("SLB9670-0001"),
).await?;
let device_id = device["device_id"].as_str().unwrap_or_default();
register_attestation_key("https://api.phycloud.phyware.io", "operator-key",
    signer.as_ref(), device_id).await?;

Traits§

HardwareIdentity
The TPM operations hardware-bound enrollment needs (issue #452); phytrace_tpm::TpmSigner implements it.

Functions§

ak_registration_message
The message a device’s signing key signs to vouch for its AK.
bind_hardware
Prove to PhyCloud that the device’s keys live in its TPM: send the EK certificate (and any intermediate CA certificates, DER) and the keys’ public areas, answer PhyCloud’s credential challenge with TPM2_ActivateCredential, and certify the signing key with the attestation key. Returns the device, whose hardware block carries the device certificate if PhyCloud has a device CA. The attestation key must already be registered (register_attestation_key).
enroll_device
Enroll signer’s key as the device for source_id; returns PhyCloud’s device record. Fails with HTTP 409 if the source already has an active device (use rotate_device_key).
enrollment_message
The message a device signs to prove it holds the key it enrolls.
public_key_pem
PEM PUBLIC KEY block for a DER SubjectPublicKeyInfo.
register_attestation_key
Register signer’s attestation key for enrolled device device_id, vouched for by its signing key. Returns the device’s AKs.
rotate_device_key
Replace device device_id’s key with signer’s; the old key is retired, so events signed before the rotation still verify.