OpenAgentID documentation
Source referencesRust module referenceoas-attestation

oas-attestation · proof_formats

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

Source: oas/oas/oas-attestation/src/proof_formats.rs. SHA-256: 958972941e10c17fae5359fed57dc1d21160a60a60bc1560f21a121015c423bb.

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.

proof_formats::ED25519_2020

Identifier for the Ed25519Signature2020 proof format (baseline).

This is the baseline format every conformant OAS implementation MUST support per Spec §14.4. JSON-LD encoded, no selective disclosure, no holder key binding. The signature is multibase base58btc encoded under the proofValue field of [crate::credential::CredentialProof].

pub const ED25519_2020: &str;

Source line: 68.

proof_formats::VC_JOSE

Identifier for the vc-jose (JWT-VC, VC-JOSE-COSE) proof format.

Compact JWS encoding suitable for transports that prefer JWT. Holder key binding is provided via the cnf (confirmation) claim per [RFC 7800]. Implementations supporting this format MUST decline selective disclosure requests on credentials encoded with it; use [SD_JWT_VC] for selective disclosure.

pub const VC_JOSE: &str;

Source line: 77.

proof_formats::SD_JWT_VC

Identifier for the sd-jwt-vc (SD-JWT VC) proof format.

Compact serialization with salted-hash selective disclosure. Holder key binding via the cnf claim per [RFC 7800]. Implementations using this format MUST use a freshly generated salt per disclosable claim per issuance, per OAS Spec §14.6.2.

The non-selective fields enumerated in Spec §14.6.1 (issuer, credentialSubject.id, oasAttestationType, issuanceDate, and any present expirationDate) MUST always be disclosed to preserve verifier policy enforcement.

pub const SD_JWT_VC: &str;

Source line: 90.

proof_formats::DATA_INTEGRITY_2025

Identifier for the data-integrity-2025 (DataIntegrityProof) format.

JSON-LD encoded with optional selective disclosure via BBS+ signature suites. Holder key binding via proof options. Implementations using BBS+ MAY produce unlinkable presentations that prevent correlation across multiple presentations of the same underlying credential.

pub const DATA_INTEGRITY_2025: &str;

Source line: 98.

proof_formats::ProofFormatId

A registered OAS proof format identifier.

Per OAS Specification §14.4, this enum enumerates the four format identifiers reserved by spec version 1.2.0. Implementations MAY register additional formats via the IANA registration procedure described in §18 or in a future spec version; future identifiers will be added as variants here.

Verifiers MUST reject credentials whose proof format identifier is not in this registry. Implementations MUST NOT silently ignore unknown proof types.

Examples

use oas_attestation::proof_formats::{ProofFormatId, ED25519_2020};

let id = ProofFormatId::Ed25519Signature2020;
assert_eq!(id.url(), ED25519_2020);
assert!(id.is_baseline());
assert!(!id.supports_selective_disclosure());
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ProofFormatId {
    /// `Ed25519Signature2020` — the OAS baseline. JSON-LD, no SD, no holder
    /// key binding. Identifier: [`ED25519_2020`].
    Ed25519Signature2020,
    /// `vc-jose` — JWT-VC compact JWS encoding. Holder key binding via `cnf`.
    /// Identifier: [`VC_JOSE`].
    VcJose,
    /// `sd-jwt-vc` — SD-JWT VC with salted-hash selective disclosure.
    /// Identifier: [`SD_JWT_VC`].
    SdJwtVc,
    /// `data-integrity-2025` — JSON-LD `DataIntegrityProof` with optional BBS+
    /// selective disclosure. Identifier: [`DATA_INTEGRITY_2025`].
    DataIntegrity2025,
}

Source line: 125.

proof_formats::ProofFormatId::url

Returns the dereferenceable HTTPS identifier URL for this format.

Per OAS Spec §14.4, implementations MAY abbreviate format identifiers in code-level constants but MUST emit and accept the full HTTPS identifier on the wire.

Returns

A &'static str containing the canonical HTTPS URL.

Examples

use oas_attestation::proof_formats::ProofFormatId;

assert_eq!(
    ProofFormatId::Ed25519Signature2020.url(),
    "https://openagent.id/proof/ed25519-2020"
);
pub const fn url(self) -> &'static str;

Source line: 161.

proof_formats::ProofFormatId::from_url

Parses a [ProofFormatId] from its dereferenceable HTTPS identifier.

Arguments

  • url - The HTTPS format identifier as published in OAS Spec §14.4.

Returns

Ok(ProofFormatId) if the URL matches a registered format.

Errors

Returns [AttestationError::UnknownProofFormat] if the URL is not in the registry. Per Spec §14.4, verifiers encountering an unrecognized format MUST reject the credential — callers SHOULD propagate this error and refuse the credential.

Examples

use oas_attestation::proof_formats::{ProofFormatId, SD_JWT_VC};

