Struct threshold_crypto::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
SecretKey
s between stack frames.
Implementations§
source§impl SecretKey
impl SecretKey
sourcepub fn from_mut(fr: &mut Fr) -> Self
pub fn from_mut(fr: &mut Fr) -> Self
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.
sourcepub fn random() -> Self
pub fn random() -> Self
Creates a new random instance of SecretKey
. If you want to use/define your own random
number generator, you should use the constructor: SecretKey::rand()
. If you do not need
to specify your own RNG, you should use the SecretKey::random()
constructor, which uses
rand::thead_rng()
internally as
its RNG.
sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Returns the matching public key.
Trait Implementations§
source§impl Clone for SecretKey
impl Clone for SecretKey
Creates a new SecretKey
by cloning another SecretKey
’s prime field element.
source§impl Rand for SecretKey
impl Rand for SecretKey
Creates a random SecretKey
from a given RNG. If you do not need to specify your own RNG, you
should use SecretKey::random()
as your constructor instead.