pub struct SigningKeyPair<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> {
pub public_key: PublicKey,
pub secret_key: SecretKey,
}Expand description
An Ed25519 keypair for public-key signatures
Create keypairs with SigningKeyPair::generate,
SigningKeyPair::from_seed, or SigningKeyPair::from_secret_key.
There is no new or Default constructor, so an all-zero secret key is
never produced implicitly.
Fields§
§public_key: PublicKeyPublic key
secret_key: SecretKeySecret key
Implementations§
Source§impl SigningKeyPair<Locked<HeapByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>>, Locked<HeapByteArray<CRYPTO_SIGN_SECRETKEYBYTES>>>
impl SigningKeyPair<Locked<HeapByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>>, Locked<HeapByteArray<CRYPTO_SIGN_SECRETKEYBYTES>>>
Sourcepub fn generate_locked_keypair() -> Result<Self, Error>
Available on crate feature protected only.
pub fn generate_locked_keypair() -> Result<Self, Error>
protected only.Source§impl SigningKeyPair<LockedRO<HeapByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>>, LockedRO<HeapByteArray<CRYPTO_SIGN_SECRETKEYBYTES>>>
impl SigningKeyPair<LockedRO<HeapByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>>, LockedRO<HeapByteArray<CRYPTO_SIGN_SECRETKEYBYTES>>>
Sourcepub fn generate_readonly_locked_keypair() -> Result<Self, Error>
Available on crate feature protected only.
pub fn generate_readonly_locked_keypair() -> Result<Self, Error>
protected only.Returns a new randomly generated locked, read-only signing keypair.
§Errors
Returns Error::Io if either allocation cannot be locked or its
page permissions cannot be changed to read-only.
§Panics
Panics if either page-aligned allocation cannot be created, its size cannot be represented with guard pages, or the operating system’s random number generator fails.
Source§impl<PublicKey: NewByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: NewByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> SigningKeyPair<PublicKey, SecretKey>
impl<PublicKey: NewByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: NewByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> SigningKeyPair<PublicKey, SecretKey>
Sourcepub fn from_secret_key(secret_key: SecretKey) -> Self
pub fn from_secret_key(secret_key: SecretKey) -> Self
Derives a signing keypair from secret_key, and consumes it, returning
a new keypair. The consumed key is wiped, even if its type does not
wipe itself on drop.
Source§impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> SigningKeyPair<PublicKey, SecretKey>
impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> SigningKeyPair<PublicKey, SecretKey>
Sourcepub fn to_seed<SeedOut: NewByteArray<CRYPTO_SIGN_SEEDBYTES>>(&self) -> SeedOut
pub fn to_seed<SeedOut: NewByteArray<CRYPTO_SIGN_SEEDBYTES>>(&self) -> SeedOut
Extracts the Ed25519 seed from this keypair’s secret key.
Sourcepub fn to_public_key<PublicKeyOut: NewByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>>(
&self,
) -> PublicKeyOut
pub fn to_public_key<PublicKeyOut: NewByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>>( &self, ) -> PublicKeyOut
Extracts the Ed25519 public key embedded in this keypair’s secret key.
Source§impl<'a, PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + TryFrom<&'a [u8]> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + TryFrom<&'a [u8]> + Zeroize> SigningKeyPair<PublicKey, SecretKey>
impl<'a, PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + TryFrom<&'a [u8]> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + TryFrom<&'a [u8]> + Zeroize> SigningKeyPair<PublicKey, SecretKey>
Sourcepub fn from_slices(
public_key: &'a [u8],
secret_key: &'a [u8],
) -> Result<Self, Error>
pub fn from_slices( public_key: &'a [u8], secret_key: &'a [u8], ) -> Result<Self, Error>
Constructs a new signing keypair from key slices, consuming them. Does not check validity or authenticity of keypair.
§Errors
Returns an error if either slice has the wrong length for its key type, or if the target key type rejects the key bytes.
Source§impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> SigningKeyPair<PublicKey, SecretKey>
impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> SigningKeyPair<PublicKey, SecretKey>
Sourcepub fn sign<Signature: NewByteArray<CRYPTO_SIGN_BYTES> + Zeroize, Message: Bytes + Zeroize>(
&self,
message: Message,
) -> SignedMessage<Signature, Message>
pub fn sign<Signature: NewByteArray<CRYPTO_SIGN_BYTES> + Zeroize, Message: Bytes + Zeroize>( &self, message: Message, ) -> SignedMessage<Signature, Message>
Signs message using this keypair, consuming the message, and returning
a new SignedMessage. The type of message should match that of the
target signed message.
Sourcepub fn sign_to_vecbox<Message: Bytes + ?Sized>(
&self,
message: &Message,
) -> VecSignedMessage
Available on crate feature alloc only.
pub fn sign_to_vecbox<Message: Bytes + ?Sized>( &self, message: &Message, ) -> VecSignedMessage
alloc only.Signs a copy of message, returning a VecSignedMessage.
Convenience wrapper for SigningKeyPair::sign.
Trait Implementations§
Source§impl<PublicKey: Clone + ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: Clone + ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> Clone for SigningKeyPair<PublicKey, SecretKey>
impl<PublicKey: Clone + ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: Clone + ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> Clone for SigningKeyPair<PublicKey, SecretKey>
Source§impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> Debug for SigningKeyPair<PublicKey, SecretKey>
impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> Debug for SigningKeyPair<PublicKey, SecretKey>
Source§impl<'de, PublicKey, SecretKey> Deserialize<'de> for SigningKeyPair<PublicKey, SecretKey>where
PublicKey: Deserialize<'de> + ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize,
SecretKey: Deserialize<'de> + ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize,
Available on crate feature serde only.
impl<'de, PublicKey, SecretKey> Deserialize<'de> for SigningKeyPair<PublicKey, SecretKey>where
PublicKey: Deserialize<'de> + ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize,
SecretKey: Deserialize<'de> + ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize,
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> Drop for SigningKeyPair<PublicKey, SecretKey>
impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> Drop for SigningKeyPair<PublicKey, SecretKey>
Source§impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> PartialEq for SigningKeyPair<PublicKey, SecretKey>
impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> PartialEq for SigningKeyPair<PublicKey, SecretKey>
Source§impl<PublicKey, SecretKey> Serialize for SigningKeyPair<PublicKey, SecretKey>
Available on crate feature serde only.
impl<PublicKey, SecretKey> Serialize for SigningKeyPair<PublicKey, SecretKey>
serde only.