Obtain powers for committing to shifted polynomials.
(
&self,
degree_bound: impl Into<Option<usize>>,
)
| 79 | |
| 80 | /// Obtain powers for committing to shifted polynomials. |
| 81 | pub fn shifted_powers( |
| 82 | &self, |
| 83 | degree_bound: impl Into<Option<usize>>, |
| 84 | ) -> Option<kzg10::Powers<E>> { |
| 85 | match (&self.shifted_powers_of_g, &self.shifted_powers_of_gamma_g) { |
| 86 | (Some(shifted_powers_of_g), Some(shifted_powers_of_gamma_g)) => { |
| 87 | let max_bound = self |
| 88 | .enforced_degree_bounds |
| 89 | .as_ref() |
| 90 | .unwrap() |
| 91 | .last() |
| 92 | .unwrap(); |
| 93 | let (bound, powers_range) = if let Some(degree_bound) = degree_bound.into() { |
| 94 | assert!(self |
| 95 | .enforced_degree_bounds |
| 96 | .as_ref() |
| 97 | .unwrap() |
| 98 | .contains(°ree_bound)); |
| 99 | (degree_bound, (max_bound - degree_bound)..) |
| 100 | } else { |
| 101 | (*max_bound, 0..) |
| 102 | }; |
| 103 | |
| 104 | let ck = kzg10::Powers { |
| 105 | powers_of_g: shifted_powers_of_g[powers_range.clone()].into(), |
| 106 | powers_of_gamma_g: shifted_powers_of_gamma_g[&bound].clone().into(), |
| 107 | }; |
| 108 | |
| 109 | Some(ck) |
| 110 | } |
| 111 | |
| 112 | (_, _) => None, |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | impl<E: Pairing> PCCommitterKey for CommitterKey<E> { |