Skip to main content

Crate mid_verify

Crate mid_verify 

Source
Expand description

§mid-verify — RP-side mID JWT verifier

Phase 0 of the mID Mission. Implements the four-step verification from ADR 0005 Decision 1: given a JWS compact-form mID token and a VerifyConfig, run all cryptographic checks entirely locally and return a VerifiedMid that captures the user’s DID, current roster version, and disclosed claims.

§The four-step verification

  1. Genesis self-signature. Decode the genesis public key from the DID’s base58 suffix; verify the genesis roster envelope’s self_signed_by_genesis_key against it.
  2. Roster chain. Each chain entry signed by a VM present in the prior entry’s roster; versions strictly monotonic.
  3. Current VM in head. The device that signed this JWT is in the head (current) roster.
  4. JWS outer signature. Standard ES256 verification against the embedded verification method’s public key.

§Zero MATA runtime calls

Per ADR 0005, RPs make zero HTTP requests to MATA infrastructure during verification. Every cryptographic input the verifier needs travels inside the JWT itself; everything else is RP-local configuration (VerifyConfig) or RP-local state (the optional rollback check the RP runs against its own database AFTER calling verify_mid_response).

§Usage

ⓘ
use mid_verify::{verify_mid_response, VerifyConfig};

let config = VerifyConfig {
    expected_audience: "https://acme.com".to_string(),
    expected_nonce: my_session_nonce.clone(),
    max_iat_skew_secs: 120,
    now_unix_secs: current_wall_clock_secs(),
};

let verified = verify_mid_response(&incoming_jwt, &config)?;

// Optional rollback check — look up the highest version this RP has
// seen for this DID in its own database, then:
let last_seen = db.lookup_last_seen_version(&verified.did).await?;
verified.check_rollback(last_seen)?;

// Persist user, issue session...

Re-exports§

pub use keys::did_from_pubkey;
pub use keys::multibase_from_pubkey;
pub use keys::pubkey_from_did;
pub use keys::pubkey_from_multibase;

Modules§

checks
The four cryptographic checks per ADR 0005 Decision 1.
keys
Key decoding from the wire-format strings.

Structs§

ClaimValue
A single claim value with provenance metadata.
EmbeddedGenesisRoster
The genesis roster envelope — version 1, self-signed by the genesis device’s signing key (the key whose public form is encoded in the DID identifier).
EmbeddedRosterChainEntry
One entry in the wallet-signed roster chain. Each entry is signed by a verification method present in the prior entry’s roster.
EmbeddedVerificationMethod
The current device’s verification method — the key that’s about to sign the JWT. Slim form (just the key + identity), no extra DID-document metadata. Must appear in the head roster of the chain.
MidJwtPayload
The mID JWT payload — the JSON object that’s base64url-encoded as the second segment of the JWS compact-form token.
VerificationMethod
A verification method = a public key bound to a DID. Same shape as the W3C DID document verificationMethod[] entry, minimum-fields form.
VerifiedMid
The result of a successful verification. Carries everything an RP needs to upsert a user row, issue a session, and (optionally) run a rollback check.
VerifyConfig
Configuration the RP supplies to verify_mid_response.

Enums§

AttestedBy
Attestation provenance for a claim.
VerifyError
The single error type returned by crate::verify_mid_response.

Functions§

verify_mid_response
Run the four-step mID verification against jwt per VerifyConfig.
verify_mid_response_echoed_nonce
verify_mid_response for a relying party that reads the nonce out of the token instead of holding it beside the session: every check except the nonce comparison, and the token’s nonce handed back.