Struct parity_crypto::publickey::Secret
source · [−]pub struct Secret { /* private fields */ }
Expand description
Represents secret key
Implementations
sourceimpl Secret
impl Secret
sourcepub fn copy_from_slice(key: &[u8]) -> Option<Self>
pub fn copy_from_slice(key: &[u8]) -> Option<Self>
Creates a Secret
from the given slice, returning None
if the slice length != 32.
Caller is responsible to zeroize input slice.
sourcepub fn copy_from_str(s: &str) -> Result<Self, Error>
pub fn copy_from_str(s: &str) -> Result<Self, Error>
Creates a Secret
from the given str
representation,
returning an error for hex big endian representation of
the secret.
Caller is responsible to zeroize input slice.
sourcepub fn zero() -> Self
pub fn zero() -> Self
Creates zero key, which is invalid for crypto operations, but valid for math operation.
sourcepub fn import_key(key: &[u8]) -> Result<Self, Error>
pub fn import_key(key: &[u8]) -> Result<Self, Error>
Imports and validates the key. Caller is responsible to zeroize input slice.
sourcepub fn check_validity(&self) -> Result<(), Error>
pub fn check_validity(&self) -> Result<(), Error>
Checks validity of this key.
sourcepub fn add(&mut self, other: &Secret) -> Result<(), Error>
pub fn add(&mut self, other: &Secret) -> Result<(), Error>
Inplace add one secret key to another (scalar + scalar)
sourcepub fn sub(&mut self, other: &Secret) -> Result<(), Error>
pub fn sub(&mut self, other: &Secret) -> Result<(), Error>
Inplace subtract one secret key from another (scalar - scalar)
sourcepub fn mul(&mut self, other: &Secret) -> Result<(), Error>
pub fn mul(&mut self, other: &Secret) -> Result<(), Error>
Inplace multiply one secret key to another (scalar * scalar)
sourcepub fn pow(&mut self, pow: usize) -> Result<(), Error>
pub fn pow(&mut self, pow: usize) -> Result<(), Error>
Compute power of secret key inplace (secret ^ pow).
sourcepub fn to_secp256k1_secret(&self) -> Result<SecretKey, Error>
pub fn to_secp256k1_secret(&self) -> Result<SecretKey, Error>
Create a secp256k1::key::SecretKey
based on this secret.
Warning the resulting secret key need to be zeroized manually.
Methods from Deref<Target = H256>
sourcepub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Extracts a byte slice containing the entire fixed hash.
sourcepub fn as_fixed_bytes(&self) -> &[u8; 32]
pub fn as_fixed_bytes(&self) -> &[u8; 32]
Extracts a reference to the byte array containing the entire fixed hash.
sourcepub fn to_low_u64_be(&self) -> u64
pub fn to_low_u64_be(&self) -> u64
Returns the lowest 8 bytes interpreted as big-endian.
Note
For hash type with less than 8 bytes the missing bytes are interpreted as being zero.
sourcepub fn to_low_u64_le(&self) -> u64
pub fn to_low_u64_le(&self) -> u64
Returns the lowest 8 bytes interpreted as little-endian.
Note
For hash type with less than 8 bytes the missing bytes are interpreted as being zero.
sourcepub fn to_low_u64_ne(&self) -> u64
pub fn to_low_u64_ne(&self) -> u64
Returns the lowest 8 bytes interpreted as native-endian.
Note
For hash type with less than 8 bytes the missing bytes are interpreted as being zero.
Trait Implementations
impl Eq for Secret
impl StructuralEq for Secret
impl StructuralPartialEq for Secret
Auto Trait Implementations
impl RefUnwindSafe for Secret
impl Send for Secret
impl Sync for Secret
impl Unpin for Secret
impl UnwindSafe for Secret
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more