pub struct UnlockedIdentity<K: KeyScheme> { /* private fields */ }Expand description
A live, in-memory identity whose secret key has been decrypted and is ready to sign.
Obtained from crate::Session::unlock or crate::Session::enroll_identity.
The secret bytes live inside the wrapped SignerHandle, which stores them
in a Zeroizing buffer and wipes them when this value is dropped — so the
decrypted key never lingers in freed memory. The type deliberately does not
implement Clone and its Debug impl redacts the secret, so an
UnlockedIdentity cannot be duplicated into a log line or a debug dump.
§Boundaries
An UnlockedIdentity must never cross an IPC boundary: it holds raw key
material and belongs solely to the user-app process that owns the identity
(dig_ecosystem #908). Hand a downstream a SigningFn via
inject_into instead of the handle itself.
Implementations§
Source§impl<K: KeyScheme> UnlockedIdentity<K>
impl<K: KeyScheme> UnlockedIdentity<K>
Sourcepub fn public_key(&self) -> &K::PublicKey
pub fn public_key(&self) -> &K::PublicKey
The public key of this identity.
For the identity scheme this is byte-identical to
dig_identity::public_key_bytes(derive_identity_sk(master)), i.e. the
key anchored in the DID profile — so signatures produced by this handle
verify against the published identity.
Sourcepub fn signing_fn(&self) -> SigningFn<K>
pub fn signing_fn(&self) -> SigningFn<K>
Produce a standalone SigningFn primitive that signs with this
identity’s key.
The returned closure owns its own zeroizing copy of the secret, so it keeps working after this handle is dropped and wipes its copy when the closure itself is dropped.
Sourcepub fn derive_symmetric_key(&self, label: &[u8]) -> Zeroizing<[u8; 32]>
pub fn derive_symmetric_key(&self, label: &[u8]) -> Zeroizing<[u8; 32]>
Derive a per-profile symmetric key (a data-encryption key, “DEK”) from
this unlocked identity, bound to label.
The DEK is HKDF-SHA256(salt = DEK_SALT, ikm = 0x02 || identity_scalar, info = label) expanded to 32 bytes. The identity scalar is the raw
secret; it is read into a zeroizing buffer, mixed into the KDF, and never
returned — only the derived key by label leaves the facade, so the
root secret stays inside (dig_ecosystem #908).
§Byte-identical to dig-app (§5.1 at-rest back-compat)
With label = b"dig-app:profile-dek:v2" this reproduces, byte-for-byte,
the DEK that dig-app’s dig-app-core/src/keystore/secrets.rs
(dek_password, the seal_data/open_data key) already uses to seal
every profile blob at rest. The construction is pinned exactly:
- hash: SHA-256 (
hkdf0.12 +sha20.10, RFC 5869); - IKM:
0x02 || identity_scalar— the same 33-byte versioned layout dig-app feeds to HKDF (to_sealed_bytes()), NOT the bare scalar; - salt:
dig_constants::DEK_SALT(b"dig-app:dek-salt:v1"); - info:
labelverbatim — passdig_constants::PROFILE_DEK_LABELto reproduce dig-app’s own profile DEK; - output: 32 bytes (
dig_constants::SYMMETRIC_KEY_LEN).
Changing any of these would derive a different DEK and make already-sealed profile data permanently unreadable, so they are frozen and covered by a golden-vector test.
The returned key and all intermediates are wrapped in Zeroizing and
wiped on drop.
Sourcepub fn inject_into<T>(&self, consumer: impl FnOnce(SigningFn<K>) -> T) -> T
pub fn inject_into<T>(&self, consumer: impl FnOnce(SigningFn<K>) -> T) -> T
Inject this identity’s signing capability into a consumer as a bare
SigningFn primitive, returning whatever the consumer builds from it.
The consumer receives only a callable — never an UnlockedIdentity,
a SignerHandle, or any identity type — which is how a downstream stays
identity-agnostic while still being able to sign.
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for UnlockedIdentity<K>
impl<K> RefUnwindSafe for UnlockedIdentity<K>
impl<K> Send for UnlockedIdentity<K>
impl<K> Sync for UnlockedIdentity<K>
impl<K> Unpin for UnlockedIdentity<K>
impl<K> UnsafeUnpin for UnlockedIdentity<K>
impl<K> UnwindSafe for UnlockedIdentity<K>
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
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.