Remove c-kzg (#8930)

#7330


  Removes `c-kzg` from our `kzg` crate and rely fully on the `rust_eth_kzg` crate.

This removes the old `Blob` type entirely and instead handles `rust_eth_kzg::KzgBlobRef`s directly which allows us to avoid some extra stack allocations . Similarly, we make `Bytes32` and `Bytes48` type aliases rather than structs as this fits better with the new `rust_eth_kzg` API.


Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
Mac L
2026-03-11 07:43:26 +02:00
committed by GitHub
parent 2bb79f43aa
commit 815040dc3c
14 changed files with 129 additions and 188 deletions

View File

@@ -3,7 +3,7 @@ use std::{fmt::Debug, hash::Hash, sync::Arc};
use bls::Signature;
use context_deserialize::context_deserialize;
use educe::Educe;
use kzg::{BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT, Blob as KzgBlob, Kzg, KzgCommitment, KzgProof};
use kzg::{BYTES_PER_BLOB, BYTES_PER_FIELD_ELEMENT, Kzg, KzgCommitment, KzgProof};
use merkle_proof::{MerkleTreeError, merkle_root_from_branch, verify_merkle_proof};
use rand::Rng;
use safe_arith::ArithError;
@@ -253,14 +253,17 @@ impl<E: EthSpec> BlobSidecar<E> {
let blob = Blob::<E>::new(blob_bytes)
.map_err(|e| format!("error constructing random blob: {:?}", e))?;
let kzg_blob = KzgBlob::from_bytes(&blob).unwrap();
let kzg_blob: &[u8; BYTES_PER_BLOB] = blob
.as_ref()
.try_into()
.map_err(|e| format!("error converting blob to kzg blob ref: {:?}", e))?;
let commitment = kzg
.blob_to_kzg_commitment(&kzg_blob)
.blob_to_kzg_commitment(kzg_blob)
.map_err(|e| format!("error computing kzg commitment: {:?}", e))?;
let proof = kzg
.compute_blob_kzg_proof(&kzg_blob, commitment)
.compute_blob_kzg_proof(kzg_blob, commitment)
.map_err(|e| format!("error computing kzg proof: {:?}", e))?;
Ok(Self {

View File

@@ -1,6 +1,6 @@
pub mod consts;
pub use kzg::{Blob as KzgBlob, Error as KzgError, Kzg, KzgCommitment, KzgProof};
pub use kzg::{Error as KzgError, Kzg, KzgCommitment, KzgProof};
use ssz_types::VariableList;