Skip to content

Commit

Permalink
VerifierKey::from_ring_and_kzg_vk
Browse files Browse the repository at this point in the history
  • Loading branch information
swasilyev committed Nov 30, 2023
1 parent 4cf381e commit 3a930bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mod tests {

let ring = Ring::<_, Bls12_381, _>::with_keys(&piop_params, &pks, &ring_builder_key);

let fixed_columns_committed = FixedColumnsCommitted::from_ring(ring);
let fixed_columns_committed = FixedColumnsCommitted::from_ring(&ring);
assert_eq!(fixed_columns_committed, verifier_key.fixed_columns_committed);
}

Expand Down
18 changes: 16 additions & 2 deletions ring/src/piop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use ark_std::{vec, vec::Vec};
use ark_std::marker::PhantomData;
use fflonk::pcs::{Commitment, PCS, PcsParams};
use fflonk::pcs::kzg::commitment::KzgCommitment;
use fflonk::pcs::kzg::KZG;
use fflonk::pcs::kzg::params::RawKzgVerifierKey;

use common::{Column, ColumnsCommited, ColumnsEvaluated, FieldColumn};
use common::gadgets::sw_cond_add::AffineColumn;
Expand Down Expand Up @@ -96,7 +98,7 @@ impl<F: PrimeField, C: Commitment<F>> FixedColumnsCommitted<F, C> {

impl<E: Pairing> FixedColumnsCommitted<E::ScalarField, KzgCommitment<E>> {
pub fn from_ring<G: SWCurveConfig<BaseField=E::ScalarField>>(
ring: Ring<E::ScalarField, E, G>,
ring: &Ring<E::ScalarField, E, G>,
) -> Self {
let cx = KzgCommitment(ring.cx.into_affine());
let cy = KzgCommitment(ring.cy.into_affine());
Expand Down Expand Up @@ -126,14 +128,26 @@ pub struct ProverKey<F: PrimeField, CS: PCS<F>, G: AffineRepr<BaseField=F>> {
pub(crate) verifier_key: VerifierKey<F, CS>, // used in the Fiat-Shamir transform
}


#[derive(Clone, CanonicalSerialize, CanonicalDeserialize)]
pub struct VerifierKey<F: PrimeField, CS: PCS<F>> {
pub(crate) pcs_raw_vk: <CS::Params as PcsParams>::RVK,
pub(crate) fixed_columns_committed: FixedColumnsCommitted<F, CS::C>,
//TODO: domain
}

impl<E: Pairing> VerifierKey<E::ScalarField, KZG<E>> {
pub fn from_ring_and_kzg_vk<G: SWCurveConfig<BaseField=E::ScalarField>>(
ring: &Ring<E::ScalarField, E, G>,
kzg_vk: RawKzgVerifierKey<E>,
) -> Self {
Self {
pcs_raw_vk: kzg_vk,
fixed_columns_committed: FixedColumnsCommitted::from_ring(ring),
}
}
}


pub fn index<F: PrimeField, CS: PCS<F>, Curve: SWCurveConfig<BaseField=F>>(
pcs_params: CS::Params,
piop_params: &PiopParams<F, Curve>,
Expand Down

0 comments on commit 3a930bd

Please sign in to comment.