MCPcopy Create free account
hub / github.com/arkworks-rs/poly-commit / shifted_powers

Method shifted_powers

poly-commit/src/sonic_pc/data_structures.rs:81–114  ·  view source on GitHub ↗

Obtain powers for committing to shifted polynomials.

(
        &self,
        degree_bound: impl Into<Option<usize>>,
    )

Source from the content-addressed store, hash-verified

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(&degree_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
117impl<E: Pairing> PCCommitterKey for CommitterKey<E> {

Callers 1

commitMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected