소스 검색

Use iter and map instead of a for loop in partialeval

to make it easier to turn it into par_iter later
Ian Goldberg 3 달 전
부모
커밋
f7e5aee507
1개의 변경된 파일4개의 추가작업 그리고 5개의 파일을 삭제
  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 {