Skip to content

Commit

Permalink
feat: Add the sumcheck relations to the co-ultrahonk prover (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
rw0x0 committed Oct 1, 2024
1 parent 8338687 commit de74477
Show file tree
Hide file tree
Showing 24 changed files with 2,483 additions and 271 deletions.
1 change: 1 addition & 0 deletions co-noir/co-ultrahonk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ ark-bn254.workspace = true
eyre.workspace = true
itertools.workspace = true
mpc-core.workspace = true
num-bigint.workspace = true
tracing.workspace = true
ultrahonk.workspace = true
4 changes: 2 additions & 2 deletions co-noir/co-ultrahonk/src/co_decider/co_sumcheck/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ where
&self.memory.relation_parameters,
&gate_separators,
&self.memory.polys,
);
)?;
let round_univariate = self.driver.open_many(&round_univariate.evaluations)?;

// Place the evaluations of the round univariate into transcript.
Expand Down Expand Up @@ -187,7 +187,7 @@ where
&self.memory.relation_parameters,
&gate_separators,
&partially_evaluated_polys,
);
)?;
let round_univariate = self.driver.open_many(&round_univariate.evaluations)?;

// Place the evaluations of the round univariate into transcript.
Expand Down
111 changes: 103 additions & 8 deletions co-noir/co-ultrahonk/src/co_decider/co_sumcheck/round.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
use crate::{
co_decider::{
relations::AllRelationAcc,
relations::{
auxiliary_relation::AuxiliaryRelation,
delta_range_constraint_relation::DeltaRangeConstraintRelation,
elliptic_relation::EllipticRelation, logderiv_lookup_relation::LogDerivLookupRelation,
permutation_relation::UltraPermutationRelation,
poseidon2_external_relation::Poseidon2ExternalRelation,
poseidon2_internal_relation::Poseidon2InternalRelation,
ultra_arithmetic_relation::UltraArithmeticRelation, AllRelationAcc, Relation,
},
types::{ProverUnivariates, RelationParameters, MAX_PARTIAL_RELATION_LENGTH},
univariates::SharedUnivariate,
},
Expand All @@ -9,7 +17,9 @@ use crate::{
use ark_ec::pairing::Pairing;
use ark_ff::One;
use mpc_core::traits::PrimeFieldMpcProtocol;
use ultrahonk::prelude::{GateSeparatorPolynomial, HonkCurve, TranscriptFieldType, Univariate};
use ultrahonk::prelude::{
GateSeparatorPolynomial, HonkCurve, HonkProofResult, TranscriptFieldType, Univariate,
};

pub(crate) type SumcheckRoundOutput<T, P> =
SharedUnivariate<T, P, { MAX_PARTIAL_RELATION_LENGTH + 1 }>;
Expand Down Expand Up @@ -122,17 +132,101 @@ impl SumcheckRound {
res
}

fn accumulate_one_relation_univariates<
T,
P: HonkCurve<TranscriptFieldType>,
R: Relation<T, P>,
>(
driver: &mut T,
univariate_accumulator: &mut R::Acc,
extended_edges: &ProverUnivariates<T, P>,
relation_parameters: &RelationParameters<P::ScalarField>,
scaling_factor: &P::ScalarField,
) -> HonkProofResult<()>
where
T: PrimeFieldMpcProtocol<P::ScalarField>,
{
if R::SKIPPABLE && R::skip(extended_edges) {
return Ok(());
}

R::accumulate(
driver,
univariate_accumulator,
extended_edges,
relation_parameters,
scaling_factor,
)
}

fn accumulate_relation_univariates<T, P: HonkCurve<TranscriptFieldType>>(
driver: &mut T,
univariate_accumulators: &mut AllRelationAcc<T, P>,
extended_edges: &ProverUnivariates<T, P>,
relation_parameters: &RelationParameters<P::ScalarField>,
scaling_factor: &P::ScalarField,
) where
) -> HonkProofResult<()>
where
T: PrimeFieldMpcProtocol<P::ScalarField>,
{
tracing::trace!("Accumulate relations");
todo!("Accumulate relations")
Self::accumulate_one_relation_univariates::<_, _, UltraArithmeticRelation>(
driver,
&mut univariate_accumulators.r_arith,
extended_edges,
relation_parameters,
scaling_factor,
)?;
Self::accumulate_one_relation_univariates::<_, _, UltraPermutationRelation>(
driver,
&mut univariate_accumulators.r_perm,
extended_edges,
relation_parameters,
scaling_factor,
)?;
Self::accumulate_one_relation_univariates::<_, _, DeltaRangeConstraintRelation>(
driver,
&mut univariate_accumulators.r_delta,
extended_edges,
relation_parameters,
scaling_factor,
)?;
Self::accumulate_one_relation_univariates::<_, _, EllipticRelation>(
driver,
&mut univariate_accumulators.r_elliptic,
extended_edges,
relation_parameters,
scaling_factor,
)?;
Self::accumulate_one_relation_univariates::<_, _, AuxiliaryRelation>(
driver,
&mut univariate_accumulators.r_aux,
extended_edges,
relation_parameters,
scaling_factor,
)?;
Self::accumulate_one_relation_univariates::<_, _, LogDerivLookupRelation>(
driver,
&mut univariate_accumulators.r_lookup,
extended_edges,
relation_parameters,
scaling_factor,
)?;
Self::accumulate_one_relation_univariates::<_, _, Poseidon2ExternalRelation>(
driver,
&mut univariate_accumulators.r_pos_ext,
extended_edges,
relation_parameters,
scaling_factor,
)?;
Self::accumulate_one_relation_univariates::<_, _, Poseidon2InternalRelation>(
driver,
&mut univariate_accumulators.r_pos_int,
extended_edges,
relation_parameters,
scaling_factor,
)?;
Ok(())
}

pub(crate) fn compute_univariate<T, P: HonkCurve<TranscriptFieldType>>(
Expand All @@ -142,7 +236,7 @@ impl SumcheckRound {
relation_parameters: &RelationParameters<P::ScalarField>,
gate_sparators: &GateSeparatorPolynomial<P::ScalarField>,
polynomials: &AllEntities<Vec<T::FieldShare>, Vec<P::ScalarField>>,
) -> SumcheckRoundOutput<T, P>
) -> HonkProofResult<SumcheckRoundOutput<T, P>>
where
T: PrimeFieldMpcProtocol<P::ScalarField>,
{
Expand All @@ -169,13 +263,14 @@ impl SumcheckRound {
&extended_edge,
relation_parameters,
&gate_sparators.beta_products[(edge_idx >> 1) * gate_sparators.periodicity],
);
)?;
}
Self::batch_over_relations_univariates(
let res = Self::batch_over_relations_univariates(
driver,
univariate_accumulators,
&relation_parameters.alphas,
gate_sparators,
)
);
Ok(res)
}
}
Loading

0 comments on commit de74477

Please sign in to comment.