Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Move CosetIndex and CommitmentIndex into kzg_multi_open #222

Merged
merged 5 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cryptography/kzg_multi_open/src/fk20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ mod verifier;
pub use cosets::recover_evaluations_in_domain_order;
pub use errors::VerifierError;
pub use prover::{FK20Prover as Prover, Input as ProverInput};
pub use verifier::FK20Verifier as Verifier;
pub use verifier::{CommitmentIndex, CosetIndex, FK20Verifier as Verifier};
19 changes: 17 additions & 2 deletions cryptography/kzg_multi_open/src/fk20/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ use std::mem::size_of;

use super::errors::VerifierError;

/// CosetIndex is a reference to a coset.
///
/// Note: We are able to use CosetIndex instead of the coset because
/// the prover and verifier both know what the cosets are that
/// we will be making and verifying opening proofs for.
pub type CosetIndex = u64;

/// CommitmentIndex is a reference to a commitment.
///
/// In order to make verification cheaper, the verifier will
/// deduplicate the list of commitments that are needed in order to verify opening proofs.
/// They will then refer to a commitment via its position in an array of deduplicated commitments
/// with the CommitmentIndex.
pub type CommitmentIndex = u64;

/// FK20Verifier initializes all of the components needed to verify KZG multi point
/// proofs that were created using the FK20Prover.
///
Expand Down Expand Up @@ -103,9 +118,9 @@ impl FK20Verifier {
&self,

deduplicated_commitments: &[G1Point],
commitment_indices: &[u64],
commitment_indices: &[CommitmentIndex],

bit_reversed_coset_indices: &[u64],
bit_reversed_coset_indices: &[CosetIndex],
bit_reversed_coset_evals: &[Vec<Scalar>],
bit_reversed_proofs: &[G1Point],
) -> Result<(), VerifierError> {
Expand Down
5 changes: 4 additions & 1 deletion cryptography/kzg_multi_open/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ pub mod commit_key;
mod fk20;
pub mod opening_key;

pub use fk20::{recover_evaluations_in_domain_order, Prover, ProverInput, Verifier, VerifierError};
pub use fk20::{
recover_evaluations_in_domain_order, CommitmentIndex, CosetIndex, Prover, ProverInput,
Verifier, VerifierError,
};

#[cfg(test)]
mod naive;
Expand Down
21 changes: 6 additions & 15 deletions eip7594/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,13 @@ pub type KZGProof = [u8; BYTES_PER_COMMITMENT];
/// that we would like to make and verify opening proofs about.
pub type KZGCommitment = [u8; BYTES_PER_COMMITMENT];

/// CellIndex is reference to a Coset.
/// CellIndex is reference to the coset/set of points that were used to create that Cell,
/// on a particular polynomial, f(x).
///
/// We are able to use CellIndex instead of the coset because
/// the prover and verifier both know what the cosets are that
/// we will be making and verifying opening proofs for.
pub type CellIndex = u64;

/// CommitmentIndex is a reference to a commitment.
///
/// In order to make verification cheaper, the verifier will
/// deduplicate the list of commitments that they need to verify opening proofs for.
/// They will then refer to a commitment via its position in an array of deduplicated commitments
/// with the CommitmentIndex.
///
/// Note: This is not exposed in the public API.
pub(crate) type CommitmentIndex = u64;
/// Note: Since the verifier and prover both know what cosets will be used
/// to evaluate the polynomials being used in opening proofs, the protocol
/// only requires an index to reference them.
pub type CellIndex = kzg_multi_open::CosetIndex;

use constants::{BYTES_PER_BLOB, BYTES_PER_CELL, BYTES_PER_COMMITMENT};
use prover::ProverContext;
Expand Down
4 changes: 3 additions & 1 deletion eip7594/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,12 @@ impl DASContext {
mod validation {
use std::collections::HashSet;

use kzg_multi_open::CommitmentIndex;

use crate::{
constants::{BYTES_PER_CELL, CELLS_PER_EXT_BLOB, EXTENSION_FACTOR},
verifier::VerifierError,
Bytes48Ref, CellIndex, CellRef, CommitmentIndex,
Bytes48Ref, CellIndex, CellRef,
};

/// Validation logic for `verify_cell_kzg_proof_batch`
Expand Down
Loading