From 931ca3050a961b493226ffc41e30778a7cb1342f Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Tue, 16 Feb 2021 14:33:37 -0800 Subject: [PATCH] Fixup Tests for Bulk Verify - Better Doc --- Cargo.toml | 2 +- src/lib.rs | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1f40acf..afb6e30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "fuzzytags" description = "a probabilistic cryptographic structure for metadata resistant tagging" -version = "0.4.1" +version = "0.4.2" repository = "https://git.openprivacy.ca/openprivacy/fuzzytags" authors = ["Sarah Jamie Lewis "] edition = "2018" diff --git a/src/lib.rs b/src/lib.rs index dcdd3e1..815c3a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -365,7 +365,21 @@ impl DetectionKey<{ GAMMA }> { } /// 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> = (0..2).map(|_x| RootSecret::<24>::generate()).collect(); + /// let tagging_keys: Vec> = 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")] pub fn test_tag_bulk(detection_keys: &Vec>, tag: &Tag<{ GAMMA }>) -> Vec { // 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 results = DetectionKey::test_tag_bulk(&detection_keys, &entangled_tag); - for (index, rindex) in results.iter().enumerate() { - assert_eq!(index, *rindex); - } + assert_eq!(results.len(), 2); } #[test]