OpenAgentID documentation
Source referencesRust module referenceoas-lineage

oas-lineage · derive

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

Source: oas/oas/oas-lineage/src/derive.rs. SHA-256: e61d3a231537dc09a8c22676cfd438afe2420195531b1246f80e567becd443db.

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.

derive::DerivedChild

The result of deriving a child entity.

Contains the child's Ed25519 keypair and a complete [LineageSection] ready to be included in the child's identity document.

Examples

use oas_lineage::derive::DerivedChild;

// DerivedChild is returned by derive_child_entity()
// It contains the child keypair and lineage section.
#[derive(Debug)]
pub struct DerivedChild {
/// The derived Ed25519 keypair for the child entity.

pub keypair: OasKeyPair,
/// The lineage section to include in the child's identity document.

pub lineage: LineageSection
}

Source line: 31.

derive::derive_child_entity

Derives a new child entity from a parent, producing a keypair and lineage.

Performs the complete child entity derivation workflow per OAS Spec §9:

  1. Derives a child Ed25519 keypair using HKDF-SHA256 (§9.3).
  2. Generates an AgentLineageProof2025 (§9.4).
  3. Constructs a complete [LineageSection] with the correct humanRootDid, creatorDid, generation, and humanRootChain.

Arguments

  • parent_keypair - The parent entity's keypair (used for signing the proof and as HKDF input for key derivation).
  • parent_doc - The parent entity's identity document (used to extract the parent's DID and lineage information).
  • child_did - The DID for the new child entity.
  • derivation_path - The HKDF derivation path (e.g., "/agent-bot-42").

Returns

A [DerivedChild] containing the derived keypair and lineage section.

Errors

Returns [LineageError] if:

  • The parent is a non-root entity without lineage ([LineageError::MissingLineage]).
  • Key derivation fails ([LineageError::Crypto]).
  • Proof generation fails ([LineageError::Crypto]).

Examples

use oas_lineage::derive::derive_child_entity;
use oas_document::builder::DocumentBuilder;
use oas_document::conformance::ConformanceLevel;
use oas_crypto::keypair::OasKeyPair;

let root_keypair = OasKeyPair::generate();
let root_doc = DocumentBuilder::new("did:oas:test:hmr:alice", "hmr")
    .conformance_level(ConformanceLevel::L1)
    .add_verification_method(&root_keypair)
    .build_and_sign(&root_keypair, "2026-01-15T00:00:00Z")
    .unwrap();

let child = derive_child_entity(
    &root_keypair,
    &root_doc,
    "did:oas:test:agent:bot",
    "/agent-bot",
).unwrap();

assert_eq!(child.lineage.human_root_did, "did:oas:test:hmr:alice");
assert_eq!(child.lineage.generation, 1);
pub fn derive_child_entity(
    parent_keypair: &OasKeyPair,
    parent_doc: &OasDocument,
    child_did: &str,
    derivation_path: &str,
) -> Result<DerivedChild, LineageError>;

Source line: 94.

On this page