Struct lamport_signature::PublicKey
[−]
[src]
pub struct PublicKey<T> { /* fields omitted */ }
A one-time signing public key.
In general, a public key is generated by the paired PrivateKey or generate_keys function.
Methods
impl<T> PublicKey<T> where
T: Digest,
[src]
T: Digest,
pub fn from_bytes<U>(bytes: &mut U) -> Result<PublicKey<T>, Error> where
U: Read,
[src]
U: Read,
Constructs a PublicKey from the object implements std::io::Read, like std::fs::File.
Example
extern crate sha2; extern crate lamport_signature; use std::fs::File; use std::io::Read; use sha2::Sha256; use lamport_signature::PublicKey; let mut file = File::open("test_key.pub").unwrap(); assert!(PublicKey::<Sha256>::from_bytes(&mut file).is_ok());
pub fn to_bytes(&self) -> Vec<u8>
[src]
Converts the inner key data into a linearized vector.
Example
extern crate sha2; extern crate rand; extern crate lamport_signature; use sha2::Sha256; use rand::{XorShiftRng, SeedableRng}; use lamport_signature::{PublicKey, generate_keys}; const SEED: [u8; 16] = [0; 16]; let mut rng = XorShiftRng::from_seed(SEED); let (_, public_key) = generate_keys::<Sha256, _>(&mut rng); assert!(public_key.to_bytes().len() == 32 * 256 * 2);
pub fn verify(&self, signature: &Signature, data: &[u8]) -> bool
[src]
Verifies the Signature.
Example
extern crate sha2; extern crate rand; extern crate lamport_signature; use sha2::Sha256; use rand::{XorShiftRng, SeedableRng}; use lamport_signature::{PrivateKey, PublicKey, generate_keys}; const SEED: [u8; 16] = [0; 16]; let mut rng = XorShiftRng::from_seed(SEED); let (mut private_key, public_key) = generate_keys::<Sha256, _>(&mut rng); const MESSAGE: &[u8] = b"hello, world!"; let signature = private_key.sign(MESSAGE).expect("failed to sign."); assert!(public_key.verify(&signature, MESSAGE));
Trait Implementations
impl<T: Debug> Debug for PublicKey<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: Clone> Clone for PublicKey<T>
[src]
fn clone(&self) -> PublicKey<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> PartialEq for PublicKey<T>
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T> Eq for PublicKey<T>
[src]
impl<T> PartialOrd for PublicKey<T>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T> Ord for PublicKey<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more