Struct SecretKey
pub struct SecretKey { /* private fields */ }
Expand description
A secret key.
Implementations§
§impl SecretKey
impl SecretKey
pub fn generate<R>(csprng: R) -> SecretKeywhere
R: CryptoRngCore,
pub fn generate<R>(csprng: R) -> SecretKeywhere
R: CryptoRngCore,
Generate a new SecretKey
with a randomness generator.
// use the OsRng option for OS depedndent most secure RNG.
let mut rng = rand::rngs::OsRng;
let _key = iroh_base::SecretKey::generate(&mut rng);
pub fn to_bytes(&self) -> [u8; 32]
pub fn to_bytes(&self) -> [u8; 32]
Convert this to the bytes representing the secret part. The public part can always be recovered.
pub fn from_bytes(bytes: &[u8; 32]) -> SecretKey
pub fn from_bytes(bytes: &[u8; 32]) -> SecretKey
Create a secret key from its byte representation.
pub fn secret(&self) -> &SigningKey
pub fn secret(&self) -> &SigningKey
Returns the [SigningKey
] for this SecretKey
.
Trait Implementations§
§impl<'de> Deserialize<'de> for SecretKey
impl<'de> Deserialize<'de> for SecretKey
§fn deserialize<D>(
deserializer: D,
) -> Result<SecretKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<SecretKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Serialize for SecretKey
impl Serialize for SecretKey
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnwindSafe for SecretKey
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more