Explorar el 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 hace 4 meses
padre
commit
f7e5aee507
Se han modificado 1 ficheros con 4 adiciones y 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 {