[][src]Struct schnorr::keys::XSecretKey

pub struct XSecretKey { /* fields omitted */ }

An Extended seceret key for use with Ristretto Schnorr signatures.

Methods

impl XSecretKey[src]

pub fn to_bytes(&self) -> [u8; 64][src]

Convert this SecretKey into an array of 64 bytes, corresponding to an Ristrettp expanded secreyt key.

Returns

An array of 64 bytes. The first 32 bytes represent the "expanded" secret key, and the last 32 bytes represent the "domain-separation" "nonce".

Examples


use schnorr::*;

let mut csprng = mohan::mohan_rand();
let mini_secret_key: SecretKey = SecretKey::generate(&mut csprng);
let secret_key: XSecretKey = XSecretKey::from(&mini_secret_key);
let secret_key_bytes: [u8; 64] = secret_key.to_bytes();

assert!(&secret_key_bytes[..] != &[0u8; 64][..]);

pub fn from_bytes(bytes: &[u8]) -> Result<XSecretKey, SchnorrError>[src]

Construct an SecretKey from a slice of bytes.

Returns

A Result whose okay value is an EdDSA SecretKey or whose error value is an SignatureError describing the error that occurred.

Examples

use schnorr::*;

let mut csprng = mohan::mohan_rand();
let secret_key: SecretKey = SecretKey::generate(&mut csprng);
let ex_secret_key: XSecretKey = XSecretKey::from(&secret_key);
let bytes: [u8; 64] = ex_secret_key.to_bytes();
let secret_key_again = XSecretKey::from_bytes(&bytes) ?;

pub fn generate<R>(csprng: R) -> XSecretKey where
    R: CryptoRng + Rng
[src]

Generate an Extended SecretKey directly,

pub fn to_public(&self) -> XPublicKey[src]

Derive the XPublicKey corresponding to this SecretKey.

pub fn as_public(&self) -> &XPublicKey[src]

Return Reference the XPublicKey corresponding to this SecretKey.

pub fn from_secret(secret: &SecretKey) -> XSecretKey[src]

Derive the XSecretKey from given SecretKey.

pub fn derive_intermediate_key(
    &self,
    customize: impl FnOnce(&mut Transcript)
) -> XSecretKey
[src]

Returns a intermediate child xprv. Users must provide customize, in order to separate sibling keys from one another through unique derivation paths.

pub fn derive_key(&self, customize: impl FnOnce(&mut Transcript)) -> SecretKey[src]

Returns a leaf private key. Users must provide customize, in order to separate sibling keys from one another through unique derivation paths.

Trait Implementations

impl Clone for XSecretKey[src]

impl ConstantTimeEq for XSecretKey[src]

impl Debug for XSecretKey[src]

impl Default for XSecretKey[src]

impl Drop for XSecretKey[src]

impl Eq for XSecretKey[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 PartialEq<XSecretKey> for XSecretKey[src]

impl Zeroize for XSecretKey[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T, U> Cast<U> for T where
    U: FromCast<T>, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

impl<T> FromBits<T> for T

impl<T> FromCast<T> for T

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

impl<T, U> IntoBits<U> for T where
    U: FromBits<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

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<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<Z> Zeroize for Z where
    Z: DefaultIsZeroes
[src]