AttestoClient.Wallet.Proof (AttestoClient v2.3.1)

Copy Markdown View Source

Build the OID4VCI holder key proof of possession (draft-ietf-oauth-openid4vci §8.2.1.1), the wallet-side mirror of Attesto.CredentialProof.verify_jwt/2.

A proof is a JWT, typed openid4vci-proof+jwt, whose header carries the holder's public key (as jwk) and whose payload proves the wallet holds the matching private key at request time:

  • aud - the Credential Issuer Identifier (:credential_issuer).
  • iat - issuance time.
  • nonce - the c_nonce the issuer previously handed out, when it did.
  • iss - the client_id, required for the authorization_code flow.

Signing and key-bound :alg/:kid validation behave as in AttestoClient.RequestObject / AttestoClient.ClientAssertion (shared AttestoClient.Builder internals).

Summary

Functions

Build a signed holder key proof, returning {:ok, compact_jws} or {:error, reason}. Fails fast on invalid input (see the error type).

Types

build_opt()

@type build_opt() ::
  {:credential_issuer, String.t()}
  | {:nonce, String.t()}
  | {:client_id, String.t()}
  | {:key_attestation, String.t()}
  | {:alg, String.t()}
  | {:kid, String.t()}
  | {:now, integer()}

error()

@type error() ::
  :invalid_key
  | :invalid_credential_issuer
  | :invalid_time
  | :unsupported_alg
  | :unsupported_key
  | {:signing_failed, String.t()}

jwk()

@type jwk() :: JOSE.JWK.t() | map()

Functions

build(jwk, opts)

@spec build(jwk(), [build_opt()]) :: {:ok, String.t()} | {:error, error()}

Build a signed holder key proof, returning {:ok, compact_jws} or {:error, reason}. Fails fast on invalid input (see the error type).

jwk is the holder's key (private half required for signing). Required option: :credential_issuer (the proof's aud). Pass :nonce with the issuer's c_nonce when it supplied one, and :client_id for the authorization_code flow (becomes iss); :alg, :kid, and :now behave as in AttestoClient.RequestObject.build/2. Pass :key_attestation (a compact JWT from AttestoClient.KeyAttestation.build/2) to carry it in the proof's key_attestation header, vouching that this key is securely stored.