Struct cfxstore::cfxkey::Secret

pub struct Secret { /* private fields */ }

Implementations§

§

impl Secret

pub fn from_slice(key: &[u8]) -> Option<Secret>

Creates a Secret from the given slice, returning None if the slice length != 32.

pub fn zero() -> Secret

Creates zero key, which is invalid for crypto operations, but valid for math operation.

pub fn from_unsafe_slice(key: &[u8]) -> Result<Secret, Error>

Imports and validates the key.

pub fn check_validity(&self) -> Result<(), Error>

Checks validity of this key.

pub fn add(&mut self, other: &Secret) -> Result<(), Error>

Inplace add one secret key to another (scalar + scalar)

pub fn sub(&mut self, other: &Secret) -> Result<(), Error>

Inplace subtract one secret key from another (scalar - scalar)

pub fn dec(&mut self) -> Result<(), Error>

Inplace decrease secret key (scalar - 1)

pub fn mul(&mut self, other: &Secret) -> Result<(), Error>

Inplace multiply one secret key to another (scalar * scalar)

pub fn neg(&mut self) -> Result<(), Error>

Inplace negate secret key (-scalar)

pub fn inv(&mut self) -> Result<(), Error>

Inplace inverse secret key (1 / scalar)

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.

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_bytes(&self) -> &[u8]

Extracts a byte slice containing the entire fixed hash.

pub fn as_fixed_bytes(&self) -> &[u8; 32]

Extracts a reference to the byte array containing the entire fixed hash.

pub fn as_ptr(&self) -> *const u8

Returns a constant raw pointer to the value.

pub fn covers(&self, b: &H256) -> bool

Returns true if all bits set in b are also set in self.

pub fn is_zero(&self) -> bool

Returns true if no bits are set.

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

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

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 Clone for Secret

§

fn clone(&self) -> Secret

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Secret

§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Deref for Secret

§

type Target = H256

The resulting type after dereferencing.
§

fn deref(&self) -> &<Secret as Deref>::Target

Dereferences the value.
§

impl Display for Secret

§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Drop for Secret

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl From<&'static str> for Secret

§

fn from(s: &'static str) -> Secret

Converts to this type from the input type.
§

impl From<[u8; 32]> for Secret

§

fn from(k: [u8; 32]) -> Secret

Converts to this type from the input type.
§

impl From<H256> for Secret

§

fn from(s: H256) -> Secret

Converts to this type from the input type.
§

impl From<SecretKey> for Secret

§

fn from(key: SecretKey) -> Secret

Converts to this type from the input type.
§

impl FromStr for Secret

§

type Err = Error

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<Secret, <Secret as FromStr>::Err>

Parses a string s to return a value of this type. Read more
§

impl LowerHex for Secret

§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.
§

impl MallocSizeOf for Secret

§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.
§

impl PartialEq for Secret

§

fn eq(&self, other: &Secret) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Eq for Secret

§

impl StructuralPartialEq for Secret

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V