Procházet zdrojové kódy

Use iter and map instead of a for loop in partialeval

to make it easier to turn it into par_iter later
Ian Goldberg před 4 měsíci
rodič
revize
ff76c3096a
1 změnil soubory, kde provedl 4 přidání a 5 odebrání
  1. 4 5
      src/shine.rs

+ 4 - 5
src/shine.rs

@@ -185,11 +185,10 @@ impl PreprocKey {
     }
 
     pub fn partialeval(&self, w: &[u8]) -> Scalar {
-        let mut res = Scalar::zero();
-        for &(theta, lagrange) in &self.secrets {
-            res += hash1(&theta, &w) * lagrange;
-        }
-        res
+        self.secrets
+            .iter()
+            .map(|&(theta, lagrange)| hash1(&theta, &w) * lagrange)
+            .sum()
     }
 
     pub fn delta(&self) -> usize {