/// Verifies that the complaint is indeed from the receiver
Verifies that the complaint is indeed from the receiver
Verifies that the complaint is indeed from the receiver
fn verify_pok(
    dkg_id: IDkgId,
    complaint: &CLibComplaint,
    complaint_bytes: &CLibComplaintBytes,
    receiver_public_key: &EphemeralPublicKey,
    receiver_public_key_bytes: &EphemeralPublicKeyBytes,
    dealer_public_key: &EphemeralPublicKey,
    dealer_public_key_bytes: &EphemeralPublicKeyBytes,
) -> Result<(), DkgVerifyResponseError> {
    let minus_hash = -complaint.pok_challenge.clone();
    let spec_t: EphemeralPublicKeyBytes = {
        let left = EphemeralPublicKey::from(&complaint.pok_response);
        let mut right = receiver_public_key.clone();
        right *= &minus_hash;
        (left + right).into()
    };
    let spec_u: EphemeralPublicKeyBytes = ((complaint.diffie_hellman.clone() * &minus_hash)
        + (dealer_public_key.clone() * &complaint.pok_response))
        .into();
    let spec_c = ChallengeDigest {
        dkg_id,
        dealer_public_key_bytes: *dealer_public_key_bytes,
        receiver_public_key_bytes: *receiver_public_key_bytes,
        diffie_hellman: complaint_bytes.diffie_hellman,
        spec_t,
        spec_u,
    }
    .digest();
    if complaint.pok_challenge != spec_c {
        Err(DkgVerifyResponseError::InvalidResponseError(
            InvalidArgumentError {
                message: "Invalid PoK in a complaint".to_string(),
            },
        ))
    } else {
        Ok(())
    }
}
fn verify_pok ( dkg_id : IDkgId , complaint : & CLibComplaint , complaint_bytes : & CLibComplaintBytes , receiver_public_key : & EphemeralPublicKey , receiver_public_key_bytes : & EphemeralPublicKeyBytes , dealer_public_key : & EphemeralPublicKey , dealer_public_key_bytes : & EphemeralPublicKeyBytes , ) -> Result < ( ) , DkgVerifyResponseError > { let minus_hash = - complaint . pok_challenge . clone ( ) ; let spec_t : EphemeralPublicKeyBytes = { let left = EphemeralPublicKey :: from ( & complaint . pok_response ) ; let mut right = receiver_public_key . clone ( ) ; right *= & minus_hash ; ( left + right ) . into ( ) } ; let spec_u : EphemeralPublicKeyBytes = ( ( complaint . diffie_hellman . clone ( ) * & minus_hash ) + ( dealer_public_key . clone ( ) * & complaint . pok_response ) ) . into ( ) ; let spec_c = ChallengeDigest { dkg_id , dealer_public_key_bytes : * dealer_public_key_bytes , receiver_public_key_bytes : * receiver_public_key_bytes , diffie_hellman : complaint_bytes . diffie_hellman , spec_t , spec_u , } . digest ( ) ; if complaint . pok_challenge != spec_c { Err ( DkgVerifyResponseError :: InvalidResponseError ( InvalidArgumentError { message : " " . to_string ( ) , } , ) ) } else { Ok ( ( ) ) } }
Verifies that the complaint is indeed from the receiver
Verifies that the complaint is indeed from the receiver
dkg_id
IDkgId
complaint
&CLibComplaint
complaint_bytes
&CLibComplaintBytes
receiver_public_key
&EphemeralPublicKey
receiver_public_key_bytes
&EphemeralPublicKeyBytes
dealer_public_key
&EphemeralPublicKey
dealer_public_key_bytes
&EphemeralPublicKeyBytes