Skip to content

Commit 88b6bd9

Browse files
Add peerdas KZG library and use it for data column construction and cell kzg verification (sigp#5701, sigp#5941, sigp#6118, sigp#6179)
Co-authored-by: kevaundray <[email protected]>
1 parent d9f8b13 commit 88b6bd9

File tree

9 files changed

+659
-268
lines changed

9 files changed

+659
-268
lines changed

Cargo.lock

Lines changed: 147 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ delay_map = "0.3"
114114
derivative = "2"
115115
dirs = "3"
116116
either = "1.9"
117+
peerdas-kzg = { git = "https://github.com/crate-crypto/peerdas-kzg", rev = "55ae9e9011d792a2998d242c2a71d822ba909fa9", package = "eip7594" }
117118
discv5 = { version = "0.4.1", features = ["libp2p"] }
118119
env_logger = "0.9"
119120
error-chain = "0.12"

beacon_node/beacon_chain/src/data_column_verification.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crate::block_verification::{
22
cheap_state_advance_to_obtain_committees, get_validator_pubkey_cache, process_block_slash_info,
33
BlockSlashInfo,
44
};
5-
use crate::{BeaconChain, BeaconChainError, BeaconChainTypes};
5+
use crate::kzg_utils::validate_data_columns;
6+
use crate::{metrics, BeaconChain, BeaconChainError, BeaconChainTypes};
67
use derivative::Derivative;
78
use fork_choice::ProtoBlock;
89
use kzg::{Error as KzgError, Kzg};
@@ -11,6 +12,7 @@ use slasher::test_utils::E;
1112
use slog::debug;
1213
use slot_clock::SlotClock;
1314
use ssz_derive::{Decode, Encode};
15+
use std::iter;
1416
use std::sync::Arc;
1517
use types::data_column_sidecar::{ColumnIndex, DataColumnIdentifier};
1618
use types::{
@@ -236,9 +238,10 @@ impl<E: EthSpec> KzgVerifiedCustodyDataColumn<E> {
236238
/// Returns an error if the kzg verification check fails.
237239
pub fn verify_kzg_for_data_column<E: EthSpec>(
238240
data_column: Arc<DataColumnSidecar<E>>,
239-
_kzg: &Kzg,
241+
kzg: &Kzg,
240242
) -> Result<KzgVerifiedDataColumn<E>, KzgError> {
241-
// TODO(das): KZG verification to be implemented
243+
let _timer = metrics::start_timer(&metrics::KZG_VERIFICATION_DATA_COLUMN_SINGLE_TIMES);
244+
validate_data_columns(kzg, iter::once(&data_column))?;
242245
Ok(KzgVerifiedDataColumn { data: data_column })
243246
}
244247

@@ -248,13 +251,14 @@ pub fn verify_kzg_for_data_column<E: EthSpec>(
248251
/// Note: This function should be preferred over calling `verify_kzg_for_data_column`
249252
/// in a loop since this function kzg verifies a list of data columns more efficiently.
250253
pub fn verify_kzg_for_data_column_list<'a, E: EthSpec, I>(
251-
_data_column_iter: I,
252-
_kzg: &'a Kzg,
254+
data_column_iter: I,
255+
kzg: &'a Kzg,
253256
) -> Result<(), KzgError>
254257
where
255258
I: Iterator<Item = &'a Arc<DataColumnSidecar<E>>> + Clone,
256259
{
257-
// TODO(das): implement KZG verification
260+
let _timer = metrics::start_timer(&metrics::KZG_VERIFICATION_DATA_COLUMN_BATCH_TIMES);
261+
validate_data_columns(kzg, data_column_iter)?;
258262
Ok(())
259263
}
260264

0 commit comments

Comments
 (0)