pub(crate) fn decrypt_and_check(
    ciphertext: &MEGaCiphertext,
    commitment: &PolynomialCommitment,
    associated_data: &[u8],
    dealer_index: usize,
    receiver_index: usize,
    secret_key: &MEGaPrivateKey,
    public_key: &MEGaPublicKey,
) -> ThresholdEcdsaResult<CommitmentOpening> {
    let opening = match ciphertext {
        MEGaCiphertext::Single(ciphertext) => {
            let opening = mega_decrypt_single(
                ciphertext,
                associated_data,
                dealer_index,
                receiver_index,
                secret_key,
                public_key,
            )?;
            CommitmentOpening::Simple(opening)
        }

        MEGaCiphertext::Pairs(ciphertext) => {
            let opening = mega_decrypt_pair(
                ciphertext,
                associated_data,
                dealer_index,
                receiver_index,
                secret_key,
                public_key,
            )?;
            CommitmentOpening::Pedersen(opening.0, opening.1)
        }
    };

    let commitment_eval_point =
        EccScalar::from_node_index(secret_key.curve().curve_type(), receiver_index as NodeIndex);
    if commitment.check_opening(&commitment_eval_point, &opening)? {
        Ok(opening)
    } else {
        Err(ThresholdEcdsaError::InconsistentCommitments)
    }
}
// Decrypt a MEGa ciphertext and return the encrypted commitment opening
Decrypt a MEGa ciphertext and return the encrypted commitment opening
Decrypt a MEGa ciphertext and return the encrypted commitment opening
pub(crate) fn decrypt_and_check(
    ciphertext: &MEGaCiphertext,
    commitment: &PolynomialCommitment,
    associated_data: &[u8],
    dealer_index: usize,
    receiver_index: usize,
    secret_key: &MEGaPrivateKey,
    public_key: &MEGaPublicKey,
) -> ThresholdEcdsaResult<CommitmentOpening> {
    let opening = match ciphertext {
        MEGaCiphertext::Single(ciphertext) => {
            let opening = mega_decrypt_single(
                ciphertext,
                associated_data,
                dealer_index,
                receiver_index,
                secret_key,
                public_key,
            )?;
            CommitmentOpening::Simple(opening)
        }
        MEGaCiphertext::Pairs(ciphertext) => {
            let opening = mega_decrypt_pair(
                ciphertext,
                associated_data,
                dealer_index,
                receiver_index,
                secret_key,
                public_key,
            )?;
            CommitmentOpening::Pedersen(opening.0, opening.1)
        }
    };
    let commitment_eval_point =
        EccScalar::from_node_index(secret_key.curve().curve_type(), receiver_index as NodeIndex);
    if commitment.check_opening(&commitment_eval_point, &opening)? {
        Ok(opening)
    } else {
        Err(ThresholdEcdsaError::InconsistentCommitments)
    }
}
pub ( crate ) fn decrypt_and_check ( ciphertext : & MEGaCiphertext , commitment : & PolynomialCommitment , associated_data : & [ u8 ] , dealer_index : usize , receiver_index : usize , secret_key : & MEGaPrivateKey , public_key : & MEGaPublicKey , ) -> ThresholdEcdsaResult < CommitmentOpening > { let opening = match ciphertext { MEGaCiphertext :: Single ( ciphertext ) => { let opening = mega_decrypt_single ( ciphertext , associated_data , dealer_index , receiver_index , secret_key , public_key , ) ? ; CommitmentOpening :: Simple ( opening ) } MEGaCiphertext :: Pairs ( ciphertext ) => { let opening = mega_decrypt_pair ( ciphertext , associated_data , dealer_index , receiver_index , secret_key , public_key , ) ? ; CommitmentOpening :: Pedersen ( opening . 0 , opening . 1 ) } } ; let commitment_eval_point = EccScalar :: from_node_index ( secret_key . curve ( ) . curve_type ( ) , receiver_index as NodeIndex ) ; if commitment . check_opening ( & commitment_eval_point , & opening ) ? { Ok ( opening ) } else { Err ( ThresholdEcdsaError :: InconsistentCommitments ) } }
Decrypt a MEGa ciphertext and return the encrypted commitment opening
Decrypt a MEGa ciphertext and return the encrypted commitment opening
ciphertext
&MEGaCiphertext
commitment
&PolynomialCommitment
associated_data
&[u8]
dealer_index
usize
receiver_index
usize
secret_key
&MEGaPrivateKey
public_key
&MEGaPublicKey
ciphertext
&MEGaCiphertext
commitment
&PolynomialCommitment
associated_data
&[u8]
dealer_index
usize
receiver_index
usize
secret_key
&MEGaPrivateKey
public_key
&MEGaPublicKey