[−][src]Struct schnorr::keys::SecretKey
An Schnorr secret key.
Methods
impl SecretKey
[src]
pub fn to_bytes(&self) -> [u8; 32]
[src]
Convert this secret key to a byte array.
pub fn as_bytes<'a>(&'a self) -> &'a [u8; 32]
[src]
View this secret key as a byte array.
pub fn from_bytes(bytes: &[u8]) -> Result<SecretKey, SchnorrError>
[src]
Construct a SecretKey
from a slice of bytes.
Example
use schnorr::*; let secret_key_bytes: [u8; SECRET_KEY_LENGTH] = [ 157, 097, 177, 157, 239, 253, 090, 096, 186, 132, 074, 244, 146, 236, 044, 196, 068, 073, 197, 105, 123, 050, 105, 025, 112, 059, 172, 003, 028, 174, 127, 096, ]; let secret_key: SecretKey = SecretKey::from_bytes(&secret_key_bytes)?;
Returns
A Result
whose okay value is an Schnorr SecretKey
or whose error value
is an SchnorrError
wrapping the internal error that occurred.
pub fn generate<T>(csprng: &mut T) -> SecretKey where
T: CryptoRng + RngCore,
[src]
T: CryptoRng + RngCore,
Generate a SecretKey
from a csprng
.
Example
extern crate rand; extern crate schnorr; use rand::Rng; use rand::OsRng; use schnorr::*; let mut csprng: OsRng = OsRng::new().unwrap(); let secret_key: SecretKey = SecretKey::generate(&mut csprng);
Afterwards, you can generate the corresponding public—provided you also
supply a hash function which implements the Digest
and Default
traits, and which returns 512 bits of output—via:
let public_key: PublicKey = PublicKey::from_secret(&secret_key);
Input
A CSPRNG with a fill_bytes()
method, e.g. rand::ChaChaRng
pub fn to_scalar(&self) -> Scalar
[src]
Helper Method to Convert key to scalar
pub fn as_scalar<'a>(&'a self) -> &'a Scalar
[src]
View this scalaras a byte array.
pub fn from_scalar(s: Scalar) -> SecretKey
[src]
Helper Method to Convert Scalar to Key
Trait Implementations
impl Borrow<Scalar> for SecretKey
[src]
impl Clone for SecretKey
[src]
impl ConstantTimeEq for SecretKey
[src]
impl Debug for SecretKey
[src]
impl Default for SecretKey
[src]
impl<'d> Deserialize<'d> for SecretKey
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'d>,
[src]
D: Deserializer<'d>,
impl Drop for SecretKey
[src]
Overwrite secret key material with null bytes when it goes out of scope.
impl Eq for SecretKey
[src]
impl<'_> From<&'_ SecretKey> for XSecretKey
[src]
fn from(msk: &SecretKey) -> XSecretKey
[src]
Construct an SecretKey
from a MiniSecretKey
.
Examples
use schnorr::*; let mini_secret_key: SecretKey = SecretKey::generate(&mut mohan::mohan_rand()); let secret_key: XSecretKey = XSecretKey::from(&mini_secret_key);
impl From<SecretKey> for PublicKey
[src]
impl From<SecretKey> for Keypair
[src]
impl PartialEq<SecretKey> for SecretKey
[src]
impl Readable for SecretKey
[src]
impl Serialize for SecretKey
[src]
impl Writeable for SecretKey
[src]
impl Zeroize for SecretKey
[src]
Auto Trait Implementations
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnwindSafe for SecretKey
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> Cast<U> for T where
U: FromCast<T>,
U: FromCast<T>,
fn cast(self) -> U
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> FromBits<T> for T
fn from_bits(t: T) -> T
impl<T> FromCast<T> for T
fn from_cast(t: T) -> T
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> IntoBits<U> for T where
U: FromBits<T>,
U: FromBits<T>,
fn into_bits(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<Z> Zeroize for Z where
Z: DefaultIsZeroes,
[src]
Z: DefaultIsZeroes,