oas-wasm · verify_lineage
Declared module signatures, types, configuration, and source documentation.
Source: oas/oas/oas-wasm/src/verify_lineage.rs. SHA-256: 0c9cc23d0054f81e4c6beb897009376acde39711afa4a2c544a1bfb2edeac5ec.
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.
verify_lineage::VerifyLineageInput
Input for lineage verification.
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct VerifyLineageInput {
/// The document whose lineage to verify (as JSON).
pub document: serde_json::Value,
/// Pre-fetched parent documents keyed by DID.
pub parents: HashMap<String, serde_json::Value>,
/// Optional maximum generation depth (defaults to 16).
#[serde(alias = "maxGeneration")]
pub max_generation: Option<u32>,
/// Verifier-controlled root trust anchors.
#[serde(default, alias = "trustAnchors")]
pub trust_anchors: Vec<TrustAnchor>
}Source line: 19.
verify_lineage::VerifyLineageResult
Result of lineage verification.
#[derive(Debug, Serialize)]
pub struct VerifyLineageResult {
/// Whether the lineage is valid.
pub ok: bool,
/// The root DID (if chain terminates at a root).
#[serde(skip_serializing_if = "Option::is_none")]
pub root_did: Option<String>,
/// The generation depth.
#[serde(skip_serializing_if = "Option::is_none")]
pub generation: Option<u32>,
/// Stable typed error code (if verification failed).
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
/// Error message (if verification failed).
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<String>
}Source line: 34.
verify_lineage::verify_lineage
Verifies a lineage chain using pre-fetched documents.
This is a synchronous function suitable for WASM environments. All parent documents must be provided upfront — no network requests are made.
Arguments
input_json- JSON string containing a [VerifyLineageInput].
Returns
A JSON string containing a [VerifyLineageResult].
Examples
use oas_wasm::verify_lineage::verify_lineage;
use oas_crypto::keypair::OasKeyPair;
use oas_document::builder::DocumentBuilder;
use oas_document::conformance::ConformanceLevel;
use oas_lineage::config::TrustAnchor;
let keypair = OasKeyPair::generate();
let doc = DocumentBuilder::new("did:oas:test:hmr:alice", "hmr")
.conformance_level(ConformanceLevel::L0)
.add_verification_method(&keypair)
.build_and_sign(&keypair, "2026-01-15T00:00:00Z")
.unwrap();
let anchor = TrustAnchor::new(
&doc.id,
format!("{}#key-1", doc.id),
keypair.public_key_multibase(),
).with_document_digest(doc.canonical_digest().unwrap());
let input = serde_json::json!({
"document": doc,
"parents": {},
"trustAnchors": [anchor]
});
let result = verify_lineage(&serde_json::to_string(&input).unwrap());
assert!(result.contains("\"ok\":true"));#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen)]
pub fn verify_lineage(input_json: &str) -> String;Source line: 112.