mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
merge eip4844
This commit is contained in:
@@ -136,13 +136,6 @@ pub fn validate_blob_for_gossip<T: BeaconChainTypes>(
|
||||
});
|
||||
}
|
||||
|
||||
// Verify that kzg commitments in the block are valid BLS g1 points
|
||||
for commitment in kzg_commitments {
|
||||
if kzg::bytes_to_g1(&commitment.0).is_err() {
|
||||
return Err(BlobError::InvalidKZGCommitment);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate commitments agains transactions in the block.
|
||||
if verify_kzg_commitments_against_transactions::<T::EthSpec>(transactions, kzg_commitments)
|
||||
.is_err()
|
||||
@@ -150,16 +143,6 @@ pub fn validate_blob_for_gossip<T: BeaconChainTypes>(
|
||||
return Err(BlobError::TransactionCommitmentMismatch);
|
||||
}
|
||||
|
||||
// Check that blobs are < BLS_MODULUS
|
||||
// TODO(pawan): Add this check after there's some resolution of this
|
||||
// issue https://github.com/ethereum/c-kzg-4844/issues/11
|
||||
// As of now, `bytes_to_bls_field` does not fail in the c-kzg library if blob >= BLS_MODULUS
|
||||
|
||||
// Validate that kzg proof is a valid g1 point
|
||||
if kzg::bytes_to_g1(&blob_sidecar.kzg_aggregated_proof.0).is_err() {
|
||||
return Err(BlobError::InvalidKzgProof);
|
||||
}
|
||||
|
||||
// Validatate that the kzg proof is valid against the commitments and blobs
|
||||
let kzg = chain
|
||||
.kzg
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
use kzg::{Error as KzgError, Kzg, BYTES_PER_BLOB};
|
||||
use types::{Blob, BlobsSidecar, EthSpec, Hash256, KzgCommitment, KzgProof, Slot};
|
||||
|
||||
fn ssz_blob_to_crypto_blob<T: EthSpec>(blob: Blob<T>) -> Option<[u8; BYTES_PER_BLOB]> {
|
||||
if blob.len() != BYTES_PER_BLOB {
|
||||
return None;
|
||||
}
|
||||
fn ssz_blob_to_crypto_blob<T: EthSpec>(blob: Blob<T>) -> kzg::Blob {
|
||||
let blob_vec: Vec<u8> = blob.into();
|
||||
let mut arr = [0; BYTES_PER_BLOB];
|
||||
arr.copy_from_slice(&blob_vec);
|
||||
Some(arr)
|
||||
arr.into()
|
||||
}
|
||||
|
||||
pub fn validate_blobs_sidecar<T: EthSpec>(
|
||||
@@ -29,8 +26,7 @@ pub fn validate_blobs_sidecar<T: EthSpec>(
|
||||
.blobs
|
||||
.into_iter()
|
||||
.map(|blob| ssz_blob_to_crypto_blob::<T>(blob.clone())) // TODO(pawan): avoid this clone
|
||||
.collect::<Option<Vec<_>>>()
|
||||
.ok_or_else(|| KzgError::InvalidBlob("Invalid blobs in sidecar".to_string()))?;
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
kzg.verify_aggregate_kzg_proof(
|
||||
&blobs,
|
||||
@@ -46,13 +42,12 @@ pub fn compute_aggregate_kzg_proof<T: EthSpec>(
|
||||
let blobs = blobs
|
||||
.into_iter()
|
||||
.map(|blob| ssz_blob_to_crypto_blob::<T>(blob.clone())) // TODO(pawan): avoid this clone
|
||||
.collect::<Option<Vec<_>>>()
|
||||
.ok_or_else(|| KzgError::InvalidBlob("Invalid blobs".to_string()))?;
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
kzg.compute_aggregate_kzg_proof(&blobs)
|
||||
}
|
||||
|
||||
pub fn blob_to_kzg_commitment<T: EthSpec>(kzg: &Kzg, blob: Blob<T>) -> Option<KzgCommitment> {
|
||||
let blob = ssz_blob_to_crypto_blob::<T>(blob)?;
|
||||
Some(kzg.blob_to_kzg_commitment(blob))
|
||||
pub fn blob_to_kzg_commitment<T: EthSpec>(kzg: &Kzg, blob: Blob<T>) -> KzgCommitment {
|
||||
let blob = ssz_blob_to_crypto_blob::<T>(blob);
|
||||
kzg.blob_to_kzg_commitment(blob)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user