[−][src]Struct schnorr::keys::Keypair
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 fromKeypair::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]
R: CryptoRng + RngCore,
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]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'d>,
[src]
D: Deserializer<'d>,
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]
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<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,