Fixup Tests for Bulk Verify - Better Doc
This commit is contained in:
parent
6ca2e3129c
commit
931ca3050a
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "fuzzytags"
|
name = "fuzzytags"
|
||||||
description = "a probabilistic cryptographic structure for metadata resistant tagging"
|
description = "a probabilistic cryptographic structure for metadata resistant tagging"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
repository = "https://git.openprivacy.ca/openprivacy/fuzzytags"
|
repository = "https://git.openprivacy.ca/openprivacy/fuzzytags"
|
||||||
authors = ["Sarah Jamie Lewis <sarah@openprivacy.ca>"]
|
authors = ["Sarah Jamie Lewis <sarah@openprivacy.ca>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
20
src/lib.rs
20
src/lib.rs
|
@ -365,7 +365,21 @@ impl<const GAMMA: u8> DetectionKey<{ GAMMA }> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A bulk testing function that takes in an vector of detection keys and returns a vector
|
/// A bulk testing function that takes in an vector of detection keys and returns a vector
|
||||||
/// of indexes where the tag matched.
|
/// of indexes where the tag matched. (Indexes not guarenteed to be ordered).
|
||||||
|
/// This function may spin up additional threads depending on the number of detection
|
||||||
|
/// keys provided.
|
||||||
|
/// ```
|
||||||
|
/// use fuzzytags::{TaggingKey, DetectionKey};
|
||||||
|
/// use fuzzytags::RootSecret;
|
||||||
|
/// let secrets: Vec<RootSecret<24>> = (0..2).map(|_x| RootSecret::<24>::generate()).collect();
|
||||||
|
/// let tagging_keys: Vec<TaggingKey<24>> = secrets.iter().map(|x| x.tagging_key()).collect();
|
||||||
|
/// // it takes ~15 minutes on a standard desktop to find a length=24 match for 2 parties, so for testing let's keep things light
|
||||||
|
/// let entangled_tag = TaggingKey::generate_entangled_tag(tagging_keys, 16);
|
||||||
|
/// let detection_keys = secrets.iter().map(|x| x.extract_detection_key(16)).collect();
|
||||||
|
///
|
||||||
|
/// let results = DetectionKey::test_tag_bulk(&detection_keys, &entangled_tag);
|
||||||
|
/// assert_eq!(results.len(), 2);
|
||||||
|
/// ```
|
||||||
#[cfg(feature = "bulk_verify")]
|
#[cfg(feature = "bulk_verify")]
|
||||||
pub fn test_tag_bulk(detection_keys: &Vec<DetectionKey<{ GAMMA }>>, tag: &Tag<{ GAMMA }>) -> Vec<usize> {
|
pub fn test_tag_bulk(detection_keys: &Vec<DetectionKey<{ GAMMA }>>, tag: &Tag<{ GAMMA }>) -> Vec<usize> {
|
||||||
// A few checks to make sure the tag is well formed.
|
// A few checks to make sure the tag is well formed.
|
||||||
|
@ -663,9 +677,7 @@ mod tests {
|
||||||
let detection_keys = secrets.iter().map(|x| x.extract_detection_key(16)).collect();
|
let detection_keys = secrets.iter().map(|x| x.extract_detection_key(16)).collect();
|
||||||
|
|
||||||
let results = DetectionKey::test_tag_bulk(&detection_keys, &entangled_tag);
|
let results = DetectionKey::test_tag_bulk(&detection_keys, &entangled_tag);
|
||||||
for (index, rindex) in results.iter().enumerate() {
|
assert_eq!(results.len(), 2);
|
||||||
assert_eq!(index, *rindex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue