ekzg_multi_open/
lib.rs

1pub mod commit_key;
2mod fk20;
3pub mod verification_key;
4
5pub use fk20::{
6    recover_evaluations_in_domain_order, CommitmentIndex, CosetIndex, Prover, ProverInput,
7    Verifier, VerifierError,
8};
9
10#[cfg(test)]
11mod naive;
12
13#[cfg(test)]
14pub(crate) fn create_insecure_commit_verification_keys(
15) -> (commit_key::CommitKey, verification_key::VerificationKey) {
16    use bls12_381::{
17        g1_batch_normalize, g2_batch_normalize, traits::*, G1Projective, G2Projective, Scalar,
18    };
19    use commit_key::CommitKey;
20    use verification_key::VerificationKey;
21
22    // A single proof will attest to the opening of 64 points.
23    let multi_opening_size = 64;
24
25    // We are making claims about a polynomial which has 4096 coefficients;
26    let num_coefficients_in_polynomial = 4096;
27
28    let g1_gen = G1Projective::generator();
29
30    let mut g1_points = Vec::new();
31    let secret = -Scalar::ONE;
32    let mut current_secret_pow = Scalar::ONE;
33    for _ in 0..num_coefficients_in_polynomial {
34        g1_points.push(g1_gen * current_secret_pow);
35        current_secret_pow *= secret;
36    }
37    let g1_points = g1_batch_normalize(&g1_points);
38
39    let ck = CommitKey::new(g1_points.clone());
40
41    let mut g2_points = Vec::new();
42    let secret = -Scalar::ONE;
43    let mut current_secret_pow = Scalar::ONE;
44    let g2_gen = G2Projective::generator();
45    // The setup needs 65 g1 elements for the verification key, in order
46    // to commit to the remainder polynomial.
47    for _ in 0..=multi_opening_size {
48        g2_points.push(g2_gen * current_secret_pow);
49        current_secret_pow *= secret;
50    }
51    let g2_points = g2_batch_normalize(&g2_points);
52
53    let vk = VerificationKey::new(
54        g1_points[0..=multi_opening_size].to_vec(),
55        g2_points,
56        multi_opening_size,
57        num_coefficients_in_polynomial,
58    );
59
60    (ck, vk)
61}