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

Method challenge_scalar

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

Source from the content-addressed store, hash-verified

99 }
100
101 fn challenge_scalar<F: Field>(&mut self, label: &'static [u8]) -> F {
102 // Reduce a double-width scalar to ensure a uniform distribution
103 // TODO: It assumes 32 byte field element. Make it generic
104 let mut buf = [0; 64];
105 self.merlin.challenge_bytes(label, &mut buf);
106 let mut counter = 0;
107 loop {
108 let c = F::from_random_bytes(&buf);
109 if let Some(chal) = c {
110 if let Some(c_inv) = chal.inverse() {
111 return c_inv;
112 }
113 }
114
115 buf[0] = counter;
116 counter += 1;
117 self.merlin.challenge_bytes(label, &mut buf);
118 }
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

Callers 14

_verifyMethod · 0.80
newMethod · 0.80
point_additionFunction · 0.80
challengeMethod · 0.80
challengesMethod · 0.80
inequality_proofFunction · 0.80
unknown_inequality_proofFunction · 0.80
product_committed_valuesFunction · 0.80

Calls 1

challenge_bytesMethod · 0.45