Skip to main content

PortableIdentityState

Struct PortableIdentityState 

Source
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: u64

Higher 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: i64

Unix seconds. Not used to order states: the revision is.

§signature: RootSignature

The 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

Source

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.

Source

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.

Source

pub fn signer(&self) -> RootKey

The root it says signed it: the one it names, or the phrase root its user’s id is.

Source

pub fn root_changes(&self) -> (RootKey, &[AddedRoot], &[RemovedRoot])

Its root changes, as RootSet reads them.

Source

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.

Source

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.

Source

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).

Source

pub fn revokes(&self, key: &DevicePublicKey) -> bool

Whether it revokes key.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for PortableIdentityState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PortableIdentityState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PortableIdentityState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for PortableIdentityState

Source§

impl PartialEq for PortableIdentityState

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PortableIdentityState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PortableIdentityState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.