Skip to main content

Module identity

Module identity 

Source
Expand description

This device’s place in the user’s Weirdnet: the user identity, its own node key and certificate, and the linked-devices roster it shares with the user’s other devices (Morph, Ymir, Bragi, …), kept current by sync passes.

An Identity lives in one directory (0700 on Unix), secrets in 0600 files:

  • seed: the user key seed, which a full device link delivers (a service device, linked with a certificate only, has none and keeps credential.json, the user’s public key, instead; see Identity::adopt_service);
  • node.key: this node’s key (libp2p protobuf encoding);
  • keys: the epoch keys (EpochKeys::export);
  • roster.json: the public roster, in the format Morph links with.

The secrets (seed, node.key, keys) go through a SecretStore: 0600 files in the directory by default (FileSecrets); apps that keep secrets in the OS keystore pass their own store to the *_with constructors. roster.json and credential.json are public and stay files.

Each identity announces one sync type (ymir.pool, bragi.app, …). Identity::tick runs a pass of that type against every other active device with pull_from_shared, so devices linked or revoked elsewhere reach this one even when the type carries no records yet: the roster and the key chain ride along with every pass.

use weirdnet_sync::identity::Identity;
let dir = std::path::Path::new("/tmp/example-identity");
let me = match Identity::open(dir, "example.app")? {
    Some(me) => me,
    None => Identity::create(dir, "my laptop", "example.app")?,
};
println!("{} on {}", me.user_id(), me.peer_id());

Structs§

FileSecrets
The default SecretStore: one 0600 file per secret in the identity’s directory.
Identity
The user identity, this node’s key and certificate, and the roster, stored in a directory.
LinkSettings
What a link transfer carries besides the identity: the roster, in Morph’s format, so any two Weirdnet apps can link each other.
Tick
What one Identity::tick did.

Traits§

SecretStore
Where an Identity keeps its secrets (seed, node.key, keys): bytes by name. Implement it over the OS keystore to keep them out of files.

Type Aliases§

SyncNode
The node type sync passes run on.