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

Method challenge_scalar_without_static_label

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

Source from the content-addressed store, hash-verified

119 }
120
121 fn challenge_scalar_without_static_label<F: Field>(&mut self, label: &[u8]) -> F {
122 // Reduce a double-width scalar to ensure a uniform distribution
123 // TODO: It assumes 32 byte field element. Make it generic
124 let mut buf = [0; 64];
125 self.merlin
126 .challenge_bytes_with_non_static_label(label, &mut buf);
127 let mut counter = 0;
128 loop {
129 let c = F::from_random_bytes(&buf);
130 if let Some(chal) = c {
131 if let Some(c_inv) = chal.inverse() {
132 return c_inv;
133 }
134 }
135
136 buf[0] = counter;
137 counter += 1;
138 self.merlin
139 .challenge_bytes_with_non_static_label(label, &mut buf);
140 }
141 }
142
143 fn challenge_scalars<F: Field>(&mut self, label: &'static [u8], count: usize) -> Vec<F> {
144 // Reduce a double-width scalar to ensure a uniform distribution

Callers

nothing calls this directly

Tested by

no test coverage detected