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.
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.