Struct exonum::crypto::SignStream
[−]
[src]
pub struct SignStream(_);
This structure provides a possibility to create and/or verify Ed25519 digital signatures for a stream of data.
Example
use exonum::crypto::{SignStream, gen_keypair}; let data: Vec<[u8; 5]> = vec![[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]; let (pk, sk) = gen_keypair(); let mut create_stream = SignStream::new(); let mut verify_stream = SignStream::new(); for chunk in data { create_stream = create_stream.update(&chunk); verify_stream = verify_stream.update(&chunk); } let file_sign = create_stream.sign(&sk); assert!(verify_stream.verify(&file_sign, &pk));
Methods
impl SignStream
[src]
pub fn new() -> Self
[src]
Creates a new instance of SignStream
.
pub fn update(self, chunk: &[u8]) -> Self
[src]
Adds a new chunk
to the message that will eventually be signed and/or verified.
pub fn sign(&mut self, secret_key: &SecretKey) -> Signature
[src]
Computes and returns a signature for the previously supplied message
using the given secret_key
.
pub fn verify(&mut self, sig: &Signature, public_key: &PublicKey) -> bool
[src]
Verifies that sig
is a valid signature for the previously supplied message
using the given public_key
.
Trait Implementations
impl Debug for SignStream
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Default for SignStream
[src]
fn default() -> SignStream
[src]
Returns the "default value" for a type. Read more