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]

[src]

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());

[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);

[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]

[src]

Formats the value using the given formatter. Read more

impl<T: Clone> Clone for PublicKey<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T> PartialEq for PublicKey<T>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<T> Eq for PublicKey<T>
[src]

impl<T> PartialOrd for PublicKey<T>
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[src]

This method returns an Ordering between self and other. Read more

1.21.0
[src]

Compares and returns the maximum of two values. Read more

1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl<T> Hash for PublicKey<T>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl<T> Send for PublicKey<T> where
    T: Send

impl<T> Sync for PublicKey<T> where
    T: Sync