Skip to main content

validate_plc_document

Function validate_plc_document 

Source
pub fn validate_plc_document(did: &str, doc: &Value) -> Result<()>
Expand description

Validate that doc is a DID document for did — the subject binding that prevents a substitution oracle (#1161).

Checks, in order (each fail-closed):

  1. The document is a JSON object.
  2. It carries a string id.
  3. id is exactly the DID that was asked for (a fragment/query on the asked DID is ignored — resolution fetches the base document).
  4. Recognized collection members, when present, have valid member shapes and no duplicate semantic identifiers.

Exact string equality is deliberate: a did:plc has no equivalent forms (lowercase base32, no path, no port), so any difference — case, padding, a different subject — is a mismatch.