40 static_assert(NUM < 5);
41 static constexpr FF inverse_two =
FF(2).
invert();
43 std::vector<FF> lagranges(NUM);
44 FF vanishing_polynomial_at_challenge;
45 if constexpr (NUM == 2) {
46 vanishing_polynomial_at_challenge = combiner_challenge * (combiner_challenge -
FF(1));
47 lagranges = {
FF(1) - combiner_challenge, combiner_challenge };
48 }
else if constexpr (NUM == 3) {
49 vanishing_polynomial_at_challenge =
50 combiner_challenge * (combiner_challenge -
FF(1)) * (combiner_challenge -
FF(2));
51 lagranges = { (
FF(1) - combiner_challenge) * (
FF(2) - combiner_challenge) * inverse_two,
52 combiner_challenge * (
FF(2) - combiner_challenge),
53 combiner_challenge * (combiner_challenge -
FF(1)) * inverse_two };
54 }
else if constexpr (NUM == 4) {
55 static constexpr FF inverse_six =
FF(6).
invert();
56 vanishing_polynomial_at_challenge = combiner_challenge * (combiner_challenge -
FF(1)) *
57 (combiner_challenge -
FF(2)) * (combiner_challenge -
FF(3));
58 lagranges = { (
FF(1) - combiner_challenge) * (
FF(2) - combiner_challenge) * (
FF(3) - combiner_challenge) *
60 combiner_challenge * (
FF(2) - combiner_challenge) * (
FF(3) - combiner_challenge) * inverse_two,
61 combiner_challenge * (combiner_challenge -
FF(1)) * (
FF(3) - combiner_challenge) * inverse_two,
62 combiner_challenge * (combiner_challenge -
FF(1)) * (combiner_challenge -
FF(2)) * inverse_six };
64 return std::make_tuple(vanishing_polynomial_at_challenge, lagranges);
69 DeciderVerificationKeys>::verify_folding_proof(
const std::vector<FF>& proof)
71 static constexpr size_t BATCHED_EXTENDED_LENGTH = DeciderVerificationKeys::BATCHED_EXTENDED_LENGTH;
72 static constexpr size_t NUM_KEYS = DeciderVerificationKeys::NUM;
75 static constexpr size_t COMBINER_LENGTH = BATCHED_EXTENDED_LENGTH -
NUM_KEYS;
77 const std::shared_ptr<DeciderVK>& accumulator = keys_to_fold[0];
79 run_oink_verifier_on_each_incomplete_key(proof);
82 const std::vector<FF> deltas = transcript->template get_powers_of_challenge<FF>(
"delta", CONST_PG_LOG_N);
84 std::vector<FF> perturbator_coeffs(CONST_PG_LOG_N + 1, 0);
85 for (
size_t idx = 1; idx <= CONST_PG_LOG_N; idx++) {
86 perturbator_coeffs[idx] = transcript->template receive_from_prover<FF>(
"perturbator_" +
std::to_string(idx));
88 const FF perturbator_challenge = transcript->template get_challenge<FF>(
"perturbator_challenge");
91 perturbator_coeffs[0] = accumulator->target_sum;
93 const FF perturbator_evaluation = perturbator.
evaluate(perturbator_challenge);
96 for (
size_t idx = DeciderVerificationKeys::NUM;
auto& val : combiner_quotient_evals) {
97 val = transcript->template receive_from_prover<FF>(
"combiner_quotient_" +
std::to_string(idx++));
101 const FF combiner_challenge = transcript->template get_challenge<FF>(
"combiner_quotient_challenge");
103 const FF combiner_quotient_evaluation = combiner_quotient.
evaluate(combiner_challenge);
106 const size_t accumulator_log_circuit_size = CONST_PG_LOG_N;
107 accumulator->vk->log_circuit_size = accumulator_log_circuit_size;
110 const auto [vanishing_polynomial_at_challenge, lagranges] =
111 compute_vanishing_polynomial_and_lagrange_evaluations<FF, NUM_KEYS>(combiner_challenge);
112 accumulator->target_sum =
113 perturbator_evaluation * lagranges[0] + vanishing_polynomial_at_challenge * combiner_quotient_evaluation;
114 accumulator->gate_challenges =
118 for (
auto [combination, to_combine] :
119 zip_view(accumulator->vk->get_all(), keys_to_fold.get_precomputed_commitments())) {
120 combination = batch_mul_native(to_combine, lagranges);
122 for (
auto [combination, to_combine] :
123 zip_view(accumulator->witness_commitments.get_all(), keys_to_fold.get_witness_commitments())) {
124 combination = batch_mul_native(to_combine, lagranges);
128 for (
auto [combination, to_combine] :
zip_view(accumulator->alphas, keys_to_fold.get_alphas())) {
129 combination = linear_combination(to_combine, lagranges);
131 for (
auto [combination, to_combine] :
132 zip_view(accumulator->relation_parameters.get_to_fold(), keys_to_fold.get_relation_parameters())) {
133 combination = linear_combination(to_combine, lagranges);