Returns witness for the given subset of a set which is committed in this commitment
(
&self,
opening: &SetCommitmentOpening<E>,
subset: BTreeSet<E::ScalarField>,
set: BTreeSet<E::ScalarField>,
srs: &SetCommitmentSRS<E>,
)
| 319 | |
| 320 | /// Returns witness for the given subset of a set which is committed in this commitment |
| 321 | pub fn open_subset_unchecked( |
| 322 | &self, |
| 323 | opening: &SetCommitmentOpening<E>, |
| 324 | subset: BTreeSet<E::ScalarField>, |
| 325 | set: BTreeSet<E::ScalarField>, |
| 326 | srs: &SetCommitmentSRS<E>, |
| 327 | ) -> Result<SubsetWitness<E>, DelegationError> { |
| 328 | let subset_size = subset.len(); |
| 329 | if subset_size == 0 { |
| 330 | return Ok(SubsetWitness(self.0)); |
| 331 | } |
| 332 | match opening { |
| 333 | SetCommitmentOpening::SetWithTrapdoor(_, s) => { |
| 334 | if subset.contains(s) { |
| 335 | Err(DelegationError::ShouldNotContainTrapdoor) |
| 336 | } else { |
| 337 | let poly = poly_from_roots(&subset.into_iter().collect::<Vec<_>>()); |
| 338 | let mut e = poly.evaluate(s); |
| 339 | e.inverse_in_place().unwrap(); |
| 340 | Ok(SubsetWitness(self.0.mul(e).into())) |
| 341 | } |
| 342 | } |
| 343 | SetCommitmentOpening::SetWithoutTrapdoor(r) => { |
| 344 | let diff = set.difference(&subset).cloned().collect::<BTreeSet<_>>(); |
| 345 | let witness = if diff.is_empty() { |
| 346 | // Subset is same as the set |
| 347 | srs.get_P1().mul_bigint(r.into_bigint()).into_affine() |
| 348 | } else { |
| 349 | // Commit to remaining elements |
| 350 | Self::commit_in_P1(r.into_bigint(), diff, srs) |
| 351 | }; |
| 352 | Ok(SubsetWitness(witness)) |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | /// Randomize the set commitment and the corresponding opening |
| 358 | pub fn randomize( |
no test coverage detected