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

Method init

proof_system/src/sub_protocols/bound_check_bpp.rs:53–84  ·  view source on GitHub ↗
(
        &mut self,
        rng: &mut R,
        comm_key: &'a [G],
        message: G::ScalarField,
        blinding: Option<G::ScalarField>,
    )

Source from the content-addressed store, hash-verified

51 }
52
53 pub fn init<R: RngCore>(
54 &mut self,
55 rng: &mut R,
56 comm_key: &'a [G],
57 message: G::ScalarField,
58 blinding: Option<G::ScalarField>,
59 ) -> Result<(), ProofSystemError> {
60 if self.sp1.is_some() || self.sp2.is_some() {
61 return Err(ProofSystemError::SubProtocolAlreadyInitialized(self.id));
62 }
63 let msg_as_u64 = enforce_and_get_u64::<G::ScalarField>(&message)?;
64
65 // blindings for the commitments in the Bulletproofs++ proof, there will be 2 Bulletproofs++ proofs, for ranges `(message - min)` and `(max - message)`
66 let bpp_randomness = vec![G::ScalarField::rand(rng), G::ScalarField::rand(rng)];
67 let (commitments, values) = ProofArbitraryRange::compute_commitments_and_values(
68 vec![(msg_as_u64, self.min, self.max)],
69 &bpp_randomness,
70 &self.setup_params,
71 )?;
72 self.init_schnorr_protocol(
73 rng,
74 comm_key,
75 message,
76 blinding,
77 (bpp_randomness[0], bpp_randomness[1]),
78 &commitments,
79 )?;
80 self.values = Some(values);
81 self.commitments = Some(commitments);
82 self.bpp_randomness = Some(bpp_randomness);
83 Ok(())
84 }
85
86 fn init_schnorr_protocol<R: RngCore>(
87 &mut self,

Callers 1

init_schnorr_protocolMethod · 0.45

Calls 1

init_schnorr_protocolMethod · 0.45

Tested by

no test coverage detected