pub struct DetectionKey<const GAMMA: u8>(/* private fields */);
Expand description
A collection of “secret” data that can be used to determine if a FuzzyTag
was intended for
the derived tagging key with probability p
Implementations§
Source§impl<const GAMMA: u8> DetectionKey<GAMMA>
impl<const GAMMA: u8> DetectionKey<GAMMA>
Source§impl<const GAMMA: u8> DetectionKey<GAMMA>
impl<const GAMMA: u8> DetectionKey<GAMMA>
Sourcepub fn false_positive_probability(&self) -> f64
pub fn false_positive_probability(&self) -> f64
calculate the ideal false positive rate of this detection key
use fuzzytags::RootSecret;
use rand::rngs::OsRng;
let mut rng = OsRng;
let secret = RootSecret::<24>::generate(&mut rng);
let tagging_key = secret.tagging_key();
// extract a detection key
let detection_key = secret.extract_detection_key(5);
detection_key.false_positive_probability();
Sourcepub fn test_tag(&self, tag: &Tag<GAMMA>) -> bool
pub fn test_tag(&self, tag: &Tag<GAMMA>) -> bool
returns true if the tag was intended for this key Example:
use fuzzytags::RootSecret;
use rand::rngs::OsRng;
let mut rng = OsRng;
let secret = RootSecret::<24>::generate(&mut rng);
let tagging_key = secret.tagging_key();
// extract a detection key
let detection_key = secret.extract_detection_key(5);
// Give tagging key to a another party...
// and then they can do...
let tag = tagging_key.generate_tag(&mut rng);
// The server can now do this:
if detection_key.test_tag(&tag) {
// the message attached to this tag *might* be for the party associated with the detection key
} else {
// the message attached to this tag is definitely *not* for the party associated with the detection key.
}
Trait Implementations§
Source§impl<const GAMMA: u8> Clone for DetectionKey<GAMMA>
impl<const GAMMA: u8> Clone for DetectionKey<GAMMA>
Source§fn clone(&self) -> DetectionKey<GAMMA>
fn clone(&self) -> DetectionKey<GAMMA>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<const GAMMA: u8> Debug for DetectionKey<GAMMA>
impl<const GAMMA: u8> Debug for DetectionKey<GAMMA>
Source§impl<'de, const GAMMA: u8> Deserialize<'de> for DetectionKey<GAMMA>
impl<'de, const GAMMA: u8> Deserialize<'de> for DetectionKey<GAMMA>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<const GAMMA: u8> Display for DetectionKey<GAMMA>
impl<const GAMMA: u8> Display for DetectionKey<GAMMA>
Auto Trait Implementations§
impl<const GAMMA: u8> Freeze for DetectionKey<GAMMA>
impl<const GAMMA: u8> RefUnwindSafe for DetectionKey<GAMMA>
impl<const GAMMA: u8> Send for DetectionKey<GAMMA>
impl<const GAMMA: u8> Sync for DetectionKey<GAMMA>
impl<const GAMMA: u8> Unpin for DetectionKey<GAMMA>
impl<const GAMMA: u8> UnwindSafe for DetectionKey<GAMMA>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more