pub struct SecretKey { /* private fields */ }Expand description
Ed25519 signing key (RFC 8032).
§Generating a key
ⓘ
use crypto::curve25519::ed25519::SecretKey;
let priv_key = SecretKey::generate().unwrap();
let pub_key = priv_key.public_key();§Signing and verification
ⓘ
use crypto::curve25519::ed25519::SecretKey;
let priv_key = SecretKey::generate().unwrap();
let pub_key = priv_key.public_key();
let sig = priv_key.sign(b"message");
assert!(pub_key.verify(b"message", &sig).is_ok());Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn generate() -> Result<SecretKey, EllipticCurveError>
pub fn generate() -> Result<SecretKey, EllipticCurveError>
Generates a fresh random secret key.
Returns EllipticCurveError::Random when the operating system’s
random number generator is unavailable or fails.
pub fn from_bytes(seed: &[u8; 32]) -> SecretKey
pub fn sign(&self, message: &[u8]) -> [u8; 64]
pub fn to_bytes(&self) -> [u8; 32]
pub fn public_key(&self) -> PublicKey
Trait Implementations§
impl Eq for SecretKey
impl StructuralPartialEq for SecretKey
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnsafeUnpin for SecretKey
impl UnwindSafe for SecretKey
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