[][src]Struct threshold_crypto::SecretKey

pub struct SecretKey(_);

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.

Methods

impl SecretKey[src]

pub fn from_mut(fr: &mut Fr) -> Self[src]

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.

pub fn random() -> Self[src]

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.

pub fn public_key(&self) -> PublicKey[src]

Returns the matching public key.

pub fn sign_g2<H: Into<G2Affine>>(&self, hash: H) -> Signature[src]

Signs the given element of G2.

pub fn sign<M: AsRef<[u8]>>(&self, msg: M) -> Signature[src]

Signs the given message.

This is equivalent to sign_g2(hash_g2(msg)).

pub fn decrypt(&self, ct: &Ciphertext) -> Option<Vec<u8>>[src]

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

pub fn reveal(&self) -> String[src]

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

Trait Implementations

impl Clone for SecretKey[src]

Creates a new SecretKey by cloning another SecretKey's prime field element.

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for SecretKey[src]

Creates a SecretKey containing the zero prime field element.

impl PartialEq<SecretKey> for SecretKey[src]

impl Drop for SecretKey[src]

Zeroes out the memory allocated from the SecretKey's field element.

impl Eq for SecretKey[src]

impl Debug for SecretKey[src]

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

impl Distribution<SecretKey> for Standard[src]

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> SecretKey[src]

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.

fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
    R: Rng
[src]

Create an iterator that generates random values of T, using rng as the source of randomness. Read more

impl<'de> Deserialize<'de> for SecretKey[src]

Auto Trait Implementations

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]