Skip to content

Commit 1d9f7bf

Browse files
committed
chore: move PeerDASContext struct to eip7594 crate and create an opaque context struct for csbindgen
1 parent e894540 commit 1d9f7bf

File tree

3 files changed

+39
-21
lines changed

3 files changed

+39
-21
lines changed

bindings/c/src/lib.rs

+12-20
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,28 @@ pub use eip7594::constants::{
2121
BYTES_PER_BLOB, BYTES_PER_CELL, BYTES_PER_COMMITMENT, BYTES_PER_FIELD_ELEMENT,
2222
CELLS_PER_EXT_BLOB, FIELD_ELEMENTS_PER_BLOB,
2323
};
24-
use eip7594::prover::ProverContext as eip7594_ProverContext;
25-
use eip7594::verifier::{VerifierContext as eip7594_VerifierContext, VerifierError};
24+
use eip7594::verifier::VerifierError;
2625

27-
// TODO: Add this into eip7594 spec tests
28-
29-
/// The context that will be used to create and verify proofs.
26+
// This is a wrapper around the PeerDASContext from the eip7594 library.
27+
// We need to wrap it as some bindgen tools cannot pick up items
28+
// not defined in this file.
29+
#[derive(Default)]
3030
pub struct PeerDASContext {
31-
prover_ctx: eip7594_ProverContext,
32-
verifier_ctx: eip7594_VerifierContext,
33-
}
34-
35-
impl Default for PeerDASContext {
36-
fn default() -> Self {
37-
PeerDASContext {
38-
prover_ctx: eip7594_ProverContext::new(),
39-
verifier_ctx: eip7594_VerifierContext::new(),
40-
}
41-
}
31+
inner: eip7594::PeerDASContext,
4232
}
4333

4434
impl PeerDASContext {
45-
pub fn prover_ctx(&self) -> &eip7594_ProverContext {
46-
&self.prover_ctx
35+
pub fn prover_ctx(&self) -> &eip7594::prover::ProverContext {
36+
self.inner.prover_ctx()
4737
}
4838

49-
pub fn verifier_ctx(&self) -> &eip7594_VerifierContext {
50-
&self.verifier_ctx
39+
pub fn verifier_ctx(&self) -> &eip7594::verifier::VerifierContext {
40+
&self.inner.verifier_ctx
5141
}
5242
}
5343

44+
// TODO: Add this into eip7594 spec tests
45+
5446
/// Create a new PeerDASContext and return a pointer to it.
5547
///
5648
/// # Memory faults

bindings/nim/nim_code/src/header.nim

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ type CResultStatus* = enum
77
Ok
88
Err
99

10-
## The context that will be used to create and verify proofs.
1110
type PeerDASContext* {.incompleteStruct.} = object
1211

1312
## A C-style struct to represent the success result of a function call.

eip7594/src/lib.rs

+27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use constants::BYTES_PER_COMMITMENT;
2+
use prover::ProverContext;
3+
use verifier::VerifierContext;
24

35
// TODO: We can remove this once we hook up the consensus-specs fixed test vectors.
46
pub mod consensus_specs_fixed_test_vector;
@@ -26,6 +28,31 @@ pub type RowIndex = u64;
2628
pub type ColumnIndex = u64;
2729
pub type Bytes48 = [u8; 48];
2830

31+
/// The context that will be used to create and verify proofs.
32+
pub struct PeerDASContext {
33+
pub prover_ctx: ProverContext,
34+
pub verifier_ctx: VerifierContext,
35+
}
36+
37+
impl Default for PeerDASContext {
38+
fn default() -> Self {
39+
PeerDASContext {
40+
prover_ctx: ProverContext::new(),
41+
verifier_ctx: VerifierContext::new(),
42+
}
43+
}
44+
}
45+
46+
impl PeerDASContext {
47+
pub fn prover_ctx(&self) -> &ProverContext {
48+
&self.prover_ctx
49+
}
50+
51+
pub fn verifier_ctx(&self) -> &VerifierContext {
52+
&self.verifier_ctx
53+
}
54+
}
55+
2956
#[cfg(test)]
3057
mod tests {
3158
use kzg_multi_open::polynomial::domain::Domain;

0 commit comments

Comments
 (0)