[]Enum sc_network::config::identity::Keypair

pub enum Keypair {
    Ed25519(Keypair),
    Rsa(Keypair),
    Secp256k1(Keypair),
}

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)

An RSA keypair.

Secp256k1(Keypair)

A Secp256k1 keypair.

Implementations

impl Keypair

pub fn generate_ed25519() -> Keypair

Generate a new Ed25519 keypair.

pub fn generate_secp256k1() -> Keypair

Generate a new Secp256k1 keypair.

pub fn rsa_from_pkcs8(pkcs8_der: &mut [u8]) -> Result<Keypair, DecodingError>

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

pub fn secp256k1_from_der(der: &mut [u8]) -> Result<Keypair, DecodingError>

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

pub fn sign(&self, msg: &[u8]) -> Result<Vec<u8, Global>, SigningError>

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

pub fn public(&self) -> PublicKey

Get the public key of this keypair.

Trait Implementations

impl Clone for Keypair

Auto Trait Implementations

impl RefUnwindSafe for Keypair[src]

impl Send for Keypair[src]

impl Sync for Keypair[src]

impl Unpin for Keypair[src]

impl UnwindSafe for Keypair[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CheckedConversion for T[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    T: From<Outer>,
    Outer: AsRef<T> + AsMut<T> + From<T>, 
[src]

pub fn from_ref(outer: &Outer) -> &T[src]

Get a reference to the inner from the outer.

pub fn from_mut(outer: &mut Outer) -> &mut T[src]

Get a mutable reference to the inner from the outer.

impl<T> MaybeRefUnwindSafe for T where
    T: RefUnwindSafe
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatedConversion for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 
[src]

impl<T, S> UniqueSaturatedInto<T> for S where
    T: Bounded,
    S: TryInto<T>, 
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]