pub struct EncryptionKey {
pub did: Did,
pub key_type: String,
pub public_key: PublicKey,
pub public_key_multibase: String,
/* private fields */
}Expand description
X25519 encryption key for envelope key agreement.
Used to compute shared secrets via Diffie-Hellman for encrypting
and decrypting Envelope payloads.
§Examples
use ma_did::{Did, EncryptionKey};
let did = Did::new_url("k51qzi5uqu5dj9807pbuod1pplf0vxh8m4lfy3ewl9qbm2s8dsf9ugdf9gedhr", None::<String>).unwrap();
let key = EncryptionKey::generate(did).unwrap();
// Export and reimport
let bytes = key.private_key_bytes();
let did2 = Did::new_url("k51qzi5uqu5dj9807pbuod1pplf0vxh8m4lfy3ewl9qbm2s8dsf9ugdf9gedhr", None::<String>).unwrap();
let restored = EncryptionKey::from_private_key_bytes(did2, bytes).unwrap();
assert_eq!(key.public_key_multibase, restored.public_key_multibase);Fields§
§did: Did§key_type: String§public_key: PublicKey§public_key_multibase: StringImplementations§
Trait Implementations§
Source§impl Clone for EncryptionKey
impl Clone for EncryptionKey
Source§fn clone(&self) -> EncryptionKey
fn clone(&self) -> EncryptionKey
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 TryFrom<&EncryptionKey> for VerificationMethod
impl TryFrom<&EncryptionKey> for VerificationMethod
Auto Trait Implementations§
impl Freeze for EncryptionKey
impl RefUnwindSafe for EncryptionKey
impl Send for EncryptionKey
impl Sync for EncryptionKey
impl Unpin for EncryptionKey
impl UnsafeUnpin for EncryptionKey
impl UnwindSafe for EncryptionKey
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