Struct ring::signature::Ed25519KeyPair
[−]
[src]
pub struct Ed25519KeyPair { /* fields omitted */ }
An Ed25519 key pair, for signing.
Methods
impl<'a> Ed25519KeyPair
[src]
fn generate(rng: &SecureRandom) -> Result<Ed25519KeyPair, Unspecified>
Generates a new random key pair. There is no way to extract the private
key bytes to save them. If you need to save the private key bytes for
future use then use generate_serializable()
instead.
fn generate_serializable(rng: &SecureRandom)
-> Result<(Ed25519KeyPair, Ed25519KeyPairBytes), Unspecified>
-> Result<(Ed25519KeyPair, Ed25519KeyPairBytes), Unspecified>
Generates a new key pair and returns the key pair as both an
Ed25519KeyPair
and a Ed25519KeyPairBytes
. There is no way to
extract the private key bytes from an Ed25519KeyPair
, so extracting
the values from the Ed25519KeyPairBytes
is the only way to get them.
fn from_bytes(private_key: &[u8],
public_key: &[u8])
-> Result<Ed25519KeyPair, Unspecified>
public_key: &[u8])
-> Result<Ed25519KeyPair, Unspecified>
Copies key data from the given slices to create a new key pair. The first slice must hold the private key and the second slice must hold the public key. Both slices must contain 32 little-endian-encoded bytes.
This is intended for use by code that deserializes key pairs.
The private and public keys will be verified to be consistent. This helps protect, for example, against the accidental swapping of the public and private components of the key pair. This also detects corruption that might have occurred during storage of the key pair.
fn public_key_bytes(&'a self) -> &'a [u8]
Returns a reference to the little-endian-encoded public key bytes.
fn sign(&self, msg: &[u8]) -> Signature
Returns the signature of the message msg
.