pub struct SignStream(_);
This structure provides a possibility to create and/or verify
digital signatures for a stream of data. If the data are split into several
chunks, the indicated chunks are added to the system and when adding is
complete, the data is signed.
The example below adds several data chunks to the system, generates a pair
of random public and secret keys, signs the data and verifies the signature.
use exonum::crypto::{SignStream, gen_keypair};
let data: Vec<[u8; 5]> = vec![[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]];
let (public_key, secret_key) = 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(&secret_key);
assert!(verify_stream.verify(&file_sign, &public_key));
Creates a new instance of SignStream
.
use exonum::crypto::SignStream;
let stream = SignStream::new();
Adds a new chunk
to the message that will eventually be signed and/or verified.
use exonum::crypto::SignStream;
let mut stream = SignStream::new();
let data = &[[1, 2, 3], [4, 5, 6], [7, 8, 9]];
for chunk in data.iter() {
stream = stream.update(chunk);
}
Computes and returns a signature for the previously supplied message
using the given secret_key
.
use exonum::crypto::{SignStream, gen_keypair};
let mut stream = SignStream::new();
let data = &[[1, 2, 3], [4, 5, 6], [7, 8, 9]];
for chunk in data.iter() {
stream = stream.update(chunk);
}
let (public_key, secret_key) = gen_keypair();
let signature = stream.sign(&secret_key);
Verifies that sig
is a valid signature for the previously supplied message
using the given public_key
.
use exonum::crypto::{SignStream, gen_keypair};
let mut stream = SignStream::new();
let mut verify_stream = SignStream::new();
let data = &[[1, 2, 3], [4, 5, 6], [7, 8, 9]];
for chunk in data.iter() {
stream = stream.update(chunk);
verify_stream = verify_stream.update(chunk);
}
let (public_key, secret_key) = gen_keypair();
let signature = stream.sign(&secret_key);
assert!(verify_stream.verify(&signature, &public_key));
Returns the "default value" for a type. Read more
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<T> Clear for T where T: InitializableFromZeroed + ?Sized, | |
Completely overwrites this value.
impl<T> InitializableFromZeroed for T where T: Default, | |
Called to initialize a place to a valid value, after it is set to all-bits-zero. Read more