Skip to content

Commit

Permalink
verify correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
bxue-l2 committed Jan 31, 2025
1 parent 85d2036 commit da92d3b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 55 deletions.
19 changes: 13 additions & 6 deletions src/bin/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fs;
use alloy_sol_types::SolCall;
use eigenda_v2_struct_rust::v2_cert::rs_struct;
use eigenda_v2_struct_rust::v2_cert::sol_struct;
use alloy_rlp::{RlpEncodable, RlpDecodable, Decodable, Encodable};
Expand All @@ -9,6 +10,9 @@ use alloy::network::{EthereumWallet, TransactionBuilder};
use alloy_signer::{Signer, SignerSync};
use alloy::rpc::types::TransactionRequest;
use alloy::signers::local::PrivateKeySigner;
use alloy::{primitives::{address, Address}};

const CERT_VERIFIER: Address = address!("0x5c33Ce64EE04400fD593F960d63336F1B65bF77B");

#[tokio::main]
async fn main() {
Expand All @@ -27,15 +31,18 @@ async fn main() {
let bn = provider.get_block_number().await.unwrap();
println!("block number is {}", bn);

let address = "0x5c33Ce64EE04400fD593F960d63336F1B65bF77B";

let call = sol_struct::verifyDACertV2Call {
let input = sol_struct::IEigenDACertVerifier::verifyDACertV2Call {
batchHeader: batch_header,
blobInclusionInfo: blob_inclusion,
nonSignerStakesAndSignature: non_signer,
};
}.abi_encode();

let tx = TransactionRequest::default().with_to(CERT_VERIFIER).with_input(input);

// as long as not error, the call is right
let _ = provider.call(&tx).await.expect("not revert");

//let tx = TransactionRequest::default().
println!("verify V2 cert onchain is correct");

}

Expand All @@ -45,7 +52,7 @@ pub fn parse_batch_header(file_path: &str) -> sol_struct::BatchHeaderV2 {
.expect("Should have been able to read the file");

let batchHeader = rs_struct::BatchHeaderV2::decode(&mut data.as_slice()).unwrap();
let batchHeader_sol = batchHeader.to_sol();
let mut batchHeader_sol = batchHeader.to_sol();

println!("batchHeader referenceBlockNumber {:?}", batchHeader_sol.referenceBlockNumber);
println!("batchHeaderm batchRoot {:?}", batchHeader_sol.batchRoot);
Expand Down
100 changes: 51 additions & 49 deletions src/v2_cert/sol_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,67 @@ use alloy_primitives::{hex, Address, U256, FixedBytes, fixed_bytes};
use alloy_sol_types::{sol, SolEnum, SolType};

sol! {
struct BatchHeaderV2 {
bytes32 batchRoot;
uint32 referenceBlockNumber;
}

struct BatchHeaderV2 {
bytes32 batchRoot;
uint32 referenceBlockNumber;
}
struct BlobInclusionInfo {
BlobCertificate blobCertificate;
uint32 blobIndex;
bytes inclusionProof;
}

struct BlobCertificate {
BlobHeaderV2 blobHeader;
bytes signature;
uint32[] relayKeys;
}

struct BlobHeaderV2 {
uint16 version;
bytes quorumNumbers;
BlobCommitment commitment;
bytes32 paymentHeaderHash;
uint32 salt;
}

struct BlobInclusionInfo {
BlobCertificate blobCertificate;
uint32 blobIndex;
bytes inclusionProof;
}

struct BlobCertificate {
BlobHeaderV2 blobHeader;
bytes signature;
uint32[] relayKeys;
}

struct BlobHeaderV2 {
uint16 version;
bytes quorumNumbers;
BlobCommitment commitment;
bytes32 paymentHeaderHash;
uint32 salt;
}
struct G1Point {
uint256 X;
uint256 Y;
}

struct G1Point {
uint256 X;
uint256 Y;
}
// Encoding of field elements is: X[1] * i + X[0]
struct G2Point {
uint256[2] X;
uint256[2] Y;
}

// Encoding of field elements is: X[1] * i + X[0]
struct G2Point {
uint256[2] X;
uint256[2] Y;
}
struct BlobCommitment {
G1Point commitment;
G2Point lengthCommitment;
G2Point lengthProof;
uint32 length;
}

struct BlobCommitment {
G1Point commitment;
G2Point lengthCommitment;
G2Point lengthProof;
uint32 length;
}
struct NonSignerStakesAndSignature {
uint32[] nonSignerQuorumBitmapIndices;
G1Point[] nonSignerPubkeys;
G1Point[] quorumApks;
G2Point apkG2;
G1Point sigma;
uint32[] quorumApkIndices;
uint32[] totalStakeIndices;
uint32[][] nonSignerStakeIndices;
}

struct NonSignerStakesAndSignature {
uint32[] nonSignerQuorumBitmapIndices;
G1Point[] nonSignerPubkeys;
G1Point[] quorumApks;
G2Point apkG2;
G1Point sigma;
uint32[] quorumApkIndices;
uint32[] totalStakeIndices;
uint32[][] nonSignerStakeIndices;
}

interface IEigenDACertVerifier {
#[sol(rpc)]
function verifyDACertV2(
BatchHeaderV2 calldata batchHeader,
BlobInclusionInfo calldata blobInclusionInfo,
NonSignerStakesAndSignature calldata nonSignerStakesAndSignature
) external view;
}

}

0 comments on commit da92d3b

Please sign in to comment.