MCPcopy Create free account
hub / github.com/docknetwork/crypto / challenge_scalars_without_static_label

Method challenge_scalars_without_static_label

utils/src/transcript.rs:169–199  ·  view source on GitHub ↗
(
        &mut self,
        label: &[u8],
        count: usize,
    )

Source from the content-addressed store, hash-verified

167 }
168
169 fn challenge_scalars_without_static_label<F: Field>(
170 &mut self,
171 label: &[u8],
172 count: usize,
173 ) -> Vec<F> {
174 // Reduce a double-width scalar to ensure a uniform distribution
175 // TODO: It assumes 32 byte field element. Make it generic
176 let mut buf = vec![0; count * 64];
177 self.merlin
178 .challenge_bytes_with_non_static_label(label, &mut buf);
179 let mut out = Vec::with_capacity(count);
180 for i in 0..count {
181 let mut counter = 0;
182 let start = i * 64;
183 let end = (i + 1) * 64;
184 loop {
185 let c = F::from_random_bytes(&buf[start..end]);
186 if let Some(chal) = c {
187 if let Some(c_inv) = chal.inverse() {
188 out.push(c_inv);
189 break;
190 }
191 }
192 buf[start] = counter;
193 counter += 1;
194 self.merlin
195 .challenge_bytes_with_non_static_label(label, &mut buf[start..end]);
196 }
197 }
198 out
199 }
200
201 fn challenge_group_elem<G: AffineRepr>(&mut self, label: &'static [u8]) -> G {
202 let mut buf = [0; 64];

Callers

nothing calls this directly

Tested by

no test coverage detected