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_core::{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<Self>
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<Self>
pub fn validate(&self) -> Result<()>
Trait Implementations§
Source§impl Clone for SigningKey
impl Clone for SigningKey
Source§impl TryFrom<&SigningKey> for VerificationMethod
impl TryFrom<&SigningKey> for VerificationMethod
Auto Trait Implementations§
impl Forget for SigningKey
impl Freeze for SigningKey
impl Move for SigningKey
impl RefUnwindSafe for SigningKey
impl Send for SigningKeywhere
RawVecInner: Send,
impl Sync for SigningKeywhere
RawVecInner: Sync,
impl Unpin for SigningKey
impl UnsafeUnpin for SigningKey
impl UnwindSafe for SigningKeywhere
RawVecInner: UnwindSafe,
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