pub struct DeviceIdentity { /* private fields */ }Expand description
A device’s private signing identity.
This is the secret half of a device’s identity: the key it uses to sign its own telemetry so a gateway or auditor can later prove the data came from this device and was not tampered with. It is built from a 32-byte seed, which a device is provisioned with and keeps in secure storage, so the same identity is recreated deterministically across reboots without generating a new key each time.
Signing is deterministic and needs no randomness, so this works unchanged on a microcontroller.
§Examples
use pamoja_security::DeviceIdentity;
let device = DeviceIdentity::from_seed(&[7u8; 32]);
let signature = device.sign(b"fridge-1: 4.8C");
assert!(device.public().verify(b"fridge-1: 4.8C", &signature).is_ok());Implementations§
Source§impl DeviceIdentity
impl DeviceIdentity
Sourcepub fn public(&self) -> PublicIdentity
pub fn public(&self) -> PublicIdentity
Returns the public identity others use to verify this device’s signatures.
§Returns
The matching PublicIdentity.
Sourcepub fn sign_message(&self, payload: &[u8]) -> Vec<u8> ⓘ
pub fn sign_message(&self, payload: &[u8]) -> Vec<u8> ⓘ
Signs a payload and returns one message carrying both.
The message is the 64-byte signature followed by the payload, which is what a
caller usually wants to put on a link: one blob to send, rather than a payload
and a detached signature to keep together and split correctly at the far end.
PublicIdentity::verify_message reverses it.
§Arguments
payload- the bytes to sign, such as an encoded reading.
§Returns
The signature followed by payload.
Trait Implementations§
Source§impl Clone for DeviceIdentity
impl Clone for DeviceIdentity
Source§fn clone(&self) -> DeviceIdentity
fn clone(&self) -> DeviceIdentity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more