Skip to main content

SigningKeyPair

Struct SigningKeyPair 

Source
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

Fields§

§public_key: PublicKey

Public key

§secret_key: SecretKey

Secret key

Implementations§

Source§

impl SigningKeyPair<Locked<HeapByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>>, Locked<HeapByteArray<CRYPTO_SIGN_SECRETKEYBYTES>>>

Source

pub fn new_locked_keypair() -> Result<Self, Error>

Available on crate feature protected only.

Returns a new locked signing keypair.

§Errors

Returns Error::Io if either allocation cannot be locked.

§Panics

Panics if either page-aligned allocation cannot be created or its size cannot be represented with guard pages.

Source

pub fn generate_locked_keypair() -> Result<Self, Error>

Available on crate feature protected only.

Returns a new randomly generated locked signing keypair.

§Errors

Returns Error::Io if either allocation cannot be locked.

§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

pub fn gen_locked_keypair() -> Result<Self, Error>

👎Deprecated:

use generate_locked_keypair() instead

Available on crate feature protected only.

Returns a new randomly generated locked signing keypair.

Prefer generate_locked_keypair. This method is retained for compatibility.

§Errors

Returns the same errors as generate_locked_keypair.

§Panics

Panics under the same conditions as generate_locked_keypair.

Source§

impl SigningKeyPair<LockedRO<HeapByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>>, LockedRO<HeapByteArray<CRYPTO_SIGN_SECRETKEYBYTES>>>

Source

pub fn generate_readonly_locked_keypair() -> Result<Self, Error>

Available on crate feature 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

pub fn gen_readonly_locked_keypair() -> Result<Self, Error>

👎Deprecated:

use generate_readonly_locked_keypair() instead

Available on crate feature protected only.

Returns a new randomly generated locked, read-only signing keypair.

Prefer generate_readonly_locked_keypair. This method is retained for compatibility.

§Errors

Returns the same errors as generate_readonly_locked_keypair.

§Panics

Panics under the same conditions as generate_readonly_locked_keypair.

Source§

impl<PublicKey: NewByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: NewByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> SigningKeyPair<PublicKey, SecretKey>

Source

pub fn new() -> Self

Creates a new, empty signing keypair.

Source

pub fn generate() -> Self

Generates a random signing keypair.

Source

pub fn gen() -> Self

👎Deprecated:

use generate() instead

Generates a random signing keypair.

Prefer generate. gen is retained for compatibility with older Rust editions.

Source

pub fn from_secret_key(secret_key: SecretKey) -> Self

Derives a signing keypair from secret_key, and consumes it, returning a new keypair.

Source

pub fn from_seed<Seed: ByteArray<CRYPTO_SIGN_SEEDBYTES>>(seed: &Seed) -> Self

Derives a signing keypair from seed, returning a new keypair.

Source§

impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> SigningKeyPair<PublicKey, SecretKey>

Source

pub fn to_seed<SeedOut: NewByteArray<CRYPTO_SIGN_SEEDBYTES>>(&self) -> SeedOut

Extracts the Ed25519 seed from this keypair’s secret key.

Source

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 SigningKeyPair<StackByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>, StackByteArray<CRYPTO_SIGN_SECRETKEYBYTES>>

Source

pub fn generate_with_defaults() -> Self

Randomly generates a new signing keypair, using default types (stack-allocated byte arrays). Provided for convenience.

Source

pub fn gen_with_defaults() -> Self

👎Deprecated:

use generate_with_defaults() instead

Randomly generates a new signing keypair, using default types (stack-allocated byte arrays). Provided for convenience.

Prefer generate_with_defaults. This method is retained for compatibility.

Source§

impl<'a, PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + TryFrom<&'a [u8]> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + TryFrom<&'a [u8]> + Zeroize> SigningKeyPair<PublicKey, SecretKey>

Source

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>

Source

pub fn sign<Signature: NewByteArray<CRYPTO_SIGN_BYTES> + Zeroize, Message: Bytes + Zeroize>( &self, message: Message, ) -> Result<SignedMessage<Signature, Message>, Error>

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.

§Errors

The fixed-size signature and secret-key types satisfy the current implementation’s requirements, so this function does not return an error for valid type implementations. The Result is retained for compatibility with the underlying signing API.

Source

pub fn sign_with_defaults<Message: Bytes>( &self, message: Message, ) -> Result<SignedMessage<StackByteArray<CRYPTO_SIGN_BYTES>, Vec<u8>>, Error>

Signs message, putting the result into a Vec. Convenience wrapper for SigningKeyPair::sign.

§Errors

The default fixed-size types satisfy the current implementation’s requirements, so this function does not return an error in normal use. The Result is retained for API compatibility.

Trait Implementations§

Source§

impl<PublicKey: Clone + ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: Clone + ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> Clone for SigningKeyPair<PublicKey, SecretKey>

Source§

fn clone(&self) -> SigningKeyPair<PublicKey, SecretKey>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> Debug for SigningKeyPair<PublicKey, SecretKey>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SigningKeyPair<PublicKey, SecretKey>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
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,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> Drop for SigningKeyPair<PublicKey, SecretKey>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<PublicKey: ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize> PartialEq for SigningKeyPair<PublicKey, SecretKey>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<PublicKey, SecretKey> Serialize for SigningKeyPair<PublicKey, SecretKey>
where PublicKey: Serialize + ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES> + Zeroize, SecretKey: Serialize + ByteArray<CRYPTO_SIGN_SECRETKEYBYTES> + Zeroize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<PublicKey, SecretKey> Zeroize for SigningKeyPair<PublicKey, SecretKey>
where PublicKey: Zeroize + ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>, SecretKey: Zeroize + ByteArray<CRYPTO_SIGN_SECRETKEYBYTES>,

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

§

impl<PublicKey, SecretKey> Freeze for SigningKeyPair<PublicKey, SecretKey>
where PublicKey: Freeze, SecretKey: Freeze,

§

impl<PublicKey, SecretKey> RefUnwindSafe for SigningKeyPair<PublicKey, SecretKey>
where PublicKey: RefUnwindSafe, SecretKey: RefUnwindSafe,

§

impl<PublicKey, SecretKey> Send for SigningKeyPair<PublicKey, SecretKey>
where PublicKey: Send, SecretKey: Send,

§

impl<PublicKey, SecretKey> Sync for SigningKeyPair<PublicKey, SecretKey>
where PublicKey: Sync, SecretKey: Sync,

§

impl<PublicKey, SecretKey> Unpin for SigningKeyPair<PublicKey, SecretKey>
where PublicKey: Unpin, SecretKey: Unpin,

§

impl<PublicKey, SecretKey> UnsafeUnpin for SigningKeyPair<PublicKey, SecretKey>
where PublicKey: UnsafeUnpin, SecretKey: UnsafeUnpin,

§

impl<PublicKey, SecretKey> UnwindSafe for SigningKeyPair<PublicKey, SecretKey>
where PublicKey: UnwindSafe, SecretKey: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.