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>,
)
| 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( |
no outgoing calls
no test coverage detected