Struct fog_crypto::stream::StreamId
source · [−]pub struct StreamId { /* private fields */ }
Expand description
An identifier for a corresponding StreamKey
. It is primarily used to indicate lockboxes are
meant for that particular key.
This is derived through a hash of the key, given a set of specific hash parameters (see
crate::stream
).
Examples
A StreamId
can be made publically visible:
let mut csprng = rand::rngs::OsRng {};
let key = StreamKey::new_temp(&mut csprng);
let id = key.id();
println!("StreamId(Base58): {}", id);
It can also be used to identify a recipient of a lockbox:
// We start with a known StreamKey
let key = StreamKey::new_temp(&mut csprng);
// ...
// We get the byte vector `encoded`, which might be a lockbox
// ...
let dec_lockbox = DataLockboxRef::from_bytes(encoded.as_ref())?;
let recipient = dec_lockbox.recipient();
if let LockboxRecipient::StreamId(ref id) = dec_lockbox.recipient() {
// Check to see if this matches the key's StreamId
if id == key.id() {
let dec_data: Vec<u8> = key.decrypt_data(&dec_lockbox)?;
}
else {
panic!("We were hoping this lockbox was for us!");
}
}
Implementations
pub fn raw_identifier(&self) -> &[u8]ⓘ
Convert into a byte vector. For extending an existing byte vector, see
encode_vec
.
Attempt to parse a base58-encoded StreamId.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for StreamId
impl UnwindSafe for StreamId
Blanket Implementations
Mutably borrows from an owned value. Read more