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
- Genesis self-signature. Decode the genesis public key from the
DID’s base58 suffix; verify the genesis roster envelope’s
self_signed_by_genesis_keyagainst it. - Roster chain. Each chain entry signed by a VM present in the prior entry’s roster; versions strictly monotonic.
- Current VM in head. The device that signed this JWT is in the head (current) roster.
- 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§
- Claim
Value - A single claim value with provenance metadata.
- Embedded
Genesis Roster - 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).
- Embedded
Roster Chain Entry - One entry in the wallet-signed roster chain. Each entry is signed by a verification method present in the prior entry’s roster.
- Embedded
Verification Method - 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.
- MidJwt
Payload - The mID JWT payload — the JSON object that’s base64url-encoded as the second segment of the JWS compact-form token.
- Verification
Method - A verification method = a public key bound to a DID. Same shape as the
W3C DID document
verificationMethod[]entry, minimum-fields form. - Verified
Mid - 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.
- Verify
Config - Configuration the RP supplies to
verify_mid_response.
Enums§
- Attested
By - Attestation provenance for a claim.
- Verify
Error - The single error type returned by
crate::verify_mid_response.
Functions§
- verify_
mid_ response - Run the four-step mID verification against
jwtperVerifyConfig.