pub struct PrivateKey {
scalar: Scalar,
public_key: PublicKey,
}Expand description
Private key - load using PrivateKey::from_hex or generate with PrivateKey::random.
Caches the associated PublicKey, which means that loading a PrivateKey involves a base
point multiplication.
Fields§
§scalar: Scalarunderlying scalar
public_key: PublicKeyassociated public key, stored for efficiency
Implementations§
Source§impl PrivateKey
impl PrivateKey
pub fn random() -> Self
pub fn public_key(&self) -> &PublicKey
Sourcepub fn scale(&self, pk: &PublicKey) -> PublicKey
pub fn scale(&self, pk: &PublicKey) -> PublicKey
Computes the PublicKey associated with the product of two PrivateKeys given only one private key.
Creates a Diffie-Hellman-type shared secret between this PrivateKey and the PublicKey.
Trait Implementations§
Source§impl Clone for PrivateKey
impl Clone for PrivateKey
Source§fn clone(&self) -> PrivateKey
fn clone(&self) -> PrivateKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PrivateKey
impl Debug for PrivateKey
Source§impl<'de> Deserialize<'de> for PrivateKey
impl<'de> Deserialize<'de> for PrivateKey
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl DigestibleSecret for PrivateKey
impl DigestibleSecret for PrivateKey
fn as_bytes(&self) -> &[u8] ⓘ
Source§fn update_digest<D: Digest>(&self, d: D, domain: impl AsRef<str>) -> D
fn update_digest<D: Digest>(&self, d: D, domain: impl AsRef<str>) -> D
Inserts this secret in the given digest
Source§fn derive_scalar<D>(&self, d: D, domain: impl AsRef<str>) -> Scalar
fn derive_scalar<D>(&self, d: D, domain: impl AsRef<str>) -> Scalar
Creates a
Scalar from this secretSource§fn derive_bytes<D>(&self, d: D, domain: impl AsRef<str>) -> Vec<u8> ⓘwhere
D: Digest,
fn derive_bytes<D>(&self, d: D, domain: impl AsRef<str>) -> Vec<u8> ⓘwhere
D: Digest,
Creates
Vec<u8> from this secret.Source§fn derive_hs256<D>(&self, d: D, domain: impl AsRef<str>) -> HS256where
D: Digest,
fn derive_hs256<D>(&self, d: D, domain: impl AsRef<str>) -> HS256where
D: Digest,
Creates a
HS256 from this secret.Source§fn derive_sealing_key<D>(&self, d: D, domain: impl AsRef<str>) -> SealingKey
fn derive_sealing_key<D>(&self, d: D, domain: impl AsRef<str>) -> SealingKey
Creates a (256-bit)
crate::misc::crypto::SealingKey from this secret.Source§impl Encoding<32> for PrivateKey
impl Encoding<32> for PrivateKey
Source§fn from_bytes(bytes: [u8; 32]) -> Option<PrivateKey>
fn from_bytes(bytes: [u8; 32]) -> Option<PrivateKey>
Decodes
Some(object) from bytes if bytes encodes some object of type Self;
otherwise returns None.Source§fn from_slice(slice: &[u8]) -> Option<Self>
fn from_slice(slice: &[u8]) -> Option<Self>
Like Self::from_bytes, but reads
[u8; N] from slice. Returns None if slice.len()!=N
or when the slice is not a valid encoding.Source§fn copy_to_slice(&self, slice: &mut [u8]) -> Option<()>
fn copy_to_slice(&self, slice: &mut [u8]) -> Option<()>
Copies the encoding of
self into slice. Returns None when slice.len()!=N.Source§fn from_hex(hex: &str) -> Option<Self>
fn from_hex(hex: &str) -> Option<Self>
Like Self::from_bytes, but reads the
[u8; N] from the 2*N-digit hex string hex.
The case of the hex digits is ignored.Source§impl From<Scalar> for PrivateKey
impl From<Scalar> for PrivateKey
Source§impl PartialEq for PrivateKey
impl PartialEq for PrivateKey
Source§impl<'de> Serialize for PrivateKey
impl<'de> Serialize for PrivateKey
impl Eq for PrivateKey
impl StructuralPartialEq for PrivateKey
Auto Trait Implementations§
impl Freeze for PrivateKey
impl RefUnwindSafe for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
impl Unpin for PrivateKey
impl UnsafeUnpin for PrivateKey
impl UnwindSafe for PrivateKey
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more