1#include <gtest/gtest.h>
41 auto commitment = Commitment::one();
44 for (
auto& eval : evaluations) {
50 prover_transcript.send_to_verifier(
"data",
data);
51 prover_transcript.template get_challenge<FF>(
"alpha");
54 prover_transcript.send_to_verifier(
"scalar", scalar);
55 prover_transcript.send_to_verifier(
"commitment", commitment);
56 prover_transcript.template get_challenges<FF>(
"beta, gamma");
59 prover_transcript.send_to_verifier(
"univariate", univariate);
60 prover_transcript.template get_challenges<FF>(
"gamma",
"delta");
62 return prover_transcript.export_proof();
81 transcript.template receive_from_prover<FF>(
"data");
82 transcript.template get_challenge<FF>(
"alpha");
85 transcript.template receive_from_prover<FF>(
"scalar");
86 transcript.template receive_from_prover<Commitment>(
"commitment");
87 transcript.template get_challenges<FF>(
"beta, gamma");
90 transcript.template receive_from_prover<Univariate>(
"univariate");
91 transcript.template get_challenges<FF>(
"gamma",
"delta");
99TEST(RecursiveHonkTranscript, InterfacesMatch)
103 constexpr size_t LENGTH = 8;
107 auto proof_data = generate_mock_proof_data<UltraFlavor, LENGTH>(prover_transcript);
111 native_transcript.load_proof(proof_data);
112 perform_mock_verifier_transcript_operations<UltraFlavor, LENGTH>(native_transcript);
115 EXPECT_EQ(prover_transcript.get_manifest(), native_transcript.get_manifest());
121 perform_mock_verifier_transcript_operations<UltraRecursiveFlavor, LENGTH>(transcript);
124 EXPECT_EQ(transcript.
get_manifest(), native_transcript.get_manifest());
135TEST(RecursiveHonkTranscript, ReturnValuesMatch)
150 const size_t LENGTH = 10;
152 for (
auto& eval : evaluations) {
158 prover_transcript.send_to_verifier(
"scalar", scalar);
159 prover_transcript.send_to_verifier(
"commitment", commitment);
160 prover_transcript.send_to_verifier(
"evaluations", evaluations);
161 prover_transcript.template get_challenges<FF>(
"alpha, beta");
162 auto proof_data = prover_transcript.export_proof();
166 native_transcript.load_proof(proof_data);
167 auto native_scalar = native_transcript.template receive_from_prover<FF>(
"scalar");
168 auto native_commitment = native_transcript.template receive_from_prover<Commitment>(
"commitment");
169 auto native_evaluations = native_transcript.template receive_from_prover<std::array<FF, LENGTH>>(
"evaluations");
170 auto [native_alpha, native_beta] = native_transcript.template get_challenges<FF>(
"alpha",
"beta");
176 auto stdlib_scalar = stdlib_transcript.template receive_from_prover<field_ct>(
"scalar");
177 auto stdlib_commitment = stdlib_transcript.template receive_from_prover<element_ct>(
"commitment");
178 auto stdlib_evaluations =
179 stdlib_transcript.template receive_from_prover<std::array<field_ct, LENGTH>>(
"evaluations");
180 auto [stdlib_alpha, stdlib_beta] = stdlib_transcript.template get_challenges<field_ct>(
"alpha",
"beta");
183 EXPECT_EQ(native_scalar, stdlib_scalar.get_value());
184 EXPECT_EQ(native_commitment, stdlib_commitment.get_value());
185 for (
size_t i = 0; i < LENGTH; ++i) {
186 EXPECT_EQ(native_evaluations[i], stdlib_evaluations[i].get_value());
189 EXPECT_EQ(
static_cast<FF>(native_alpha), stdlib_alpha.get_value());
190 EXPECT_EQ(
static_cast<FF>(native_beta), stdlib_beta.get_value());
198TEST(RecursiveTranscript, InfinityConsistencyGrumpkin)
201 using NativeCommitment =
typename NativeCurve::AffineElement;
202 using NativeFF = NativeCurve::ScalarField;
209 NativeCommitment infinity = NativeCommitment::infinity();
212 prover_transcript.send_to_verifier(
"infinity", infinity);
213 NativeFF challenge = prover_transcript.get_challenge<NativeFF>(
"challenge");
214 auto proof_data = prover_transcript.export_proof();
217 verifier_transcript.load_proof(proof_data);
218 verifier_transcript.receive_from_prover<NativeCommitment>(
"infinity");
219 auto verifier_challenge = verifier_transcript.get_challenge<NativeFF>(
"challenge");
225 EXPECT_TRUE(stdlib_infinity.is_point_at_infinity().get_value());
226 auto stdlib_challenge = stdlib_transcript.
get_challenge<
FF>(
"challenge");
228 EXPECT_EQ(challenge, verifier_challenge);
229 EXPECT_EQ(verifier_challenge, NativeFF(stdlib_challenge.get_value() %
FF::modulus));
237TEST(RecursiveTranscript, InfinityConsistencyBN254)
240 using NativeCommitment =
typename NativeCurve::AffineElement;
241 using NativeFF = NativeCurve::ScalarField;
249 NativeCommitment infinity = NativeCommitment::infinity();
252 prover_transcript.send_to_verifier(
"infinity", infinity);
253 NativeFF challenge = prover_transcript.get_challenge<NativeFF>(
"challenge");
254 auto proof_data = prover_transcript.export_proof();
257 verifier_transcript.load_proof(proof_data);
258 verifier_transcript.receive_from_prover<NativeCommitment>(
"infinity");
259 auto verifier_challenge = verifier_transcript.get_challenge<NativeFF>(
"challenge");
265 EXPECT_TRUE(stdlib_commitment.is_point_at_infinity().get_value());
266 auto stdlib_challenge = stdlib_transcript.
get_challenge<
FF>(
"challenge");
268 EXPECT_EQ(challenge, verifier_challenge);
269 EXPECT_EQ(verifier_challenge, stdlib_challenge.get_value());
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
T receive_from_prover(const std::string &label)
Reads the next element of type T from the transcript, with a predefined label, only used by verifier.
void load_proof(const std::vector< DataType > &proof)
TranscriptManifest get_manifest() const
ChallengeType get_challenge(const std::string &label)
Curve::AffineElement Commitment
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
The recursive counterpart to the "native" Ultra flavor.
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
group_elements::affine_element< Fq, Fr, Params > affine_element
A simple wrapper around a vector of stdlib field elements representing a proof.
cycle_group represents a group Element of the proving system's embedded curve i.e....
const std::vector< FF > data
auto generate_mock_proof_data(auto prover_transcript)
Create some mock data; add it to the provided prover transcript in various mock rounds.
void perform_mock_verifier_transcript_operations(auto transcript)
Perform series of verifier transcript operations.
TEST(RecursiveHonkTranscript, InterfacesMatch)
Test basic transcript functionality and check circuit.
NativeTranscript NativeTranscript
std::conditional_t< IsGoblinBigGroup< C, Fq, Fr, G >, element_goblin::goblin_element< C, goblin_field< C >, Fr, G >, element_default::element< C, Fq, Fr, G > > element
element wraps either element_default::element or element_goblin::goblin_element depending on parametr...
field< Bn254FrParams > fr
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static constexpr uint256_t modulus
static field random_element(numeric::RNG *engine=nullptr) noexcept