pub enum Keypair {
    Ed25519(Keypair),
    Rsa(Keypair),
    Secp256k1(Keypair),
    Ecdsa(Keypair),
}
Expand description

Identity keypair of a node.

Example: Generating RSA keys with OpenSSL

openssl genrsa -out private.pem 2048
openssl pkcs8 -in private.pem -inform PEM -topk8 -out private.pk8 -outform DER -nocrypt
rm private.pem      # optional

Loading the keys:

let mut bytes = std::fs::read("private.pk8").unwrap();
let keypair = Keypair::rsa_from_pkcs8(&mut bytes);

Variants§

§

Ed25519(Keypair)

An Ed25519 keypair.

§

Rsa(Keypair)

Available on crate feature rsa and non-WebAssembly only.

An RSA keypair.

§

Secp256k1(Keypair)

Available on crate feature secp256k1 only.

A Secp256k1 keypair.

§

Ecdsa(Keypair)

Available on crate feature ecdsa only.

An ECDSA keypair.

Implementations§

Generate a new Ed25519 keypair.

Available on crate feature secp256k1 only.

Generate a new Secp256k1 keypair.

Available on crate feature ecdsa only.

Generate a new ECDSA keypair.

Available on crate feature rsa and non-WebAssembly only.

Decode an keypair from a DER-encoded secret key in PKCS#8 PrivateKeyInfo format (i.e. unencrypted) as defined in RFC5208.

Available on crate feature secp256k1 only.

Decode a keypair from a DER-encoded Secp256k1 secret key in an ECPrivateKey structure as defined in RFC5915.

Sign a message using the private key of this keypair, producing a signature that can be verified using the corresponding public key.

Get the public key of this keypair.

Encode a private key as protobuf structure.

Decode a private key from a protobuf structure and parse it as a Keypair.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.