[][src]Struct nisty::Keypair

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

Create keys, sign messages, verify signatures.

Key generation from a seed needs no further entropic input. Signatures are always deterministic, they need no entropic input.

As a user of this library, you need to think long and hard whether the seeds you use to generate keys are sufficiently entropic. But after that, no more such thought is necessary – in particular, entropy failure during signing will never reveal your keys.

Fields

secret: SecretKeypublic: PublicKey

Methods

impl Keypair[src]

pub fn generate(
    seed: impl AsArrayRef<[u8; 32]>,
    tries: usize
) -> Result<Keypair>
[src]

Generate new public key, based on a seed assumed to be entropic.

IT IS YOUR RESPONSIBILITY TO THINK ABOUT WHETHER YOUR SEEDS ARE ENTROPIC.

Approach: if the given seed does not correspond to a secret key, we repeatedly compute its SHA-256 digest, until it passes muster, at most tries times.

Instead of calling with tries = 1, consider using Keypair::try_from_bytes directly.

If you can't make up your mind about how many tries to allow, use Keypair::generate_patiently instead.

pub fn generate_patiently(seed: impl AsArrayRef<[u8; 32]>) -> Keypair[src]

Like Keypair::generate, but keeps on trying indefinitely.

pub fn try_from_bytes(secret_key_bytes: &[u8; 32]) -> Result<Keypair>[src]

Return keypair with given bytes as secret key, if valid.

If uncertain whether the bytes are a valid secret key, try Keypair::generate with tries > 1 instead.

pub fn split(self) -> (SecretKey, PublicKey)[src]

Consume the keypair and return its secret and public components.

Use the secret key to sign, use the public key to verify.

pub fn sign(&self, message: &[u8]) -> Signature[src]

Sign arbitrary data. Delegates to SecretKey::sign.

pub fn sign_prehashed(&self, prehashed_message: &[u8; 32]) -> Signature[src]

Sign data that is prehashed, probably with SHA-256. Delegates to SecretKey::sign_prehashed.

pub fn verify(
    &self,
    message: &[u8],
    signature: impl AsArrayRef<[u8; 64]>
) -> bool
[src]

Verify that a claimed signature for a message is valid. Delegates to PublicKey::verify.

pub fn verify_prehashed(
    &self,
    prehashed_message: &[u8; 32],
    signature: impl AsArrayRef<[u8; 64]>
) -> bool
[src]

Verify that a claimed signature for a prehashed message is valid. Delegates to PublicKey::verify_prehashed.

Trait Implementations

impl Clone for Keypair[src]

impl Debug for Keypair[src]

impl<'_> From<&'_ SecretKey> for Keypair[src]

impl PartialEq<Keypair> for Keypair[src]

impl StructuralPartialEq for Keypair[src]

impl<'_> TryFrom<&'_ [u8; 32]> for Keypair[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl Send for Keypair

impl Sync for Keypair

impl Unpin 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> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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.