pub struct KZG10<E: Pairing, P: DenseUVPolynomial<E::ScalarField>> { /* private fields */ }
Expand description

KZG10 is an implementation of the polynomial commitment scheme of Kate, Zaverucha and Goldbgerg

Implementations§

source§

impl<E, P> KZG10<E, P>where E: Pairing, P: DenseUVPolynomial<E::ScalarField, Point = E::ScalarField>, for<'a, 'b> &'a P: Div<&'b P, Output = P>,

source

pub fn setup<R: RngCore>( max_degree: usize, produce_g2_powers: bool, rng: &mut R ) -> Result<UniversalParams<E>, Error>

Constructs public parameters when given as input the maximum degree degree for the polynomial commitment scheme.

Examples
use ark_poly_commit::kzg10::KZG10;
use ark_bls12_381::Bls12_381;
use ark_bls12_381::Fr;
use ark_poly::univariate::DensePolynomial;
use ark_ec::pairing::Pairing;
use ark_std::test_rng;
type UniPoly_381 = DensePolynomial<<Bls12_381 as Pairing>::ScalarField>;

let rng = &mut test_rng();
let params = KZG10::<Bls12_381, UniPoly_381>::setup(10, false, rng).expect("Setup failed");
source

pub fn commit( powers: &Powers<'_, E>, polynomial: &P, hiding_bound: Option<usize>, rng: Option<&mut dyn RngCore> ) -> Result<(Commitment<E>, Randomness<E::ScalarField, P>), Error>

Outputs a commitment to polynomial.

Examples
use ark_poly_commit::kzg10::{KZG10, Powers};
use ark_bls12_381::Bls12_381;
use ark_bls12_381::Fr;
use ark_poly::DenseUVPolynomial;
use ark_poly::univariate::DensePolynomial;
use ark_ec::pairing::Pairing;
use ark_ec::AffineRepr;
use ark_std::test_rng;
use ark_std::Zero;
type UniPoly_381 = DensePolynomial<<Bls12_381 as Pairing>::ScalarField>;

let rng = &mut test_rng();
let params = KZG10::<Bls12_381, UniPoly_381>::setup(10, false, rng).expect("Setup failed");
let powers_of_g = params.powers_of_g[..=10].to_vec();
let powers_of_gamma_g = (0..=10)
    .map(|i| params.powers_of_gamma_g[&i])
    .collect();
let powers = Powers {
    powers_of_g: ark_std::borrow::Cow::Owned(powers_of_g),
    powers_of_gamma_g: ark_std::borrow::Cow::Owned(powers_of_gamma_g),
};
let secret_poly = UniPoly_381::rand(10, rng);
let (comm, r) = KZG10::<Bls12_381, UniPoly_381>::commit(&powers, &secret_poly, None, None).expect("Commitment failed");
assert!(!comm.0.is_zero(), "Commitment should not be zero");
assert!(!r.is_hiding(), "Commitment should not be hiding");
source

pub fn compute_witness_polynomial( p: &P, point: P::Point, randomness: &Randomness<E::ScalarField, P> ) -> Result<(P, Option<P>), Error>

Compute witness polynomial.

The witness polynomial w(x) the quotient of the division (p(x) - p(z)) / (x - z) Observe that this quotient does not change with z because p(z) is the remainder term. We can therefore omit p(z) when computing the quotient.

source

pub fn check( vk: &VerifierKey<E>, comm: &Commitment<E>, point: E::ScalarField, value: E::ScalarField, proof: &Proof<E> ) -> Result<bool, Error>

Verifies that value is the evaluation at point of the polynomial committed inside comm.

source

pub fn batch_check<R: RngCore>( vk: &VerifierKey<E>, commitments: &[Commitment<E>], points: &[E::ScalarField], values: &[E::ScalarField], proofs: &[Proof<E>], rng: &mut R ) -> Result<bool, Error>

Check that each proof_i in proofs is a valid proof of evaluation for commitment_i at point_i.

Auto Trait Implementations§

§

impl<E, P> RefUnwindSafe for KZG10<E, P>where E: RefUnwindSafe, P: RefUnwindSafe,

§

impl<E, P> Send for KZG10<E, P>where P: Send,

§

impl<E, P> Sync for KZG10<E, P>

§

impl<E, P> Unpin for KZG10<E, P>where E: Unpin, P: Unpin,

§

impl<E, P> UnwindSafe for KZG10<E, P>where E: UnwindSafe, P: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V