pub struct SigningKey(/* private fields */);Expand description
Signing key for Ed25519 signatures
Automatically zeroized on drop to protect key material.
§Security
- 256-bit private key
- Constant-time operations
- Automatically zeroized when dropped
- Note: Implements
Clonefor testing convenience, but cloning key material increases exposure. Use sparingly in production code.
§Examples
use aion_context::crypto::SigningKey;
let key = SigningKey::generate();
let message = b"test message";
let signature = key.sign(message);Implementations§
Source§impl SigningKey
impl SigningKey
Sourcepub fn generate() -> Self
pub fn generate() -> Self
Generate a new random signing key using OS entropy
Uses the operating system’s cryptographically secure random number
generator (/dev/urandom on Unix, CryptGenRandom on Windows).
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Create a signing key from bytes
§Errors
Returns AionError::InvalidPrivateKey if the bytes are not a valid Ed25519 private key
Sourcepub fn to_bytes(&self) -> &[u8; 32]
pub fn to_bytes(&self) -> &[u8; 32]
Get the bytes of this signing key
Returns a reference to the key bytes
Sourcepub fn sign(&self, message: &[u8]) -> [u8; 64]
pub fn sign(&self, message: &[u8]) -> [u8; 64]
Sign a message
Creates an Ed25519 signature over the message using this key.
§Examples
use aion_context::crypto::SigningKey;
let key = SigningKey::generate();
let signature = key.sign(b"message");
assert_eq!(signature.len(), 64);Sourcepub fn verifying_key(&self) -> VerifyingKey
pub fn verifying_key(&self) -> VerifyingKey
Get the corresponding verifying key
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 moreAuto 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more