Process received commitments to the shares from another party and store it
(
&mut self,
sender_id: ParticipantId,
commitments: Commitments,
)
| 67 | |
| 68 | /// Process received commitments to the shares from another party and store it |
| 69 | pub fn receive_commitment( |
| 70 | &mut self, |
| 71 | sender_id: ParticipantId, |
| 72 | commitments: Commitments, |
| 73 | ) -> Result<(), OTError> { |
| 74 | if self.id == sender_id { |
| 75 | return Err(OTError::SenderIdCannotBeSameAsSelf(sender_id, self.id)); |
| 76 | } |
| 77 | if self.other_commitments.contains_key(&sender_id) { |
| 78 | return Err(OTError::AlreadyHaveCommitmentFromParticipant(sender_id)); |
| 79 | } |
| 80 | expect_equality!( |
| 81 | self.own_shares_and_salts.len(), |
| 82 | commitments.0.len(), |
| 83 | OTError::IncorrectNoOfCommitments |
| 84 | ); |
| 85 | self.other_commitments.insert(sender_id, commitments); |
| 86 | Ok(()) |
| 87 | } |
| 88 | |
| 89 | /// Process a received share from another party, verify it against the commitment receiver earlier |
| 90 | /// and store the shares |