OpenAgentID documentation
Source referencesRust module referenceoas-attestation

oas-attestation · oid4vp

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

Source: oas/oas/oas-attestation/src/oid4vp.rs. SHA-256: 93be1a5e1335c2ba0bd9657bc94547d8becc78be721afa638c2fc6722af37854.

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.

oid4vp::RESPONSE_TYPE_VP_TOKEN

Default OID4VP response_type value for verifiable presentations.

pub const RESPONSE_TYPE_VP_TOKEN: &str;

Source line: 140.

oid4vp::RESPONSE_MODE_DIRECT_POST

Default OID4VP response_mode value for direct POST responses.

pub const RESPONSE_MODE_DIRECT_POST: &str;

Source line: 143.

oid4vp::PresentationDefinition

Verifier-side declaration of what credentials a holder must present.

Per the OID4VP / DIF Presentation Exchange spec, a presentation definition is the contract between the verifier and the holder: it names a set of input descriptors, each describing one credential the verifier wants to see.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PresentationDefinition {
/// Unique identifier for this definition.

pub id: String,
/// Optional human-readable name (shown to the holder during consent).

#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// Optional human-readable purpose explaining why the verifier needs

/// the credentials.

#[serde(skip_serializing_if = "Option::is_none")]
pub purpose: Option<String>,
/// One or more input descriptors, each describing a credential the

/// verifier requires.

pub input_descriptors: Vec<InputDescriptor>
}

Source line: 156.

oid4vp::InputDescriptor

A single credential requirement within a [PresentationDefinition].

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct InputDescriptor {
/// Unique identifier for this descriptor (the holder's

/// [`DescriptorMap`] entries reference it by ID).

pub id: String,
/// Optional name shown to the holder.

#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// Optional human-readable purpose.

#[serde(skip_serializing_if = "Option::is_none")]
pub purpose: Option<String>,
/// Constraints — field path expressions and filters the credential

/// must satisfy.

#[serde(default, skip_serializing_if = "Constraints::is_empty")]
pub constraints: Constraints
}

Source line: 176.

oid4vp::Constraints

Constraint set for an [InputDescriptor].

#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Constraints {
/// One or more required field path expressions and filters.

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub fields: Vec<InputField>
}

Source line: 197.

oid4vp::Constraints::is_empty

Returns true if no constraints are declared.

pub fn is_empty(&self) -> bool;

Source line: 205.

oid4vp::InputField

A single field constraint within a [Constraints] block.

Per DIF Presentation Exchange, each field carries a list of JSONPath expressions identifying where the value should be found in the credential, plus an optional JSON Schema filter the value must satisfy.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct InputField {
/// JSONPath expressions pointing to candidate locations in the credential.

pub path: Vec<String>,
/// Optional human-readable purpose.

#[serde(skip_serializing_if = "Option::is_none")]
pub purpose: Option<String>,
/// Optional JSON Schema filter the resolved value must satisfy.

#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<serde_json::Value>
}

Source line: 216.

oid4vp::AuthorizationRequest

OID4VP Authorization Request — issued by the verifier and delivered to the holder over any transport (URL query string, custom messaging, QR code, deep link).

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct AuthorizationRequest {
/// OAuth 2.0 `response_type` — fixed to `"vp_token"` for OID4VP.

pub response_type: String,
/// OAuth 2.0 `response_mode` — typically `"direct_post"` for OID4VP.

pub response_mode: String,
/// Verifier identifier (audience). Becomes `proof.domain` on the

/// holder's signed presentation. MUST be cross-checked at verify time.

pub client_id: String,
/// Verifier-supplied nonce. Becomes `proof.challenge` on the holder's

/// signed presentation. MUST be cross-checked at verify time.

pub nonce: String,
/// Optional opaque state echoed back unchanged in the response.

#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
/// The presentation definition the holder must satisfy.

pub presentation_definition: PresentationDefinition
}

Source line: 237.

oid4vp::create_authorization_request

