[][src]Struct schnorr::keys::Keypair

pub struct Keypair {
    pub secret: SecretKey,
    pub public: PublicKey,
}

An Schnorr keypair.

Fields

secret: SecretKey

The secret half of this keypair.

public: PublicKey

The public half of this keypair.

Methods

impl Keypair[src]

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

Convert this keypair to bytes.

Returns

An array of bytes, [u8; KEYPAIR_LENGTH]. The first SECRET_KEY_LENGTH of bytes is the SecretKey, and the next PUBLIC_KEY_LENGTH bytes is the PublicKey

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

Construct a Keypair from the bytes of a PublicKey and SecretKey.

Inputs

  • bytes: an &[u8] representing the scalar for the secret key, and a compressed Edwards-Y coordinate of a point on curve25519, both as bytes. (As obtained from Keypair::to_bytes().)

Warning

Absolutely no validation is done on the key. If you give this function bytes which do not represent a valid point, or which do not represent corresponding parts of the key, then your Keypair will be broken and it will be your fault.

Returns

A Result whose okay value is an Schnorr Keypair or whose error value is an SchnorrError describing the error that occurred.

pub fn generate<R>(csprng: &mut R) -> Keypair where
    R: CryptoRng + RngCore
[src]

Generate an schnorr keypair.

Example

extern crate rand;
extern crate schnorr;


use rand::Rng;
use rand::rngs::OsRng;
use schnorr::*;

let mut csprng: OsRng = OsRng;
let keypair: Keypair = Keypair::generate(&mut csprng);

Input

A CSPRNG with a fill_bytes() method, e.g. rand::ChaChaRng.

The caller must also supply a hash function which implements the Digest and Default traits, and which returns 512 bits of output. The standard hash function used is Blake2b-512,

pub fn from_secret(s: &SecretKey) -> Keypair[src]

Derive the PublicKey corresponding to this SecretKey.

Trait Implementations

impl Clone for Keypair[src]

impl Debug for Keypair[src]

impl Default for Keypair[src]

impl<'d> Deserialize<'d> for Keypair[src]

impl Drop for Keypair[src]

impl From<SecretKey> for Keypair[src]

impl Readable for Keypair[src]

impl Serialize for Keypair[src]

impl Writeable for Keypair[src]

impl Zeroize for Keypair[src]

Auto Trait Implementations

impl RefUnwindSafe for Keypair

impl Send for Keypair

impl Sync for Keypair

impl Unpin for Keypair

impl UnwindSafe for Keypair

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<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[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]