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

Method new_with_given_base

bulletproofs_plus_plus/src/range_proof.rs:200–253  ·  view source on GitHub ↗

Creates a new prover instance.

(
        base: u16,
        num_bits: u16,
        V: Vec<G>,
        v: Vec<u64>,
        gamma: Vec<G::ScalarField>,
    )

Source from the content-addressed store, hash-verified

198
199 /// Creates a new prover instance.
200 pub fn new_with_given_base(
201 base: u16,
202 num_bits: u16,
203 V: Vec<G>,
204 v: Vec<u64>,
205 gamma: Vec<G::ScalarField>,
206 ) -> Result<Self, BulletproofsPlusPlusError> {
207 if !base.is_power_of_two() {
208 return Err(BulletproofsPlusPlusError::ExpectedPowerOfTwo(format!(
209 "base={} but should be a power of 2",
210 base
211 )));
212 }
213 if !num_bits.is_power_of_two() {
214 return Err(BulletproofsPlusPlusError::ExpectedPowerOfTwo(format!(
215 "num_bits={} but should be a power of 2",
216 num_bits
217 )));
218 }
219 if num_bits < util::base_bits(base) {
220 return Err(BulletproofsPlusPlusError::ValueIncompatibleWithBase(format!("number of bits in value={} which should not be less than number of bits in base={}", num_bits, base)));
221 }
222 if v.len() != V.len() {
223 return Err(BulletproofsPlusPlusError::UnexpectedLengthOfVectors(
224 format!(
225 "length of values={} not equal to length of commitments={}",
226 v.len(),
227 V.len()
228 ),
229 ));
230 }
231 if v.len() != gamma.len() {
232 return Err(BulletproofsPlusPlusError::UnexpectedLengthOfVectors(
233 format!(
234 "length of values={} not equal to length of randomness={}",
235 v.len(),
236 gamma.len()
237 ),
238 ));
239 }
240 Ok(Self {
241 base,
242 num_bits,
243 V,
244 v,
245 gamma,
246 r1_comm: None,
247 r1_sec: None,
248 r2_comm: None,
249 r2_sec: None,
250 r3_comm: None,
251 r3_sec: None,
252 })
253 }
254
255 pub fn prove<R: RngCore>(
256 mut self,

Callers

nothing calls this directly

Calls 2

base_bitsFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected