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

Method open_set

delegatable_credentials/src/set_commitment.rs:278–301  ·  view source on GitHub ↗

Checks if the commitment can be opened with the given opening and for the given set.

(
        &self,
        opening: &SetCommitmentOpening<E>,
        set: BTreeSet<E::ScalarField>,
        srs: &SetCommitmentSRS<E>,
    )

Source from the content-addressed store, hash-verified

276
277 /// Checks if the commitment can be opened with the given opening and for the given set.
278 pub fn open_set(
279 &self,
280 opening: &SetCommitmentOpening<E>,
281 set: BTreeSet<E::ScalarField>,
282 srs: &SetCommitmentSRS<E>,
283 ) -> Result<(), DelegationError> {
284 match opening {
285 SetCommitmentOpening::SetWithTrapdoor(r, s) => {
286 let P1 = srs.get_P1().into_group();
287 let s_P1 = P1.mul_bigint(s.into_bigint()).into_affine();
288 let C = P1.mul_bigint(r.into_bigint()).into_affine();
289 if !set.contains(s) || (C != self.0) || (s_P1 != *srs.get_s_P1()) {
290 return Err(DelegationError::InvalidOpening);
291 }
292 Ok(())
293 }
294 SetCommitmentOpening::SetWithoutTrapdoor(r) => {
295 if Self::commit_in_P1(r.into_bigint(), set, srs) != self.0 {
296 return Err(DelegationError::InvalidOpening);
297 }
298 Ok(())
299 }
300 }
301 }
302
303 /// Same as `Self::open_subset_unchecked` but additionally checks if the subset is indeed a subset and the opening is valid.
304 pub fn open_subset(

Callers 3

open_subsetMethod · 0.80
checkFunction · 0.80
verifyMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected