Skip to main content

Account

Struct Account 

Source
pub struct Account {
    pub user_id: Uuid,
    pub master: MasterKey,
    pub user_ik: HybridSigningKey,
    pub device: DeviceKeys,
}
Expand description

A fully unlocked account in memory.

Fields§

§user_id: Uuid

The account owner’s user id (UUIDv7).

§master: MasterKey

The backed-up root key.

§user_ik: HybridSigningKey

The user identity key (root of signing trust). Signs the device directory.

§device: DeviceKeys

This device’s keys.

Implementations§

Source§

impl Account

Source

pub fn create(ids: IdSource<'_>) -> Self

Create a brand-new account with a fresh master key, user IK, and first device, using the software DEK composition. The fallback the design keeps for hosts with no secure element; create_with_hardware_dek is the bound form.

The user and device ids are UUIDv7s minted from ids.

Source

pub fn create_with_hardware_dek( ids: IdSource<'_>, element: Arc<dyn HardwareKeyAgreement>, key_alias: String, ) -> Result<Self, HardwareSignerError>

Create a brand-new account whose DEK’s classical half is generated inside element under key_alias and never leaves it. The ML-KEM-768 half is drawn fresh here and sealed under the master key like any software seed.

Fails only if the element refuses enrollment (unavailable, biometric cancelled, bad key) — deliberately not silently falling back to software, because a caller that asked for hardware binding and got software would believe a guarantee it does not have. A caller that wants best-effort binding probes the element first and calls create itself.

Source

pub fn from_parts( ids: IdSource<'_>, user_id: Uuid, master: MasterKey, user_ik: HybridSigningKey, dek: DeviceDek, ) -> Self

Assemble an account from existing account-level material on a new device: the account’s user_id, its master key (e.g. recovered from the server escrow with recover_master_key), and its user identity key (e.g. opened from a sealed identity with open_sealed_identity).

Everything per-device is fresh: a new device_id and DSK, plus the caller’s dek. A recovered device is a new device — it never resumes a lost device’s keys, whose classical halves may have been hardware-bound and are gone with it. The device_id is a UUIDv7 minted from ids.

Source

pub fn sealed_identity(&self) -> Vec<u8> ⓘ

The user identity key’s private seeds sealed under the master key, in a domain-separated form a client may store off-device (e.g. beside the master-key escrow).

The user IK is drawn at random at account creation, not derived from the master key — rotating the master key must not rotate the identity, and the server pins the identity public key on the first directory publish. So a device that recovers only the master key would otherwise have to mint a new IK, which the server refuses for an account it has already anchored. This blob is a wrap reachable from the master key, not a second root: whoever recovers the master key opens it, nobody else can.

Source

pub fn open_sealed_identity( master: &MasterKey, sealed: &[u8], ) -> Result<HybridSigningKey, CryptoError>

Open a sealed_identity blob under master.

Returns CryptoError::Auth when master is not the key that sealed it (or the blob was tampered with), and CryptoError::Malformed when it opens but is not a sealed user IK — e.g. an AccountFile’s sealed device key, which the domain prefix keeps from being accepted as an identity.

Source

pub fn to_file( &self, passphrase: &[u8], tier: DeviceTier, ) -> Result<AccountFile, CryptoError>

Encrypt the account for persistence: master under passphrase (cost = tier), identity/device private keys under the master key.

Source

pub fn to_file_with( &self, passphrase: &[u8], params: Argon2Params, ) -> Result<AccountFile, CryptoError>

As to_file but with explicit Argon2id parameters (used by tests to avoid the multi-hundred-MiB production cost).

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
§

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

§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more