MCPcopy Index your code
hub / github.com/arkworks-rs/poly-commit / init_stack

Function init_stack

poly-commit/src/streaming_kzg/data_structures.rs:68–84  ·  view source on GitHub ↗
(n: usize, challenges_len: usize)

Source from the content-addressed store, hash-verified

66}
67
68fn init_stack<F: Field>(n: usize, challenges_len: usize) -> Vec<(usize, F)> {
69 let mut stack = Vec::with_capacity(challenges_len);
70
71 // generally we expect the size to be a power of two.
72 // If not, we are going to fill the stack as if the array was padded to zero up to the expected size.
73 let chunk_size = 1 << challenges_len;
74 if n % chunk_size != 0 {
75 let mut delta = chunk_size - n % chunk_size;
76 for i in (0..challenges_len).rev() {
77 if delta >= 1 << i {
78 stack.push((i, F::zero()));
79 delta -= 1 << i
80 }
81 }
82 }
83 stack
84}
85
86impl<'a, F, I> FoldedPolynomialTreeIter<'a, F, I>
87where

Callers 2

newMethod · 0.85
iterMethod · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected