Struct blsttc::SecretKey

source ·
pub struct SecretKey(_);
Expand description

A secret key; wraps a single prime field element. The field element is heap allocated to avoid any stack copying that result when passing SecretKeys between stack frames.

Serde integration

SecretKey implements Deserialize but not Serialize to avoid accidental serialization in insecure contexts. To enable both use the ::serde_impl::SerdeSecret wrapper which implements both Deserialize and Serialize.

Implementations

Creates a new SecretKey from a mutable reference to a field element. This constructor takes a reference to avoid any unnecessary stack copying/moving of secrets (i.e. the field element). The field element is copied bytewise onto the heap, the resulting Box is stored in the returned SecretKey.

WARNING this constructor will overwrite the referenced Fr element with zeros after it has been copied onto the heap.

Creates a new random instance of SecretKey.

If you want to use/define your own random number generator, you should use the constructor: SecretKey::sample(). If you do not need to specify your own RNG, you should use the SecretKey::random() constructor, which uses rand::thread_rng() internally as its RNG.

Returns the matching public key.

Signs the given element of G2.

Signs the given message.

Converts the secret key to big endian bytes

Deserialize from big endian bytes

Deserialize a hex-encoded representation of a SecretKey to a SecretKey instance.

Serialize this SecretKey instance to a hex-encoded String.

Returns the decrypted text, or None, if the ciphertext isn’t valid.

Generates a non-redacted debug string. This method differs from the Debug implementation in that it does leak the secret prime field element.

Derives a child secret key for a given index.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

A debug statement where the secret prime field element is redacted.

Formats the value using the given formatter. Read more

Creates a SecretKey containing the zero prime field element.

Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more

Creates a new random instance of SecretKey. If you do not need to specify your own RNG, you should use the SecretKey::random() constructor, which uses rand::thread_rng() internally as its RNG.

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
Executes the destructor for this type. Read more

Utility to convert blsttc to blst types

Converts to this type from the input type.

Utility to compare between blsttc and blst types

This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more
Causes self to use its Binary implementation when Debug-formatted.
Causes self to use its Display implementation when Debug-formatted. Read more
Causes self to use its LowerExp implementation when Debug-formatted. Read more
Causes self to use its LowerHex implementation when Debug-formatted. Read more
Causes self to use its Octal implementation when Debug-formatted.
Causes self to use its Pointer implementation when Debug-formatted. Read more
Causes self to use its UpperExp implementation when Debug-formatted. Read more
Causes self to use its UpperHex implementation when Debug-formatted. Read more
Formats each item in a sequence. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function. Read more
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.