pub struct IdentityStore { /* private fields */ }Expand description
Keystore for managing named Soroban identities.
Implementations§
Source§impl IdentityStore
impl IdentityStore
Sourcepub fn new() -> Result<Self, StorageError>
pub fn new() -> Result<Self, StorageError>
Initialize the keystore in the default OS-portable config directory (~/.config/sdkt/identities/).
If the SDKT_IDENTITY_DIR environment variable is set, its value is used instead of the
OS-default config directory. This provides a cross-platform override (works on macOS and
Windows, where XDG_CONFIG_HOME is ignored by directories::ProjectDirs), and is the
canonical way for tests and CI to isolate the identity store.
Sourcepub fn with_dir<P: AsRef<Path>>(dir: P) -> Result<Self, StorageError>
pub fn with_dir<P: AsRef<Path>>(dir: P) -> Result<Self, StorageError>
Initialize the keystore in a custom directory.
Sourcepub fn generate(&self, name: &str) -> Result<Identity, StorageError>
pub fn generate(&self, name: &str) -> Result<Identity, StorageError>
Generate a new random ED25519 identity.
Sourcepub fn import(
&self,
name: &str,
secret_key: &str,
) -> Result<Identity, StorageError>
pub fn import( &self, name: &str, secret_key: &str, ) -> Result<Identity, StorageError>
Import an identity from a secret key (S…) string.
Sourcepub fn resolve_signing_identity(
&self,
name: &str,
) -> Result<Identity, StorageError>
pub fn resolve_signing_identity( &self, name: &str, ) -> Result<Identity, StorageError>
Resolve the signing identity named by a CLI --identity value.
The signing commands default --identity to the reserved literal
DEFAULT_IDENTITY_NAME ("default"), which can never be a real key.
When name is that sentinel this returns the identity selected by
IdentityStore::set_default; for any other name it is exactly
IdentityStore::get, so an explicit --identity <name> is unchanged.
§Errors
Returns StorageError::NoDefaultIdentity when the sentinel is used and
no default has been configured, and the IdentityStore::get error for
any other unresolvable name.
Sourcepub fn remove(&self, name: &str) -> Result<(), StorageError>
pub fn remove(&self, name: &str) -> Result<(), StorageError>
Delete an identity.
Returns StorageError::NotFound when no identity with that name
exists, matching NetworkStore::remove, so a mistyped name is reported
rather than treated as a successful removal.
Sourcepub fn set_default(&self, name: &str) -> Result<(), StorageError>
pub fn set_default(&self, name: &str) -> Result<(), StorageError>
Set an identity as the default.
Sourcepub fn get_default(&self) -> Result<Identity, StorageError>
pub fn get_default(&self) -> Result<Identity, StorageError>
Load the default identity.
Sourcepub fn load_signing_key(&self, name: &str) -> Result<SigningKey, StorageError>
pub fn load_signing_key(&self, name: &str) -> Result<SigningKey, StorageError>
Load the signing key (ed25519_dalek::SigningKey) for a named identity.
This is the keystore integration point used by transaction signing:
the caller extracts the 32-byte seed via signing_key.to_bytes() and
passes it to sdkt_xdr::Ed25519Signer::from_seed. The secret material
is never exposed as a string; only the in-memory SigningKey is
returned, and only for the duration the caller holds it.
§Errors
Returns StorageError if the identity does not exist or its secret
cannot be loaded.