Commit to the given set with provided randomness
(
randomness: E::ScalarField,
set: BTreeSet<E::ScalarField>,
srs: &SetCommitmentSRS<E>,
)
| 211 | |
| 212 | /// Commit to the given set with provided randomness |
| 213 | pub fn new_with_given_randomness( |
| 214 | randomness: E::ScalarField, |
| 215 | set: BTreeSet<E::ScalarField>, |
| 216 | srs: &SetCommitmentSRS<E>, |
| 217 | ) -> Result<(Self, SetCommitmentOpening<E>), DelegationError> { |
| 218 | let set_size = set.len(); |
| 219 | |
| 220 | if set_size > srs.size() { |
| 221 | return Err(DelegationError::InsufficientSetCommitmentSRSSize( |
| 222 | set_size, |
| 223 | srs.size(), |
| 224 | )); |
| 225 | } |
| 226 | |
| 227 | let P1_table = WindowTable::new(set_size, srs.get_P1().into_group()); |
| 228 | let s_P1 = srs.get_s_P1().into_group(); |
| 229 | // Check if set contains the trapdoor |
| 230 | for s in set.iter() { |
| 231 | if P1_table.multiply(s) == s_P1 { |
| 232 | return Ok(( |
| 233 | SetCommitment(P1_table.multiply(&randomness).into_affine()), |
| 234 | SetCommitmentOpening::SetWithTrapdoor(randomness, *s), |
| 235 | )); |
| 236 | } |
| 237 | } |
| 238 | Ok(( |
| 239 | SetCommitment(Self::commit_in_P1(randomness.into_bigint(), set, srs)), |
| 240 | SetCommitmentOpening::SetWithoutTrapdoor(randomness), |
| 241 | )) |
| 242 | } |
| 243 | |
| 244 | /// Commit to the given set when provided with a commitment to the randomness. |
| 245 | /// It is assumed that `comm_rand` is indeed of the form `r*P1` where `r` is the randomness. A PoK would |
nothing calls this directly
no test coverage detected