pub struct EncryptedKeyContainer {
pub version: u8,
pub salt: String,
pub nonce: String,
pub ciphertext: String,
pub public_key: Option<String>,
}Expand description
Encrypted key container format (devsyrem’s versioned format)
This structure holds all data needed to decrypt a private key:
- Salt for key derivation
- Nonce for AES-GCM
- Encrypted private key (ciphertext + auth tag)
The container can be serialized to JSON for storage/transmission.
Fields§
§version: u8Version for future format changes
salt: StringSalt for Argon2 key derivation (base64)
nonce: StringNonce for AES-GCM (base64)
ciphertext: StringEncrypted private key with auth tag (base64)
public_key: Option<String>Public key for verification (base58, optional)
Implementations§
Source§impl EncryptedKeyContainer
impl EncryptedKeyContainer
Sourcepub fn encrypt(
private_key: &[u8],
passphrase: &str,
) -> Result<Self, SignerError>
pub fn encrypt( private_key: &[u8], passphrase: &str, ) -> Result<Self, SignerError>
Create a new encrypted key container from a plaintext private key
§Arguments
private_key- The 32-byte Ed25519 seed or 64-byte keypairpassphrase- The passphrase to encrypt with
§Returns
The encrypted container
§Memory Lifecycle
The private key is copied into a secure buffer for processing, and all intermediate values are zeroized.
Sourcepub fn to_json(&self) -> Result<String, SignerError>
pub fn to_json(&self) -> Result<String, SignerError>
Serialize the container to JSON
Sourcepub fn from_json(json: &str) -> Result<Self, SignerError>
pub fn from_json(json: &str) -> Result<Self, SignerError>
Deserialize from JSON
Trait Implementations§
Source§impl Clone for EncryptedKeyContainer
impl Clone for EncryptedKeyContainer
Source§fn clone(&self) -> EncryptedKeyContainer
fn clone(&self) -> EncryptedKeyContainer
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<'de> Deserialize<'de> for EncryptedKeyContainer
impl<'de> Deserialize<'de> for EncryptedKeyContainer
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 EncryptedKeyContainer
impl RefUnwindSafe for EncryptedKeyContainer
impl Send for EncryptedKeyContainer
impl Sync for EncryptedKeyContainer
impl Unpin for EncryptedKeyContainer
impl UnsafeUnpin for EncryptedKeyContainer
impl UnwindSafe for EncryptedKeyContainer
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