Performance Improvements #2
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "fuzzytags"
|
||||
description = "a probabilistic cryptographic structure for metadata resistant tagging"
|
||||
version = "0.4.2"
|
||||
version = "0.5.0"
|
||||
repository = "https://git.openprivacy.ca/openprivacy/fuzzytags"
|
||||
authors = ["Sarah Jamie Lewis <sarah@openprivacy.ca>"]
|
||||
edition = "2018"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use fuzzytags::{RootSecret, TaggingKey};
|
||||
use std::time::Duration;
|
||||
use rand::rngs::OsRng;
|
||||
use std::time::Duration;
|
||||
|
||||
fn benchmark_entangled(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("entangling");
|
||||
|
@ -14,7 +14,13 @@ fn benchmark_entangled(c: &mut Criterion) {
|
|||
let public_key_1 = secret_key_1.tagging_key();
|
||||
let public_key_2 = secret_key_2.tagging_key();
|
||||
group.bench_with_input(BenchmarkId::from_parameter(p), p, |b, _gamma| {
|
||||
b.iter(|| TaggingKey::generate_entangled_tag(vec![public_key_1.clone(), public_key_2.clone()], &mut rng, *p))
|
||||
b.iter(|| {
|
||||
TaggingKey::generate_entangled_tag(
|
||||
vec![public_key_1.clone(), public_key_2.clone()],
|
||||
&mut rng,
|
||||
*p,
|
||||
)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -21,6 +21,7 @@ use brute_force::adaptors;
|
|||
#[cfg(feature = "entangled")]
|
||||
use brute_force::brute_force;
|
||||
|
||||
use rand_core::{CryptoRng, RngCore};
|
||||
#[cfg(feature = "bulk_verify")]
|
||||
use rayon::iter::IndexedParallelIterator;
|
||||
#[cfg(feature = "bulk_verify")]
|
||||
|
@ -29,7 +30,6 @@ use rayon::iter::IntoParallelRefIterator;
|
|||
use rayon::iter::ParallelIterator;
|
||||
#[cfg(feature = "bulk_verify")]
|
||||
use std::sync::mpsc::channel;
|
||||
use rand_core::{RngCore, CryptoRng};
|
||||
|
||||
/// A tag is a probabilistic cryptographic structure. When constructed for a given `TaggingKey`
|
||||
/// it will pass the `DetectionKey::test_tag` 100% of the time. For other tagging keys
|
||||
|
@ -214,7 +214,6 @@ impl<const GAMMA: u8> RootSecret<{ GAMMA }> {
|
|||
/// let secret = RootSecret::<24>::generate(&mut rng);
|
||||
/// ```
|
||||
pub fn generate<R: RngCore + CryptoRng>(rng: &mut R) -> RootSecret<{ GAMMA }> {
|
||||
|
||||
let mut secret = vec![];
|
||||
for _i in 0..GAMMA {
|
||||
let sk_i = Scalar::random(rng);
|
||||
|
@ -691,7 +690,9 @@ mod tests {
|
|||
fn test_multiple() {
|
||||
use crate::TaggingKey;
|
||||
let mut rng = OsRng;
|
||||
let secrets: Vec<RootSecret<24>> = (0..2).map(|_x| RootSecret::<24>::generate(&mut rng)).collect();
|
||||
let secrets: Vec<RootSecret<24>> = (0..2)
|
||||
.map(|_x| RootSecret::<24>::generate(&mut rng))
|
||||
.collect();
|
||||
let tagging_keys: Vec<TaggingKey<24>> = secrets.iter().map(|x| x.tagging_key()).collect();
|
||||
|
||||
// it takes ~2 minutes on a standard desktop to find a length=24 match for 2 parties, so for testing let's keep things light
|
||||
|
@ -710,7 +711,9 @@ mod tests {
|
|||
fn test_check_multiple() {
|
||||
use crate::TaggingKey;
|
||||
let mut rng = OsRng;
|
||||
let secrets: Vec<RootSecret<24>> = (0..2).map(|_x| RootSecret::<24>::generate(&mut rng)).collect();
|
||||
let secrets: Vec<RootSecret<24>> = (0..2)
|
||||
.map(|_x| RootSecret::<24>::generate(&mut rng))
|
||||
.collect();
|
||||
let tagging_keys: Vec<TaggingKey<24>> = secrets.iter().map(|x| x.tagging_key()).collect();
|
||||
// it takes ~2 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, &mut rng, 16);
|
||||
|
|
Loading…
Reference in New Issue