Fixup Tests for Bulk Verify - Better Doc

This commit is contained in:
Sarah Jamie Lewis 2021-02-16 14:33:37 -08:00
parent 6ca2e3129c
commit 931ca3050a
2 changed files with 17 additions and 5 deletions

View File

@ -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 <sarah@openprivacy.ca>"]
edition = "2018"

View File

@ -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
/// 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")]
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.
@ -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]