|
|
|
@ -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);
|
|
|
|
|