pub struct VerifiedMid {
pub did: String,
pub genesis_roster_hash: [u8; 32],
pub current_version: u64,
pub claims: BTreeMap<String, ClaimValue>,
pub iat: u64,
pub exp: u64,
pub aud: String,
pub roster_hashes: Vec<(u64, [u8; 32])>,
}Expand description
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.
Fields§
§did: StringThe user’s DID. Stable across the user’s lifetime; the RP’s user table primary key.
genesis_roster_hash: [u8; 32]SHA-256 of the canonical genesis-roster bytes. The RP records
this on first sight as the user’s anchor; on subsequent sign-ins
the same DID MUST produce the same genesis_roster_hash (the
RP’s upsert can guard the invariant).
current_version: u64The head roster’s version. Monotonically increases as the user adds / revokes devices. The RP can record this and reject lower versions on subsequent sign-ins to defeat stolen-device replay.
claims: BTreeMap<String, ClaimValue>The claim values the user consented to disclose, exactly as the wallet asserted them.
iat: u64The JWT’s issued-at, Unix seconds.
exp: u64The JWT’s expiry, Unix seconds.
aud: StringThe JWT’s audience — equals config.expected_audience after
successful verify.
roster_hashes: Vec<(u64, [u8; 32])>(version, SHA-256 of its canonical bytes) for every roster the token
carries, genesis first, head last. An RP records the head’s pair and
passes it to VerifiedMid::check_continuity next time, which is what
catches a history branched off an older roster.
Implementations§
Source§impl VerifiedMid
impl VerifiedMid
Sourcepub fn check_rollback(
&self,
last_seen_version: Option<u64>,
) -> Result<(), VerifyError>
pub fn check_rollback( &self, last_seen_version: Option<u64>, ) -> Result<(), VerifyError>
Check that the current roster version is at least as new as the last version the RP has seen for this DID.
The RP fetches last_seen_version from its own per-DID store
(typically a users.last_seen_roster_version column). Pass
None if this is a DID the RP has never seen — in that case
the check trivially passes and the RP records the current
version as the new high-water mark.
Sourcepub fn head(&self) -> (u64, [u8; 32])
pub fn head(&self) -> (u64, [u8; 32])
The head roster’s (version, hash): what an RP records as its mark.
Sourcepub fn check_continuity(
&self,
mark: Option<(u64, [u8; 32])>,
) -> Result<(), VerifyError>
pub fn check_continuity( &self, mark: Option<(u64, [u8; 32])>, ) -> Result<(), VerifyError>
Check that this token’s roster history continues the one the RP saw
last. mark is the (version, hash) the RP recorded (Self::head
of an earlier token), or None for a DID it has never seen.
Refuses an older head (VerifyError::RollbackDetected, as
Self::check_rollback) and, unlike it, a history that does not carry
the recorded roster at the recorded version (VerifyError::ForkDetected).
Every token carries its full chain from genesis, so the recorded roster
must be in it.