pub struct Ed25519PrivateKey(/* private fields */);
Expand description
An Ed25519 private key for creating digital signatures.
Ed25519 is a public-key signature system based on the Edwards curve over the finite field GF(2^255 - 19). It provides the following features:
- Fast single-signature verification
- Fast key generation
- High security level (equivalent to 128 bits of symmetric security)
- Collision resilience - hash function collisions don’t break security
- Protection against side-channel attacks
- Small signatures (64 bytes) and small keys (32 bytes)
This implementation allows:
- Creating random Ed25519 private keys
- Deriving the corresponding public key
- Signing messages
- Converting between various formats
Implementations§
Source§impl Ed25519PrivateKey
impl Ed25519PrivateKey
Sourcepub fn new_using(rng: &mut impl RandomNumberGenerator) -> Self
pub fn new_using(rng: &mut impl RandomNumberGenerator) -> Self
Creates a new random Ed25519 private key using the given random number generator.
Sourcepub const fn from_data(data: [u8; 32]) -> Self
pub const fn from_data(data: [u8; 32]) -> Self
Restores an Ed25519 private key from an array of bytes.
Sourcepub fn from_data_ref(data: impl AsRef<[u8]>) -> Result<Self>
pub fn from_data_ref(data: impl AsRef<[u8]>) -> Result<Self>
Restores an Ed25519 private key from a reference to an array of bytes.
Sourcepub fn derive_from_key_material(key_material: impl AsRef<[u8]>) -> Self
pub fn derive_from_key_material(key_material: impl AsRef<[u8]>) -> Self
Derives a new SigningPrivateKey
from the given key material.
pub fn hex(&self) -> String
pub fn from_hex(hex: impl AsRef<str>) -> Result<Self>
Source§impl Ed25519PrivateKey
impl Ed25519PrivateKey
Sourcepub fn public_key(&self) -> Ed25519PublicKey
pub fn public_key(&self) -> Ed25519PublicKey
Derives the public key from this Ed25519 private key.
pub fn sign(&self, message: impl AsRef<[u8]>) -> [u8; 64]
Trait Implementations§
Source§impl AsRef<[u8]> for Ed25519PrivateKey
Implements AsRef<u8> to allow Ed25519PrivateKey to be treated as a byte
slice.
impl AsRef<[u8]> for Ed25519PrivateKey
Implements AsRef<u8> to allow Ed25519PrivateKey to be treated as a byte slice.
Source§impl Clone for Ed25519PrivateKey
impl Clone for Ed25519PrivateKey
Source§fn clone(&self) -> Ed25519PrivateKey
fn clone(&self) -> Ed25519PrivateKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Ed25519PrivateKey
Implements Debug to output the key with a type label.
impl Debug for Ed25519PrivateKey
Implements Debug to output the key with a type label.
Source§impl Default for Ed25519PrivateKey
Implements Default to create a new random Ed25519PrivateKey.
impl Default for Ed25519PrivateKey
Implements Default to create a new random Ed25519PrivateKey.
Source§impl Display for Ed25519PrivateKey
Implements Display to output the key as a hex string.
impl Display for Ed25519PrivateKey
Implements Display to output the key as a hex string.
Source§impl<'a> From<&'a Ed25519PrivateKey> for &'a [u8]
Implements conversion from an Ed25519PrivateKey reference to a byte slice.
impl<'a> From<&'a Ed25519PrivateKey> for &'a [u8]
Implements conversion from an Ed25519PrivateKey reference to a byte slice.
Source§fn from(value: &'a Ed25519PrivateKey) -> Self
fn from(value: &'a Ed25519PrivateKey) -> Self
Source§impl<'a> From<&'a Ed25519PrivateKey> for &'a [u8; 32]
Implements conversion from an Ed25519PrivateKey reference to a byte array
reference.
impl<'a> From<&'a Ed25519PrivateKey> for &'a [u8; 32]
Implements conversion from an Ed25519PrivateKey reference to a byte array reference.
Source§fn from(value: &'a Ed25519PrivateKey) -> Self
fn from(value: &'a Ed25519PrivateKey) -> Self
Source§impl From<[u8; 32]> for Ed25519PrivateKey
Implements conversion from a byte array to an Ed25519PrivateKey.
impl From<[u8; 32]> for Ed25519PrivateKey
Implements conversion from a byte array to an Ed25519PrivateKey.
Source§impl Hash for Ed25519PrivateKey
impl Hash for Ed25519PrivateKey
Source§impl PartialEq for Ed25519PrivateKey
impl PartialEq for Ed25519PrivateKey
impl Eq for Ed25519PrivateKey
impl StructuralPartialEq for Ed25519PrivateKey
Auto Trait Implementations§
impl Freeze for Ed25519PrivateKey
impl RefUnwindSafe for Ed25519PrivateKey
impl Send for Ed25519PrivateKey
impl Sync for Ed25519PrivateKey
impl Unpin for Ed25519PrivateKey
impl UnwindSafe for Ed25519PrivateKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Lower case
letters are used (e.g. f9b4ca
)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)