Explorar o código

Use iter and map instead of a for loop in partialeval

to make it easier to turn it into par_iter later
Ian Goldberg hai 4 meses
pai
achega
ff76c3096a
Modificáronse 1 ficheiros con 4 adicións e 5 borrados
  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 {