OpenAgentID documentation
Source referencesRust module referenceoas-sdk

oas-sdk · identity

Declared module signatures, types, configuration, and source documentation.

Source: oas/oas/oas-sdk/src/identity.rs. SHA-256: 654abc5c2246dab8bdf0c0effdd8037ea2551b53ed23f3a535226d5db67183db.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

identity::CreatedIdentity

The result of creating a new root identity.

Contains the signed identity document and the keypair used to sign it. The caller is responsible for securely storing the keypair.

#[derive(Debug)]
pub struct CreatedIdentity {
/// The signed OAS Identity Document.

pub document: OasDocument,
/// The Ed25519 keypair for this identity.

pub keypair: OasKeyPair
}

Source line: 19.

identity::create_hmr

Creates a new Human Root (HMR) identity.

Generates a fresh Ed25519 keypair, constructs an OAS Identity Document for a did:oas:<namespace>:hmr:<identifier> DID, and signs it.

Arguments

  • namespace - The OAS namespace (e.g., "l1fe", "test").
  • identifier - The unique identifier within the namespace.
  • created - ISO 8601 timestamp for the document metadata.

Returns

A [CreatedIdentity] containing the signed document and keypair.

Errors

Returns [OasError] if DID construction or document building fails.

Examples

use oas_sdk::identity::create_hmr;

let identity = create_hmr("test", "alice", "2026-01-15T00:00:00Z");
assert!(identity.is_ok());
let identity = identity.unwrap();
assert_eq!(identity.document.id, "did:oas:test:hmr:alice");
pub fn create_hmr(
    namespace: &str,
    identifier: &str,
    created: &str,
) -> Result<CreatedIdentity, OasError>;

Source line: 55.

identity::create_mhr

Creates a new Multi-Human Root (MHR) identity.

Similar to [create_hmr] but for multi-human threshold root entities. MHR identities use did:oas:<namespace>:mhr:<identifier>.

Arguments

  • namespace - The OAS namespace (e.g., "l1fe", "test").
  • identifier - The unique identifier within the namespace.
  • created - ISO 8601 timestamp for the document metadata.

Returns

A [CreatedIdentity] containing the signed document and keypair.

Errors

Returns [OasError] if DID construction or document building fails.

Examples

use oas_sdk::identity::create_mhr;

let identity = create_mhr("test", "system1", "2026-01-15T00:00:00Z");
assert!(identity.is_ok());
let identity = identity.unwrap();
assert_eq!(identity.document.id, "did:oas:test:mhr:system1");
pub fn create_mhr(
    namespace: &str,
    identifier: &str,
    created: &str,
) -> Result<CreatedIdentity, OasError>;

Source line: 101.

identity::create_root_with_keypair

Creates a new root identity with a pre-existing keypair.

Use this when you need to control the keypair (e.g., loading from storage).

Arguments

  • namespace - The OAS namespace.
  • kind - The entity kind ("hmr" or "mhr").
  • identifier - The unique identifier.
  • keypair - The Ed25519 keypair to use.
  • created - ISO 8601 timestamp.

Returns

A signed [OasDocument].

Errors

Returns [OasError] if document building fails.

Examples

use oas_sdk::identity::create_root_with_keypair;
use oas_crypto::keypair::OasKeyPair;

let keypair = OasKeyPair::generate();
let doc = create_root_with_keypair("test", "hmr", "alice", &keypair, "2026-01-15T00:00:00Z");
assert!(doc.is_ok());
pub fn create_root_with_keypair(
    namespace: &str,
    kind: &str,
    identifier: &str,
    keypair: &OasKeyPair,
    created: &str,
) -> Result<OasDocument, OasError>;

Source line: 148.

On this page