pub struct StoredKeypair {
pub key_id: KeyId,
pub created_at: OffsetDateTime,
pub secret_key: String,
pub public_key: String,
}Expand description
An Ed25519 keypair stored as base64-encoded strings with metadata.
Fields§
§key_id: KeyIdUnique identifier for this keypair.
created_at: OffsetDateTimeTimestamp when the keypair was generated.
secret_key: StringBase64-encoded Ed25519 secret key (32 bytes).
public_key: StringBase64-encoded Ed25519 public key (32 bytes).
Implementations§
Source§impl StoredKeypair
impl StoredKeypair
Sourcepub fn signing_key(&self) -> Result<SigningKey, CryptoError>
pub fn signing_key(&self) -> Result<SigningKey, CryptoError>
Decodes and returns the Ed25519 signing key.
Sourcepub fn verifying_key(&self) -> Result<VerifyingKey, CryptoError>
pub fn verifying_key(&self) -> Result<VerifyingKey, CryptoError>
Decodes and returns the Ed25519 verifying (public) key.
Sourcepub fn secret_key_bytes(&self) -> Result<[u8; 32], CryptoError>
pub fn secret_key_bytes(&self) -> Result<[u8; 32], CryptoError>
Returns the raw 32-byte secret key.
Sourcepub fn sign_bytes(
&self,
payload: &[u8],
) -> Result<MessageSignature, CryptoError>
pub fn sign_bytes( &self, payload: &[u8], ) -> Result<MessageSignature, CryptoError>
Signs raw bytes and returns a detached MessageSignature.
Sourcepub fn sign_json<T: Serialize>(
&self,
payload: &T,
) -> Result<MessageSignature, CryptoError>
pub fn sign_json<T: Serialize>( &self, payload: &T, ) -> Result<MessageSignature, CryptoError>
Serializes payload to canonical JSON, then signs the bytes.
Sourcepub fn write_to_path(&self, path: &Path) -> Result<(), CryptoError>
pub fn write_to_path(&self, path: &Path) -> Result<(), CryptoError>
Writes the keypair to a JSON file with restrictive permissions (0600 on Unix).
Sourcepub fn read_from_path(path: &Path) -> Result<Self, CryptoError>
pub fn read_from_path(path: &Path) -> Result<Self, CryptoError>
Reads a keypair from a JSON file at the given path.
Trait Implementations§
Source§impl Clone for StoredKeypair
impl Clone for StoredKeypair
Source§fn clone(&self) -> StoredKeypair
fn clone(&self) -> StoredKeypair
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StoredKeypair
impl Debug for StoredKeypair
Source§impl<'de> Deserialize<'de> for StoredKeypair
impl<'de> Deserialize<'de> for StoredKeypair
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for StoredKeypair
impl RefUnwindSafe for StoredKeypair
impl Send for StoredKeypair
impl Sync for StoredKeypair
impl Unpin for StoredKeypair
impl UnsafeUnpin for StoredKeypair
impl UnwindSafe for StoredKeypair
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
Mutably borrows from an owned value. Read more