pub struct CredentialBundle { /* private fields */ }Expand description
An encrypted local bundle, safe to persist outside the replicated DAG.
This is a local storage format, not a portable Account schema or a recovery export. All convenience logins use this same format, including empty passwords. Encrypted records may be served to filesystem-trusted socket clients; their passwords and decrypted keys need not be sent to a daemon.
Implementations§
Source§impl CredentialBundle
impl CredentialBundle
Sourcepub fn seal(
account_id: &ID,
keys: &[PrivateKey],
password: &str,
) -> Result<Self>
pub fn seal( account_id: &ID, keys: &[PrivateKey], password: &str, ) -> Result<Self>
Encrypt exactly these installation keys and this Account locator with one password. Keys must be nonempty and unique. No reference lookup, membership enrollment, or database write occurs. Every password string is accepted, including empty. Empty-string wrapping provides no meaningful confidentiality against anyone holding the bundle.
use eidetica::{ID, account::{CredentialBundle, AccountSigner}, auth::crypto::generate_keypair};
let account_id = ID::from_bytes("example-account-locator");
let (private, public) = generate_keypair();
let encrypted = CredentialBundle::seal(&account_id, &[private], "local password")?;
let bytes = serde_json::to_vec(&encrypted)?; // Persist only outside the Entry DAG.
let stored: CredentialBundle = serde_json::from_slice(&bytes)?;
let unlocked = stored.unlock_for(&account_id, "local password")?;
let acting = AccountSigner::new(account_id.clone(), unlocked.signer(&public)?);
assert_eq!(acting.account_id(), &account_id);
assert_eq!(acting.key_id(), public);
drop(unlocked); // The acting handle owns an independent signer clone.Sourcepub fn unlock(&self, password: &str) -> Result<UnlockedCredentials>
pub fn unlock(&self, password: &str) -> Result<UnlockedCredentials>
Unlock on the client. The Account locator and every private key are authenticated by the same envelope. Unknown formats, tampering and wrong passwords fail closed without echoing decrypted bytes in diagnostics.
Sourcepub fn unlock_for(
&self,
account_id: &ID,
password: &str,
) -> Result<UnlockedCredentials>
pub fn unlock_for( &self, account_id: &ID, password: &str, ) -> Result<UnlockedCredentials>
Unlock only if the encrypted locator matches the expected Account. A directory hint or copied encrypted blob cannot rebind its locator.
Trait Implementations§
Source§impl Clone for CredentialBundle
impl Clone for CredentialBundle
Source§fn clone(&self) -> CredentialBundle
fn clone(&self) -> CredentialBundle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CredentialBundle
impl Debug for CredentialBundle
Source§impl<'de> Deserialize<'de> for CredentialBundle
impl<'de> Deserialize<'de> for CredentialBundle
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for CredentialBundle
impl RefUnwindSafe for CredentialBundle
impl Send for CredentialBundle
impl Sync for CredentialBundle
impl Unpin for CredentialBundle
impl UnsafeUnpin for CredentialBundle
impl UnwindSafe for CredentialBundle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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