diff --git a/Cargo.toml b/Cargo.toml index f2861b9..629167d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,4 +29,4 @@ name = "fuzzy_tags_benches" harness = false [features] -entangled = ["brute-force"] +entangled = ["brute-force"] \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 29687e4..3877729 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -170,13 +170,11 @@ impl Display for Tag<{ GAMMA }> { /// The complete secret. Can't directly be used for testing. Instead you will need to generate /// a DetectionKey using `extract_detection_key` -#[derive(Debug, Serialize, Deserialize)] +#[derive(Serialize, Deserialize)] pub struct RootSecret { /// the detection key - this can be given to adversarial servers to help probabilistically /// filter messages (with a false-positive rate derived from γ and a 0% false negative rate) secret: Vec, - /// the tagging key - this can be given to people who you want to contact you - tagging_key: TaggingKey<{ GAMMA }>, } impl RootSecret<{ GAMMA }> { @@ -190,18 +188,13 @@ impl RootSecret<{ GAMMA }> { /// ``` pub fn generate() -> RootSecret<{ GAMMA }> { let mut rng = OsRng::default(); - let g = RISTRETTO_BASEPOINT_POINT; let mut secret = vec![]; - let mut p_keys = vec![]; for _i in 0..GAMMA { let sk_i = Scalar::random(&mut rng); - let pk_i = g.mul(sk_i); secret.push(sk_i); - p_keys.push(pk_i); } RootSecret:: { - secret, - tagging_key: TaggingKey { 0: p_keys }, + secret: secret } } @@ -228,7 +221,15 @@ impl RootSecret<{ GAMMA }> { /// let tagging_key = secret.tagging_key(); /// ``` pub fn tagging_key(&self) -> TaggingKey<{ GAMMA }> { - self.tagging_key.clone() + let g = RISTRETTO_BASEPOINT_POINT; + let mut tagging_key = vec![]; + for sk_i in self.secret.iter() { + let pk_i = g.mul(sk_i); + tagging_key.push(pk_i); + } + TaggingKey::{ + 0: tagging_key + } } /// a hash function that takes 3 ristretto points as a parameter and outputs 0 or 1.