let parsed = ProofFormatId::from_url(SD_JWT_VC).unwrap();
assert_eq!(parsed, ProofFormatId::SdJwtVc);

let unknown = ProofFormatId::from_url("https://example.com/unknown");
assert!(unknown.is_err());
pub fn from_url(url: &str) -> Result<Self, AttestationError>;

Source line: 198.

proof_formats::ProofFormatId::is_baseline

Returns true if this format is the OAS baseline.

Per Spec §14.4, every conformant implementation MUST support the baseline format. Currently only Ed25519Signature2020 is the baseline.

Examples

use oas_attestation::proof_formats::ProofFormatId;

assert!(ProofFormatId::Ed25519Signature2020.is_baseline());
assert!(!ProofFormatId::SdJwtVc.is_baseline());
pub const fn is_baseline(self) -> bool;

Source line: 231.

proof_formats::ProofFormatId::supports_selective_disclosure

Returns true if this format supports selective disclosure.

Per Spec §14.6, only formats with this capability flag set MAY be used to issue credentials whose claims will be selectively disclosed at presentation time.

Examples

use oas_attestation::proof_formats::ProofFormatId;

assert!(!ProofFormatId::Ed25519Signature2020.supports_selective_disclosure());
assert!(!ProofFormatId::VcJose.supports_selective_disclosure());
assert!(ProofFormatId::SdJwtVc.supports_selective_disclosure());
// data-integrity-2025 supports SD only when the BBS+ suite is used;
// the registry flag indicates capability, not unconditional support.
assert!(ProofFormatId::DataIntegrity2025.supports_selective_disclosure());
pub const fn supports_selective_disclosure(self) -> bool;

Source line: 253.

proof_formats::ProofFormatId::supports_holder_key_binding

Returns true if this format supports holder key binding at presentation time.

Per Spec §14.5, presentations of authority-bearing attestations (CapabilityVerification and any custom type that opts in) MUST be bound to the holder's key. Formats that do not support holder key binding cannot be used for authority-bearing attestations that may be presented by a descendant of the subject.

Examples

use oas_attestation::proof_formats::ProofFormatId;

assert!(!ProofFormatId::Ed25519Signature2020.supports_holder_key_binding());
assert!(ProofFormatId::VcJose.supports_holder_key_binding());
assert!(ProofFormatId::SdJwtVc.supports_holder_key_binding());
assert!(ProofFormatId::DataIntegrity2025.supports_holder_key_binding());
pub const fn supports_holder_key_binding(self) -> bool;

Source line: 276.

proof_formats::ProofFormatId::legacy_proof_type

Returns the legacy proof type string used in JSON-LD encoded credentials, if applicable.

Only JSON-LD formats (Ed25519Signature2020 and data-integrity-2025) carry a proof type field in the credential document. Compact-encoded formats (JWT-VC, SD-JWT VC) do not.

Returns

Some(&str) for JSON-LD formats, None for compact-encoded formats.

Examples

use oas_attestation::proof_formats::ProofFormatId;

assert_eq!(
    ProofFormatId::Ed25519Signature2020.legacy_proof_type(),
    Some("Ed25519Signature2020")
);
assert_eq!(
    ProofFormatId::DataIntegrity2025.legacy_proof_type(),
    Some("DataIntegrityProof")
);
assert_eq!(ProofFormatId::SdJwtVc.legacy_proof_type(), None);
assert_eq!(ProofFormatId::VcJose.legacy_proof_type(), None);
pub const fn legacy_proof_type(self) -> Option<&'static str>;

Source line: 307.

proof_formats::ProofFormat

Trait abstraction for OAS credential proof formats.

Per OAS Specification §14.4 (v1.2.0), this trait is the dispatch surface every proof format implementation MUST satisfy. Implementations are stateless, reusable across many credentials, and Send + Sync so they can be stored in registry maps shared across threads or trait objects.

The baseline implementation is [Ed25519Signature2020Format], which every conformant OAS implementation MUST support per §14.4.

Future Format Implementations

Additional proof formats (vc-jose, sd-jwt-vc, data-integrity-2025) will implement this trait in subsequent crate versions. Each new format will live in its own submodule behind a feature flag and will conform to the same sign / verify shape defined here.

Examples

use oas_attestation::credential::OasCredential;
use oas_attestation::proof_formats::{Ed25519Signature2020Format, ProofFormat};
use oas_attestation::types::AttestationType;
use oas_crypto::keypair::OasKeyPair;

let format = Ed25519Signature2020Format;
let keypair = OasKeyPair::generate();
let cred = OasCredential::builder()
    .issuer("did:oas:test:hmr:auditor")
    .subject_id("did:oas:test:agent:target")
    .attestation_type(AttestationType::SecurityAudit)
    .issuance_date("2026-01-15T00:00:00Z")
    .subject_claim("auditType", serde_json::json!("codeAudit"))
    .subject_claim("result", serde_json::json!("pass"))
    .subject_claim("severityFindings", serde_json::json!({"critical": 0}))
    .subject_claim("toolOrMethodology", serde_json::json!("OWASP"))
    .subject_claim("auditDate", serde_json::json!("2026-01-15T00:00:00Z"))
    .build()
    .unwrap();

