[−][src]Struct libp2p_secio::SecioKeyPair
Private and public keys of the local node.
Generating offline keys with OpenSSL
RSA
Generating the keys:
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -outform DER -pubout -out public.der
openssl pkcs8 -in private.pem -topk8 -nocrypt -out private.pk8
rm private.pem # optional
Loading the keys:
let key_pair = SecioKeyPair::rsa_from_pkcs8(include_bytes!("private.pk8"), include_bytes!("public.der"));
Methods
impl SecioKeyPair
[src]
pub fn rsa_from_pkcs8<P>(
private: &[u8],
public: P
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>> where
P: Into<Vec<u8>>,
[src]
private: &[u8],
public: P
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>> where
P: Into<Vec<u8>>,
Builds a SecioKeyPair
from a PKCS8 private key and public key.
pub fn ed25519_generated() -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>>
[src]
Generates a new Ed25519 key pair and uses it.
pub fn ed25519_raw_key(
key: impl AsRef<[u8]>
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>>
[src]
key: impl AsRef<[u8]>
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>>
Builds a SecioKeyPair
from a raw ed25519 32 bytes private key.
Returns an error if the slice doesn't have the correct length.
pub fn secp256k1_generated(
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>>
[src]
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>>
Generates a new random sec256k1 key pair.
pub fn secp256k1_raw_key<K>(
key: K
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>> where
K: AsRef<[u8]>,
[src]
key: K
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>> where
K: AsRef<[u8]>,
Builds a SecioKeyPair
from a raw secp256k1 32 bytes private key.
pub fn secp256k1_from_der<K>(
key: K
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>> where
K: AsRef<[u8]>,
[src]
key: K
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>> where
K: AsRef<[u8]>,
Builds a SecioKeyPair
from a secp256k1 private key in DER format.
pub fn to_public_key(&self) -> PublicKey
[src]
Returns the public key corresponding to this key pair.
pub fn to_peer_id(&self) -> PeerId
[src]
Builds a PeerId
corresponding to the public key of this key pair.
Trait Implementations
impl Clone for SecioKeyPair
[src]
fn clone(&self) -> SecioKeyPair
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl Send for SecioKeyPair
impl Sync for SecioKeyPair
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Same for T
type Output = T
Should always be Self