Struct c_kzg::KzgSettings

source ·
#[repr(C)]
pub struct KzgSettings { /* private fields */ }
Expand description

Stores the setup and parameters needed for computing KZG proofs.

Implementations§

source§

impl KZGSettings

Holds the parameters of a kzg trusted setup ceremony.

source

pub fn load_trusted_setup( g1_monomial_bytes: &[u8], g1_lagrange_bytes: &[u8], g2_monomial_bytes: &[u8], precompute: u64, ) -> Result<Self, Error>

Initializes a trusted setup from a flat array of FIELD_ELEMENTS_PER_BLOB G1 points in monomial form, a flat array of FIELD_ELEMENTS_PER_BLOB G1 points in Lagrange form, and a flat array of 65 G2 points in monomial form.

source

pub fn load_trusted_setup_file( file_path: &Path, precompute: u64, ) -> Result<Self, Error>

Loads the trusted setup parameters from a file. The file format is as follows:

FIELD_ELEMENTS_PER_BLOB 65 # This is fixed and is used for providing multiproofs up to 64 field elements. FIELD_ELEMENT_PER_BLOB g1 byte values in Lagrange form 65 g2 byte values in monomial form FIELD_ELEMENT_PER_BLOB g1 byte values in monomial form

source

pub fn parse_kzg_trusted_setup( trusted_setup: &str, precompute: u64, ) -> Result<Self, Error>

Parses the contents of a KZG trusted setup file into a KzgSettings.

source

pub fn load_trusted_setup_file_inner( file_path: &CStr, precompute: u64, ) -> Result<Self, Error>

Loads the trusted setup parameters from a file.

Same as load_trusted_setup_file .

source

pub fn blob_to_kzg_commitment( &self, blob: &Blob, ) -> Result<KZGCommitment, Error>

source

pub fn compute_kzg_proof( &self, blob: &Blob, z_bytes: &Bytes32, ) -> Result<(KZGProof, Bytes32), Error>

source

pub fn compute_blob_kzg_proof( &self, blob: &Blob, commitment_bytes: &Bytes48, ) -> Result<KZGProof, Error>

source

pub fn verify_kzg_proof( &self, commitment_bytes: &Bytes48, z_bytes: &Bytes32, y_bytes: &Bytes32, proof_bytes: &Bytes48, ) -> Result<bool, Error>

source

pub fn verify_blob_kzg_proof( &self, blob: &Blob, commitment_bytes: &Bytes48, proof_bytes: &Bytes48, ) -> Result<bool, Error>

source

pub fn verify_blob_kzg_proof_batch( &self, blobs: &[Blob], commitments_bytes: &[Bytes48], proofs_bytes: &[Bytes48], ) -> Result<bool, Error>

source

pub fn compute_cells_and_kzg_proofs( &self, blob: &Blob, ) -> Result<(Box<[Cell; 128]>, Box<[KZGProof; 128]>), Error>

source

pub fn recover_cells_and_kzg_proofs( &self, cell_indices: &[u64], cells: &[Cell], ) -> Result<(Box<[Cell; 128]>, Box<[KZGProof; 128]>), Error>

source

pub fn verify_cell_kzg_proof_batch( &self, commitments_bytes: &[Bytes48], cell_indices: &[u64], cells: &[Cell], proofs_bytes: &[Bytes48], ) -> Result<bool, Error>

Trait Implementations§

source§

impl Debug for KZGSettings

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for KZGSettings

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Hash for KZGSettings

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for KZGSettings

source§

fn eq(&self, other: &KZGSettings) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for KZGSettings

source§

impl Send for KZGSettings

source§

impl StructuralPartialEq for KZGSettings

source§

impl Sync for KZGSettings

Safety: The memory for roots_of_unity and g1_values and g2_values are only freed on calling free_trusted_setup which only happens when we drop the struct.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.

source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.