oas-attestation · sd_jwt_vc
Declared module signatures, types, configuration, and source documentation.
Source: oas/oas/oas-attestation/src/sd_jwt_vc.rs. SHA-256: 030aa958aaddddb462b84a41e56bec4b794538a7f12304be56759d3537fa1a9d.
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.
sd_jwt_vc::SD_JWT_VC_TYP
SD-JWT VC media type per draft-ietf-oauth-sd-jwt-vc.
pub const SD_JWT_VC_TYP: &str;Source line: 125.
sd_jwt_vc::VC_CLAIM
JWT payload claim name carrying the OAS credential body.
pub const VC_CLAIM: &str;Source line: 128.
sd_jwt_vc::SD_CLAIM
JWT payload claim name carrying the array of disclosure hashes.
pub const SD_CLAIM: &str;Source line: 131.
sd_jwt_vc::SD_ALG_CLAIM
JWT payload claim name declaring the hash algorithm used for _sd.
pub const SD_ALG_CLAIM: &str;Source line: 134.
sd_jwt_vc::SD_ALG_SHA256
Hash algorithm used for _sd digests ("sha-256" per the IETF spec).
pub const SD_ALG_SHA256: &str;Source line: 137.
sd_jwt_vc::SALT_BYTE_LENGTH
Salt length in bytes (16 bytes = 128 bits, matching the IETF reference).
pub const SALT_BYTE_LENGTH: usize;Source line: 140.
sd_jwt_vc::NON_SELECTIVE_SUBJECT_FIELDS
Fields that MUST always be disclosed per OAS Spec §14.6.1.
These are emitted as plain payload claims, not as _sd hashes, so they
are visible to every verifier regardless of which disclosures the holder
chooses to present.
pub const NON_SELECTIVE_SUBJECT_FIELDS: &[&str];Source line: 147.
sd_jwt_vc::Disclosure
A single SD-JWT VC disclosure: a salted commitment to one credential
claim, in the form [salt, claim_name, claim_value].
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Disclosure {
/// Base64url-encoded random salt (16 bytes raw).
pub salt: String,
/// The claim name being disclosed.
pub claim_name: String,
/// The claim value being disclosed.
pub claim_value: serde_json::Value
}Source line: 156.
sd_jwt_vc::Disclosure::new_with_random_salt
Constructs a disclosure with a freshly generated 16-byte random salt
via OsRng. Per Spec §14.6.2, implementations MUST use a fresh salt
per claim per issuance.
pub fn new_with_random_salt(
claim_name: impl Into<String>,
claim_value: serde_json::Value,
) -> Self;Source line: 169.
sd_jwt_vc::Disclosure::with_salt
Constructs a disclosure with a caller-supplied salt. Use this only
for deterministic test fixtures; production code MUST use
[Self::new_with_random_salt].
pub fn with_salt(
salt: impl Into<String>,
claim_name: impl Into<String>,
claim_value: serde_json::Value,
) -> Self;Source line: 185.
sd_jwt_vc::Disclosure::to_b64
Encodes the disclosure as base64url(JSON([salt, claim_name, claim_value])).
pub fn to_b64(&self) -> Result<String, AttestationError>;Source line: 198.
sd_jwt_vc::Disclosure::from_b64
Parses a disclosure from its base64url(JSON) form.
pub fn from_b64(b64: &str) -> Result<Self, AttestationError>;Source line: 209.
sd_jwt_vc::Disclosure::hash
Returns the base64url-encoded SHA-256 hash of the disclosure's
base64url string. This is the value placed in the payload's _sd
array per Spec §14.6 + draft-ietf-oauth-sd-jwt-vc.
pub fn hash(&self) -> Result<String, AttestationError>;Source line: 252.
sd_jwt_vc::SdJwtVcPayload
SD-JWT VC payload — JWT registered claims plus _sd (disclosure hashes),
_sd_alg (hash algorithm), and the always-disclosed vc body.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SdJwtVcPayload {
pub iss: String,
pub sub: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub nbf: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub exp: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub jti: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cnf: Option<serde_json::Value>,
/// Hash algorithm declaration — fixed to `"sha-256"`.
#[serde(rename = "_sd_alg")]
pub sd_alg: String,
/// Disclosure hash digests, in arbitrary order.
#[serde(rename = "_sd")]
pub sd: Vec<String>,
/// The OAS credential body, with selectively disclosable claims removed
/// from `credentialSubject`. The non-selective fields per Spec §14.6.1
/// remain in place.
pub vc: serde_json::Value
}Source line: 268.
sd_jwt_vc::SdJwtVcHeader
JOSE header for an SD-JWT VC.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SdJwtVcHeader {
pub alg: String,
pub typ: String,
pub kid: String
}Source line: 297.
sd_jwt_vc::SdJwtVcHeader::new
pub fn new(alg: impl Into<String>, kid: impl Into<String>) -> Self;Source line: 304.
sd_jwt_vc::SdJwtVcSignOptions
Caller-supplied options for [sign_credential_sd_jwt_vc].
#[derive(Debug, Clone)]
pub struct SdJwtVcSignOptions {
pub verification_method_id: String,
pub issuance_unix_seconds: Option<i64>,
pub jwt_id: Option<String>,
pub holder_public_key_jwk: Option<serde_json::Value>
}Source line: 319.
sd_jwt_vc::SdJwtVc
An issuer-signed SD-JWT VC, including all original disclosures.
At presentation time, the holder uses [present_sd_jwt_vc] to produce a
new compact form containing only a subset of disclosures.
#[derive(Debug, Clone)]
pub struct SdJwtVc {
}Source line: 335.
sd_jwt_vc::SdJwtVc::header
pub fn header(&self) -> &SdJwtVcHeader;Source line: 348.
sd_jwt_vc::SdJwtVc::payload
pub fn payload(&self) -> &SdJwtVcPayload;Source line: 351.
sd_jwt_vc::SdJwtVc::disclosures
pub fn disclosures(&self) -> &[Disclosure];Source line: 354.
sd_jwt_vc::SdJwtVc::as_compact_string
pub fn as_compact_string(&self) -> &str;Source line: 357.
sd_jwt_vc::SdJwtVc::issuer
pub fn issuer(&self) -> &str;Source line: 360.
sd_jwt_vc::SdJwtVc::subject
pub fn subject(&self) -> &str;Source line: 363.
sd_jwt_vc::SdJwtVc::algorithm
pub fn algorithm(&self) -> &str;Source line: 366.
sd_jwt_vc::SdJwtVc::disclosed_claim
Returns a disclosed claim by name, or None if it isn't included
in the disclosures (either because the holder didn't include it or
because it was never disclosable).
pub fn disclosed_claim(&self, claim_name: &str) -> Option<&serde_json::Value>;Source line: 373.
sd_jwt_vc::SdJwtVc::format_id
pub const fn format_id() -> ProofFormatId;Source line: 380.
sd_jwt_vc::SdJwtVc::format_url
pub const fn format_url() -> &'static str;Source line: 383.
sd_jwt_vc::sign_credential_sd_jwt_vc
Issues an SD-JWT VC for the given credential.
Per Spec §14.6.1, the non-selective fields (issuer, credentialSubject.id,
oasAttestationType, issuanceDate, expirationDate) remain in plain
view. All other credentialSubject fields become selectively disclosable
disclosures.
The returned [SdJwtVc] holds the full set of disclosures so the
holder can later choose which subset to present via [present_sd_jwt_vc].
pub fn sign_credential_sd_jwt_vc(
credential: &OasCredential,
signer: &dyn Signer,
options: &SdJwtVcSignOptions,
) -> Result<SdJwtVc, AttestationError>;Source line: 426.
sd_jwt_vc::verify_sd_jwt_vc
Verifies an SD-JWT VC compact string against an issuer [Verifier].
Per Spec §14.6 + draft-ietf-oauth-sd-jwt-vc:
- Splits the compact form on
~— first segment is the JWT, remaining are disclosures (with the trailing tilde producing an empty final element which is dropped). - Validates the JOSE header type is
vc+sd-jwt. - Enforces algorithm match between header and verifier.
- Verifies the JWT signature over
header.payload. - For each presented disclosure, recomputes its hash and confirms the
hash is in the payload's
_sdarray. Disclosures whose hash is not in_sdcause rejection — this is the integrity binding that prevents holders from injecting unrelated claims.
On success, returns an [SdJwtVc] populated with the disclosures
included in the input. The verifier can then call disclosed_claim to
inspect individual revealed claims.
pub fn verify_sd_jwt_vc(
compact: &str,
verifier: &dyn Verifier,
) -> Result<SdJwtVc, AttestationError>;Source line: 544.
sd_jwt_vc::present_sd_jwt_vc
Builds a derived SD-JWT VC presentation containing only the disclosures for the requested claim names.
Per Spec §14.6, the holder can selectively reveal a subset of the
originally disclosed claims at presentation time. The verifier still
validates the JWT signature against the issuer key — the _sd hashes
commit to all disclosures the issuer attached, so the holder cannot
invent new claims, only choose which to hide.
Claim names not present in the original disclosures are silently skipped (they may be non-selective fields that are already plain-view in the payload).
pub fn present_sd_jwt_vc(
issued: &SdJwtVc,
claims_to_disclose: &[&str],
) -> Result<SdJwtVc, AttestationError>;Source line: 657.