let signed = format.sign(
    &cred, &keypair,
    "did:oas:test:hmr:auditor#key-1",
    "2026-01-15T00:00:00Z",
).unwrap();

assert!(format.verify(&signed, &keypair.verifying_key_bytes()).is_ok());
pub trait ProofFormat: Send + Sync {
    /// Returns the registered format identifier per Spec §14.4.
    fn format_id(&self) -> ProofFormatId;

    /// Returns `true` if this format supports selective disclosure of claims
    /// per Spec §14.6. Default delegates to the format identifier's
    /// capability flag.
    fn supports_selective_disclosure(&self) -> bool ;

    /// Returns `true` if this format supports holder key binding at
    /// presentation time per Spec §14.5. Default delegates to the format
    /// identifier's capability flag.
    fn supports_holder_key_binding(&self) -> bool ;

    /// Signs an OAS credential with this proof format and returns a new
    /// credential with the proof field populated.
    ///
    /// # Arguments
    ///
    /// * `credential` - The unsigned credential to sign.
    /// * `keypair` - The issuer's signing keypair.
    /// * `verification_method_id` - Full ID of the verification method
    ///   (e.g., `"did:oas:test:hmr:auditor#key-1"`).
    /// * `created` - ISO 8601 timestamp for the proof.
    ///
    /// # Returns
    ///
    /// A new [`OasCredential`] with the `proof` field populated.
    ///
    /// # Errors
    ///
    /// Returns [`AttestationError`] if validation, canonicalization, or
    /// signing fails.
    fn sign(
        &self,
        credential: &OasCredential,
        keypair: &OasKeyPair,
        verification_method_id: &str,
        created: &str,
    ) -> Result<OasCredential, AttestationError>;

    /// Verifies a signed credential against a known issuer public key.
    ///
    /// # Arguments
    ///
    /// * `credential` - The signed credential to verify.
    /// * `issuer_public_key` - The 32-byte Ed25519 public key of the issuer.
    ///
    /// # Returns
    ///
    /// `Ok(())` if the credential is valid and the proof verifies.
    ///
    /// # Errors
    ///
    /// Returns [`AttestationError`] on any validation or signature failure.
    /// Per Spec §14.4, verifiers encountering an unrecognized format MUST
    /// reject the credential.
    fn verify(
        &self,
        credential: &OasCredential,
        issuer_public_key: &[u8],
    ) -> Result<(), AttestationError>;
}

Source line: 378.

proof_formats::Ed25519Signature2020Format

The baseline Ed25519Signature2020 proof format implementation per Spec §14.4.

This is the format every conformant OAS implementation MUST support. It uses JCS canonicalization (RFC 8785) and Ed25519 signatures with multibase base58btc encoding for the proof value, as defined in Spec §13.1.

The implementation delegates to the existing module-level [crate::sign::sign_credential] and [crate::verify::verify_credential] functions, preserving the existing public API while adding trait-based dispatch for users who need to swap formats at runtime.

Examples

use oas_attestation::credential::OasCredential;
use oas_attestation::proof_formats::{Ed25519Signature2020Format, ProofFormat, ProofFormatId};
use oas_attestation::types::AttestationType;
use oas_crypto::keypair::OasKeyPair;

let format = Ed25519Signature2020Format;
assert_eq!(format.format_id(), ProofFormatId::Ed25519Signature2020);
assert!(format.format_id().is_baseline());
assert!(!format.supports_selective_disclosure());
assert!(!format.supports_holder_key_binding());

let keypair = OasKeyPair::generate();
let cred = OasCredential::builder()
    .issuer("did:oas:test:hmr:auditor")
    .subject_id("did:oas:test:agent:target")
    .attestation_type(AttestationType::SecurityAudit)
    .issuance_date("2026-01-15T00:00:00Z")
    .subject_claim("auditType", serde_json::json!("codeAudit"))
    .subject_claim("result", serde_json::json!("pass"))
    .subject_claim("severityFindings", serde_json::json!({"critical": 0}))
    .subject_claim("toolOrMethodology", serde_json::json!("OWASP"))
    .subject_claim("auditDate", serde_json::json!("2026-01-15T00:00:00Z"))
    .build()
    .unwrap();

let signed = format.sign(
    &cred, &keypair,
    "did:oas:test:hmr:auditor#key-1",
    "2026-01-15T00:00:00Z",
).unwrap();

assert!(format.verify(&signed, &keypair.verifying_key_bytes()).is_ok());
#[derive(Debug, Default, Clone, Copy)]
pub struct Ed25519Signature2020Format;

Source line: 495.

On this page