pub struct PortableIdentityState {
pub user: PortableUserId,
pub revision: u64,
pub revoked: Vec<RevokedKey>,
pub issued_at: i64,
pub signature: RootSignature,
pub signer: Option<RootKey>,
pub roots_added: Vec<AddedRoot>,
pub roots_removed: Vec<RemovedRoot>,
}Expand description
A user’s root’s list of revoked device keys, at a revision, and the roots it has added and removed. Revocation only grows: a verifier checks credentials against the union of every valid state it has seen for the user, and keeps the newest (by revision) to hand on. A credential is good unless that union revokes its device key: adding a device needs no new state, so it lists no authorized keys.
Root changes are cumulative too: a state lists every root added and
removed so far, and a verifier works out the roots from all of them
(RootSet).
Fields§
§user: PortableUserId§revision: u64Higher is newer; each state the root makes is the last plus one.
revoked: Vec<RevokedKey>Sorted by key, one per key, as Self::new makes it; the
signature covers the set, whatever its order here.
issued_at: i64Unix seconds. Not used to order states: the revision is.
signature: RootSignatureThe signer’s, over Self::message.
signer: Option<RootKey>The root that signed it; absent, the phrase root the user’s id is.
roots_added: Vec<AddedRoot>Every root added so far, each with its proof that it is held.
roots_removed: Vec<RemovedRoot>Every root removed so far.
Implementations§
Source§impl PortableIdentityState
impl PortableIdentityState
Sourcepub fn new(
user: PortableUserId,
revision: u64,
revoked: Vec<RevokedKey>,
issued_at: i64,
sign: impl FnOnce(&[u8]) -> Signature,
) -> Result<Self, StateError>
pub fn new( user: PortableUserId, revision: u64, revoked: Vec<RevokedKey>, issued_at: i64, sign: impl FnOnce(&[u8]) -> Signature, ) -> Result<Self, StateError>
A state sign signs with user’s phrase root. revoked is put
in Self::message’s order, one entry per key (the earliest);
more than MAX_REVOKED is refused. Dropping lapsed entries
(revocation_lapsed) is the caller’s.
Sourcepub fn signed_by(
user: PortableUserId,
signer: RootKey,
revision: u64,
changes: StateChanges,
issued_at: i64,
sign: impl FnOnce(&[u8]) -> RootSignature,
) -> Result<Self, StateError>
pub fn signed_by( user: PortableUserId, signer: RootKey, revision: u64, changes: StateChanges, issued_at: i64, sign: impl FnOnce(&[u8]) -> RootSignature, ) -> Result<Self, StateError>
A state signer signs with sign: any kind of root, and
any root changes. Lists are put in Self::message’s order, one
entry each; over the limits is refused. A phrase identity’s own
phrase root, changing no roots, signs the STATE_DOMAIN layout.
Sourcepub fn signer(&self) -> RootKey
pub fn signer(&self) -> RootKey
The root it says signed it: the one it names, or the phrase root its user’s id is.
Sourcepub fn root_changes(&self) -> (RootKey, &[AddedRoot], &[RemovedRoot])
pub fn root_changes(&self) -> (RootKey, &[AddedRoot], &[RemovedRoot])
Its root changes, as RootSet reads them.
Sourcepub fn message(
user: &PortableUserId,
revision: u64,
revoked: &[RevokedKey],
issued_at: i64,
) -> Vec<u8> ⓘ
pub fn message( user: &PortableUserId, revision: u64, revoked: &[RevokedKey], issued_at: i64, ) -> Vec<u8> ⓘ
What the root signs: STATE_DOMAIN, then user
(32 bytes), revision (u64), issued_at (i64), the count of entries
(u32), then the entries sorted ascending by key, one per key, each
the key (32 bytes) and its revoked_at (i64); the integers
big-endian. revoked is taken as a set; a key given twice counts
once, with its earliest revoked_at.
Sourcepub fn signed_message(&self) -> Vec<u8> ⓘ
pub fn signed_message(&self) -> Vec<u8> ⓘ
What its signer signed. Self::message for a state of
the phrase root its user’s id is that changes no roots; else
STATE_V3_DOMAIN, the same fields, then the signer
(RootKey::bytes), the count of roots added (u8) and each sorted
ascending by root, as the root, its adder and its added_at (i64),
and the count of roots removed (u8) and each root sorted ascending
with its removed_at (i64). The additions’ signatures are not in
it: each is checked against its own message.
Sourcepub fn verify(&self) -> Result<(), StateError>
pub fn verify(&self) -> Result<(), StateError>
Whether the root it names signed it, it is within the limits, and
every root it adds is valid and signed its addition. The counts
are checked first, on the lists as given, so an oversized one
costs no sorting. Whether its signer is one of the user’s roots is
the verifier’s (RootSet).
Sourcepub fn revokes(&self, key: &DevicePublicKey) -> bool
pub fn revokes(&self, key: &DevicePublicKey) -> bool
Whether it revokes key.
Sourcepub fn same_as(&self, other: &PortableIdentityState) -> bool
pub fn same_as(&self, other: &PortableIdentityState) -> bool
Whether other says the same as this: the same signed bytes and
signature, whatever order its lists are in.
Sourcepub fn digest(&self) -> [u8; 32]
pub fn digest(&self) -> [u8; 32]
BLAKE3 of what its signer signed and of its signature as CBOR (the
wire’s codec) writes it: one value for one state, whatever order
its lists are in. Two states of one revision are ordered by it, the
lower first (newest_first), so every verifier picks the same
one as the newest.
Sourcepub fn root_changes_covered_by(&self, others: &[PortableIdentityState]) -> bool
pub fn root_changes_covered_by(&self, others: &[PortableIdentityState]) -> bool
Whether others carry every root change this state makes: each
root it adds is added in one of them, and each root it removes is
removed in one of them, no later. A state whose changes others
carry adds nothing to the root set they make. Its revocations are
not looked at.