pub struct SigningKey {
pub did: Did,
pub key_type: String,
pub public_key_multibase: String,
/* private fields */
}Expand description
Ed25519 signing key for document proofs and message signatures.
§Examples
use ma_did::{Did, SigningKey};
let did = Did::new_url("k51qzi5uqu5dj9807pbuod1pplf0vxh8m4lfy3ewl9qbm2s8dsf9ugdf9gedhr", None::<String>).unwrap();
let key = SigningKey::generate(did).unwrap();
let signature = key.sign(b"hello world");
assert!(!signature.is_empty());
// Export and reimport private key bytes
let bytes = key.private_key_bytes();
let did2 = Did::new_url("k51qzi5uqu5dj9807pbuod1pplf0vxh8m4lfy3ewl9qbm2s8dsf9ugdf9gedhr", None::<String>).unwrap();
let restored = SigningKey::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_multibase: StringImplementations§
Source§impl SigningKey
impl SigningKey
pub fn generate(did: Did) -> Result<SigningKey, MaError>
pub fn sign(&self, data: &[u8]) -> Vec<u8> ⓘ
pub fn verifying_key(&self) -> VerifyingKey
pub fn private_key_bytes(&self) -> [u8; 32]
pub fn from_private_key_bytes( did: Did, private_key: [u8; 32], ) -> Result<SigningKey, MaError>
pub fn validate(&self) -> Result<(), MaError>
Trait Implementations§
Source§impl Clone for SigningKey
impl Clone for SigningKey
Source§fn clone(&self) -> SigningKey
fn clone(&self) -> SigningKey
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<&SigningKey> for VerificationMethod
impl TryFrom<&SigningKey> for VerificationMethod
Auto Trait Implementations§
impl Freeze for SigningKey
impl RefUnwindSafe for SigningKey
impl Send for SigningKey
impl Sync for SigningKey
impl Unpin for SigningKey
impl UnsafeUnpin for SigningKey
impl UnwindSafe for SigningKey
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