Update kzg to get windows going, expose blst features (#4177)

* fmt

* update kzg

* use commit from main repo
This commit is contained in:
Divma
2023-04-10 19:05:01 -05:00
committed by GitHub
parent f6f63b18ed
commit fca8559acc
5 changed files with 40 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ mod trusted_setup;
pub use crate::{kzg_commitment::KzgCommitment, kzg_proof::KzgProof, trusted_setup::TrustedSetup};
use c_kzg::Bytes48;
pub use c_kzg::{
Blob, Error as CKzgError, KZGSettings, BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT,
Blob, Error as CKzgError, KzgSettings, BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT,
FIELD_ELEMENTS_PER_BLOB,
};
use std::path::PathBuf;
@@ -21,7 +21,7 @@ pub enum Error {
/// A wrapper over a kzg library that holds the trusted setup parameters.
pub struct Kzg {
trusted_setup: KZGSettings,
trusted_setup: KzgSettings,
}
impl Kzg {
@@ -32,7 +32,7 @@ impl Kzg {
/// The number of G2 points should be equal to 65.
pub fn new_from_trusted_setup(trusted_setup: TrustedSetup) -> Result<Self, Error> {
Ok(Self {
trusted_setup: KZGSettings::load_trusted_setup(
trusted_setup: KzgSettings::load_trusted_setup(
trusted_setup.g1_points(),
trusted_setup.g2_points(),
)
@@ -47,7 +47,7 @@ impl Kzg {
#[deprecated]
pub fn new_from_file(file_path: PathBuf) -> Result<Self, Error> {
Ok(Self {
trusted_setup: KZGSettings::load_trusted_setup_file(file_path)
trusted_setup: KzgSettings::load_trusted_setup_file(file_path)
.map_err(Error::InvalidTrustedSetup)?,
})
}
@@ -58,7 +58,7 @@ impl Kzg {
blob: Blob,
kzg_commitment: KzgCommitment,
) -> Result<KzgProof, Error> {
c_kzg::KZGProof::compute_blob_kzg_proof(blob, kzg_commitment.into(), &self.trusted_setup)
c_kzg::KzgProof::compute_blob_kzg_proof(blob, kzg_commitment.into(), &self.trusted_setup)
.map_err(Error::KzgProofComputationFailed)
.map(|proof| KzgProof(proof.to_bytes().into_inner()))
}
@@ -70,7 +70,7 @@ impl Kzg {
kzg_commitment: KzgCommitment,
kzg_proof: KzgProof,
) -> Result<bool, Error> {
c_kzg::KZGProof::verify_blob_kzg_proof(
c_kzg::KzgProof::verify_blob_kzg_proof(
blob,
kzg_commitment.into(),
kzg_proof.into(),
@@ -100,7 +100,7 @@ impl Kzg {
.map(|proof| Bytes48::from_bytes(&proof.0))
.collect::<Result<Vec<Bytes48>, _>>()
.map_err(Error::InvalidBytes)?;
c_kzg::KZGProof::verify_blob_kzg_proof_batch(
c_kzg::KzgProof::verify_blob_kzg_proof_batch(
blobs,
&commitments_bytes,
&proofs_bytes,
@@ -111,7 +111,7 @@ impl Kzg {
/// Converts a blob to a kzg commitment.
pub fn blob_to_kzg_commitment(&self, blob: Blob) -> Result<KzgCommitment, Error> {
c_kzg::KZGCommitment::blob_to_kzg_commitment(blob, &self.trusted_setup)
c_kzg::KzgCommitment::blob_to_kzg_commitment(blob, &self.trusted_setup)
.map_err(Error::InvalidBlob)
.map(|com| KzgCommitment(com.to_bytes().into_inner()))
}