OpenAgentID documentation
Source referencesRust module referenceoas-attestation

oas-attestation · lineage_vc

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

Source: oas/oas/oas-attestation/src/lineage_vc.rs. SHA-256: ad645c49dca7878d8e4a9e1c805951c07f48b18ef627edb4315b95a2fdb76e3a.

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.

lineage_vc::LineageRootKind

The kind of root anchor a lineage chain terminates at, per OAS Spec §14.7.1.

On the wire, encoded as the lowercase string "hmr", "mhr", or "enr" to match the spec example in §14.7.1.

Examples

use oas_attestation::lineage_vc::LineageRootKind;

assert_eq!(LineageRootKind::Hmr.as_str(), "hmr");
assert_eq!(LineageRootKind::Mhr.as_str(), "mhr");
assert_eq!(LineageRootKind::Enr.as_str(), "enr");

assert_eq!("hmr".parse::<LineageRootKind>().unwrap(), LineageRootKind::Hmr);
assert!("invalid".parse::<LineageRootKind>().is_err());
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum LineageRootKind {
    /// Human Root (HMR) per OAS Spec §6 — single human accountability anchor.
    Hmr,
    /// Multi-Human Root (MHR) per OAS Spec §7 — threshold-signed multi-party anchor.
    Mhr,
    /// Enterprise Root (ENR) per OAS Spec §8 — MHR-governed enterprise anchor.
    Enr,
}

Source line: 95.

lineage_vc::LineageRootKind::as_str

Returns the canonical lowercase string form used on the wire.

pub const fn as_str(self) -> &'static str;

Source line: 106.

lineage_vc::LineageAttestationContext

Per-link metadata that [AgentLineageProof] does not carry but the LineageAttestation credential subject schema requires.

Per OAS Spec §14.7.1, the credential subject MUST contain generationDepth, rootAnchor, rootKind, and derivedAt. The native AgentLineageProof2025 does not encode these fields, so callers using the bridge MUST supply them. The values are typically derived from the lineage walking context: generation_depth from the chain walker's depth counter, root_anchor from the topmost ancestor's DID, root_kind from inspecting that ancestor's identity document, and derived_at from the parent's derivation log.

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LineageAttestationContext {
/// Generation depth from the nearest root, where 1 is the first

/// derivation from the root and increases by 1 per hop. Must be in

/// the range `[1, MAX_GENERATION]` per OAS Spec §10 (`MAX_GENERATION = 16`).

pub generation_depth: u32,
/// Root anchor DID — the topmost ancestor in the lineage chain. MUST be

/// a valid `did:oas` identifier of kind `hmr`, `mhr`, or `enr`.

pub root_anchor: String,
/// The root kind matching `root_anchor`'s entity kind.

pub root_kind: LineageRootKind,
/// ISO 8601 UTC timestamp marking when the derivation occurred.

pub derived_at: String
}

Source line: 158.

lineage_vc::LineageAttestationData

All lineage data extracted from a LineageAttestation credential by [lineage_proof_from_credential].

This is the round-trip target type. Calling lineage_proof_to_credential(proof, ctx) then lineage_proof_from_credential(...) MUST produce a value where every field matches the original proof and ctx exactly. This guarantee is enforced by the round-trip property test in this module.

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LineageAttestationData {
/// Parent DID (matches `AgentLineageProof::parent_did` and the credential

/// `issuer`).

pub parent_did: String,
/// Child DID (matches `AgentLineageProof::child_did` and the credential

/// `credentialSubject.id`).

pub child_did: String,
/// HKDF derivation path (matches `AgentLineageProof::derivation_path`).

pub derivation_path: String,
/// Generation depth from the root (caller-supplied, not in

/// `AgentLineageProof`).

pub generation_depth: u32,
/// Root anchor DID (caller-supplied).

pub root_anchor: String,
/// Root kind (caller-supplied).

pub root_kind: LineageRootKind,
/// Derivation timestamp (caller-supplied).

pub derived_at: String
}

Source line: 185.

lineage_vc::lineage_proof_to_credential

Converts an AgentLineageProof2025 into an [OasCredential] of type LineageAttestation per OAS Spec §14.7.

