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: UuidThe account owner’s user id (UUIDv7).
master: MasterKeyThe backed-up root key.
user_ik: HybridSigningKeyThe user identity key (root of signing trust). Signs the device directory.
device: DeviceKeysThis device’s keys.
Implementations§
Source§impl Account
impl Account
Sourcepub fn create(ids: IdSource<'_>) -> Self
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.
Sourcepub fn create_with_hardware_dek(
ids: IdSource<'_>,
element: Arc<dyn HardwareKeyAgreement>,
key_alias: String,
) -> Result<Self, HardwareSignerError>
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.
Sourcepub fn from_parts(
ids: IdSource<'_>,
user_id: Uuid,
master: MasterKey,
user_ik: HybridSigningKey,
dek: DeviceDek,
) -> Self
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.
Sourcepub fn sealed_identity(&self) -> Vec<u8> ⓘ
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.
Sourcepub fn open_sealed_identity(
master: &MasterKey,
sealed: &[u8],
) -> Result<HybridSigningKey, CryptoError>
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.
Sourcepub fn to_file(
&self,
passphrase: &[u8],
tier: DeviceTier,
) -> Result<AccountFile, CryptoError>
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.
Sourcepub fn to_file_with(
&self,
passphrase: &[u8],
params: Argon2Params,
) -> Result<AccountFile, CryptoError>
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§
impl !RefUnwindSafe for Account
impl !UnwindSafe for Account
impl Freeze for Account
impl Send for Account
impl Sync for Account
impl Unpin for Account
impl UnsafeUnpin for Account
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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