Constructs an [AuthorizationRequest] with default response_type and response_mode values.

pub fn create_authorization_request(
    definition: PresentationDefinition,
    nonce: impl Into<String>,
    client_id: impl Into<String>,
) -> AuthorizationRequest;

Source line: 262.

oid4vp::PresentationSubmission

Holder-side mapping from the credentials in vp_token back to the verifier's input descriptors.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PresentationSubmission {
/// Unique identifier for this submission.

pub id: String,
/// Identifier of the presentation definition this submission satisfies.

pub definition_id: String,
/// One descriptor map entry per credential in `vp_token`.

pub descriptor_map: Vec<DescriptorMap>
}

Source line: 284.

oid4vp::DescriptorMap

A single entry in a [PresentationSubmission]'s descriptor map.

Tells the verifier where to find a credential within the vp_token and which proof format to use to verify it.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DescriptorMap {
/// Identifier of the [`InputDescriptor`] this credential satisfies.

pub id: String,
/// Proof format identifier from the OAS Spec §14.4 registry. Verifiers

/// route the credential to the matching verification routine based on

/// this value.

pub format: String,
/// JSONPath expression pointing to the credential within the `vp_token`.

/// `"$"` means the entire `vp_token` IS the credential (single-credential

/// case).

pub path: String
}

Source line: 300.

oid4vp::Oid4vpResponse

The holder's full OID4VP response carrying the signed presentation, the submission descriptor map, and the echoed state.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Oid4vpResponse {
/// The signed [`OasPresentation`] (or, for non-OAS formats, an opaque

/// JSON value). For OAS attestation flows this is the W3C VP from

/// [`crate::presentation::sign_presentation`].

pub vp_token: serde_json::Value,
/// Submission map — one entry per credential in `vp_token`.

pub presentation_submission: PresentationSubmission,
/// Echoed `state` from the request, if the request included one.

#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>
}

Source line: 322.

oid4vp::create_oid4vp_response

Constructs an [Oid4vpResponse] from a verifier request and a holder-signed presentation.

The function:

  1. Cross-checks the presentation's proof.challenge against request.nonce so the response cannot be built with a stale or mismatched VP.
  2. Cross-checks the presentation's proof.domain against request.client_id for the same reason.
  3. Serializes the presentation as the vp_token.
  4. Echoes the request's state.

Errors

  • [AttestationError::PresentationChallengeMismatch] if the VP's challenge doesn't match the request nonce.
  • [AttestationError::PresentationDomainMismatch] if the VP's domain doesn't match the request client_id.
  • [AttestationError::MissingProof] if the VP is unsigned.
pub fn create_oid4vp_response(
    request: &AuthorizationRequest,
    presentation: OasPresentation,
    descriptor_map: Vec<DescriptorMap>,
) -> Result<Oid4vpResponse, AttestationError>;

Source line: 355.

oid4vp::verify_oid4vp_response

Validates an [Oid4vpResponse] against an [AuthorizationRequest] and the holder's public key.

  1. Validates that response.presentation_submission.definition_id matches request.presentation_definition.id.
  2. Parses response.vp_token as an [OasPresentation].
  3. Calls [crate::presentation::verify_presentation] with the request's nonce and client_id, which enforces the cryptographic challenge + domain replay protection per Spec §14.5.
  4. Confirms the descriptor map is non-empty (the verifier's input descriptors must be satisfied — a presentation with zero descriptors is rejected).

On success, returns the parsed [OasPresentation] for further inspection (e.g., to apply the holder binding rule from §14.5.1).

Errors

  • [AttestationError::MissingField] if the definition IDs don't match or the descriptor map is empty.
  • [AttestationError::Json] if vp_token doesn't parse as a presentation.
  • Any error from [verify_presentation] (signature, challenge, domain).
pub fn verify_oid4vp_response(
    response: &Oid4vpResponse,
    request: &AuthorizationRequest,
    holder_public_key: &[u8],
) -> Result<OasPresentation, AttestationError>;

Source line: 416.

On this page