The returned credential is unsigned — callers who need a signed VC MUST sign it separately using [crate::sign::sign_credential] (or the equivalent [crate::proof_formats::Ed25519Signature2020Format] trait dispatch). Per Spec §14.7.2, the signature MUST be produced by the parent's signing key, the same key authorized to produce the equivalent AgentLineageProof2025.

The AttestationContext parameter supplies the four spec-required subject fields that [AgentLineageProof] does not itself carry: generation_depth, root_anchor, root_kind, derived_at.

Arguments

  • proof - The native lineage proof to bridge.
  • ctx - The per-link metadata required by Spec §14.7.1.

Returns

An unsigned [OasCredential] with oasAttestationType: LineageAttestation and all six required subject fields populated.

Errors

Returns [AttestationError] if the resulting credential fails structural validation (e.g., parent or child DIDs are not valid did:oas identifiers).

Examples

use oas_attestation::lineage_vc::{
    lineage_proof_to_credential, LineageAttestationContext, LineageRootKind,
};
use oas_attestation::types::AttestationType;
use oas_crypto::keypair::OasKeyPair;
use oas_crypto::proof::AgentLineageProof;

let parent = OasKeyPair::generate();
let proof = AgentLineageProof::generate(
    &parent,
    "did:oas:test:hmr:alice",
    "did:oas:test:agent:bot",
    "/agent-bot",
).unwrap();

let ctx = LineageAttestationContext {
    generation_depth: 1,
    root_anchor: "did:oas:test:hmr:alice".to_string(),
    root_kind: LineageRootKind::Hmr,
    derived_at: "2026-04-06T00:00:00Z".to_string(),
};

let cred = lineage_proof_to_credential(&proof, &ctx).unwrap();
assert_eq!(cred.issuer, "did:oas:test:hmr:alice");
assert_eq!(cred.oas_attestation_type, Some(AttestationType::LineageAttestation));
pub fn lineage_proof_to_credential(
    proof: &AgentLineageProof,
    ctx: &LineageAttestationContext,
) -> Result<OasCredential, AttestationError>;

Source line: 268.

lineage_vc::lineage_proof_from_credential

Extracts [LineageAttestationData] from an [OasCredential] previously produced by [lineage_proof_to_credential] (or any other source that follows the OAS Spec §14.7.1 schema).

This is the inverse of [lineage_proof_to_credential]. Round-trip (to_credentialfrom_credential) is byte-equivalent in all shared fields and is enforced by the property test in this module.

Arguments

  • credential - A credential whose oasAttestationType is LineageAttestation and whose subject contains all six required fields.

Returns

A populated [LineageAttestationData].

Errors

  • [AttestationError::UnknownAttestationType] if the credential's oasAttestationType is not LineageAttestation.
  • [AttestationError::MissingField] if any required subject field is missing or has the wrong JSON type.
  • [AttestationError::InvalidSubject] if the subject id is missing or not a valid did:oas identifier.

Examples

use oas_attestation::lineage_vc::{
    lineage_proof_from_credential, lineage_proof_to_credential,
    LineageAttestationContext, LineageRootKind,
};
use oas_crypto::keypair::OasKeyPair;
use oas_crypto::proof::AgentLineageProof;

let parent = OasKeyPair::generate();
let proof = AgentLineageProof::generate(
    &parent,
    "did:oas:test:hmr:alice",
    "did:oas:test:agent:bot",
    "/agent-bot",
).unwrap();

let ctx = LineageAttestationContext {
    generation_depth: 1,
    root_anchor: "did:oas:test:hmr:alice".to_string(),
    root_kind: LineageRootKind::Hmr,
    derived_at: "2026-04-06T00:00:00Z".to_string(),
};

let cred = lineage_proof_to_credential(&proof, &ctx).unwrap();
let data = lineage_proof_from_credential(&cred).unwrap();

assert_eq!(data.parent_did, proof.parent_did);
assert_eq!(data.child_did, proof.child_did);
assert_eq!(data.derivation_path, proof.derivation_path);
assert_eq!(data.generation_depth, ctx.generation_depth);
pub fn lineage_proof_from_credential(
    credential: &OasCredential,
) -> Result<LineageAttestationData, AttestationError>;

Source line: 363.

On this page