Struct nisty::SecretKey [−][src]
Secret part of a keypair, a scalar. Signs messages.
Implementations
impl SecretKey
[src]
pub fn sign_with(secret_bytes: [u8; 32], message: &[u8]) -> Signature
[src]
Sign data using provided secret key buffer.
pub fn sign(&self, message: &[u8]) -> Signature
[src]
Sign arbitrary data.
Convenience method, calls sign_prehashed
on prehash(message)
.
pub fn sign_prehashed(&self, prehashed_message: &[u8; 32]) -> Signature
[src]
Sign data that is prehashed, probably with SHA-256.
impl SecretKey
[src]
pub fn agree(&self, public_key: &PublicKey) -> Result<SharedSecret>
[src]
Agree on a shared secret with a public key.
Remark: These shared secrets are not random and should never be used as cryptographically strong key material without first being passed through a key derivation function, see e.g. RFC 5869, Section 3.3.
use nisty::{Keypair, SEED_LENGTH}; let seed_0 = [0u8; SEED_LENGTH]; let seed_1 = [1u8; SEED_LENGTH]; let keypair_0 = Keypair::generate_patiently(&seed_0); let keypair_1 = Keypair::generate_patiently(&seed_1); assert_ne!(keypair_0.public, keypair_1.public); let secret_0 = keypair_0.secret.agree(&keypair_1.public).unwrap(); let secret_1 = keypair_1.secret.agree(&keypair_0.public).unwrap(); assert_eq!(secret_0, secret_1);
TODO: Find out when exactly this can fail. Can we remove Result-ing?
TODO: Clarify whether this is the x-coordinate of (ab.G) = secret_key*public_key or what.
impl SecretKey
[src]
pub fn try_from_bytes(secret_key_bytes: &[u8; 32]) -> Result<Self>
[src]
pub fn to_bytes(self) -> [u8; 32]
[src]
pub fn as_bytes(&self) -> &[u8; 32]
[src]
Trait Implementations
impl AsArrayRef<[u8; 32]> for SecretKey
[src]
fn as_array_ref(&self) -> &[u8; 32]
[src]
impl AsArrayRef<[u8; 32]> for &SecretKey
[src]
fn as_array_ref(&self) -> &[u8; 32]
[src]
impl Clone for SecretKey
[src]
fn clone(&self) -> SecretKey
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for SecretKey
[src]
impl From<&'_ SecretKey> for Keypair
[src]
impl From<&'_ SecretKey> for PublicKey
[src]
impl Into<[u8; 32]> for SecretKey
[src]
impl PartialEq<SecretKey> for SecretKey
[src]
impl StructuralPartialEq for SecretKey
[src]
impl TryFrom<&'_ [u8; 32]> for SecretKey
[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,
pub 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.
pub 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>,