Skip to content

Identity (Rust)

Your app works with cryptographic identities — real people and devices, not usernames and passwords. Reach the identity API through app.identity().

Listing identities

identity().list() () -> Vec<Identity>

List the identities available to your app — own identities and contacts (remote identities you've been introduced to). Own identities have privkey: true; the key itself stays in wish-core.

rust
for id in app.identity().list()? {
    let kind = if id.privkey { "(own)" } else { "(contact)" };
    println!("{} {}", id.name.as_deref().unwrap_or("?"), kind);
}

Identity:

FieldTypeDescription
uidVec<u8>Identity UID (32 bytes) — stable, never changes
nameOption<String>Display name
privkeybooltrue for own identities, false for contacts

Getting identity details

identity().get(uid) (uid: &[u8]) -> IdentityFull

Get full details for an identity — signers, contacts, and hosts.

rust
let identity = app.identity().get(&uid)?;

for host in &identity.hosts {
    println!("  {}", host.name.as_deref().unwrap_or("unnamed"));
}

IdentityFull adds:

FieldTypeDescription
signersVec<Signer>Cryptographic keys that can act as this identity — { signer_id, name? }
contactsVec<Vec<u8>>Contact UIDs (own identities only)
hostsVec<IdentityHost>Known devices — { host_id, name?, role?, transports, .. }

Signing and verification

identity.sign / identity.verify are not namespaced in wish-sdk-rs yet — call the endpoints directly:

rust
let signed: ciborium::value::Value =
    app.rpc().request("identity.sign", sign_args)?;

let result: ciborium::value::Value =
    app.rpc().request("identity.verify", vec![signed_document])?;

The claim passed to identity.sign is an arbitrary byte string that becomes part of the signed statement.

Reacting to changes

The identity signal fires whenever identities change — new identity created, contact added, name updated. Subscribe via app.signals() and re-fetch app.identity().list() to stay current.