38 using FF =
typename InnerFlavor::FF;
39 static constexpr size_t FIRST_WITNESS_INDEX = InnerFlavor::NUM_PRECOMPUTED_ENTITIES;
43 const auto num_public_inputs = inner_prover.prover_instance->num_public_inputs();
45 InnerFlavor::USE_PADDING ? CONST_PROOF_SIZE_LOG_N : inner_prover.prover_instance->log_dyadic_size();
46 structured_proof.deserialize(inner_prover.transcript->test_get_proof_data(), num_public_inputs, log_n);
53 structured_proof.sumcheck_univariates[0].value_at(0) += delta;
54 structured_proof.sumcheck_univariates[0].value_at(1) -= delta;
64 structured_proof.gemini_fold_comms[0] = structured_proof.gemini_fold_comms[0] *
FF::random_element();
65 structured_proof.gemini_fold_evals[0] =
FF::zero();
72 structured_proof.serialize(inner_prover.transcript->test_get_proof_data(), log_n);
73 inner_prover.transcript->test_set_proof_parsing_state(
74 0, compute_proof_length_for_export<InnerFlavor>(num_public_inputs));
75 inner_proof = inner_prover.export_proof();
86 using Commitment =
typename InnerFlavor::Curve::AffineElement;
87 using FF =
typename InnerFlavor::FF;
88 using ProofFF =
typename ProofType::value_type;
89 using Codec =
typename InnerFlavor::Transcript::Codec;
91 static constexpr size_t NUM_FRS_PER_COMMITMENT = Codec::template calc_num_fields<Commitment>();
95 size_t offset = inner_proof.size() - NUM_FRS_PER_COMMITMENT;
96 auto element_span = std::span{ inner_proof }.subspan(
offset, NUM_FRS_PER_COMMITMENT);
97 auto commitment = Codec::template deserialize_from_fields<Commitment>(element_span);
98 commitment = commitment *
FF(2);
99 auto serialized = Codec::serialize_to_fields(commitment);
104 static constexpr size_t FRS_PER_POINT = Commitment::PUBLIC_INPUTS_SIZE;
105 static constexpr size_t NUM_LIMB_BITS = bb::stdlib::NUM_LIMB_BITS_IN_FIELD_SIMULATION;
107 if (inner_proof.size() >= FRS_PER_POINT) {
110 std::copy_n(inner_proof.begin(), FRS_PER_POINT, p0_limbs.begin());
111 Commitment P0 = Commitment::reconstruct_from_public(p0_limbs);
114 Commitment tampered = P0 + Commitment::one();
117 if constexpr (FRS_PER_POINT == 8) {
122 for (
size_t i = 0; i < 4; ++i) {
123 inner_proof[i] = ProofFF((x_val >> (i * NUM_LIMB_BITS)) & LIMB_MASK);
124 inner_proof[i + 4] = ProofFF((y_val >> (i * NUM_LIMB_BITS)) & LIMB_MASK);
126 }
else if constexpr (FRS_PER_POINT == 2) {
128 inner_proof[0] = ProofFF(tampered.x);
129 inner_proof[1] = ProofFF(tampered.y);
131 static_assert(FRS_PER_POINT == 8 || FRS_PER_POINT == 2,
132 "Unsupported curve: FRS_PER_POINT must be 8 (BN254) or 2 (Grumpkin)");
void tamper_with_proof(InnerProver &inner_prover, ProofType &inner_proof, TamperType type)
Test method that provides several ways to tamper with a proof. TODO(https://github....