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
impl KZGSettings
Holds the parameters of a kzg trusted setup ceremony.
sourcepub fn load_trusted_setup(
g1_monomial_bytes: &[u8],
g1_lagrange_bytes: &[u8],
g2_monomial_bytes: &[u8],
precompute: u64,
) -> Result<Self, Error>
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.
sourcepub fn load_trusted_setup_file(
file_path: &Path,
precompute: u64,
) -> Result<Self, Error>
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
sourcepub fn parse_kzg_trusted_setup(
trusted_setup: &str,
precompute: u64,
) -> Result<Self, Error>
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.
sourcepub fn load_trusted_setup_file_inner(
file_path: &CStr,
precompute: u64,
) -> Result<Self, Error>
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
.
pub fn blob_to_kzg_commitment( &self, blob: &Blob, ) -> Result<KZGCommitment, Error>
pub fn compute_kzg_proof( &self, blob: &Blob, z_bytes: &Bytes32, ) -> Result<(KZGProof, Bytes32), Error>
pub fn compute_blob_kzg_proof( &self, blob: &Blob, commitment_bytes: &Bytes48, ) -> Result<KZGProof, Error>
pub fn verify_kzg_proof( &self, commitment_bytes: &Bytes48, z_bytes: &Bytes32, y_bytes: &Bytes32, proof_bytes: &Bytes48, ) -> Result<bool, Error>
pub fn verify_blob_kzg_proof( &self, blob: &Blob, commitment_bytes: &Bytes48, proof_bytes: &Bytes48, ) -> Result<bool, Error>
pub fn verify_blob_kzg_proof_batch( &self, blobs: &[Blob], commitments_bytes: &[Bytes48], proofs_bytes: &[Bytes48], ) -> Result<bool, Error>
pub fn compute_cells_and_kzg_proofs( &self, blob: &Blob, ) -> Result<(Box<[Cell; 128]>, Box<[KZGProof; 128]>), Error>
pub fn recover_cells_and_kzg_proofs( &self, cell_indices: &[u64], cells: &[Cell], ) -> Result<(Box<[Cell; 128]>, Box<[KZGProof; 128]>), Error>
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
impl Debug for KZGSettings
source§impl Drop for KZGSettings
impl Drop for KZGSettings
source§impl Hash for KZGSettings
impl Hash for KZGSettings
source§impl PartialEq for KZGSettings
impl PartialEq for KZGSettings
impl Eq for KZGSettings
impl Send for KZGSettings
impl StructuralPartialEq for KZGSettings
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.