(&mut self, label: &'static [u8], count: usize)
| 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 |
| 145 | // TODO: It assumes 32 byte field element. Make it generic |
| 146 | let mut buf = vec![0; count * 64]; |
| 147 | self.merlin.challenge_bytes(label, &mut buf); |
| 148 | let mut out = Vec::with_capacity(count); |
| 149 | for i in 0..count { |
| 150 | let mut counter = 0; |
| 151 | let start = i * 64; |
| 152 | let end = (i + 1) * 64; |
| 153 | loop { |
| 154 | let c = F::from_random_bytes(&buf[start..end]); |
| 155 | if let Some(chal) = c { |
| 156 | if let Some(c_inv) = chal.inverse() { |
| 157 | out.push(c_inv); |
| 158 | break; |
| 159 | } |
| 160 | } |
| 161 | buf[start] = counter; |
| 162 | counter += 1; |
| 163 | self.merlin.challenge_bytes(label, &mut buf[start..end]); |
| 164 | } |
| 165 | } |
| 166 | out |
| 167 | } |
| 168 | |
| 169 | fn challenge_scalars_without_static_label<F: Field>( |
| 170 | &mut self, |
nothing calls this directly
no test coverage detected