/// Checks whether my share is correct in all dealings and responds with any
/// complaints.
///
/// # Arguments
/// * `seed` - A random seed used to generate complaints.
/// * `receiver_secret_key_bytes` - the current node is the receiver; this is
///   the current node's secret ephemeral key used to decrypt the threshold key
///   share.
/// * `dkg_id` - identifier for the key generation
/// * `verified_dealings` - for each qualified dealer, the dealer's public key
///   and the key share for the current node.
/// * `receiver_index` - each receiver has an index; this is the index for the
///   current node.
/// # Panics
/// This method is not expected to panic.
/// # Errors
/// This method MUST return an error if:
/// * one of the keys is malformed.  It is the caller's responsibility to verify
///   that the data is well formed before calling this method.
Checks whether my share is correct in all dealings and responds with any
complaints.
Checks whether my share is correct in all dealings and responds with any complaints .
pub fn create_response(
    seed: Randomness,
    receiver_secret_key_bytes: &EphemeralSecretKeyBytes,
    dkg_id: IDkgId,
    verified_dealings: &BTreeMap<EphemeralPublicKeyBytes, CLibDealingBytes>,
    receiver_index: NodeIndex,
) -> Result<CLibResponseBytes, DkgCreateResponseError> {
    let receiver_secret_key = EphemeralSecretKey::try_from(receiver_secret_key_bytes)
        .map_err(DkgCreateResponseError::MalformedSecretKeyError)?;
    let receiver_public_key = EphemeralPublicKey::from(&receiver_secret_key);
    let mut rng = ChaChaRng::from_seed(seed.get());
    let complaints: Result<
        BTreeMap<EphemeralPublicKeyBytes, Option<CLibComplaintBytes>>,
        DkgCreateResponseError,
    > = verified_dealings
        .iter()
        .map(|(dealer_public_key_bytes, dealing)| {
            complaint::complain_maybe(
                &mut rng,
                dkg_id,
                receiver_index,
                &receiver_secret_key,
                &receiver_public_key,
                dealer_public_key_bytes,
                dealing,
            )
            .map(|complaint_maybe| (*dealer_public_key_bytes, complaint_maybe))
        })
        .collect();
    let complaints = complaints?;
    Ok(CLibResponseBytes { complaints })
}
pub fn create_response ( seed : Randomness , receiver_secret_key_bytes : & EphemeralSecretKeyBytes , dkg_id : IDkgId , verified_dealings : & BTreeMap < EphemeralPublicKeyBytes , CLibDealingBytes > , receiver_index : NodeIndex , ) -> Result < CLibResponseBytes , DkgCreateResponseError > { let receiver_secret_key = EphemeralSecretKey :: try_from ( receiver_secret_key_bytes ) . map_err ( DkgCreateResponseError :: MalformedSecretKeyError ) ? ; let receiver_public_key = EphemeralPublicKey :: from ( & receiver_secret_key ) ; let mut rng = ChaChaRng :: from_seed ( seed . get ( ) ) ; let complaints : Result < BTreeMap < EphemeralPublicKeyBytes , Option < CLibComplaintBytes > > , DkgCreateResponseError , > = verified_dealings . iter ( ) . map ( | ( dealer_public_key_bytes , dealing ) | { complaint :: complain_maybe ( & mut rng , dkg_id , receiver_index , & receiver_secret_key , & receiver_public_key , dealer_public_key_bytes , dealing , ) . map ( | complaint_maybe | ( * dealer_public_key_bytes , complaint_maybe ) ) } ) . collect ( ) ; let complaints = complaints ? ; Ok ( CLibResponseBytes { complaints } ) }
Checks whether my share is correct in all dealings and responds with any
complaints.
Checks whether my share is correct in all dealings and responds with any complaints .
seed
Randomness
receiver_secret_key_bytes
&EphemeralSecretKeyBytes
dkg_id
IDkgId
verified_dealings
&BTreeMap<EphemeralPublicKeyBytes, CLibDealingBytes>
receiver_index
NodeIndex
panics
This method is not expected to panic.
This method is not expected to panic .
errors
This method MUST return an error if:
one of the keys is malformed.  It is the caller's responsibility to verify
that the data is well formed before calling this method.
This method MUST return an error if : one of the keys is malformed . It is the caller ' s responsibility to verify that the data is well formed before calling this method .