pub struct Secret { /* private fields */ }Implementations§
Source§impl Secret
impl Secret
Sourcepub fn from_slice(key: &[u8]) -> Option<Self>
pub fn from_slice(key: &[u8]) -> Option<Self>
Creates a Secret from the given slice, returning None if the slice
length != 32.
pub fn import_key(key: &[u8]) -> Result<Self, Error>
Sourcepub fn zero() -> Self
pub fn zero() -> Self
Creates zero key, which is invalid for crypto operations, but valid for math operation.
Sourcepub fn from_unsafe_slice(key: &[u8]) -> Result<Self, Error>
pub fn from_unsafe_slice(key: &[u8]) -> Result<Self, Error>
Imports and validates the key.
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). This function is not intended to be used with large powers.
Sourcepub fn to_secp256k1_secret(&self) -> Result<SecretKey, Error>
pub fn to_secp256k1_secret(&self) -> Result<SecretKey, Error>
Create secp256k1::key::SecretKey based on this secret
pub fn to_hex(&self) -> String
Methods from Deref<Target = H256>§
pub 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.
pub 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.
pub 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.
pub 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§
Source§impl SecretKey for Secret
impl SecretKey for Secret
Source§fn from_unsafe_slice(bytes: &[u8]) -> Result<Self, CryptoError>
fn from_unsafe_slice(bytes: &[u8]) -> Result<Self, CryptoError>
impl Eq for Secret
impl StructuralPartialEq for Secret
Auto Trait Implementations§
impl Freeze for Secret
impl RefUnwindSafe for Secret
impl Send for Secret
impl Sync for Secret
impl Unpin for Secret
impl UnwindSafe for Secret
Blanket Implementations§
§impl<T, U> AsByteSlice<T> for U
impl<T, U> AsByteSlice<T> for U
fn as_byte_slice(&self) -> &[u8] ⓘ
§impl<U> AsSliceOf for U
impl<U> AsSliceOf for U
fn as_slice_of<T>(&self) -> Result<&[T], Error>where
T: FromByteSlice,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Upper case
letters are used (e.g. F9B4CA)