fn verify_commitment_openings(
        commitment: &PolynomialCommitment,
        openings: &[CommitmentOpening],
    ) -> ThresholdEcdsaResult<()> {
        let constant_term = commitment.constant_term();
        let curve_type = constant_term.curve_type();
        let curve = EccCurve::new(curve_type);

        match commitment {
            PolynomialCommitment::Simple(_) => {
                let mut g_openings = Vec::with_capacity(openings.len());

                for (idx, opening) in openings.iter().enumerate() {
                    if let CommitmentOpening::Simple(value) = opening {
                        let index = EccScalar::from_node_index(curve_type, idx as NodeIndex);
                        g_openings.push((index, *value));
                    } else {
                        panic!("Unexpected opening type");
                    }
                }

                let dlog = EccScalar::interpolation_at_zero(&g_openings)?;
                let pt = dlog.curve().generator_g()?.scalar_mul(&dlog)?;
                assert_eq!(pt, constant_term);
            }

            PolynomialCommitment::Pedersen(_) => {
                let mut g_openings = Vec::with_capacity(openings.len());
                let mut h_openings = Vec::with_capacity(openings.len());

                for (idx, opening) in openings.iter().enumerate() {
                    if let CommitmentOpening::Pedersen(value, mask) = opening {
                        let index = EccScalar::from_node_index(curve_type, idx as NodeIndex);
                        g_openings.push((index, *value));
                        h_openings.push((index, *mask));
                    } else {
                        panic!("Unexpected opening type");
                    }
                }

                let dlog_g = EccScalar::interpolation_at_zero(&g_openings)?;
                let dlog_h = EccScalar::interpolation_at_zero(&h_openings)?;
                let pt_g = curve.generator_g()?.scalar_mul(&dlog_g)?;
                let pt_h = curve.generator_h()?.scalar_mul(&dlog_h)?;
                let pt = pt_g.add_points(&pt_h)?;
                assert_eq!(pt, constant_term);
            }
        }

        Ok(())
    }
/// Verified that parties holding secret `openings` can reconstruct the
/// opening of the constant term of `commitment`.
Verified that parties holding secret `openings` can reconstruct the
opening of the constant term of `commitment`.
Verified that parties holding secret ` openings ` can reconstruct the opening of the constant term of ` commitment ` .
fn verify_commitment_openings(
        commitment: &PolynomialCommitment,
        openings: &[CommitmentOpening],
    ) -> ThresholdEcdsaResult<()> {
        let constant_term = commitment.constant_term();
        let curve_type = constant_term.curve_type();
        let curve = EccCurve::new(curve_type);
        match commitment {
            PolynomialCommitment::Simple(_) => {
                let mut g_openings = Vec::with_capacity(openings.len());
                for (idx, opening) in openings.iter().enumerate() {
                    if let CommitmentOpening::Simple(value) = opening {
                        let index = EccScalar::from_node_index(curve_type, idx as NodeIndex);
                        g_openings.push((index, *value));
                    } else {
                        panic!("Unexpected opening type");
                    }
                }
                let dlog = EccScalar::interpolation_at_zero(&g_openings)?;
                let pt = dlog.curve().generator_g()?.scalar_mul(&dlog)?;
                assert_eq!(pt, constant_term);
            }
            PolynomialCommitment::Pedersen(_) => {
                let mut g_openings = Vec::with_capacity(openings.len());
                let mut h_openings = Vec::with_capacity(openings.len());
                for (idx, opening) in openings.iter().enumerate() {
                    if let CommitmentOpening::Pedersen(value, mask) = opening {
                        let index = EccScalar::from_node_index(curve_type, idx as NodeIndex);
                        g_openings.push((index, *value));
                        h_openings.push((index, *mask));
                    } else {
                        panic!("Unexpected opening type");
                    }
                }
                let dlog_g = EccScalar::interpolation_at_zero(&g_openings)?;
                let dlog_h = EccScalar::interpolation_at_zero(&h_openings)?;
                let pt_g = curve.generator_g()?.scalar_mul(&dlog_g)?;
                let pt_h = curve.generator_h()?.scalar_mul(&dlog_h)?;
                let pt = pt_g.add_points(&pt_h)?;
                assert_eq!(pt, constant_term);
            }
        }
        Ok(())
    }
fn verify_commitment_openings ( commitment : & PolynomialCommitment , openings : & [ CommitmentOpening ] , ) -> ThresholdEcdsaResult < ( ) > { let constant_term = commitment . constant_term ( ) ; let curve_type = constant_term . curve_type ( ) ; let curve = EccCurve :: new ( curve_type ) ; match commitment { PolynomialCommitment :: Simple ( _ ) => { let mut g_openings = Vec :: with_capacity ( openings . len ( ) ) ; for ( idx , opening ) in openings . iter ( ) . enumerate ( ) { if let CommitmentOpening :: Simple ( value ) = opening { let index = EccScalar :: from_node_index ( curve_type , idx as NodeIndex ) ; g_openings . push ( ( index , * value ) ) ; } else { panic ! ( " " ) ; } } let dlog = EccScalar :: interpolation_at_zero ( & g_openings ) ? ; let pt = dlog . curve ( ) . generator_g ( ) ? . scalar_mul ( & dlog ) ? ; assert_eq ! ( pt constant_term ) ; } PolynomialCommitment :: Pedersen ( _ ) => { let mut g_openings = Vec :: with_capacity ( openings . len ( ) ) ; let mut h_openings = Vec :: with_capacity ( openings . len ( ) ) ; for ( idx , opening ) in openings . iter ( ) . enumerate ( ) { if let CommitmentOpening :: Pedersen ( value , mask ) = opening { let index = EccScalar :: from_node_index ( curve_type , idx as NodeIndex ) ; g_openings . push ( ( index , * value ) ) ; h_openings . push ( ( index , * mask ) ) ; } else { panic ! ( " " ) ; } } let dlog_g = EccScalar :: interpolation_at_zero ( & g_openings ) ? ; let dlog_h = EccScalar :: interpolation_at_zero ( & h_openings ) ? ; let pt_g = curve . generator_g ( ) ? . scalar_mul ( & dlog_g ) ? ; let pt_h = curve . generator_h ( ) ? . scalar_mul ( & dlog_h ) ? ; let pt = pt_g . add_points ( & pt_h ) ? ; assert_eq ! ( pt constant_term ) ; } } Ok ( ( ) ) }
Verified that parties holding secret `openings` can reconstruct the
opening of the constant term of `commitment`.
Verified that parties holding secret ` openings ` can reconstruct the opening of the constant term of ` commitment ` .
commitment
&PolynomialCommitment
openings
&[CommitmentOpening]
commitment
&PolynomialCommitment
openings
&[CommitmentOpening]