[−][src]Struct nisty::Keypair
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: SecretKey
public: PublicKey
Methods
impl Keypair
[src]
pub fn generate(
seed: impl AsArrayRef<[u8; 32]>,
tries: usize
) -> Result<Keypair>
[src]
seed: impl AsArrayRef<[u8; 32]>,
tries: usize
) -> Result<Keypair>
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]
&self,
message: &[u8],
signature: impl AsArrayRef<[u8; 64]>
) -> bool
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]
&self,
prehashed_message: &[u8; 32],
signature: impl AsArrayRef<[u8; 64]>
) -> bool
Verify that a claimed signature for a prehashed message is valid.
Delegates to PublicKey::verify_prehashed
.
Trait Implementations
impl Clone for Keypair
[src]
fn clone(&self) -> Keypair
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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]
Auto Trait Implementations
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
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>,