pub struct KZG { /* private fields */ }
Expand description
Main interesting struct of the rust-kzg-bn254 crate. [Kzg] is a struct that holds the SRS points in monomial form, and provides methods for committing to a blob, (either via a Blob itself, or a PolynomialCoeffForm or PolynomialEvalForm), and generating and verifying proofs.
The Blob and PolynomialCoeffForm/PolynomialEvalForm structs are mostly https://en.wikipedia.org/wiki/Passive_data_structure with constructor and few helper methods.
Implementations§
Source§impl KZG
impl KZG
pub fn new() -> Self
Sourcepub fn calculate_and_store_roots_of_unity(
&mut self,
length_of_data_after_padding: u64,
) -> Result<(), KzgError>
pub fn calculate_and_store_roots_of_unity( &mut self, length_of_data_after_padding: u64, ) -> Result<(), KzgError>
Calculates the roots of unities and assigns it to the struct
§Arguments
length_of_data_after_padding
- Length of the blob data after padding in bytes.
§Returns
Result<(), KzgError>
§Details
- Generates roots of unity needed for FFT operations
§Example
use rust_kzg_bn254_prover::kzg::KZG;
use rust_kzg_bn254_primitives::blob::Blob;
use ark_std::One;
use ark_bn254::Fr;
let mut kzg = KZG::new();
let input_blob = Blob::from_raw_data(b"test blob data");
kzg.calculate_and_store_roots_of_unity(input_blob.len().try_into().unwrap()).unwrap();
pub fn get_roots_of_unities(&self) -> Vec<Fr>
Sourcepub fn get_nth_root_of_unity(&self, i: usize) -> Option<&Fr>
pub fn get_nth_root_of_unity(&self, i: usize) -> Option<&Fr>
helper function to get the
Sourcepub fn commit_eval_form(
&self,
polynomial: &PolynomialEvalForm,
srs: &SRS,
) -> Result<G1Affine, KzgError>
pub fn commit_eval_form( &self, polynomial: &PolynomialEvalForm, srs: &SRS, ) -> Result<G1Affine, KzgError>
Commit the polynomial with the srs values loaded into [Kzg].
Sourcepub fn commit_coeff_form(
&self,
polynomial: &PolynomialCoeffForm,
srs: &SRS,
) -> Result<G1Affine, KzgError>
pub fn commit_coeff_form( &self, polynomial: &PolynomialCoeffForm, srs: &SRS, ) -> Result<G1Affine, KzgError>
Commit the polynomial with the srs values loaded into [Kzg].
Sourcepub fn commit_blob(&self, blob: &Blob, srs: &SRS) -> Result<G1Affine, KzgError>
pub fn commit_blob(&self, blob: &Blob, srs: &SRS) -> Result<G1Affine, KzgError>
commit to a Blob, by transforming it into a PolynomialEvalForm and then calling [Kzg::commit_eval_form].
pub fn compute_proof_with_known_z_fr_index( &self, polynomial: &PolynomialEvalForm, index: u64, srs: &SRS, ) -> Result<G1Affine, KzgError>
Sourcepub fn compute_proof(
&self,
polynomial: &PolynomialEvalForm,
z_fr: &Fr,
srs: &SRS,
) -> Result<G1Affine, KzgError>
pub fn compute_proof( &self, polynomial: &PolynomialEvalForm, z_fr: &Fr, srs: &SRS, ) -> Result<G1Affine, KzgError>
Compute a kzg proof from a polynomial in evaluation form. We don’t currently support proofs for polynomials in coefficient form, but one can take the FFT of the polynomial in coefficient form to get the polynomial in evaluation form. This is available via the method PolynomialCoeffForm::to_eval_form. TODO(anupsv): Accept bytes instead of Fr element. Ref: https://github.com/Layr-Labs/rust-kzg-bn254/issues/29
Sourcepub fn compute_quotient_eval_on_domain(
&self,
z_fr: &Fr,
eval_fr: &[Fr],
value_fr: &Fr,
) -> Fr
pub fn compute_quotient_eval_on_domain( &self, z_fr: &Fr, eval_fr: &[Fr], value_fr: &Fr, ) -> Fr
refer to DA for more context
Trait Implementations§
impl StructuralPartialEq for KZG
Auto Trait Implementations§
impl Freeze for KZG
impl RefUnwindSafe for KZG
impl Send for KZG
impl Sync for KZG
impl Unpin for KZG
impl UnwindSafe for KZG
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more