pub fn verify_response(
    dkg_id: IDkgId,
    verified_dealings: &BTreeMap<EphemeralPublicKeyBytes, CLibDealingBytes>,
    receiver_index: NodeIndex,
    receiver_public_key_bytes: EphemeralPublicKeyBytes,
    response: &CLibResponseBytes,
) -> Result<(), DkgVerifyResponseError> {
    if verified_dealings.len() != response.complaints.len() {
        return Err(DkgVerifyResponseError::InvalidResponseError(
            InvalidArgumentError {
                message: "CLibDealings don't match responses".to_string(),
            },
        ));
    }
    for (dealer_public_key_bytes, complaint_maybe) in &response.complaints {
        let dealing = verified_dealings
            .get(dealer_public_key_bytes)
            .ok_or_else(|| {
                DkgVerifyResponseError::InvalidResponseError(InvalidArgumentError {
                    message: "Cannot respond to no dealing".to_string(),
                })
            })?;
        if let Some(complaint) = complaint_maybe {
            complaint::verify_complaint(
                dkg_id,
                dealing,
                receiver_index,
                dealer_public_key_bytes,
                &receiver_public_key_bytes,
                complaint,
            )?
        }
    }
    Ok(())
}
/// Verifies the response against all dealings. This is used before including
/// the response in a block.
///
/// # Arguments
/// * `dkg_id` - identifier for the key generation
/// * `verified_dealings` - for each qualified dealer, their dealing.
/// * `receiver_index` - each receiver has an index; this is the index for the
///   responding receiver.
/// * `receiver_key` - the receiver's public key, used to verify that the
///   receiver's complaints are legitimate.
/// * `response` - the response being verified.
/// # Panics
/// This method is not expected to panic.
/// # Errors
/// This method MUST return an error if:
/// * the length of `verified_dealings` is not the same as that of `response`.
/// * a complaint in the response is invalid.
Verifies the response against all dealings. This is used before including
the response in a block.
Verifies the response against all dealings . This is used before including the response in a block .
pub fn verify_response(
    dkg_id: IDkgId,
    verified_dealings: &BTreeMap<EphemeralPublicKeyBytes, CLibDealingBytes>,
    receiver_index: NodeIndex,
    receiver_public_key_bytes: EphemeralPublicKeyBytes,
    response: &CLibResponseBytes,
) -> Result<(), DkgVerifyResponseError> {
    if verified_dealings.len() != response.complaints.len() {
        return Err(DkgVerifyResponseError::InvalidResponseError(
            InvalidArgumentError {
                message: "CLibDealings don't match responses".to_string(),
            },
        ));
    }
    for (dealer_public_key_bytes, complaint_maybe) in &response.complaints {
        let dealing = verified_dealings
            .get(dealer_public_key_bytes)
            .ok_or_else(|| {
                DkgVerifyResponseError::InvalidResponseError(InvalidArgumentError {
                    message: "Cannot respond to no dealing".to_string(),
                })
            })?;
        if let Some(complaint) = complaint_maybe {
            complaint::verify_complaint(
                dkg_id,
                dealing,
                receiver_index,
                dealer_public_key_bytes,
                &receiver_public_key_bytes,
                complaint,
            )?
        }
    }
    Ok(())
}
pub fn verify_response ( dkg_id : IDkgId , verified_dealings : & BTreeMap < EphemeralPublicKeyBytes , CLibDealingBytes > , receiver_index : NodeIndex , receiver_public_key_bytes : EphemeralPublicKeyBytes , response : & CLibResponseBytes , ) -> Result < ( ) , DkgVerifyResponseError > { if verified_dealings . len ( ) != response . complaints . len ( ) { return Err ( DkgVerifyResponseError :: InvalidResponseError ( InvalidArgumentError { message : " " . to_string ( ) , } , ) ) ; } for ( dealer_public_key_bytes , complaint_maybe ) in & response . complaints { let dealing = verified_dealings . get ( dealer_public_key_bytes ) . ok_or_else ( | | { DkgVerifyResponseError :: InvalidResponseError ( InvalidArgumentError { message : " " . to_string ( ) , } ) } ) ? ; if let Some ( complaint ) = complaint_maybe { complaint :: verify_complaint ( dkg_id , dealing , receiver_index , dealer_public_key_bytes , & receiver_public_key_bytes , complaint , ) ? } } Ok ( ( ) ) }
Verifies the response against all dealings.
Verifies the response against all dealings .
dkg_id
IDkgId
verified_dealings
&BTreeMap<EphemeralPublicKeyBytes, CLibDealingBytes>
receiver_index
NodeIndex
receiver_public_key_bytes
EphemeralPublicKeyBytes
response
&CLibResponseBytes
dkg_id
IDkgId
verified_dealings
&BTreeMap<EphemeralPublicKeyBytes, CLibDealingBytes>
receiver_index
NodeIndex
receiver_public_key_bytes
EphemeralPublicKeyBytes
response
&CLibResponseBytes
panics
This method is not expected to panic.
This method is not expected to panic .
errors
This method MUST return an error if:
the length of `verified_dealings` is not the same as that of `response`.
a complaint in the response is invalid.
This method MUST return an error if : the length of ` verified_dealings ` is not the same as that of ` response ` . a complaint in the response is invalid .